
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@agonx402/client
Advanced tools
Consumer SDK for the Agon payment protocol. Use this to register an account, deposit USDC, and make paid API calls to any merchant running @agonx402/platform.
npm install @agonx402/client
Peer dependencies: @solana/web3.js (only needed in Keypair mode)
import { AgonClient } from '@agonx402/client'
import { Keypair } from '@solana/web3.js'
const wallet = Keypair.fromSecretKey(/* your key */)
const agon = new AgonClient({
baseUrl: 'https://api.agon.so',
wallet,
})
// Register and deposit
const { apiKey } = await agon.register()
await agon.deposit(10) // 10 USDC
// Make paid API calls — payment is automatic
const res = await agon.fetch('https://merchant.com/api/premium')
const data = await res.json()
For environments without direct access to a Keypair (e.g. embedded wallets):
import { AgonClient } from '@agonx402/client'
const agon = new AgonClient({
baseUrl: 'https://api.agon.so',
apiKey: 'ak_xxx', // from dashboard or previous registration
signer: async (message) => {
// Use Privy, Phantom, or any wallet to sign
const signature = await myWallet.signMessage(message)
return { signature, message }
},
})
// Discover account info from the API key
const account = await agon.getAccount()
// Make paid API calls
const res = await agon.fetch('https://merchant.com/api/data')
Set limits to protect against excessive spending:
await agon.setSpendingControls({
maxPerRequest: 1_000_000, // $1 max per request
dailySpendingLimit: 50_000_000, // $50/day
proxyEnabled: true,
proxyAllowedDomains: ['api.openai.com'],
})
When a limit is exceeded, the SDK can auto-override with a wallet signature:
const agon = new AgonClient({
baseUrl: 'https://api.agon.so',
wallet,
apiKey: 'ak_xxx',
onLimitExceeded: async (details) => {
if (details.requested < 5_000_000) return 'approve' // auto-approve under $5
return 'reject'
},
})
Keep your balance topped up automatically:
await agon.setAutoRefill({
threshold: 5, // Refill when balance drops below $5
replenishAmount: 20, // Add $20 per refill
monthlyLimit: 100, // Max $100/month in auto-refills
approveAmount: 100, // On-chain SPL approval amount
})
When calling merchant APIs, the SDK automatically creates a short-lived auth token
(X-AGON-TOKEN) instead of exposing the raw API key. The merchant never sees ak_xxx.
You can also create tokens manually for custom integrations:
const { token, expires_in } = await agon.createAuthToken({ maxAmount: 1_000_000 })
// Use token in X-AGON-TOKEN header when calling a merchant
// maxAmount caps the charge at $1 — merchant cannot request more
Tokens are signed by the Agon server, expire in 60 seconds (configurable up to 5 min),
and are single-use — each token can only authorize one reservation, preventing replay attacks.
The agon.fetch() method creates a fresh token automatically for each request.
| Method | Mode | Description |
|---|---|---|
register() | Keypair | Create account, get API key and deposit address |
createAuthToken({ ttl?, maxAmount? }) | Both | Create a short-lived, amount-capped token for merchant requests |
getAccount() | Both | Get account info from API key (sets accountId internally) |
getBalance() | Both | Get current balance (requires accountId) |
deposit(amountUsdc) | Keypair | Send USDC on-chain and credit the account |
withdraw(amountUsdc) | Both | Withdraw USDC to owner wallet |
setSpendingControls(...) | Both | Update spending limits |
getSpendingControls() | Both | Get current spending limits |
setAutoRefill(...) | Keypair | Configure auto-refill with on-chain approval |
revokeAutoRefill() | Keypair | Disable auto-refill and revoke delegation |
fetch(url, init?) | Both | HTTP request with automatic payment (uses auth tokens) |
rotateKey() | Both | Revoke current key and get a new one |
revokeKey() | Both | Revoke the current API key |
MIT
FAQs
Consumer SDK for Agon — deposit, withdraw, and pay with USDC
The npm package @agonx402/client receives a total of 0 weekly downloads. As such, @agonx402/client popularity was classified as not popular.
We found that @agonx402/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.