Setting Up a Solana Wallet for DocketLayer

Guides  ·  Setup

DocketLayer uses the x402 Protocol: instead of API keys, you pay for each query result directly, in USDC, at the moment you ask for it. That requires a wallet on the Solana blockchain, funded with USDC.

This guide walks through setting one up — whether you're exploring the API interactively, testing a prototype, or building an agent that queries autonomously.

Why Solana and USDC

The x402 model — pay per query, no accounts, no keys, no billing cycle — only works if payment is fast, cheap, and stable. Solana clears all three bars.

Transactions settle in under a second and cost a fraction of a cent. At a $0.99 query price, the network fee is noise. That makes genuine micropayment economics possible — something most chains can't offer.

USDC is the payment currency. It's a regulated, dollar-pegged stablecoin issued by Circle. What you put in is what you spend: $20 of USDC is $20, not a token whose value shifted while your agent was running. For programmatic workflows that need predictable costs, that matters.

Browser Wallet for Testing

If you're exploring the API manually or running quick tests, a browser wallet is the easiest starting point. Phantom is the most widely used Solana wallet and works well for this purpose.

After installing the extension and creating a wallet, you'll have a Solana address. Before putting real funds in, use DocketLayer's test mode to confirm your integration is working:

curl "https://api.docketlayer.ai/v2/case?court_code=nysd&case_id=1:24-cv-09822&test=1"

The test=1 parameter returns fixture data with no payment required. Use it to validate your request structure, inspect the response format, and understand what the API returns before connecting a funded wallet.

Programmatic Wallet for Agents

For any production system — a backend service, a scheduled agent, an automated workflow — you need a keypair your code can use to sign transactions without human interaction. This is a standard Solana keypair: a public key (the wallet address) and a secret key (used to sign).

Install the Solana web3.js library:

npm install @solana/web3.js @solana/spl-token
yarn add @solana/web3.js @solana/spl-token

Generate a new keypair:

import { Keypair } from '@solana/web3.js';
import { writeFileSync } from 'fs';

// Generate a new keypair
const keypair = Keypair.generate();

// Save the secret key — store this securely, never commit it
const secretKey = Array.from(keypair.secretKey);
writeFileSync('wallet.json', JSON.stringify(secretKey));

console.log('Public key (wallet address):', keypair.publicKey.toBase58());

Protect your secret key

The secret key is the wallet. Anyone who has it controls the funds. Never commit it to source control, never log it, and never include it in client-side code. In production, load it from an environment variable or a secrets manager — not from a file on disk.

To load the keypair at runtime:

import { Keypair } from '@solana/web3.js';
import { readFileSync } from 'fs';

// Load the keypair from file (or from an environment variable in production)
const secretKey = Uint8Array.from(
  JSON.parse(readFileSync('wallet.json', 'utf-8'))
);
const keypair = Keypair.fromSecretKey(secretKey);

console.log('Wallet address:', keypair.publicKey.toBase58());

The public key is your wallet address — the identifier you use to receive USDC and that appears in transaction records. Keep the secret key private; share only the public key.

Getting USDC into Your Wallet

Once you have a wallet address, you need USDC on Solana mainnet in it. There are a few ways to get there depending on where you're starting from.

Buy directly on a centralized exchange. Coinbase, Kraken, and most major exchanges let you purchase USDC and withdraw directly to a Solana address. When withdrawing, select the Solana network explicitly — USDC exists on multiple chains, and withdrawing to the wrong network will result in funds that are inaccessible from a Solana wallet.

Bridge from another chain. If you already hold USDC on Ethereum or another network, you can bridge it to Solana using Circle's Cross-Chain Transfer Protocol (CCTP) or a third-party bridge. CCTP is the most direct path and doesn't involve wrapped tokens.

Use a fiat on-ramp. Services like MoonPay and Transak allow direct purchase of USDC to a Solana address using a credit card or bank transfer, without requiring an exchange account.

For development and testing purposes, a small amount — $10 to $20 — is more than enough to run a meaningful number of test queries against real courts before committing to larger volumes.

Verifying Your Balance

Before making your first paid query, confirm that USDC has arrived in your wallet. You can check programmatically using the Solana web3.js library and DocketLayer's public RPC endpoint:

curl "https://api.docketlayer.ai/v2/status"
import { Connection, PublicKey } from '@solana/web3.js';
import { getAssociatedTokenAddress } from '@solana/spl-token';

const connection = new Connection('https://solana-mainnet.publicnode.com');
const walletAddress = new PublicKey('YOUR_WALLET_ADDRESS');
const usdcMint = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');

const tokenAccount = await getAssociatedTokenAddress(usdcMint, walletAddress);
const balance = await connection.getTokenAccountBalance(tokenAccount);

console.log('USDC balance:', balance.value.uiAmount);

The USDC mint address on Solana mainnet is EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v. This is the only USDC token DocketLayer accepts — not wrapped USDC, not USDC from another network.

Associated token accounts

Solana doesn't store token balances on the wallet address itself — each token has a separate "associated token account." If your wallet has never held USDC before, this account doesn't exist yet. Sending USDC to your wallet for the first time creates it automatically; the sender pays a small rent fee (a few cents) to initialize it. This is normal and happens once per wallet per token.

Next Steps

With a funded wallet, you're ready to make your first paid query. The Quickstart Guide walks through the complete x402 payment handshake — from receiving the 402 challenge to constructing the signed transaction to verifying the response.

Further Reading