Introduction
Docs

Fuse

Fuse puts every agent that pays on its own fuse: a rating per period over a USDC account the agent does not own. The agent key is worth that rating and nothing more.

Why a fuse

Agents pay for things now. An inference call, a search, a scraped page: services answer 402 Payment Required with a price and the agent pays it over x402. The usual way to let an agent do that is to hand it a wallet with money in it.

That wallet is a problem the day its key leaks or the agent gets stuck in a retry loop. Everything in it is within reach. A fuse moves the money out of the agent’s reach and leaves it one number to spend against.

Three parts

PartWhat it is
The fuseAn account of the Fuse program holding the terms: the rating, the period, the expiry, whether it is pulled or blown, and the running totals.
The fuse accountA USDC token account that holds the money. The fuse owns it. The agent key never does.
The allowanceThe amount the agent key is approved to move out of the fuse account, using the token program’s own Approve. This is the rating, live.

Where to go next

Start

Quick start

Open a fusebox, add a fuse, give its key to the agent, and swap fetch for agent.fetch.

1. Add a fuse

In the fusebox, pick a name, a rating and a period, and fund the account. The fusebox gives you an agent key that is approved for the rating and holds nothing else.

2. Import the SDK

The SDK is one ES module with no dependencies. Import it straight from this site:

import { fuse, createBudget } from "https://fuseagent.vercel.app/lib/fuse.js";

const budget = createBudget({ name: "research", limit: 2, period: "hour" });
const agent  = fuse({ budget, key });

const res = await agent.fetch("https://search.example/q?s=fuses");
<script type="module">
  import { fuse, createBudget } from "https://fuseagent.vercel.app/lib/fuse.js";
  const agent = fuse({ budget: createBudget({ limit: 2, period: "hour" }) });
  agent.fetch("/api/paid").then(r => r.json()).then(console.log);
</script>
# what the SDK does, by hand
curl -i https://search.example/q                       # 402 + PAYMENT-REQUIRED header
curl -i https://search.example/q \
  -H "PAYMENT-SIGNATURE: <base64 payment>"              # 200 + PAYMENT-RESPONSE

3. Let it blow

When a price is over what is left, agent.fetch throws FuseBlown before it signs anything. Catch it and decide what the agent does next.

try {
  const res = await agent.fetch(url);
} catch (e) {
  if (e.name === "FuseBlown") console.log("rolls at", new Date(e.rollsAt));
  else throw e;
}
NOTEThe signer you pass to fuse() decides what actually gets signed. Without one, the SDK runs a dry run: it builds the exact four-instruction payment plan and sends it as the header, without touching a chain. That is what Try it uses.
Start

The fusebox

The fusebox is the panel of every fuse your wallet owns: its meter, its state and its pull, plus a main that pulls all of them.

A fuse card

  • Meter. Spent against the rating this period. The last ticks warm amber past 62% and run white-hot past 85%.
  • State. Live, Blown or Pulled.
  • Controls. Reset, Pull or Seat, Fund, Rotate key, Close.
  • Copy code. The two lines that put this fuse into an agent.

The main

The main sits above all the cards. Pulling it revokes every agent key in one go; seating it approves each of them for what is left of its rating again.

Dry run

The fusebox on this site keeps its fuses in your browser and moves no money. Agents you run there pay test services with the dry-run signer, so you can watch a fuse heat, blow and roll without funding anything.

Fuses

Fuses

A fuse is three things on chain and one rule: the agent key can move the smaller of what is left of the rating and what is in the account.

The model

what the key can pay next  =  min( rating − spent this period ,  account balance )
                              → 0 if the fuse is blown, pulled or expired

Fields

FieldTypeMeaning
limitu64The rating: base units of the mint per period.
periodu32Seconds. 60, 3600, 86400 or 604800 in the fusebox; any value in the program.
periodStarti64Unix time the current period began.
spentu64Taken off the allowance this period.
blownboolSet by a payment that did not fit. Cleared by a roll or a reset.
pulledboolSet by the owner. While set, the allowance is revoked.
expiresi640 for never. After it, nothing passes.

Life of a fuse

  1. Created and funded: the account holds money, the key is approved for the rating.
  2. Live: payments take the price off the allowance.
  3. Blown: a price over what is left. Nothing is sent, nothing passes.
  4. Rolled: the period ends, the full rating is approved again, the fuse is whole.
Fuses

Blow

A fuse blows when a price is above what is left this period. It is the one place Fuse is stricter than a plain allowance.

What happens

The SDK reads the price from the 402, compares it to what is left, and stops before it signs. It throws FuseBlown with the price, what was left and when the period rolls. The fuse records itself as blown.

Why nothing else passes

