agent.pay(url), settles a real on-chain
payment and returns the gated response. No API key, no KYC, no
custodian. The protocol is token-free: there is nothing to buy, list, or
hold to use it.
You’ll need a few cents of MATIC on Polygon to fund your agent’s
wallet. The SDK generates the wallet for you — you just send funds to
the address it prints.
1
Install the SDK
Pick your language. Both packages are published as stable
1.0.0.2
Create an agent
Agent.new() generates a fresh keypair and prints the funding
address. Persist the secret (secret_b58 / secretB58) if you want
to reuse this agent identity later.3
Fund the wallet
Send a small amount of MATIC to the address printed above — a few
cents is plenty for the example call. Funds stay in your agent’s own
wallet until a payment settles; AiFinPay never holds them.
4
Make a paid call
agent.pay(url) handles the full HTTP 402 handshake for you: it
reads the payment challenge, signs it, settles on-chain, retries the
request with the proof headers, and returns the gated response.5
See the result
You get back the upstream response body — in this case a model
completion. The
x-payment-receipt header carries the on-chain
transaction hash, so every paid call is independently verifiable on
Polygonscan.What just happened
You saw one function call. Under the hood:1
402 challenge
The server returned HTTP 402 with a JSON block listing the
chain, asset,
payTo address, amount, and a one-time nonce.2
Settle on-chain
The SDK submitted one transaction on Polygon mainnet — an atomic
split (merchant / treasury / IP-creator) in a single tx. No
custodian touches the funds at any point.
3
Retry with proof
The SDK retried your request with the payment proof headers, the
server verified on-chain, forwarded to the upstream service, and
returned the response.
mSECCO credits earned on paid calls are a non-transferable internal
accounting unit — usage credits, not a tradable asset. There is no
token to acquire to use AiFinPay.
Next steps
Python SDK
Full
aifinpay-agent API: agent persistence, custom payloads, and
fee-on-top split invoices.Node / TypeScript SDK
Full
@aifinpay/agent API for TypeScript and Node runtimes.MCP server
Zero-code: drop
@aifinpay/mcp into Claude Desktop, Cursor, or
Windsurf and let the model pay for x402-gated APIs itself.Framework adapters
Paste-and-run examples for LangChain, CrewAI, OpenAI Agents, AutoGPT,
and Flowise.