Developers Forum for XinFin XDC Network

Rushabh Parmar
Rushabh Parmar

Posted on

Building an AI Agent That Sends USDC on XDC Network Using Plain English

Introduction

Artificial Intelligence is evolving from a tool that generates information into a system capable of taking actions.

This new generation of software — often called Agentic AI — goes beyond answering questions. AI agents can understand user intent, make decisions, and interact with external systems to complete real tasks autonomously.

To explore this concept, I built Agentic XDC Payments: an AI-powered payment agent that enables users to send USDC on the XDC Network using simple natural language instructions.

Rather than interacting with wallets, smart contracts, or blockchain interfaces directly, a user simply types:

Send 1 USDC to xdc1abc...
Enter fullscreen mode Exit fullscreen mode

The AI agent interprets the request, verifies the details, prepares the transaction, and executes it on-chain.

The result is a seamless bridge between human language and blockchain transactions.


What the Project Does

The application lets users initiate blockchain payments through conversation.

Instead of manually opening a wallet, selecting a token, entering an address, and configuring a transaction — users simply describe their intent.

The AI agent handles everything else:

  • Understanding the natural language request
  • Extracting the recipient address and amount
  • Validating the transaction parameters
  • Presenting a confirmation prompt
  • Executing the USDC transfer on XDC Mainnet

This creates an experience where blockchain payments feel as natural as messaging a digital assistant.


Technology Stack

The project combines four technologies that work together to create an end-to-end agentic payment workflow.

Claude AI

Claude serves as the reasoning engine. Its job is to analyze a natural language instruction and convert it into structured transaction data.

For example, given the input:

"Send 10 USDC to xdc123..."
Enter fullscreen mode Exit fullscreen mode

Claude extracts:

{
  "action": "transfer",
  "amount": 10,
  "token": "USDC",
  "to": "xdc123..."
}
Enter fullscreen mode Exit fullscreen mode

This transformation from human language into machine-readable instructions is the core of the agent.

Node.js

Node.js acts as the orchestration layer. It manages the full lifecycle — reading user input from the terminal, communicating with the Claude API, presenting confirmations, and triggering the blockchain interaction.

ethers.js

ethers.js handles all blockchain functionality: connecting to XDC Network, managing the wallet, constructing the ERC-20 transfer transaction, signing it locally, and broadcasting it to the network.

XDC Network

XDC Network is the execution and settlement layer. Once the transaction is signed, it is submitted to the XDC blockchain where it becomes a permanent, verifiable on-chain record.


How the Code Works

The project follows a clean, sequential workflow from input to on-chain settlement.

Step 1 — User Input

The terminal waits for a plain English instruction:

You > send 1 USDC to 0xB0EF2A0337A519d50780E33d268341CE75ce8383
Enter fullscreen mode Exit fullscreen mode

Step 2 — AI Parsing

The instruction is sent to Claude AI. Claude analyzes the text and returns a structured JSON object containing the recipient address, token, and amount. No regex, no manual parsing — just natural language understanding.

Step 3 — Validation

Before any transaction is constructed, the application validates:

  • Recipient address format (supports both xdc and 0x prefixes)
  • Amount is a positive number within the safety limit
  • USDC contract is correctly loaded

This prevents malformed or unintended transactions from reaching the blockchain.

Step 4 — Confirmation

The agent displays a clear summary and requires explicit approval:

  ─────────────────────────────────────────
  To      : 0xB0EF2A...e8383
  Amount  : 1 USDC
  Gas     : ~0.01 XDC (legacy tx, 12.5 gwei)
  ─────────────────────────────────────────
  Confirm send? (yes / no):
Enter fullscreen mode Exit fullscreen mode

The user remains in full control. Nothing executes without a yes.

Step 5 — Transaction Construction

Using ethers.js, the application constructs a USDC ERC-20 transfer.

Important XDC-specific settings:

