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:
- Service Availability: The service may be unavailable, suspended, or permanently shut down at any time without prior notice. No SLA or uptime guarantees.
- Data Loss Risk: All data may be lost at any time without recovery. Users are solely responsible for maintaining independent backups.
- No Liability: AgentGatePay is NOT LIABLE for any direct, indirect, or consequential damages including lost cryptocurrency, failed transactions, service interruptions, or loss of revenue.
- Financial Risk: Blockchain transactions are irreversible. Users are solely responsible for securing private keys, API keys, and compliance with laws.
- No Warranty: This SDK is provided "AS IS" without warranties of any kind.
📄 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:
- 🤖 Built for AI agents and autonomous systems
- 🛡️ AIF (Agent Interaction Firewall) - First firewall built for AI agents
- ⛓️ Multi-chain support (Ethereum, Base, Polygon, Arbitrum)
- 💰 Multiple stablecoins (USDC on all chains, USDT/DAI on most)
- 🔐 AP2 mandate protocol for budget-controlled payments
- 🔌 MCP (Model Context Protocol) integration
- 📊 Real-time analytics and webhooks
- ⚡ Sub-5 second payment verification
Gateway Commission: 0.5% fee on all payments
- Automatically deducted via two-transaction model
- Commission TX: 0.5% → AgentGatePay wallet (covers infrastructure costs)
- Merchant TX: 99.5% → seller wallet
- Both transactions atomic and transparent on-chain
Installation:
npm install agentgatepay-sdkQuick 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-sdkQuick 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:
- Ethereum (Chain ID: 1) - Ethereum Mainnet
- Base (Chain ID: 8453) - Base (USDT not supported)
- Polygon (Chain ID: 137) - Polygon PoS
- Arbitrum (Chain ID: 42161) - Arbitrum One
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/min- User signup - 5 per hour per IP
Rate limit headers (RFC 6585 compliant):
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1234567890
Retry-After: 42
1. Distributed Rate Limiting
- ✅ Production-ready distributed counters
- ✅ Enforced across all server instances
- ✅ 1-minute fixed windows with automatic TTL cleanup
- ✅ Graceful degradation (fails open on errors)
2. Replay Protection
- ✅ TX-hash based nonces (cryptographically unique)
- ✅ 24-hour TTL on used nonces
- ✅ Prevents double-spending at API level
- ✅ Automatic detection: uses
tx_hashor explicitnonce
3. Agent Reputation System (Enabled by default)
- Score range: 0-200 (new agents start at 100)
- Blocking thresholds:
- 0-30: ❌ Blocked (bad actor)
- 31-60:
⚠️ Warning (suspicious) - 61-200: ✅ Allowed (good standing)
- Real-time tracking of agent behavior
- Fail-open design (errors never break payments)
- Manual override available for false positives
4. Mandatory Mandates (Breaking change Nov 2024)
⚠️ All payments MUST have an AP2 mandate- Budget tracking and enforcement
- Scope validation (permissions)
- Prevents unauthorized payments
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:
- Check response headers for remaining quota
- Implement exponential backoff on 429 errors
- Cache mandate tokens (reuse for multiple payments)
- Respect
Retry-Afterheader
Example:
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...
}
}- LangChain: Coming soon
- AutoGPT: Coming soon
- CrewAI: Coming soon
- Vercel AI SDK: Coming soon
- Semantic Kernel: Coming soon
- AutoGen: Coming soon
- Claude Desktop (MCP): Coming soon
- REST API: https://api.agentgatepay.com
- MCP Endpoint: https://mcp.agentgatepay.com
- Dashboard: https://api.agentgatepay.com/dashboard
Check out the agentgatepay-examples repository for integration examples with popular AI frameworks.
cd javascript
npm install
npm run build
npm testcd python
pip install -e ".[dev]"
pytest
black agentgatepay_sdk/
mypy agentgatepay_sdk/cd javascript
npm version patch|minor|major
npm run build
npm publishcd python
python setup.py sdist bdist_wheel
twine upload dist/*- GitHub Issues: AgentGatePay/agentgatepay-sdks
- Examples Repository: AgentGatePay/agentgatepay-examples
- Email: support@agentgatepay.com
MIT License - see LICENSE for details.
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Built for the agent economy 🤖⚡💰