Settlement
On-chain transfer of owed funds from the vault to the recipient.
Settlement is the process of moving tokens from the channel vault to the recipient, based on accumulated usage. Settlement is always net — one on-chain transaction covers all usage since the last settlement, regardless of how many API calls occurred.
When settlement happens
Settlement is triggered when any of these conditions are met:
- Time interval —
settle_intervalseconds have elapsed since the last settlement - Usage threshold — accumulated usage exceeds a server-defined amount
- Explicit request — either party requests settlement
- Channel close — final settlement occurs automatically on close
Settlement process
- Server constructs a metering proof (see Metering)
- Server submits the
settleinstruction to the AMP program - Program verifies: amount is within balance and rate limit, settle interval has elapsed
- Program transfers tokens from vault to recipient's token account
- Program updates:
balance -= amount,total_consumed += amount,last_settle_ts = now
await program.methods
.settle(new BN(settleAmount))
.accounts({
authority: recipientKeypair.publicKey,
channelState: channelPDA,
vault: vaultPDA,
recipientTokenAccount: recipientAta,
tokenProgram: TOKEN_PROGRAM_ID,
})
.signers([recipientKeypair])
.rpc()Rate limiting
The rate_limit field on the channel constrains the maximum amount that can be settled per interval. This protects the funder from excessive charges:
settleinstruction verifiesamount <= rate_limitsettleinstruction verifiesnow >= last_settle_ts + settle_interval
Auto-settlement
The server SDK includes an auto-settlement engine that runs a background loop:
const amp = new AMP({
// ...
settlement: {
auto: true, // start auto-settlement (default: true)
interval: 3600, // settle every hour
},
})Net clearing
The key advantage over per-request protocols:
| Protocol | 1,000 calls | On-chain transactions |
|---|---|---|
| x402 | 1,000 payments | 1,000 |
| AMP | 1 settlement | 1 |
The server accumulates all usage off-chain and settles the total in a single transaction.