const tx = await usdc.transfer(to, amountWei, {
  type: 0,                                  // Legacy tx — XDC does not support EIP-1559
  gasPrice: ethers.parseUnits("12.5", "gwei"), // XDC minimum gas price
  gasLimit: 100_000n,
});
Enter fullscreen mode Exit fullscreen mode

Image description

Step 6 — Broadcast

The signed transaction is broadcast to XDC Mainnet. The blockchain validates and includes it in the next block.

Step 7 — Confirmation

The agent returns a success message with the transaction hash and a direct XDCScan link:

  ✓  Sent 1 USDC successfully!
  ✓  Tx hash : 0x17f26f8554f22a1ed2b018b584bf3f13cb2e222067a8bbdfbce7b7f0e5b5a874
  ✓  Explorer: https://xdcscan.com/tx/0x17f26f8554f22a1ed2b018b584bf3f13cb2e222067a8bbdfbce7b7f0e5b5a874
  ✓  Block   : 103647109
Enter fullscreen mode Exit fullscreen mode

Live Demonstration

During testing, the agent successfully completed a live USDC transfer on XDC Mainnet.

Step What Happened
1. Human intent Typed: send 1 USDC to 0xB0EF2A...
2. AI understanding Claude extracted address and amount
3. Safety check Reviewed and typed yes
4. Autonomous execution Agent signed and broadcast the tx
5. On-chain settlement XDC Network confirmed in block 103,647,109

Verified transaction on XDCScan:
0x17f26f8554f22a1ed2b018b584bf3f13cb2e222067a8bbdfbce7b7f0e5b5a874

Real USDC moved on-chain through a conversational interface.


Project Structure

xdc-usdc-agent/
├── src/
│   ├── agent.js      ← CLI loop and user interaction
│   ├── parser.js     ← Claude AI intent parser
│   ├── usdc.js       ← USDC contract calls (balance + transfer)
│   └── wallet.js     ← Wallet loader (private key or mnemonic)
├── .env.example      ← Configuration template
└── package.json
Enter fullscreen mode Exit fullscreen mode

Key Technical Notes for XDC Developers

If you are building on XDC Network, these constraints are important:

  • Use legacy transaction type 0 — XDC does not support EIP-1559 transactions
  • Minimum gas price is 12.5 gwei — transactions below this will be rejected
  • estimateGas can be unreliable — set gasLimit manually (100,000 is safe for ERC-20 transfers)
  • Address prefix — XDC uses an xdc prefix; convert to 0x for ethers.js using "0x" + addr.slice(3)
  • USDC contract on Mainnet0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1

Why This Matters

Most AI demonstrations stop at content generation.

This project demonstrates something more meaningful: AI agents that take actions.

The future of AI is not just answering questions — it is helping users accomplish tasks. Blockchain networks provide a transparent and programmable execution layer for those tasks. By combining Claude's language understanding with XDC's on-chain settlement, developers can transform natural language directly into verifiable financial outcomes.

This pattern opens the door to more complex agentic workflows: scheduled payments, multi-step DeFi interactions, automated treasury operations — all triggered by plain English.


Open Source

The complete source code is available on GitHub:

github.com/RushabhParmar12/agentic-xdc-payments

Developers are encouraged to explore, fork, and extend the project for new agentic use cases on XDC Network.


Conclusion

Agentic AI represents a shift from software that provides information to software that performs actions.

This project demonstrates that shift in a direct, practical way:

  1. A user expresses intent in plain English
  2. Claude AI understands and structures the request
  3. The application validates and confirms with the user
  4. ethers.js signs and broadcasts the transaction
  5. XDC Network settles it permanently on-chain

This is more than a payment application. It is a working example of how AI agents and blockchain infrastructure can combine to build the next generation of autonomous financial systems.


Built with Claude AI · ethers.js · Node.js · XDC Network


Disclaimer: This application uses AI to interpret natural language instructions. While safety checks are implemented, AI outputs may occasionally be incorrect or incomplete. Always review transaction details carefully before confirming. The user remains fully responsible for all transactions executed through this application.

Discussion (0)