Quickstart Guide
Get started with AgentBank in under 5 minutes. This guide will walk you through installation, setup, and making your first payment.
Prerequisites
Before you begin, make sure you have:
- Node.js 18+ installed
- An AgentBank API key (sign up at agentbank.dev)
- Basic knowledge of TypeScript/JavaScript
Step 1: Installation
Install the AgentBank SDK using your preferred package manager:
npm install agentbank-sdk
# or
yarn add agentbank-sdk
# or
pnpm add agentbank-sdkStep 2: Configuration
Create a .env file in your project root and add your API key:
AGENTBANK_API_KEY=your_api_key_hereStep 3: Initialize the Client
Create a new file and initialize the AgentBank client:
agentbank.ts
import { AgentBank } from 'agentbank-sdk'
export const bank = new AgentBank({
apiKey: process.env.AGENTBANK_API_KEY,
// Optional: Configure default chains
defaultChains: ['ethereum', 'polygon', 'arbitrum'],
// Optional: Set timeout
timeout: 30000
})Step 4: Make Your First Payment
Now you're ready to send your first payment with automatic fallback:
payment.ts
import { bank } from './agentbank'
async function sendPayment() {
try {
const result = await bank.pay({
amount: 100, // Amount in smallest unit (e.g., cents for USDC)
currency: 'USDC',
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
// The SDK will try these chains in order
chains: ['ethereum', 'polygon', 'arbitrum'],
// Optional: Add metadata
metadata: {
orderId: 'order_123',
customerId: 'customer_456'
}
})
console.log('✅ Payment successful!')
console.log('Transaction hash:', result.txHash)
console.log('Completed on chain:', result.chain)
console.log('Gas used:', result.gasUsed)
return result
} catch (error) {
console.error('❌ Payment failed:', error)
throw error
}
}
sendPayment()Automatic Fallback in Action
If Ethereum is congested, the SDK will automatically try Polygon, then Arbitrum. You don't need to handle retries or chain selection manually.
Step 5: Monitor Transactions
You can check the status of any transaction using the transaction hash:
const status = await bank.getTransactionStatus(result.txHash)
console.log('Status:', status.status) // 'pending' | 'confirmed' | 'failed'
console.log('Confirmations:', status.confirmations)
console.log('Block number:', status.blockNumber)Next Steps
Congratulations! You've successfully made your first payment with AgentBank. Here's what to explore next: