> ## Documentation Index
> Fetch the complete documentation index at: https://developers.stellar.org/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK helpers for common tasks

> Before you write your own helper, check this list of tasks that the JavaScript SDK already handles, from funding testnet accounts to reading token balances.

## Before you write a helper

The JavaScript SDK, `@stellar/stellar-sdk`, has built-in helpers for many tasks that apps often code by hand. Check this table before you write your own. Every helper here is in version 17.x of the SDK, and each name links to its entry in the [SDK reference](https://stellar.github.io/js-stellar-sdk).

The call forms below use these imports and an RPC client for testnet:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
import {
  Address,
  Asset,
  Soroban,
  checkAuthEntryReadiness,
  contract,
  inspectAuthEntry,
  rpc,
} from "@stellar/stellar-sdk";

const server = new rpc.Server("https://soroban-testnet.stellar.org");
```

## Helpers by task

| Task | Helper | Notes |
| - | - | - |
| Fund a testnet account or contract | [`server.fundAddress(address)`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/#serverfundaddressaddress-friendboturl) | Takes a `G...` or `C...` address. Calls Friendbot and checks that the funding transaction succeeded. Works only on networks that run Friendbot. |
| Make a read-only contract call | [`server.queryContract(contractId, method, args)`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/#serverquerycontractcontractid-method-args-networkpassphrase) | Simulates the call and returns `{ result, isReadCall }`. It never signs or sends a transaction. Pass `args` as an object keyed by parameter name. |
| Read the token balance of an account or contract | [`server.getAssetBalance(address, asset)`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/#servergetassetbalanceaddress-asset-networkpassphrase) | Takes an `Asset`. For a `G...` address it reads the trustline. For a `C...` address it reads the balance from the asset's Stellar Asset Contract. For the XLM balance of a `G...` address, use [`server.getAccountEntry`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/#servergetaccountentryaddress). |
| Wait for a transaction result | [`server.pollTransaction(hash, opts)`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/#serverpolltransactionhash-opts) | Returns the first `SUCCESS` or `FAILED` response. If the transaction is still not found after the last attempt (by default 30 attempts, one second apart), it returns the `NOT_FOUND` response. |
| Display and parse token amounts | [`Soroban.formatTokenAmount(amount, decimals)`](https://stellar.github.io/js-stellar-sdk/reference/core-soroban-primitives/#sorobanformattokenamountamount-decimals) and [`Soroban.parseTokenAmount(value, decimals)`](https://stellar.github.io/js-stellar-sdk/reference/core-soroban-primitives/#sorobanparsetokenamountvalue-decimals) | Both take and return strings, so there is no floating-point rounding. `Soroban.formatTokenAmount("123000", 4)` returns `"12.3"`. |
| Call a contract without generated bindings | [`contract.Client.from(options)`](https://stellar.github.io/js-stellar-sdk/reference/contracts-client/#clientfromoptions) | Takes `{ contractId, rpcUrl, networkPassphrase }`. Reads the contract's spec from the network and returns a client with one method for each contract function. Also works for Stellar Asset Contracts. |
| Inspect the credentials of an auth entry | [`inspectAuthEntry(entry)`](https://stellar.github.io/js-stellar-sdk/reference/core-soroban-primitives/#inspectauthentry) | Returns the credential type, address, nonce, expiration ledger, and whether the entry is signed. To check that an entry is ready to submit, use [`checkAuthEntryReadiness(entry, currentLedgerSeq)`](https://stellar.github.io/js-stellar-sdk/reference/core-soroban-primitives/#checkauthentryreadiness). |
| Tell account, contract, and muxed addresses apart | [`Address.fromString(address).type`](https://stellar.github.io/js-stellar-sdk/reference/core-soroban-primitives/#addresstype) | Returns `"account"`, `"contract"`, `"muxedAccount"`, `"muxedContract"`, `"claimableBalance"`, or `"liquidityPool"`. |

## Related guides

* [Comprehensive frontend guide for Stellar dapps](https://developers.stellar.org/docs/build/guides/dapps/frontend-guide.md)
* [Submit a transaction to Stellar RPC using the JavaScript SDK](https://developers.stellar.org/docs/build/guides/transactions/submit-transaction-wait-js.md)
* [Verify trustlines](https://developers.stellar.org/docs/build/guides/basics/verify-trustlines.md)
* [Client SDKs](https://developers.stellar.org/docs/tools/sdks/client-sdks.md)
