
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.
@agentpay-dev/sdk
Advanced tools
SDK for building AI Agents that pay and get paid via CKB Fiber Network
| Method | Best For | Example |
|---|---|---|
| SDK | TypeScript apps | new AgentWallet(...) |
| MCP | Claude/GPT AI | npx agentpay-mcp |
| Skills | Any AI framework | .agent/skills/agentpay-payment/ |
| x402 | HTTP 402 middleware | /x402/create-hold |
| Hub | No node needed | createHubWallet(...) |
| Docker | Self-hosted node | pnpm setup |
npm install @agentpay-dev/sdk @agentpay-dev/core
import { AgentWallet } from '@agentpay-dev/sdk';
const wallet = new AgentWallet({ fiberRpcUrl: 'http://127.0.0.1:8227' });
const result = await wallet.payAndCall(
'http://translate-bot:3001',
'translate',
{ text: 'Hello World', target: 'zh' },
{ maxBudget: '1000000000' },
);
console.log(result.output); // { translated: '[zh] Hello World' }
console.log(result.amount); // '100000000' (actual cost)
import { ServiceProvider } from '@agentpay-dev/sdk';
const provider = new ServiceProvider({
services: [{
name: 'translate',
description: 'Translate text between languages',
pricing: { model: 'per-call', amount: '100000000', asset: 'CKB' },
input_schema: { text: 'string', target: 'string' },
output_schema: { translated: 'string' },
}],
});
provider.onTask('translate', async (input) => {
const { text, target } = input as { text: string; target: string };
return { translated: `[${target}] ${text}` };
});
provider.listen(3001);
// Provider creates hold invoice
const { invoice_address, preimage, payment_hash } =
await wallet.createHoldInvoice('100000000', 'Translation job');
// Client pays the invoice (funds locked)
await clientWallet.rpc.sendPayment({ invoice: invoice_address });
// Provider does the work, then settles (collects funds)
await wallet.rpc.settleInvoice({ payment_hash, payment_preimage: preimage });
// OR cancel (refund to client)
await wallet.rpc.cancelInvoice({ payment_hash });
import { createHubWallet } from '@agentpay-dev/sdk';
const wallet = createHubWallet({
hubUrl: 'http://hub.agentpay.dev:4000',
apiKey: 'ap_your_key_here',
});
const result = await wallet.payAndCall(
'http://translate-bot:3001', 'translate',
{ text: 'Hello', target: 'zh' },
);
Caller Provider Fiber
| |---- newInvoice(hash) ---->| (hold)
|<-- INVOICE -----------| |
|---- sendPayment ------+-------------------------->| (locked)
|--- TASK_INPUT ------->| |
| |---- execute task |
| |---- settleInvoice ------->| (settled)
|<-- TASK_RESULT -------| |
MIT
FAQs
AgentPay SDK �?Give your Agent a wallet in 3 lines of code
We found that @agentpay-dev/sdk 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.