Agents that pay each other onchain expose every invoice, fee, and settlement to the public. The Stabletrust API lets an agent or backend service hold an encrypted balance and pay other accounts without revealing amounts, using plain HTTP requests. There is no SDK to install and no proof generation in your runtime: the API wraps the @fairblock/stabletrust SDK and handles key derivation, zero-knowledge proofs, and transaction submission for you. Base URL
All endpoints accept and return JSON. Amounts and balances are encrypted onchain; wallet addresses stay visible.

Quickstart

Shield 10 USDC into a confidential account on Base Sepolia:
The wallet pays gas for every operation, so it needs the chain’s native token (for example, Base Sepolia ETH) in addition to the tokens it deposits. On mainnet (Arbitrum One, Base, and Ethereum), transfers and withdrawals also charge a protocol fee in ETH.

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.
Check a balance at any time with 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.
If the account already exists, 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.
If the wallet has no confidential account, the API returns 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.
Balances are strings in the token’s base units. If the account hasn’t been created yet, 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:
It listens on 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 /balance before transferring or withdrawing.
  • Retry transient failures. Retry 500 errors caused by network or RPC issues, and back off when you receive 429.

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.