DEV Community

Cover image for How to Give Your AI Agent a Crypto Wallet in 5 Minutes
OpenClaw Cash
OpenClaw Cash

Posted on

How to Give Your AI Agent a Crypto Wallet in 5 Minutes

How to Give Your AI Agent a Crypto Wallet in 5 Minutes

AI agents can browse the web, write code, and book meetings. But the moment they need to move money, most setups fall apart.

You either hardcode a private key, wire up a janky workaround, or just skip it entirely. None of those are production-ready.

In this tutorial, I'll show you how to give your AI agent a proper managed wallet with spending limits, token transfers, and DEX swaps using OpenClawCash.


What We're Building

By the end of this post your agent will be able to:

  • Create and access a managed wallet (EVM or Solana)
  • Check token balances
  • Send native and token transfers
  • Execute DEX swaps via Uniswap (EVM) or Jupiter (Solana)

All without ever touching a raw private key in your code.


Prerequisites

  • An OpenClawCash account → openclawcash.com
  • An API key (generated from your dashboard)
  • Any AI agent framework (LangChain, CrewAI, AutoGPT, custom doesn't matter)

Step 1 Create a Wallet

Once you're signed in, create a wallet from the dashboard and assign it to your agent. You'll get back a wallet address on EVM or Solana mainnet.

You can also set policy controls at this point spending limits and address restrictions. This is what makes it production-safe. Your agent can only spend what you allow it to.


Step 2 Authenticate Your Agent

All agent API calls use an X-Agent-Key header. Generate one from your dashboard and keep it in your environment variables.

X-Agent-Key: your_agent_key_here
Enter fullscreen mode Exit fullscreen mode

Never hardcode this in your source. Treat it like any other secret.


Step 3 Discover Wallets

Your agent can list all wallets it has access to:

GET /api/agent/wallets
X-Agent-Key: your_agent_key_here
Enter fullscreen mode Exit fullscreen mode

This returns wallet addresses and chain info no balances at this stage, just discovery.


Step 4 Check Balances

To get native and token balances for a specific wallet:

GET /api/agent/wallet?address=0xYourWalletAddress
X-Agent-Key: your_agent_key_here
Enter fullscreen mode Exit fullscreen mode

Returns native balance (ETH, SOL) plus any ERC-20 or SPL token balances.


Step 5 Send a Transfer

Your agent can now send funds programmatically:

POST /api/agent/transfer
X-Agent-Key: your_agent_key_here

{
  "from": "0xYourWalletAddress",
  "to": "0xRecipientAddress",
  "token": "ETH",
  "amount": "0.01"
}
Enter fullscreen mode Exit fullscreen mode

If the transfer violates a policy you set (e.g. exceeds spending limit), it'll be rejected before it hits the chain.


Step 6 Execute a DEX Swap

Need your agent to swap tokens? One call handles it:

POST /api/agent/swap
X-Agent-Key: your_agent_key_here

{
  "wallet": "0xYourWalletAddress",
  "fromToken": "ETH",
  "toToken": "USDC",
  "amount": "0.05"
}
Enter fullscreen mode Exit fullscreen mode

Routes automatically through Uniswap on EVM chains or Jupiter on Solana.


Plugging It Into Your Agent

Here's a minimal example of how this looks inside a LangChain tool:

import requests

AGENT_KEY = "your_agent_key_here"
BASE_URL = "https://openclawcash.com/api/agent"

def send_transfer(to_address: str, amount: str, token: str = "ETH"):
    response = requests.post(
        f"{BASE_URL}/transfer",
        headers={"X-Agent-Key": AGENT_KEY},
        json={
            "from": "0xYourWalletAddress",
            "to": to_address,
            "token": token,
            "amount": amount
        }
    )
    return response.json()
Enter fullscreen mode Exit fullscreen mode

Wrap this in a LangChain Tool and your agent can now reason about when and how to move funds with guardrails already in place.


Why This Matters

Most crypto + AI setups right now are brittle. Raw private keys in env files, no spending limits, no audit trail.

OpenClawCash gives you managed wallets with policy controls and a full activity history so when your agent acts autonomously, you're not flying blind.


What's Next


Built something cool with OpenClawCash? Drop it in the comments would love to see what people are building.

Top comments (0)