What is Pocket
Pocket is a trading layer for AI agents on BNB Chain. Connect your agent, set its conditions and stay private.
The pool contract holds custody and checks Groth16 proofs of valid note transitions. Spending proofs hide which notes are consumed. Direct transaction senders, deposits, trading amounts and withdrawals remain visible on-chain.
Quickstart
Everything below happens in the web app. There's nothing to install.
- 1Sign inOpen the app and sign in with your wallet. Signing a message proves it's you; it sends no transaction.
- 2Create an allocationSet a budget, the tokens your agent may trade, its percentage choices and whether you approve each trade. Each allocation gets its own wallet.
- 3Fund and shieldSend BNB or USDT to the allocation's wallet address on BNB Smart Chain, then shield it. The protocol fee is 0.5%; keep a little public BNB for gas.
- 4Connect your agentIn Connections, pick the app your agent lives in: ChatGPT, Claude Code, Grok, Cursor, Muse, WeChat, any MCP app or your own code.
- 5Trade or payReview a PancakeSwap quote and confirm the trade, or paste a Pocket receiving address to send a shielded payment. The recipient can recover and spend its note.
- 6Withdraw and reviewWithdraw to the wallet’s public address, inspect Activity, edit permissions or revoke the agent’s access.
What is private
Notes keep their contents encrypted. The current agent service submits transactions directly from each wallet, so its public sender and transaction timing remain visible. The owner service holds the keys and can read its managed wallets.
| Action | Who | What and how much | Which notes |
|---|---|---|---|
| Deposit | Public | Public | creates one note, contents encrypted |
| Holding | Private | Private | Private |
| Swap quote | owner service / RPC | owner service / RPC | not sent |
| Swap settlement | Public | Public | Private |
| Pocket Pay | public sender, private recipient | Private | Private |
| Withdraw | Public | Public | Private |
On a swap, the sender, pair, amounts, executor, nullifiers and timing are public. Pocket Pay publishes commitments, nullifiers and encrypted receipts without a public token payout. It does not hide the transaction sender.
Pocket for agents
Give an agent a wallet with encrypted notes and a scoped access key. The owner service checks its token budgets, allowed actions, slippage, expiry and revocation before authorizing an operation.
| Capability | What the agent can do |
|---|---|
| Connect any agent | Connect through MCP tools or the JavaScript SDK with a scoped access key. |
| Manage funds | Recover notes, check private balances, request quotes, trade and withdraw. |
| Trade within permissions | Act only inside a budget, token allowlist, slippage cap and time window. |
| Pocket Pay | Send shielded payments to other agents, users and services. |
Connecting an agent
Pocket doesn't build or host agents. You connect the one you already run: give it a label in the app, choose its rules, and get an access key shown once. The key identifies that agent. It is not your spending key and can't move anything outside the rules.
Connect over MCP
In Blind mode your agent reaches Pocket through a remote MCP server. There is nothing to install on your side, and the agent never sees balances or amounts.
- 1Create an access keyOpen an active allocation, go to Connections, name your agent and create its external access key. The key is shown once.
- 2Add Pocket to your agentIn Claude Code, copy the one-line setup command. In Cursor, download the settings file. In any other MCP app, choose Streamable HTTP, paste the MCP server URL and put the key in its bearer token field.
- 3Give it the skillOptional. Download the Blind agent skill and drop it into your agent's skills folder. It explains percentages, approvals and safe retries, and holds no keys.
- 4Ask for a tradeYour agent reads its choices, asks for something like "buy BNB with 5%", and the exact trade waits in Approvals for you.
| Blind tool | Does |
|---|---|
pocket_blind_capabilities | Reads allowed tokens, the percentage choices and how trades get approved. |
pocket_blind_propose | Asks for one percentage trade. Exact amounts stay with you. |
pocket_blind_execute | Runs a resolved trade, only when you allowed automatic mode. |
pocket_blind_status | Reads a coarse status for a request. |
pocket_blind_cancel | Cancels a request that was not sent yet. |
pocket_blind_pause | Pauses its own connection. Only you can resume it. |
Full access tools
| Tool | Does | Spends budget |
|---|---|---|
pocket_balance / pocket_recover | Reads cached balances or recovers notes from events. | No |
pocket_create_wallet | Creates the wallet assigned to this credential. | No |
pocket_quote | Requests a quote from PancakeSwap liquidity on BNB Smart Chain. | No |
pocket_shield / pocket_trade | Shields BNB or proves and settles a swap. | Yes |
pocket_withdraw | Exits funds to the wallet’s public address. | Yes |
pocket_usage / pocket_operation | Reads budget use or an operation’s persisted status. | No |
pocket_receive_address / pocket_pay | Shares a receiving address or sends a shielded payment. | Payment only |
The JavaScript SDK exposes the same operations. Persist a unique request ID before each money operation and reuse it for retries.
Permissions
The owner service enforces these rules. Limits apply per credential, including reserved amounts for pending operations.
- 1Active and unexpiredA revoked or expired credential cannot authorize operations. Revocation is permanent.
- 2Allowed action and tokensShielding, quoting, trading, payments and withdrawals are enabled separately. Both trade assets must be allowed.
- 3Allowed recipientAn optional Pocket Pay allowlist restricts payments to exact receiving addresses.
- 4Slippage within capThe requested trade slippage must fit the configured basis-point limit.
- 5Within token budgetsEach asset has a per-action cap and a day, week or lifetime budget, measured in exact token amounts.
- 6Within gas budgetA separate BNB allowance limits total gas and the maximum cost of one transaction.
Where rules are enforced
Pocket keeps wallet keys in the owner service’s encrypted vault and gives agents scoped credentials. These are service-enforced permissions; the operator and host remain trusted. An owner can create separate wallets or assign credentials to an existing wallet.
| Mode | How it works | Worst case if the agent is compromised |
|---|---|---|
| Scoped credential | The service signs only operations allowed by that credential’s policy. | It can spend within that credential’s configured limits. |
| Separate wallet | Its own wallet balance adds a limit on available funds. | It can spend available funds within its credential’s limits. |
Pocket Pay
Pocket Pay sends a recipient-owned note within the pool. Share the receiving address from the app, paste it into Pocket Pay, choose a token and amount, and submit. The recipient recovers the note from encrypted events and can pay onward, trade or withdraw.
A separate transfer circuit checks ownership, membership and conservation. A payment consumes up to two notes and produces a recipient note plus optional sender change. It moves no public assets and charges no additional protocol fee. Amount, asset and recipient remain private inputs; the transaction sender and timing remain public. Receiving addresses belong to one chain and pool.
Notes
A note is a private record that says "this owner has this much of this asset in this pool". Your balance is the sum of your unspent notes. Notes are never edited: spending one burns it and creates new ones.
The pool stores only a commitment, a Poseidon hash of all the note's fields. Two random values, rho and blinding, make every commitment unique and unguessable even for identical amounts.
- chainIdthe chain ID, so a note can't move to another chain
- poolthis pool's address
- ownerthe wallet that deposited
- assettoken address, zero for native BNB
- amountvalue after the fee
- spendKeyHashPoseidon hash of your spend secret
- rhorandom, feeds the nullifier
- blindingrandom, hides everything else
Alongside the commitment, the pool emits the note encrypted to your viewing key: a 401-byte ciphertext sealed with HPKE (X25519, HKDF-SHA256, ChaCha20-Poly1305). Anyone can see it. Only you can open it.
The note tree
Every new commitment becomes a leaf in a Poseidon Merkle tree with 32 levels, room for about 4.3 billion notes. Each insert produces a new root.
To spend, you prove your note is a leaf under some root the pool has recorded, without saying which leaf. Pocket keeps every root for the life of the pool, so notes created at different times can be spent together, each with its own membership path.
Nullifiers
When you spend a note you reveal its nullifier, a Poseidon hash of the chain, pool, the note's rho and your spend secret. The pool marks it as burned. Trying to spend the same note again reveals the same nullifier and is rejected with InvalidSpend.
Without your spend secret, nobody can link a nullifier back to the commitment it came from, so the chain sees that some note was spent but not which one.
Keys
Pocket gives you two independent keys, generated in your browser.
| Key | What it does | If someone else gets it |
|---|---|---|
| Viewing key | Decrypts your notes so you can see balances and recover them from chain events. | They can see your balances. They cannot spend. |
| Spending key | Derives a spend secret per note. Needed to create nullifiers and prove ownership. | They can spend your notes. Guard it. |
The two are generated separately on purpose, and backups refuse to export them if they are identical. Your connected wallet is still the note owner: deposits bind it, and withdrawals pay it.
Proofs
Each action has its own Groth16 circuit on the BN254 curve, written as readable Circom sources in Pocket v2. Your wallet software, the browser or the owner service, generates the proof, and a verifier contract checks it on-chain. What a proof binds is listed below. Change any of it after proving, and verification fails.
| Circuit | Public inputs | Binds |
|---|---|---|
| Deposit | 6 | chain, pool, depositor, asset, net amount, commitment |
| Trade | 18 | chain, pool, up to 2 roots and nullifiers, pair, amounts, deadline, executor, up to 2 outputs, output ciphertext hash |
| Withdrawal | 15 | chain, pool, up to 2 roots and nullifiers, owner, asset, amount, deadline, change commitment, change ciphertext hash |
| Transfer (Pocket Pay) | 13 | chain, pool, up to 2 roots and nullifiers, deadline, up to 2 output commitments, output ciphertext hash. No asset or amount. |
Binding the chain and pool means a proof can't be replayed anywhere else. Binding the ciphertext hash means nobody can swap your encrypted output for one sealed to them.
Shield
Shielding moves tokens from your wallet into the pool and gives you a private note.
- 1Create and seal the noteYour browser picks fresh randomness, derives a spend secret and encrypts the note to your viewing key.
- 2Prove the depositThe proof binds the chain, pool, your address, the asset, the net amount and the commitment.
- 3Get an admissionYou sign the deposit request. The pool owner's admission service checks it against its policy and returns an approval valid for at most 5 minutes, tied to this exact commitment and ciphertext.
- 4SubmitThe pool checks the proof, consumes the approval, and for tokens confirms that exactly the stated amount arrived. Then the note is inserted.
TransferMismatch. Only reviewed assets on the pool's allowlist can be deposited.Swap
Swaps happen inside the pool. You spend notes in one asset and receive a note in another, without revealing which notes were spent. The pair, the amounts and the sending wallet are public.
- 1Get a quotePocket reads PancakeSwap V2 reserves and returns an exact-input quote within your slippage tolerance, through BNB directly or one hop via WBNB. Agent quotes expire within 60 seconds.
- 2Prove the tradeYour browser proves you own one or two notes covering the sell amount and describes up to two outputs: the bought asset and your change.
- 3Settle atomicallyThe pool sends the sell amount to Pocket's PancakeSwap executor, which must return exactly the quoted buy amount. If reserves moved or anything else is off, the whole trade reverts, nullifiers included.
| Optional solver RFQ (Nostr kind) | Message | Visible to relays |
|---|---|---|
| 28631 | Request | pair, amount, deadline |
| 28632 | Quote | encrypted |
| 28633 | Execute | encrypted |
| 28634 | Result | encrypted |
Withdraw
Withdrawing spends one or two of your notes and sends tokens to the note owner, the wallet you deposited from. If the notes are worth more than you take out, the rest comes back as one change note.
- No fee on withdrawals.
- Works while the pool is paused and after an asset is disabled. Exits never check the pause flag.
- The proof reveals the owner, asset and amount, but not which notes were spent.
Fees
One flat protocol fee of 50 basis points, rounded down: the fee on an amount is that amount divided by 200, ignoring the remainder.
| Action | Charged on | Example |
|---|---|---|
| Shield | the deposit | 10 BNB in → 9.95 BNB note, 0.05 fee |
| Swap | the bought amount | quote of 600 USDT → 597 USDT note, 3 fee |
| Withdraw | nothing | free, you only pay gas |
| Pocket Pay | nothing | free, you only pay gas |
Fees sit in a separate reserve per asset. The treasury can claim that reserve and nothing else. After every action the pool holds exactly what it owes notes plus the fees it earned.
Deposit admission
Deposits need an admission: a signature from the pool owner's admission signer saying this wallet may make this exact deposit. Admission only ever applies to deposits. Trades, withdrawals and Pocket Pay on existing notes don't need it.
- You sign the request with the depositing wallet, so nobody can request admission on your behalf.
- Approvals last at most 5 minutes and are tied to the pool, your address, the asset, the amounts, the commitment and the ciphertext hash.
- Each approval works once. Replays revert with InvalidAdmission.
- A denial or review only blocks that deposit. It never touches existing notes or withdrawals.
Changing the signer or policy is one configuration call on the admission contract, with no redeploy.
Backup and recovery
You can get your notes back two ways.
Encrypted backup file
The Keys card exports your viewing and spending keys sealed with a passphrase of at least 12 characters, using AES-256-GCM and a key derived with PBKDF2-SHA256 over at least 600,000 iterations. Without the passphrase the file is useless.
Rescanning the chain
With your viewing key, Pocket reads every NoteCreated event, tries to decrypt each one, and rebuilds your notes and their Merkle paths. Your spending key then re-derives each note's spend secret and checks it against the commitment.
Guarantees
The pool rejects forged proofs, double spends, replays across chains or pools, altered ciphertexts, stale quotes, expired or reused admissions, lying tokens and underpaying solvers. Each one is a specific check in the contract.
Watch them fail live in the attack console, along with the transactions from the latest end-to-end run that actually mined and reverted them.
Governance powers
Governance is deliberately narrow.
It can
- Enable or disable assets for deposits and trading.
- Pause deposits and trading.
- Change the deposit admission signer and policy.
It cannot
- Move or freeze anyone's notes.
- Stop withdrawals, even while paused.
- Take anything beyond the fee reserve.
Limits
| Limit | Value |
|---|---|
| Notes spent per action | 1 or 2 |
| Swap outputs | 1 or 2 (bought asset plus change) |
| Withdrawal change | 0 or 1 note |
| Largest amount | below 2¹²⁸ base units |
| Pocket Pay notes | 1 or 2 in, 1 or 2 out |
| Admission lifetime | 300 seconds |
| Agent quote lifetime | 60 seconds at most |
| Chain | BNB Smart Chain |
| Tokens | BNB and USDT |
FAQ
Glossary
| Term | Meaning |
|---|---|
| Note | A private record of value you own inside the pool. |
| Commitment | The Poseidon hash of a note. The only thing stored in the tree. |
| Nullifier | A one-time tag revealed when a note is spent, to stop double spends. |
| Root | The top hash of the note tree. Proofs show membership under a known root. |
| Viewing key | Decrypts your notes. Read-only. |
| Spending key | Lets you spend notes. Keep it secret. |
| Admission | A short-lived, single-use approval from the pool owner for one deposit. |
| Solver | A quoting service. Pocket's built-in route uses PancakeSwap V2; independent solvers can also quote over Nostr. |
| Executor | The contract that receives the sell side and must return the exact buy side. |
| Access key | A scoped credential that lets one agent use one wallet, only within its policy. |
| Owner service | The service you run that holds wallet keys and enforces every agent's policy. |
| Receiving address | What you share to get paid with Pocket Pay. It never reveals your spending key. |
| Epoch | A full 32-level tree, sealed so a new one can start. |