With a plain allowance, a cheaper payment that still fits would go through. A blown fuse refuses everything until it rolls or the owner resets it. An agent that tried to spend over its rating once is doing something you did not plan for, and the cheapest moment to look at it is right then.

WARNINGThe blown flag lives in the fuse, not in the token program. A key used outside the SDK can still move what is left of the allowance until the period rolls. If you think a key has leaked, pull the fuse: that revokes the allowance itself.
Fuses

Roll and reset

Two ways to get the full rating back: the clock, and you.

Roll

At the end of every period, one transaction closes it with what it spent, clears blown, and approves the full rating again. Fuse’s keeper sends it for every fuse at its boundary, on the chain’s own clock. Each closed period stays in your ledger.

Reset

A reset is the owner doing the same thing early: the full rating again, now, inside the same period. It is one transaction from your wallet.

import { replace, reset } from "https://fuseagent.vercel.app/lib/fuse.js";
replace(budget);  // close the period now, open the next one
reset(budget);    // full rating back, same period
Fuses

Pull

Pulling a fuse revokes the agent key in one transaction. It holds from the next slot.

The instruction

A pull is the token program’s Revoke on the fuse account, plus the fuse marking itself pulled. Seating it again is an Approve for what is left of the rating.

import { ix } from "https://fuseagent.vercel.app/lib/fuse.js";
const pull = ix.revoke(fuseAccount, owner);          // data: [5]
const seat = ix.approve(fuseAccount, agentKey, owner, 2_000_000n); // data: [4, u64 le]

The main

The main in the fusebox sends one revoke per fuse, packed into as few transactions as fit.

Fuses

Keys

One agent, one key. The key holds no money and no SOL; it is only ever the delegate of one fuse account.

Rotate

Rotating approves a fresh key and revokes the old one in the same transaction. The old key pays nothing from the next slot. The fuse account, and so the payer a service sees as the source, stays the same.

Expiry

A fuse can carry an expiry. After it, the SDK refuses with FuseExpired and the keeper revokes the allowance at the next roll.

Agents

SDK

lib/fuse.js is a single ES module with no dependencies. Every function below is exported from it.

fuse(options)

OptionMeaning
budgetA fuse from createBudget(). Required.
keyThe agent key, { publicKey }, plus whatever your signer needs.
signerasync (requirement, budget, key) => ({ header, value, plan }). Defaults to dryRunSigner.
fetchThe fetch to use. Defaults to the global one.
onEventCalled with request, 402, paid, refused and response events.

Returns { fetch(url, init), remaining(), budget }.

createBudget(options)

limit in whole USDC, period as "minute", "hour", "day", "week" or seconds, balance, expires in ms. Returns a plain object you can store as JSON.

Other exports

charge(b, price)Check a price against the fuse and take it, or throw.
remaining(b)What the key can still pay this period.
replace(b) · reset(b)Roll now · full rating, same period.
pull(b) · seat(b)Mark the fuse pulled or seated.
readRequirement(res)Read a 402, version 1 or 2, and return the Solana exact requirement.
paymentPlan(req, b, key)The four instructions a payment is made of.
ix.approve · ix.revoke · ix.transferCheckedToken program instructions with the real byte layouts.
base58encode and decode.
mockService({ price })A fetch that answers 402, then 200 once paid. For tests.
Agents

x402

A fuse payment is a standard x402 payment in the exact scheme for Solana. The SDK speaks both versions of the protocol.

The exchange

→  GET /search?q=fuses
←  402 Payment Required
   PAYMENT-REQUIRED: base64({ x402Version: 2, accepts: [{ scheme: "exact", network: "solana:5eykt4…",
                              amount: "60000", asset: USDC, payTo, extra: { feePayer } }] })
   · the SDK checks 0.06 against the fuse, then signs
→  GET /search?q=fuses
   PAYMENT-SIGNATURE: base64({ x402Version: 2, scheme: "exact", payload: { transaction } })
←  200 OK
   PAYMENT-RESPONSE: base64({ success: true, transaction, network })

Version 1

On version 1 the requirement comes in the body, the amount is maxAmountRequired, and the payment goes back in X-PAYMENT. readRequirement() handles both.

Amounts

Amounts in x402 are base units of the mint. USDC has 6 decimals, so "60000" is 0.06 USDC.

Agents

Recipes

Small patterns that come up in every agent.

Wait for the roll

catch (e) {
  if (e.name === "FuseBlown") await sleep(e.rollsAt - Date.now());
}

Log every payment

const agent = fuse({ budget, key, onEvent: e => e.type === "paid" && console.log(e.url, e.amount) });

One fuse per tool

