Loading repository data…
Loading repository data…
AgentGatePay / repository
Official JavaScript/TypeScript and Python SDKs for AgentGatePay - Payment gateway for the agent economy. Multi-chain crypto payments (USDC, USDT, DAI) with AP2 mandates and MCP protocol support.
Official JavaScript/TypeScript and Python SDKs for AgentGatePay - Secure multi-chain cryptocurrency payment gateway for AI agents and autonomous systems.
AgentGatePay is currently in BETA. By using this SDK and service, you acknowledge and accept:
📄 Read the full DISCLAIMER.md before using.
BY USING THIS SDK, YOU AGREE TO THESE TERMS.
AgentGatePay enables AI agents to make and accept cryptocurrency payments with multi-chain support (Ethereum, Base, Polygon, Arbitrum) for stablecoins (USDC, USDT, DAI).
Key Features:
Gateway Commission: 0.5% fee on all payments
Installation:
npm install agentgatepay-sdk
Quick Start:
import { AgentGatePay } from 'agentgatepay-sdk';
const client = new AgentGatePay({
apiKey: 'pk_live_...',
apiUrl: 'https://api.agentgatepay.com'
});
// Issue a mandate (budget tracks spending in USD equivalent)
const mandate = await client.mandates.issue(
'my-agent-123', // subject
100.0, // budget in USD (tracks value across USDC/USDT/DAI)
'resource.read,payment.execute', // scope
1440 // ttl_minutes
);
// Make a payment (client pays in stablecoins: USDC, USDT, or DAI)
const payment = await client.payments.submitTxHash(
mandate.mandateToken, // mandate token
'0x...', // blockchain tx_hash (client sends USDC/USDT/DAI)
undefined, // tx_hash_commission (optional)
'base', // chain (ethereum, base, polygon, arbitrum)
'USDC' // token (USDC, USDT, or DAI)
);
📚 Full JavaScript Documentation
Installation:
pip install agentgatepay-sdk
Quick Start:
from agentgatepay_sdk import AgentGatePay
client = AgentGatePay(
api_key='pk_live_...',
api_url='https://api.agentgatepay.com'
)
# Issue a mandate (budget tracks spending in USD equivalent)
mandate = client.mandates.issue(
subject='my-agent-123',
budget=100.0, # budget in USD (tracks value across USDC/USDT/DAI)
scope='resource.read,payment.execute',
ttl_minutes=1440
)
# Make a payment (client pays in stablecoins: USDC, USDT, or DAI)
payment = client.payments.submit_tx_hash(
mandate=mandate['mandateToken'], # mandate token
tx_hash='0x...', # blockchain tx_hash (client sends USDC/USDT/DAI)
chain='base', # chain (ethereum, base, polygon, arbitrum)
token='USDC' # token (USDC, USDT, or DAI)
)
| Module | JavaScript | Python | Description |
|---|---|---|---|
| Auth | ✅ | ✅ | User signup, API key management, wallet management |
| Mandates | ✅ | ✅ | Issue and verify AP2 budget mandates |
| Payments | ✅ | ✅ | Submit payments, verify transactions, payment history |
| Webhooks | ✅ | ✅ | Configure payment notifications |
| Analytics | ✅ | ✅ | Revenue tracking, spending analytics |
| MCP Tools | ✅ | ✅ | Model Context Protocol integration |
| Audit | ✅ | ✅ | Access audit logs and transaction history |
| Token | Ethereum | Base | Polygon | Arbitrum |
|---|---|---|---|---|
| USDC | ✅ (6 decimals) | ✅ (6 decimals) | ✅ (6 decimals) | ✅ (6 decimals) |
| USDT | ✅ (6 decimals) | ❌ | ✅ (6 decimals) | ✅ (6 decimals) |
| DAI | ✅ (18 decimals) | ✅ (18 decimals) | ✅ (18 decimals) | ✅ (18 decimals) |
Chain Details:
AIF (Agent Interaction Firewall) is the first firewall built specifically for AI agents, protecting agents from other agents in the autonomous economy.
| User Type | Rate Limit | Benefits |
|---|---|---|
| Anonymous | 20 requests/min | Basic access, no signup required |
| With Account | 100 requests/min | 5x more requests, payment history, reputation tracking |
Per-Endpoint Limits:
/health - 60 requests/min/mandates/issue - 20 requests/min/x402/resource - 60 requests/minRate limit headers (RFC 6585 compliant):
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1234567890
Retry-After: 42
1. Distributed Rate Limiting
2. Replay Protection
tx_hash or explicit nonce3. Agent Reputation System (Enabled by default)
4. Mandatory Mandates (Breaking change Nov 2024)
Create a free account to get 5x more requests:
// JavaScript
const user = await client.auth.signup({
email: 'agent@example.com',
password: 'secure_password',
account_type: 'agent' // or 'merchant' or 'both'
});
// Auto-generated API key (shown once)
console.log(user.api_key); // pk_live_abc123...
# Python
user = client.auth.signup(
email='agent@example.com',
password='secure_password',
account_type='agent' # or 'merchant' or 'both'
)
# Auto-generated API key (shown once)
print(user['api_key']) # pk_live_abc123...
Then use your API key:
const client = new AgentGatePayClient({
apiKey: 'pk_live_abc123...', // ← 100 requests/min
baseUrl: 'https://api.agentgatepay.com'
});
Best Practices:
Retry-After headerExample:
try {
const mandate = await client.mandates.issue({...});
} catch (error) {
if (error.status === 429) {
const retryAfter = error.headers['retry-after'];
console.log(`Rate limited. Retry after ${retryAfter} seconds`);
await sleep(retryAfter * 1000);
// Retry...
}
}
Check out the agentgatepay-examples repository for integration examples with popular AI frameworks.
cd javascript
npm install
npm run build
npm test
cd python
pip install -e ".[dev]"
pytest
black agentgatepay_sdk/
mypy agentgatepay_sdk/
cd javascript
npm version patch|minor|major
npm run build
npm publish
cd python
python setup.py sdist bdist_wheel
twine upload dist/*
MIT License - see LICENSE for details.
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Built for the agent economy 🤖⚡💰