basepay-agentkit
v0.1.0
Published
BasePay action provider for Coinbase AgentKit — gasless USDC transfers, batch pay, escrow, and subscriptions on Base Mainnet
Downloads
145
Maintainers
Readme
@basepay/agentkit
BasePay action provider for Coinbase AgentKit — gasless USDC transfers, batch payments, escrow, and on-chain subscriptions on Base Mainnet.
What it does
@basepay/agentkit gives any AgentKit-powered AI agent five USDC payment primitives on Base Mainnet:
| Action | Description |
|--------|-------------|
| basepay_send_usdc | Direct USDC transfer (agent pays ETH gas) |
| basepay_send_usdc_gasless | EIP-3009 gasless transfer — relay pays gas, agent needs no ETH |
| basepay_batch_pay_usdc | Pay up to 200 recipients in a single tx |
| basepay_create_escrow | Time-lock USDC; payee claims after unlock period |
| basepay_subscribe | On-chain recurring USDC payment at any interval |
All four contracts are verified on Basescan:
| Contract | Address |
|----------|---------|
| BatchPayV2 | 0xe40d…c68 |
| EscrowV2 | 0x1eb2…499 |
| SubscriptionManagerV2 | 0x1019…421 |
Installation
npm install @basepay/agentkit @coinbase/agentkit viem zod
# or
pnpm add @basepay/agentkit @coinbase/agentkit viem zodQuick start
import { AgentKit } from "@coinbase/agentkit";
import { ViemWalletProvider } from "@coinbase/agentkit";
import { basePayActionProvider } from "@basepay/agentkit";
import { createWalletClient, http } from "viem";
import { base } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
// 1. Create a wallet client on Base Mainnet
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const client = createWalletClient({ account, chain: base, transport: http() });
const walletProvider = new ViemWalletProvider(client);
// 2. Create AgentKit with the BasePay action provider
const agentKit = await AgentKit.from({
walletProvider,
actionProviders: [
basePayActionProvider(), // use hosted BasePay relay
// basePayActionProvider({ relayUrl: "https://your-relay.example.com" }),
],
});
// 3. Get actions and wire into your LLM framework
const tools = getLangChainTools(agentKit);With LangChain
import { getLangChainTools } from "@coinbase/agentkit-langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
const tools = getLangChainTools(agentKit);
const llm = new ChatOpenAI({ model: "gpt-4o" });
const agent = createReactAgent({ llm, tools });
const result = await agent.invoke({
messages: [
{ role: "user", content: "Send 5 USDC gaslessly to 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" }
]
});Actions in detail
basepay_send_usdc
Send USDC to any address. Agent wallet pays ETH gas.
{
"to": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"amount": "10.5"
}basepay_send_usdc_gasless
EIP-3009 gasless transfer via the BasePay relay. The agent signs a TransferWithAuthorization typed message — no ETH required.
{
"to": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"amount": "5"
}Requirement: wallet provider must support
signTypedData(e.g.ViemWalletProvider,CdpEvmWalletProvider).
basepay_batch_pay_usdc
Pay multiple recipients atomically. Auto-approves USDC allowance if needed.
{
"recipients": [
{ "address": "0xAlice…", "amount": "10" },
{ "address": "0xBob…", "amount": "15.5" },
{ "address": "0xCarol…", "amount": "5" }
],
"memo": "Q2 contributor payroll"
}basepay_create_escrow
Lock USDC until a time-lock expires, then the payee can claim it.
{
"payee": "0xContractor…",
"amount": "500",
"unlockAfterSeconds": 604800,
"memo": "Website delivery milestone"
}basepay_subscribe
Create a recurring on-chain charge. Anyone can call charge() once per interval.
{
"payee": "0xServiceProvider…",
"amount": "9.99",
"intervalSeconds": 2592000,
"memo": "Monthly API subscription"
}Configuration
basePayActionProvider({
relayUrl: "https://your-own-relay.example.com", // default: BasePay hosted relay
})Self-host the relay: the relay is open-source at github.com/osr21/basepay. It requires only a funded EOA (DEPLOYER_PRIVATE_KEY with ETH on Base).
Supported networks
- Base Mainnet (chainId
8453) only
Links
- BasePay dApp: base-pay.replit.app
- Contracts + source: github.com/osr21/basepay
- Coinbase AgentKit: github.com/coinbase/agentkit
- USDC on Base: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
License
Apache-2.0 — same as Coinbase AgentKit.
