@agonx402/sdk is the official TypeScript SDK for the Agon Protocol. It wraps the live Anchor program into a small set of typed helpers so you can integrate the protocol without hand-rolling IDLs, PDAs, or message encoders.
The SDK is developed in the open at Agonx402/agon-protocol-sdk.
What is inside
The package exposes five composable layers:| Layer | What it gives you |
|---|---|
AgonClient | A thin, typed wrapper around the Anchor program with one method per instruction. |
| PDA helpers | Deterministic derivations for every account the program uses (global-config, token-registry, participant, vault-token-account, channel-v2). |
| Message builders | agon-cmt-v5 commitment and agon-clr-v4 clearing round message encoders, plus Ed25519 pre-instruction helpers. |
| Account helpers | Convenience readers for participant token balances and for computing the next commitment amount from a channel. |
| Constants & IDL | AGON_PROTOCOL_PROGRAM_ID, AGON_CHAIN_IDS, seed strings, and the generated Anchor IDL. |
@coral-xyz/anchor, @solana/web3.js, and @noble/curves — all standard in the Solana TypeScript ecosystem. It has no hidden RPC behaviour: every call you make goes through the AnchorProvider you construct it with.
Install
- Node.js
>= 18 - An Anchor-compatible
AnchorProvider(browser wallet adapter, backend keypair, test ledger, etc.)
"type": "module"). In CommonJS codebases, use a dynamic import() or switch to ESM.
Quick start
AgonClient uses the live program ID baked into the IDL (Ba2puU8D2CLD1dYfRQ4YBXxirdyz3zVLLChvMf9AqJ1Y on devnet). To target a different deployment, pass a programId override:
Sign a commitment and settle
The following snippet is the full direct-settlement flow, compressed. See Recipes for the expanded version with participant setup, deposits, and channel creation.- The commitment is signed off-chain by the payer. The payee is the one who submits it on-chain.
createEd25519Instructionmust be added to the same transaction assettleIndividual; Agon verifies it through theinstructionssysvar.
Versioning
The SDK is on the0.1.x line while the protocol surface stabilises. Breaking changes are signalled in the npm changelog and tracked against the program’s IDL. The package ships the generated IDL and TypeScript program type, so upgrading the SDK is always aligned with a protocol upgrade.
Where to go next
AgonClient
Every instruction the SDK can build — initialize, deposit, lock, settle, withdraw.
PDAs & constants
Derive every account the program uses, deterministically and off-chain.
Messages
Build
agon-cmt-v5 and agon-clr-v4 messages and sign them with Ed25519.Recipes
End-to-end flows: register, fund, sign, settle, withdraw.

