One Anchor program, breaker. It owns the rules; the token program enforces the limit on every payment.
Program id
Built with Anchor. It reaches tokens through the token interface, so a budget can hold a mint of SPL Token or of Token-2022.
How it is built
The agent key is the standard delegate of a token account, approved for an amount. A payment is a TransferChecked signed by that delegate, straight to the token program. The Breaker program takes no part in it.
The program learns what was paid the next time it touches the budget, by reading how far the token account’s delegated amount has fallen below what it last approved. It adds that difference to the period’s spend and to the lifetime spend, then carries out the instruction. Every budget instruction starts with this step.
spent since the last touch = approved_at_touch - delegated_amount
remaining = limit - (spent_at_touch - reset_spent_at_touch)
while the budget is on and not expired, else 0
The allowance is set with the token program’s Approve and removed with Revoke, signed by the Budget address through a cross-program call. No key held by a person or a server can sign for a budget.
Accounts
Account
Holds
Size
Config
The admin and the fee rate. One per program.
43 bytes
Panel
The owner and the count of budgets. One per wallet.
45 bytes
Budget
The terms and the running totals of one budget.
303 bytes
Budget account
The budget’s money: a token account for its mint, owned by the Budget address, with the agent key as delegate.
A token account
Drawer
Marks a budget that draws on its panel’s reserve. One per drawing budget.
73 bytes
Reserve
The panel’s money for one mint: a token account owned by the Panel address. Budgets that draw fill from it.
A token account
Fee account
The funding fees for one mint, owned by a program address that no key signs for.
A token account
ChannelRecord
One payment channel a budget opened: what it deposited and the period that deposit counts against.
225 bytes
Channels
How many channels a budget has open. It exists only while one is.
77 bytes
Line
One service a budget on lines pays: its payout address, its cap per period and its spend.
105 bytes
Lines
How many lines a budget has. While it exists the budget is on lines.
45 bytes
Member
A wallet the owner lets sign some of the panel’s instructions, with its roles.
74 bytes
Config
Field
Type
What it is
admin
Pubkey
Who may set the fee. Set once, when the Config is created by the program’s upgrade authority.
fee_bps
u16
The funding fee in basis points, 0 to 10,000.
bump
u8
The address bump.
Panel
Field
Type
What it is
owner
Pubkey
The wallet that owns the panel and every budget in it.
budget_count
u32
How many budgets are open.
bump
u8
The address bump.
Budget
Field
Type
What it is
panel
Pubkey
The panel it belongs to.
seed_agent_key
Pubkey
The agent key it opened with. Part of the address; it never changes.
agent_key
Pubkey
The key now approved as delegate.
mint
Pubkey
The mint the budget holds and pays in.
token_program
Pubkey
SPL Token or Token-2022.
label
String
1 to 64 bytes.
limit
u64
The allowance granted per period, in base units.
period_seconds
i64
The length of a period.
period_start
i64
When the current period started, in unix seconds.
expiry
Option<i64>
When the budget stops paying, if it does.
on
bool
Whether it is switched on.
spent_at_touch
u64
This period’s spend as of the last instruction.
approved_at_touch
u64
The allowance the program last set.
lifetime_spent
u64
Everything the budget has paid, as of the last instruction.
bump
u8
The address bump.
reset_spent_at_touch
u64
This period’s spend at the last reset. What was spent since then counts against the limit.
Drawer
Field
Type
What it is
budget
Pubkey
The budget that draws.
panel
Pubkey
The panel whose reserve it draws on.
bump
u8
The address bump.
ChannelRecord
Field
Type
What it is
budget
Pubkey
The budget that pays into the channel.
channel
Pubkey
The channel, an account of the payment-channels program.
payee
Pubkey
The channel’s payee: the key of the facilitator that opened it.
recipient
Pubkey
Who the channel pays out to: the service’s payTo.
authorized_signer
Pubkey
The key that signs the channel’s vouchers: the agent key for a session, the service’s for a metered call.
deposit
u64
Everything put into the channel.
counted
u64
The part of the deposit counted against the period in period_start.
period_start
i64
The period the deposit counts against. A top-up in a later period starts the count again.
rent_payer
Pubkey
Who paid the record’s rent, and gets it back when it closes.
bump
u8
The address bump.
Channels
Field
Type
What it is
budget
Pubkey
The budget.
open
u32
How many of its channels are open.
rent_payer
Pubkey
Who paid its rent, returned when the last channel closes.
bump
u8
The address bump.
Line
Field
Type
What it is
budget
Pubkey
The budget.
recipient
Pubkey
The service’s payout address, its payTo. A channel charged to this line pays out to it alone.
cap
u64
The most the service may take in one period.
spent
u64
What the line was charged in the period period_start names.
committed
u64
What that spend still holds in open channels: the most their closing can give back to the line.
period_start
i64
The period spent belongs to. A charge in a later period starts spent and committed at zero.
bump
u8
The address bump.
Lines
Field
Type
What it is
budget
Pubkey
The budget.
count
u32
How many lines it has.
bump
u8
The address bump.
Member
Field
Type
What it is
panel
Pubkey
The panel.
key
Pubkey
The member’s wallet.
roles
u8
Bit 1 is Switch, bit 2 is Limits; one or both.
bump
u8
The address bump.
To read a budget’s live figures between instructions, add what the token account shows:
remaining now = token account's delegated_amount
spent this period now = spent_at_touch + approved_at_touch - delegated_amount
Instructions
Instruction
Signer
What it does
open_panel
Owner
Creates the owner’s panel.
open_budget
Owner; a Limits member with no funding
Creates the budget and its account, moves the funding in less the fee, approves the agent key for the limit, and starts the first period.
fund
Owner
Moves an amount from the owner to the budget account, less the fee to the fee account.
withdraw
Owner
Moves an amount from the budget account to the owner.
set_limit
Owner or a Limits member
Sets the limit, period and expiry. The allowance becomes what now remains.
roll
None
Once the period has ended: records its spend, starts the next and approves the limit again. Past expiry it revokes instead.
reset
Owner or a Limits member
Approves the full limit now. The period keeps its end.
switch_off
Owner or a Switch member
Revokes the delegate.
switch_on
Owner or a Limits member
Approves what remained.
rotate_key
Owner or a Limits member
Replaces the agent key; the new approval replaces the old one.
close_budget
Owner
Returns the balance and the rent to the owner and closes the budget.
init_config
Admin
Creates the Config. Only the program’s upgrade authority can.
set_fee
Admin
Sets the fee rate.
fund_reserve
Owner
Moves an amount from the owner to the panel’s reserve, less the fee to the fee account.
withdraw_reserve
Owner
Moves an amount from the reserve to the owner.
draw_on
Owner or a Limits member
Creates the budget’s Drawer, so it draws on the reserve.
draw_off
Owner or a Limits member
Closes the Drawer and returns its rent to the owner. The budget keeps its balance.
draw
None
Moves from the reserve what brings the budget account’s balance up to its delegated amount, as far as the reserve holds. Signed by the Panel address.
open_channel
Agent key, rent payer
Counts the deposit against the period’s limit and lowers the allowance by it, then opens a payment channel with the budget as payer and records it.
top_up_channel
Agent key
Counts an amount against the period’s limit the same way, then adds it to an open channel.
distribute_channel
None
Runs the channel program’s distribute. For a sealed channel it pays the service, returns the rest to the budget account and, if counted this period, to the allowance, and closes the record. An open channel pays out what is settled and stays open.
close_channel
None
Closes the record of a channel distributed outside Breaker, crediting what it returned while the channel program still holds it.
request_channel_close
Owner or a Switch member; anyone while the budget is off or expired
Runs the channel program’s request_close, which starts the channel’s grace.
set_line
Owner or a Limits member
Adds a line for a service, or sets a new cap on one. The first creates Lines and revokes the agent key’s delegation.
remove_line
Owner or a Limits member
Closes a line and returns its rent to the owner. The last one closes Lines and approves the key for what remains.
add_member
Owner
Creates a Member for a wallet with its roles. The owner pays its rent.
set_roles
Owner
Sets a member’s roles.
remove_member
Owner
Closes the Member and returns its rent; the wallet is refused from the next instruction on.
Arguments
Instruction
Arguments
Checks
open_budget
label, limit, period_seconds, expiry, funding
The label is 1 to 64 bytes. The limit is above zero; the funding may be zero. The period is 60 seconds or more. The expiry, if any, is in the future.
fund
amount
Above zero.
withdraw
amount
Above zero and within the balance.
set_limit
limit, period_seconds, expiry
As for open_budget.
reset, switch_on
None
The budget is not expired.
rotate_key
None; the new key is an account
The new key differs from the current one.
roll
None
The period has ended, or the budget is past its expiry.
fund_reserve
amount
Above zero.
withdraw_reserve
amount
Above zero and within the reserve.
draw_on, draw_off, draw
None
The budget belongs to the panel. draw needs the budget’s Drawer.
The budget is on and not expired. The deposit is above zero, within what remains this period and within the balance. The channel program checks the rest of the open.
top_up_channel
amount
As for open_channel. The channel is the record’s.
distribute_channel
recipients
The channel is the record’s and still held by the channel program.
close_channel
None
The channel is distributed, or no longer exists.
request_channel_close
None
The signer is the owner, or the budget is off or expired.
set_line
recipient, cap
The cap is above zero. The first line needs the budget to have no channel open.
remove_line
recipient
The budget has a line for that recipient.
Amounts are u64 in the mint’s base units and times are unix seconds. The app offers periods of an hour, a day and a week. recipients is a list of { recipient: Pubkey, bps: u16 }, the channel program’s payout split; the SDK and Breaker’s facilitator send one entry, the service’s payTo at 10,000.
The roll
roll takes no signer: whoever pays its network fee may send it, and it can only do the one thing the budget’s own terms call for. It moves period_start forward by whole periods, so a budget that sat through several keeps the rhythm it opened with. Breaker’s keeper sends it for every budget at the earlier of its period end and its expiry.
The draw
draw takes no signer either. It moves only from the budget’s own panel reserve into the budget’s own account, and only what the allowance the program set calls for. For a drawing budget, the keeper sends roll and draw in one transaction, and the app adds draw to Reset, Switch on and Change in the transaction the owner signs.
The channels
A budget pays into a channel of the payment-channels program, CHNLxYvVA28MJP9PrFuDXccuoGXAx7jBacfLEkahyGsX, through cross-program calls signed with the budget’s seeds: open, top_up, request_close and distribute. Vouchers, settlement and sealing are the channel program’s own. Money a channel returns goes only to the budget account, so distribute_channel and close_channel take no signer.
On a budget on lines, open_channel must name one recipient at the full share, 10,000, and pass that recipient’s Line; top_up_channel passes the line of the channel’s recipient. The amount has to fit the line’s cap less its spend this period as well as the budget, and is added to both.
distribute_channel reads the channel’s deposit and what was settled before it distributes: the channel program frees a channel past its open window as it distributes, and after that nothing on chain says what it returned. The credit to the allowance is the smaller of what came back and counted, and never takes the period’s spend below where it stood at the last reset. close_budget takes the budget’s Channels address as its one remaining account and refuses while that account exists. On a budget on lines, the part that comes back is credited to the channel’s line too, up to what that line still has committed in the period.
On lines
Allowance is granted in one place, set_allowance, and every instruction that calls it passes the budget’s Lines address. While that account exists the grant is zero: a budget on lines leaves its agent key with no delegation, and money leaves the budget account only through open_channel and top_up_channel, which move it as the account’s owner and are charged to a line.
Takes the Lines address
Why
set_limit, reset, switch_off, switch_on, rotate_key, roll
They set the allowance, which is zero on lines.
draw
On lines it fills the balance up to what remains of the limit, not up to a delegated amount.
They charge or credit the line, passed as an optional Line account.
close_budget
It refuses while Lines exists. The API’s Close build removes every line first, in the same transaction.
Members
The instructions a member may sign take an authority signer where they took the owner, and an optional Member account. The program accepts the authority when it is the panel’s owner, or when the Member at ["member", panel, authority] holds the instruction’s role. draw_off and remove_line also name the owner, where the rent of what they close returns. open_budget signed by a member refuses any funding, and its two token accounts for the funding are optional. Everything else stays the owner’s alone: fund, withdraw, fund_reserve, withdraw_reserve, close_budget and the three member instructions. The Team page has the roles in full.
Role
Bit
Instructions
Switch
1
switch_off, request_channel_close
Limits
2
set_limit, reset, switch_on, rotate_key, open_budget with no funding, draw_on, draw_off, set_line, remove_line
A panel owned by a Squads v4 vault needs nothing from the program: the vault signs as the owner when a vault transaction executes.
Events
Every instruction emits one event. Breaker’s indexer follows them, together with each budget account’s outgoing transfers, to build the ledger you read in the panel. Payments themselves are plain token transfers that anyone can read from the chain.
Event
Emitted by
Carries
ConfigChanged
init_config, set_fee
The admin, the fee rate and the time.
PanelOpened
open_panel
The panel, its owner and the time.
BudgetChanged
Every budget instruction
The action and a full picture of the budget after it.
ReserveChanged
fund_reserve, withdraw_reserve, draw
The action, the amount, the fee and the reserve’s balance after it.
The channel, its record, and the budget after the change.
LineChanged
set_line, remove_line, and a channel instruction that charges or credits a line
The line after the change and how many lines the budget has.
MemberChanged
add_member, set_roles, remove_member
The member and its roles after the change.
BudgetChanged, LineChanged, ChannelChanged and DrawChanged end with signer: the wallet that signed the instruction, the owner, a member, or for a permissionless instruction whoever sent it.
BudgetChanged
Field
What it is
action
One of Open, Fund, Withdraw, SetLimit, Roll, Reset, SwitchOff, SwitchOn, RotateKey, Close.
budget, panel, owner
The budget and whose it is.
seed_agent_key, agent_key
The key it opened with and the key now approved.
mint, token_program, token_account
What it holds and where.
label, limit, period_seconds, period_start, expiry, on
A budget’s address is fixed by the key it opened with, so rotating the key changes who can pay and leaves the budget, its account and its money where they are.