Docs
Agent keys
An agent key is an ordinary Solana keypair with one power: it is the approved delegate on one budget account. Here is what that makes it, how to make one, and how to replace it.
What the key is
The key holds no USDC and no SOL. The money sits in the budget account, which the budget owns, and the key is named on that account as its delegate for an amount. That amount is everything the key can do.
| The key | |
|---|---|
| Signs | Payments out of its budget account, up to the allowance, and two small reports to Breaker. |
| Pays fees with | Nothing. The service’s facilitator is the fee payer of every payment. |
| Belongs to | One budget. A budget’s address is derived from the panel and the key it opened with. |
| Is replaced by | Rotate key, in one transaction from the owner. |
Generate one in the panel
On New budget and on Rotate key, choose Generate here. The keypair is made in your browser. Its public half goes into the transaction you sign; its secret half is shown once on the confirmation screen, with Copy the key and Download.
Take the key from the confirmation screen before you leave it. It is shown there once and is kept nowhere else.
Bring your own
Choose Paste a public key to use a keypair you made yourself. The secret then never leaves the machine it was made on.
solana-keygen new --no-bip39-passphrase -o agent.json
solana-keygen pubkey agent.json # paste this into the panel
Or in code:
import { Keypair } from '@solana/web3.js'
const agent = Keypair.generate()
console.log(agent.publicKey.toBase58()) // paste this into the panel
console.log(JSON.stringify([...agent.secretKey])) // keep this for the agent
The forms the SDK reads
Pass the key to breaker() as key in any of these. Each may hold a 32-byte seed or a 64-byte secret key.
| Form | Looks like |
|---|---|
| A base58 string | What the panel shows and what most wallets export. |
| A JSON byte array, as a string | The contents of a solana-keygen file: [12,201,…]. |
Uint8Array | Bytes you already hold in memory. |
| An array of numbers | The parsed contents of a keypair file. |
import { readFileSync } from 'node:fs'
import { breaker } from '@breaker/sdk'
// from the environment
const a = breaker({ budget: process.env.BREAKER_BUDGET, key: process.env.BREAKER_AGENT_KEY })
// from a keypair file
const b = breaker({ budget: process.env.BREAKER_BUDGET, key: readFileSync('agent.json', 'utf8') })
Where it lives
The key belongs with the agent: an environment variable, a secret in your deploy platform, a keypair file on the machine. The agent needs two values to pay, the budget’s address and the key, and the docs name them BREAKER_BUDGET and BREAKER_AGENT_KEY.
The key is used on the agent’s machine only. The SDK signs with it locally; what leaves the machine is a signed payment for one price, and reports that carry a signature and no key material.
One key, one budget
Give each agent its own key and its own budget. The budget’s address is derived from the panel and the key it opened with, so a key opens one budget in a panel, and each agent then has its own limit, its own switch and its own ledger.
On chain, the key is the name of the agent. It is the authority of every payment the agent makes, so anyone reading the chain can tell one agent’s payments from another’s by it.
Replace a key
Open the budget and press Rotate key. Generate or paste the new key and sign. A token account has one delegate, so approving the new key removes the old one in the same instruction.
| After the transaction | |
|---|---|
| The new key | Is approved for what remained of this period’s limit. |
| The old key | Pays nothing from the budget account. An agent still holding it gets BudgetOff. A session it opened keeps it as voucher signer, within that session’s deposit, until the channel closes: switch the budget off first to close them. |
| The budget | Keeps its address, its money, its periods, its ledger and its lines. |
| The agent | Needs the new key in BREAKER_AGENT_KEY. BREAKER_BUDGET stays as it is. |
To stop a key at once without replacing it, Switch off. Both are covered on the Budgets page.