The Stabletrust SDK provides a simple, robust interface for executing confidential transfers using homomorphic encryption and zero-knowledge proofs. It lets developers integrate confidentiality directly into their apps - securing token deposits, private transfers, and withdrawals - without requiring deep cryptographic expertise.

What it does

Deposit

Convert public ERC20 tokens into a confidential encrypted balance.

Transfer

Send tokens privately without leaking amounts or balances to the public.

Withdraw

Move funds from the confidential layer back to public ERC20 tokens.

What you can build

Privacy by default unlocks new use cases for open finance that institutions and enterprises require:
  • Confidential payroll apps - stream salaries to employees and contractors without publishing compensation onchain.
  • Confidential token launchpads - let participants contribute privately, hiding contribution sizing from competitors or bots.
  • Web wallets with confidential transfers built in - give everyday users privacy by default for their transactions and balances.
  • x402 payments with confidential transfers - fast, confidential micro-payments for subscriptions, APIs, or AI agents.
  • Treasury management - let DAOs and funds move capital without broadcasting strategy to the market.
Need to shield wallet addresses too, not just amounts? Anonymous transfers route through the Fairycloak relay using numeric account IDs, fully decoupled from any public EVM address - with gasless transfers and withdrawals. See Anonymous Transfers or reach out at hello@fairblock.network to request access.

Installation

Install the Stabletrust SDK into your project:
npm install @fairblock/stabletrust

Supported Networks

The SDK currently supports confidential transfers on the following testnets:
NetworkChain IDNotes
Ethereum Sepolia11155111
Arbitrum Sepolia421614
Base Sepolia84532
Stable Testnet2201
Arc5042002
Tempo42431Uses token-based fees like PathUSD

Quick Start: Code Snippets

The SDK revolves around the ConfidentialTransferClient, which handles the cryptographic heavy lifting.
For a complete walkthrough, see Building an App with the SDK - a step-by-step tutorial for a Next.js app. The snippets below are for quick reference.
1

Initialize the client

Set up the client with your RPC URL and chain ID.
import { ConfidentialTransferClient } from '@fairblock/stabletrust';
import { ethers } from 'ethers';

// Example: Base Sepolia setup
const client = new ConfidentialTransferClient(
  'https://sepolia.base.org',
  84532
);
2

Ensure the account is set up

Before any confidential operation, make sure the user account is initialized onchain. This is a one-time step per user per chain.
// signer is a standard ethers.js Signer
const { privateKey, publicKey } = await client.ensureAccount(signer);
3

Deposit tokens

Deposit tokens to make the balance confidential. Always parse amounts using the token’s decimals (e.g. 6 for USDC).
const tokenDecimals = 6;
const depositAmount = ethers.parseUnits('1.0', tokenDecimals);

await client.confidentialDeposit(signer, tokenAddress, depositAmount);
4

Transfer confidentially

Send tokens to any recipient. The transferred amount is encrypted and hidden from the public ledger.
const transferAmount = ethers.parseUnits('0.5', tokenDecimals);

await client.confidentialTransfer(
  signer,
  recipientAddress,
  tokenAddress,
  transferAmount
);
5

Check the confidential balance

Fetch the user’s decrypted available and pending balance. Use the token’s decimals to format for display.
const balance = await client.getConfidentialBalance(
  signer.address,
  privateKey,
  tokenAddress
);

console.log(
  'Total Confidential Balance:',
  ethers.formatUnits(balance.amount, tokenDecimals)
);

Resources

NPM Package

@fairblock/stabletrust

GitHub

stabletrust-sdk source code

Build a full app

Step-by-step Next.js tutorial.

Confidential Builders Program

Apply to build on the Stabletrust SDK.