An end-to-end walkthrough: register, fund, open a channel, sign a commitment, and settle.
This guide shows the smallest useful Agon integration: one payer, one payee, one token, one payment channel, and one settled agon-cmt-v5 message.The examples mirror the current protocol tests. Until a dedicated SDK ships, this is the most direct way to integrate Agon today.
import * as anchor from "@coral-xyz/anchor";import { Program } from "@coral-xyz/anchor";import { Ed25519Program, PublicKey, SystemProgram } from "@solana/web3.js";import { AgonProtocol } from "../target/types/agon_protocol";const provider = anchor.AnchorProvider.env();anchor.setProvider(provider);const program = anchor.workspace.agonProtocol as Program<AgonProtocol>;
The channel PDA seed order is payer_id (u32 LE) || payee_id (u32 LE) || token_id (u16 LE) under the channel-v2 prefix. If you derive in a different order, settle_* instructions will reject the account.
The payeeOwner signer is only required when the payee’s inbound-channel policy demands consent. Under Permissionless, channel creation does not require the payee to sign.
agon-cmt-v5 is cumulative. It does not say “pay 25 again.” It says “this channel is now authorized up to cumulative amount X.”The helper below matches the real test suite:
The signer above must match the channel’s current authorized_signer. This key signs new cumulative payment amounts for that channel. By default it is the payer wallet that created the channel; if the channel uses a different signing key, that key must sign here instead.
authorized_signer signs the payment update. authorized_settler may submit the signed update on-chain. They are separate roles — see Authorized settler.
The program verifies the Ed25519 instruction, parses the message, checks the message_domain, validates the canonical payer / payee / token / channel, then moves the delta between the old and new cumulative amounts.
The payee balance has increased by the same amount.
Any locked funds used by the settlement have been consumed first.
If an operator also needs to be paid, model that as a separate channel payment rather than as a fee field inside this message — see Operator payment.That is the full direct settlement flow.