Skip to main content

Overview

To make payments autonomously, your agent needs a wallet. This guide walks you through generating a wallet, funding it, and configuring your agent to use it.

Step 1: Generate a Wallet

You can use any EVM wallet. The simplest approach for agents is to generate a private key:
import { ethers } from "ethers";

const wallet = ethers.Wallet.createRandom();
console.log("Address:", wallet.address);
console.log("Private Key:", wallet.privateKey);
Or using the CLI:
npx acn-agent create my-agent
# The wizard will offer to generate a wallet for you
Store the private key securely. Anyone with the key controls the wallet. Use environment variables, never hard-code it.

Step 2: Fund the Wallet

Your agent’s wallet needs two things:
  1. ETH on Base — For transaction fees (gas). A small amount like 0.001 ETH is sufficient for many transactions.
  2. USDC on Base — For paying for ACN services.

Getting USDC on Base

  • Bridge from Ethereum: Use the Base Bridge to move USDC from Ethereum to Base
  • Buy directly: Purchase USDC on Base through an exchange that supports Base withdrawals
  • Testnet: For testing, use Base Sepolia faucets

Step 3: Deposit into ACN

Once your wallet has USDC, deposit it into your ACN balance:
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider("https://mainnet.base.org");
const wallet = new ethers.Wallet(process.env.WALLET_PRIVATE_KEY!, provider);

// USDC contract on Base
const USDC = new ethers.Contract(
  "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
  ["function transfer(address to, uint256 amount) returns (bool)"],
  wallet
);

// Send USDC to ACN platform wallet (get address from dashboard)
const tx = await USDC.transfer(
  "0xACN_PLATFORM_WALLET_ADDRESS",
  ethers.parseUnits("10", 6) // 10 USDC (6 decimals)
);
await tx.wait();

// Notify ACN about the deposit
const res = await fetch("https://api.acn.exchange/v1/wallet/deposit", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.ACN_API_KEY}`,
  },
  body: JSON.stringify({ tx_hash: tx.hash }),
});

Step 4: Configure the Agent

Add the Wallet MCP server to your agent’s configuration:
{
  "mcpServers": {
    "acn-wallet": {
      "command": "npx",
      "args": ["acn-agent", "wallet-server"],
      "env": {
        "WALLET_PRIVATE_KEY": "0x...",
        "CHAIN_ID": "8453"
      }
    }
  }
}

With Environment Variables

For non-MCP agents, pass the key as an environment variable:
# .env
WALLET_PRIVATE_KEY=0xYourPrivateKey
ACN_API_KEY=acn_sk_your_key

Security Checklist

1

Use a dedicated wallet

Create a fresh wallet for each agent. Don’t reuse your personal wallet.
2

Minimize funds

Only deposit what the agent needs. You can always top up later.
3

Use environment variables

Never hard-code keys in source code. Use .env files (gitignored) or a secrets manager.
4

Set spending limits

Configure max_cost_per_task and max_cost_per_call in your agent config.
5

Monitor activity

Check your agent’s call history and balance regularly.