🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@agentpay-dev/sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agentpay-dev/sdk

AgentPay SDK �?Give your Agent a wallet in 3 lines of code

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@agentpay-dev/sdk

SDK for building AI Agents that pay and get paid via CKB Fiber Network

Features

  • AgentWallet �?Client-side SDK for calling paid Agent services
  • ServiceProvider �?Server-side SDK for receiving paid service requests
  • HubClient �?Managed Fiber access (no node required)
  • Hold Scheme �?Trustless escrow: lock �?verify �?settle/cancel
  • Production-hardened �?Input validation, timeouts, CORS, body limits
  • Fiber v0.7.1 Compatible �?Auto hex conversion for all RPC calls

6 Ways to Use AgentPay

MethodBest ForExample
SDKTypeScript appsnew AgentWallet(...)
MCPClaude/GPT AInpx agentpay-mcp
SkillsAny AI framework.agent/skills/agentpay-payment/
x402HTTP 402 middleware/x402/create-hold
HubNo node neededcreateHubWallet(...)
DockerSelf-hosted nodepnpm setup

Install

npm install @agentpay-dev/sdk @agentpay-dev/core

Quick Start

As a Caller (pay for services)

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)

As a Provider (earn from services)

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);

Hold Scheme (escrow)

// 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 });

Via Hub (no Fiber node needed)

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' },
);

Protocol Flow (Hold Scheme)

Caller                    Provider                  Fiber
  |                       |---- newInvoice(hash) ---->|  (hold)
  |<-- INVOICE -----------|                           |
  |---- sendPayment ------+-------------------------->|  (locked)
  |--- TASK_INPUT ------->|                           |
  |                       |---- execute task          |
  |                       |---- settleInvoice ------->|  (settled)
  |<-- TASK_RESULT -------|                           |

License

MIT

Keywords

agentpay

FAQs

Package last updated on 15 Mar 2026

Did you know?

Socket

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.

Install

Related posts