@fairblock/stabletrust SDK and handles key derivation, zero-knowledge proofs, and transaction submission for you.
Base URL
Quickstart
Shield 10 USDC into a confidential account on Base Sepolia:How it works
1
Create accounts
POST /account/create provisions the wallet’s confidential account. It’s idempotent, so it’s safe to call every time. A recipient must have an account before it can receive a transfer. Deposit, transfer, and withdraw create the caller’s own account automatically if it’s missing.2
Deposit
POST /deposit moves public ERC-20 tokens from the wallet into its confidential account. The balance is now encrypted onchain.3
Transfer
POST /transfer sends tokens to another confidential account. The amount is hidden onchain, and the funds arrive in the recipient’s pending balance.4
Apply (optional)
POST /apply moves received funds from pending to available. Deposit, transfer, and withdraw already apply pending funds automatically when they need them, so call this when you want to settle received funds explicitly, for example before checking a balance.5
Withdraw
POST /withdraw moves tokens from the confidential balance back to the wallet as public ERC-20.POST /balance. It’s read-only and sends no transaction.
Request fields
These fields are shared across endpoints:
Confidential balances keep 2 decimal places, so the smallest amount is 0.01 of a token (
"10000" for USDC). Amounts with more precision are rounded down to 2 decimal places, and amounts below 0.01 are rejected.
Endpoints
POST /account/create
Provisions the wallet’s confidential account if it doesn’t exist yet. Idempotent.
created is false and message is "Account already exists".
POST /deposit
Moves public ERC-20 tokens from the wallet into its confidential account. The wallet must hold the tokens.
POST /transfer
Sends tokens confidentially to another account. The recipient must already have a confidential account.
POST /apply
Moves the wallet’s pending balance (received funds) to its available balance.
400 with "No confidential account for this wallet; create one first".
POST /withdraw
Moves tokens from the confidential balance back to the wallet as public ERC-20.
POST /balance
Decrypts and returns the confidential balance. Read-only: it sends no transaction and never creates an account.
exists is false and every balance is "0".
GET /health
Checks that the API is up.
Errors
Supported chains
See Supported Networks for the Stabletrust contract on each chain.
Self-hosting
The API is open source at github.com/Fairblock/stabletrust-api. Run it yourself to keep private keys inside your own infrastructure:PORT (default 3000). Optional environment variables:
Best practices
- Use a dedicated agent wallet funded with only what the agent needs, since its private key travels with every request.
- Create the recipient’s account first. A transfer to an address without a confidential account fails.
- Check the available balance with
/balancebefore transferring or withdrawing. - Retry transient failures. Retry
500errors caused by network or RPC issues, and back off when you receive429.
When to use the SDK instead
The API performs standard confidential transfers: amounts and balances are hidden, but wallet addresses are visible onchain. Use the SDK directly if you want private keys to stay in your own runtime, or if you need to hide the sender’s address with unlinkable transfers.Build an App with the SDK
Use the
@fairblock/stabletrust SDK directly in your app or agent runtime.Unlinkable Transfers
Hide the sender’s address as well as the amount.