nexuspay-agentkit
v0.1.0
Published
NexusPay action provider for Coinbase AgentKit — managed USDC wallets, spending policies, and x402 micropayments for AI agents
Maintainers
Readme
nexuspay-agentkit
NexusPay action provider for Coinbase AgentKit. Gives any AgentKit-powered AI agent managed USDC wallets, spending policies, P2P transfers, and x402 micropayments on Base — in one import.
Install
npm install nexuspay-agentkit @coinbase/agentkitQuick Start
import { AgentKit } from "@coinbase/agentkit";
import { getLangChainTools } from "@coinbase/agentkit-langchain";
import { nexusPayActionProvider } from "nexuspay-agentkit";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatOpenAI } from "@langchain/openai";
const agentKit = await AgentKit.from({
cdpApiKeyName: process.env.CDP_API_KEY_NAME!,
cdpApiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY!,
actionProviders: [
nexusPayActionProvider({
baseUrl: process.env.NEXUSPAY_URL!, // your NexusPay deployment
apiKey: process.env.NEXUSPAY_API_KEY!, // from NexusPay dashboard → API Keys
}),
],
});
const tools = await getLangChainTools(agentKit);
const llm = new ChatOpenAI({ model: "gpt-4o" });
const agent = createReactAgent({ llm, tools });
// The agent can now:
// — check wallet balances
// — send USDC on-chain
// — transfer instantly to other agents
// — pay x402 paywalls automatically
// — audit its own transaction history
// — create and check spending policiesAvailable Actions
| Action | Description |
|---|---|
| nexuspay_get_balance | Get USDC balance for an agent wallet |
| nexuspay_list_wallets | List all agent wallets and balances |
| nexuspay_create_wallet | Create a new CDP-backed agent wallet on Base |
| nexuspay_send_payment | Send USDC on-chain to any address |
| nexuspay_p2p_transfer | Instant zero-gas transfer between agents |
| nexuspay_pay_x402 | Pay an x402 paywall to gain API access |
| nexuspay_list_transactions | List recent transactions with filters |
| nexuspay_check_policies | Check spending limits for an agent |
| nexuspay_create_policy | Set spending limits for an agent wallet |
Example Agent Prompts
Once connected, your agent understands natural language payment instructions:
"Check the balance of agent-researcher before sending the payment"
"Transfer $2.50 to agent-writer for the content it generated"
"Pay the inference API at /api/premium/gpt4 using agent-alpha's wallet"
"Set a $10 daily limit on agent-beta's spending"
"Show me the last 10 transactions from agent-alpha"Environment Variables
NEXUSPAY_URL=https://your-nexuspay.vercel.app
NEXUSPAY_API_KEY=npk_live_...
# Coinbase CDP (for AgentKit)
CDP_API_KEY_NAME=your-cdp-key-name
CDP_API_KEY_PRIVATE_KEY=your-cdp-private-keyGet a NexusPay API Key
- Go to your NexusPay dashboard
- Open the API Keys tab
- Click Create Key and copy the raw key (shown once)
- Set it as
NEXUSPAY_API_KEYin your environment
Multi-Agent Example
// Agent A pays Agent B for a completed task
await agent.invoke({
messages: [{
role: "user",
content: `
Agent B just completed the data analysis task.
Transfer $5 USDC from agent-orchestrator to agent-analyst as payment.
Then check agent-orchestrator's remaining balance.
`,
}],
});x402 Micropayments
NexusPay implements the x402 protocol for HTTP pay-per-request. When your agent hits a monetized API and gets an HTTP 402 response, it can pay automatically:
// Agent receives 402 from a paid API
// Calls nexuspay_pay_x402 automatically
// Gets access — no human intervention needed