Skip to content
A wallet is a key pair: a public address that anyone can pay, and a private key that signs for it. In this step you create one, read its balance from devnet, and get free test SOL (to pay fees) and test dollars (USDC, to send in the next step).

​Set up a project

You need Node.js 20.18 or later. Create a folder and install Solana Kit, its RPC and signer plugins, and the clients for the token programs this quickstart calls (the Token Program and Token-2022):
Terminal
Save this as client.ts. Every step imports client from it: a Kit client that connects to devnet, signs and pays fees with your wallet (wallet.json), and includes the token programs’ instructions. Run every step from this folder, where the scripts save wallet.json, asset.json, and holder.json.
client.ts
For the CLI tabs you only need the Solana CLI, which includes spl-token. Run its commands from one folder too.

​Read the balance

Save this as balance.ts and run npx tsx balance.ts. The first run creates wallet.json, finds a balance of 0, and asks solana.com’s devnet faucet for 0.02 SOL, enough for every step of this quickstart. Later runs reuse the same wallet.
TypeScript
Output of npx tsx balance.tsLocal test network (Surfpool)
npx tsx balance.ts
Wallet: GmzAkU8mWhtHasB144D9HvTp5GEdrKZfSzoP5NUD2YH4
Airdrop: 3TGMyhcv6zBfFmQqfEJXZXXwaT2QXDb62DpvvUJvXiJpNfzsZZdDSauymdPKSEZbPrqfJYspkTkxFjG23LfoQZM9
Balance: 0.02 SOL
USDC: 0
Get free devnet USDC for GmzAkU8mWhtHasB144D9HvTp5GEdrKZfSzoP5NUD2YH4 at https://faucet.circle.com (pick Solana Devnet).
Confirmed
What the code does:
  • client.identity.address is your wallet’s public address.
  • client.rpc.getBalance(address) asks a devnet RPC node for the balance. Balances are in lamports; 1 SOL is 1,000,000,000 lamports.
  • The fetch to https://solana.com/api/devnet-airdrop requests 0.02 test SOL from solana.com’s devnet faucet. It answers once the transfer is confirmed, and the script prints the transaction signature. If the faucet can’t send, the script prints its reason (or the HTTP status) and points you to the Solana faucet.
  • tokenBalance(address), from client.ts, reads your USDC. Dollars on Solana are tokens: your wallet holds USDC in a token account for the USDC mint. Until you get some, there’s no token account yet, so the script prints USDC: 0.

​Get test dollars

Devnet USDC is free from Circle. Open the Circle faucet, choose USDC and Solana Devnet, paste your wallet address (the script printed it), and send. Then run npx tsx balance.ts again:
No airdrop? solana.com’s faucet sends a small amount only to a new wallet, one with no SOL and no transactions yet. It funds each wallet once, answers once per day per network address, and has a daily limit. When it can’t send, the script prints No airdrop: and the reason, for example This wallet already has devnet SOL or history, an Airdrop limit reached message, or an HTTP status. In every case, or if you need more SOL, get test SOL from the Solana faucet, then run npx tsx balance.ts again.
A balance is one field of an account. To see the rest, such as the owner, the raw data bytes, and how a token mint’s bytes decode into its supply and authorities, see raw and decoded account data.