What This Workflow Does
This n8n template solves a critical problem in the AI economy: how do autonomous agents pay for the resources they consume? Traditional payment systems require human intervention, but this workflow enables AI agents to autonomously purchase API calls, compute time, or data using cryptocurrency.
The system creates a complete cryptocurrency payment infrastructure where sellers can monetize their APIs and digital resources, while buyer agents can automatically pay for what they use. It implements the x402 protocol (HTTP 402 Payment Required) with multi-chain support, allowing transactions on Ethereum, Base, Polygon, and Arbitrum using stablecoins like USDC, USDT, and DAI.
Beyond simple payments, the template includes budget management through AP2 mandates, real-time monitoring dashboards, and failsafe verification ensuring resources are only delivered after on-chain payment confirmation. This transforms your API from a free service into a revenue-generating asset that works 24/7 without manual billing.
How It Works
The automation follows a secure, verifiable payment flow that ensures both parties get what they expect: sellers receive payment, buyers receive resources.
Step 1: Mandate Creation & Budget Authorization
The buyer agent first creates an AP2 mandate—a pre-authorized spending limit (e.g., $100 for 7 days). This mandate is stored in n8n's data table and acts as a cryptographic permission slip, preventing unlimited spending while allowing autonomous transactions within defined boundaries.
Step 2: Resource Request & Payment Requirement
When the AI agent requests a resource (like an API call), the seller's n8n workflow returns HTTP 402 "Payment Required" with specific details: wallet address, price in USD, preferred token, and blockchain. This standardized response tells the buyer exactly what and how to pay.
Step 3: Dual Transaction Signing
The buyer workflow signs two blockchain transactions via a Render-deployed service: one sending 99.5% to the merchant and another sending 0.5% to AgentGatePay as commission. This happens automatically using the wallet private key stored securely in Render environment variables.
Step 4: Payment Verification & Resource Delivery
The buyer resubmits the request with transaction hashes as proof. The seller verifies both transactions on-chain via AgentGatePay's API, then delivers the purchased resource. All steps are logged for monitoring and audit purposes.
Who This Is For
This template is ideal for developers and businesses building in the AI agent economy. If you're creating autonomous systems that need to consume paid APIs, or if you're an API provider wanting to monetize access to AI agents, this solution bridges the gap.
AI startups can use it to give their agents spending capabilities. SaaS companies can implement pay-per-use APIs. Digital content creators can sell access to premium data feeds. The system works for any scenario where you need to exchange digital value for cryptocurrency without human intervention.
Technical teams comfortable with n8n, basic blockchain concepts, and API development will get the most value. The template handles the complex payment logic so you can focus on your core product rather than building payment infrastructure from scratch.
What You'll Need
- n8n instance (cloud or self-hosted) with workflow editing permissions
- Two AgentGatePay accounts (one buyer, one seller) with API keys
- Cryptocurrency wallet with private key for the buyer account
- Small amount of stablecoins (USDC recommended) on Base network for testing
- Render account for deploying the transaction signing service (free tier available)
- Basic understanding of blockchain transactions and HTTP APIs
Pro tip: Start with the Base network for lowest gas fees (~$0.001 per transaction) and USDC for simplest decimal handling. Test with $1-2 worth of tokens before scaling up.
Quick Setup Guide
You can have this system running in under 10 minutes following these steps:
- Create Accounts: Sign up for separate AgentGatePay buyer and seller accounts. Save both API keys securely.
- Deploy Signing Service: Use the one-click Render deploy button, adding your buyer API key and wallet private key as environment variables.
- Fund Wallet: Send a small amount of USDC to your buyer wallet on the Base network, plus a tiny amount of ETH for gas.
- Import Workflows: Import all three n8n templates (Buyer Agent, Seller API, Monitoring Dashboard) into your n8n instance.
- Configure Seller: Update the seller workflow with your merchant wallet address, API key, and resource pricing.
- Configure Buyer: Update the buyer workflow with your AgentGatePay credentials, budget limits, and the Render service URL.
- Create Data Table: In n8n settings, create an "AgentPay_Mandates" table with a "mandate_token" string column.
- Execute & Test: Run the buyer workflow and watch the autonomous payment process complete in 5-8 seconds.
Key Benefits
24/7 Autonomous Transactions: Your AI agents can pay for resources anytime without human approval, enabling truly autonomous operations that work across timezones and weekends.
Multi-Chain Flexibility: Support Ethereum, Base, Polygon, and Arbitrum with USDC, USDT, or DAI tokens. Switch chains based on gas fees and transaction speed requirements.
Budget Control & Security: AP2 mandates limit spending to pre-authorized amounts and timeframes. Even if an agent goes rogue, it can't drain your entire wallet.
Transparent Audit Trail: Every payment is recorded on-chain with immutable proof. Monitor spending, track revenue, and generate reports directly from blockchain data.
Minimal Commission: At just 0.5% per transaction, AgentGatePay is significantly cheaper than traditional payment processors while providing blockchain-level security and automation.