Guides1 min read

Create a wallet locally and read its balance via API

Create or connect a wallet locally, then read its public balance and history with CryptoAPI.

cryptoapi team
Guides
On this page

Use your existing wallet or generate one in your application. CryptoAPI reads public addresses and relays signed transactions across Ethereum, BNB, Bitcoin and Tron.

1. Create or connect a wallet locally

For an EVM wallet, ethers v6 can generate a wallet in your application. Use an established wallet or signer for Bitcoin and Tron so you get their address and transaction formats.

ts
import { Wallet } from "ethers";

const wallet = Wallet.createRandom();
const address = wallet.address;

Back up the wallet through your signing software before using it to hold funds. Keep the private key and recovery phrase in the wallet. Your integration sends only the public address for balance and history requests.

2. Read the balance

Create a CryptoAPI key in your dashboard and use it from your server. Replace the example address with your wallet address.

bash
curl --request POST "https://api.cryptoapi.so/api/wallet/balance" \
  --header "key: $CRYPTOAPI_KEY" \
  --header "Content-Type: application/json" \
  --data '{"network":"ethereum","address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","tokens":[]}'

Read the balance entries from data. The API returns balance as a decimal string and usdValue as a number when a mainnet rate is available.

3. Add history and a send flow

The live index covers up to 30 days. Use GET /api/blockchain/transactions/history for available archived days and follow nextCursor. The response reports coverage gaps in missingDays.

For a transfer, read the network’s transaction metadata or build an unsigned transaction through the API. Review the recipient, amount and fees, sign in your wallet, then use POST /api/wallet/send to broadcast the signed payload.

Read it, then ship it

Copy the code above and run it today.

Every snippet in this guide works on the free plan. Grab a key and make your first call in a minute.