Documentation
AgentPayAPI provides risk-first infrastructure for autonomous AI transactions. Give your AI agents the ability to transact on-chain with hard cryptographic limits, ensuring they can operate autonomously without risking your entire treasury.
Quickstart
Install the official Node.js SDK via npm, yarn, or pnpm:
npm install @agentpay/sdkInitialize the client and execute your first transaction:
import { AgentPay } from '@agentpay/sdk';// Initialize with your API keyconst client = new AgentPay(process.env.AGENTPAY_API_KEY);// Execute a transactionconst receipt = await client.execute({to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',value: '0.05', // ETHchain: 'base'});console.log(`Transaction successful: ${receipt.hash}`);
Authentication
Authenticate your API requests using your secret API key. You can generate and manage API keys in the Dashboard.
Pass the API key to the SDK constructor, or set it as an environment variable AGENTPAY_API_KEY. Never commit your API keys to version control.
Risk Controls
AgentPayAPI enforces risk limits cryptographically before any transaction is signed. If a transaction violates a limit, it is blocked at the API level and never broadcast to the network.
- Global Limits: Maximum transaction value, daily volume limits, and allowed networks.
- Per-Contract Limits: Restrict agents to interact only with specific smart contracts (e.g., only Uniswap V3 routers).
- Velocity Limits: Maximum number of transactions per hour/day to prevent runaway loops.
Supported Networks
We currently support 7 networks (5 mainnets and 2 testnets). Use the exact string identifier in the chain parameter when executing transactions.
| Network | Identifier | Type |
|---|---|---|
| Ethereum | ethereum | Mainnet |
| Base | base | Mainnet |
| Polygon | polygon | Mainnet |
| Arbitrum | arbitrum | Mainnet |
| Optimism | optimism | Mainnet |
| Sepolia | sepolia | Testnet |
| Base Sepolia | base-sepolia | Testnet |
Client Initialization
Initialize the AgentPay client with your API key. You can pass the key directly, or let the SDK automatically pick it up from the AGENTPAY_API_KEY environment variable.
import { AgentPay } from '@agentpay/sdk';// Option 1: Pass API key explicitlyconst client = new AgentPay('sk_live_...');// Option 2: Uses process.env.AGENTPAY_API_KEY automaticallyconst client = new AgentPay();
Execute Transaction
Execute a transaction on-chain. The API will automatically evaluate the transaction against your configured risk limits before signing and broadcasting.
const receipt = await client.execute({to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',value: '0.05',chain: 'base',data: '0x' // Optional contract calldata});
Parameters
| Parameter | Type | Description |
|---|---|---|
| to | string | The destination address or contract. Required. |
| value | string | The amount of native token to send (in ETH/MATIC/etc). Required. |
| chain | string | The network identifier (e.g., 'base'). Required. |
| data | string | Hex-encoded contract calldata. Optional, defaults to '0x'. |