Give an agent a separate fuse for each expensive tool: a small hourly one for inference, a daily one for search. One blown fuse stops one tool, not the whole agent.

Agents

Try it

The SDK from this site against a test service that answers 402. Every line below is an event from agent.fetch.

// press agent.fetch(url)

The code running here

import { fuse, createBudget, mockService } from "../lib/fuse.js";
const budget = createBudget({ limit: 0.3, period: "hour" });
const agent = fuse({ budget, fetch: mockService({ price: 0.06 }), onEvent: print });
await agent.fetch("https://search.example/q");
Reference

Program

Every fuse operation comes down to token program instructions on the fuse account. These are the byte layouts the SDK builds.

Token instructions

InstructionTagDataSigner
Approve4[4, amount u64 le]Owner
Revoke5[5]Owner
TransferChecked12[12, amount u64 le, decimals u8]Agent key, as delegate

A payment

#InstructionValue
1SetComputeUnitLimit20,000 units
2SetComputeUnitPrice1 micro-lamport per unit
3TransferCheckedThe price, from the fuse account to the service’s token account
4MemoThe service’s reference, or a random one

Addresses

Token programTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
USDCEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
Networksolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
Reference

Errors

Every refusal happens before anything is signed. None of them moves money.

NameCodeWhenCarries
FuseBlown6001The price is over what is left, or the fuse already blew this period.price, left, rollsAt
FusePulled6002The owner pulled the fuse or the main.—
FuseExpired6003The fuse is past its expiry.expiredAt
FuseWrongMint6004The service asks for a mint the fuse does not hold.—
FuseEmpty6005The rating has room, the account does not. Fund it.price, balance
Reference

Constants

Numbers the SDK and the fusebox use.

NameValue
PERIODS.minute60
PERIODS.hour3,600
PERIODS.day86,400
PERIODS.week604,800
USDC decimals6
Compute unit limit20,000
Memoup to 256 bytes
Meter warm / hot62% / 85% of the rating
Protocol

For services

What you already do is what a fuse needs. A fuse payment follows the x402 exact scheme for Solana to the letter.

From your side

  1. Answer 402 with an exact price on Solana.
  2. Name your price in USDC.
  3. Name payTo, your wallet.
  4. Name your facilitator’s key as extra.feePayer, so the agent needs no SOL.
  5. Hand the payment to your facilitator and answer with the result.

The one thing that differs

In most x402 payments the account the money leaves belongs to the key that signs. In a fuse payment the signer is the account’s delegate: the money leaves an account the fuse owns, and the agent key signs as the one approved to move it. The token program treats both the same way, and a facilitator checks the mint, the amount and the destination, so it passes the same checks.

TransferChecked
  source       the fuse account        (not the payer's own wallet account)
  mint         USDC
  destination  your token account
  authority    the agent key           (the source account's delegate)
  amount       your price, in full

Who paid

The transfer’s authority is the agent key: one agent, one key, the steadiest name for a customer. The source is the fuse account, which stays the same when the owner rotates the key.

An agent at its limit

The SDK checks the price before it signs. An agent whose fuse cannot cover your price sends you no payment at all: you see the first request and no second one. Your facilitator is never handed a transfer that would fail.

Protocol

Threat model

What a fuse protects, and what it does not.

EventWorst case
Agent key leaksWhat is left of this period’s rating. Pull the fuse and it is zero from the next slot.
Agent loopsThe SDK blows the fuse at the first price over the line. Nothing passes until the roll.
Service overchargesOne payment, up to what is left. The blow stops the next one.
Owner wallet leaksEverything in every fuse. A fuse protects you from your agent, not from yourself.
WARNINGKeep the rating small and the period short for agents you do not watch. A fuse is cheap to replace; a month of money is not.
Protocol

$FUSE

The coin of everyone who would rather lose 2 USDC to a looping agent than 1,240. Fair launch on Solana.

What it is

$FUSE is the token of this project. Fuses themselves hold USDC and payments settle in USDC; you never need $FUSE to put an agent on a fuse.

Contract

The address appears above once the coin is live. Click it to copy.

Protocol

FAQ

Short answers.

Does the agent need SOL?

No. The service’s facilitator pays the network fee as feePayer.

Can a service tell it is a fuse?

Only by reading the source account. The transfer, the amount and the destination are the ones it asked for.

What if I set the rating too low?

The fuse blows, you see it in the fusebox, and you change the rating in one transaction.

Is the fusebox on this site real money?

No. It is a dry run kept in your browser, so you can watch fuses heat and blow without funding anything.

Why not just a smaller wallet?

A smaller wallet still loses everything in it, and you have to refill it by hand. A fuse holds a month behind a daily rating and refills its own allowance every period.