DEV Community

Cover image for Beyond Transactions: How AI Agents Execute Offchain Actions
Wallet Guy
Wallet Guy

Posted on

Beyond Transactions: How AI Agents Execute Offchain Actions

Your AI agents can analyze market data, generate trading strategies, and even write smart contracts. But when it comes to actually executing transactions, they hit a wall. Most agents are stuck in read-only mode, unable to interact with DeFi protocols or handle real money. WAIaaS changes this by giving AI agents secure wallet capabilities through a self-hosted API that integrates with popular frameworks like Claude MCP.

Why Offchain Actions Matter for AI Agents

Traditional blockchain interactions focus on transactions — moving tokens, calling smart contracts, minting NFTs. But real AI agent workflows require much more. Your agent might need to check DeFi positions across multiple protocols, pay for API calls automatically using crypto, or execute complex multi-step strategies that combine onchain and offchain operations.

The challenge isn't just about having a wallet. It's about giving agents the right level of access without compromising security. You need granular policies, multi-layered approval systems, and the ability to revoke access instantly if something goes wrong.

WAIaaS Offchain Action Framework

WAIaaS provides 45 MCP tools that extend far beyond basic transactions. These tools are organized into categories that mirror how AI agents actually work:

Wallet Operations: Balance checks, address resolution, and asset management across multiple chains. Your agent can query positions across 15 DeFi protocols and get a unified view.

Transaction Pipeline: Not just sending transactions, but simulating them first, checking policy compliance, and handling multi-step approvals. Every transaction goes through a 7-stage pipeline with built-in safety checks.

DeFi Integration: Direct protocol integration means agents can interact with Aave, Jupiter, Lido, and other protocols without writing custom smart contract code.

Cross-Chain Actions: Bridge assets automatically using LI.FI and Across protocols when the agent's strategy requires tokens on different chains.

Payment Automation: The x402 HTTP payment protocol lets agents pay for API calls using crypto, enabling truly autonomous operation.

Here's how an AI agent checks DeFi positions across all protocols:

curl http://127.0.0.1:3100/v1/defi/positions \
  -H "Authorization: Bearer wai_sess_eyJhbGciOiJIUzI1NiJ9..."
Enter fullscreen mode Exit fullscreen mode

The response includes lending positions, staking rewards, and LP positions with USD values calculated automatically:

{
  "positions": [
    {
      "protocol": "aave-v3",
      "type": "lending",
      "asset": "USDC",
      "amount": "1500.00",
      "apy": "4.2%",
      "health_factor": "2.1"
    },
    {
      "protocol": "lido",
      "type": "staking",
      "asset": "stETH",
      "amount": "0.5",
      "rewards_earned": "0.002"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Policy-Driven Security for Autonomous Agents

The biggest concern with AI agents handling money is security. WAIaaS addresses this with 21 policy types and 4 security tiers. Instead of giving agents unlimited access, you define exactly what they can do:

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "SPENDING_LIMIT",
    "rules": {
      "instant_max_usd": 100,
      "notify_max_usd": 500,
      "delay_max_usd": 2000,
      "delay_seconds": 900,
      "daily_limit_usd": 5000
    }
  }'
Enter fullscreen mode Exit fullscreen mode

This policy creates a 4-tier system:

  • INSTANT: Transactions under $100 execute immediately
  • NOTIFY: $100-500 transactions execute with notifications
  • DELAY: $500-2000 transactions wait 15 minutes (cancellable)
  • APPROVAL: Anything over $2000 requires human approval

You can also restrict which tokens, contracts, and DeFi protocols the agent can access. The default-deny approach means agents are blocked from unexpected actions unless explicitly permitted.

MCP Integration: Plug and Play AI Wallets

Model Context Protocol (MCP) makes it trivial to give existing AI frameworks wallet capabilities. WAIaaS provides an MCP server with all 45 tools pre-configured:

npm install -g @waiaas/cli
waiaas quickset --mode mainnet
waiaas mcp setup --all
Enter fullscreen mode Exit fullscreen mode

This automatically registers WAIaaS with Claude Desktop. Your Claude agent immediately gains access to wallet operations:

{
  "mcpServers": {
    "waiaas": {
      "command": "npx",
      "args": ["-y", "@waiaas/mcp"],
      "env": {
        "WAIAAS_BASE_URL": "http://127.0.0.1:3100",
        "WAIAAS_SESSION_TOKEN": "wai_sess_<your-token>",
        "WAIAAS_DATA_DIR": "~/.waiaas"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Now Claude can perform complex blockchain operations through natural language:

User: "Check my DeFi positions and rebalance if my Aave health factor is below 1.5"

Claude: Uses get_defi_positions tool → sees health factor of 1.2 → uses action_provider tool to repay some debt → confirms with get_defi_positions again.

Advanced Use Cases: x402 and ERC-8004

WAIaaS enables AI agent patterns that aren't possible with traditional wallets. The x402 HTTP payment protocol lets agents pay for API services automatically:

import { WAIaaSClient } from '@waiaas/sdk';

const client = new WAIaaSClient({
  baseUrl: 'http://127.0.0.1:3100',
  sessionToken: process.env.WAIAAS_SESSION_TOKEN,
});

// Agent pays for API call automatically when service returns HTTP 402
const response = await client.x402Fetch('https://api.market-data.ai/analysis', {
  method: 'POST',
  body: JSON.stringify({ symbol: 'BTC' }),
});

console.log('Paid for analysis:', await response.json());
Enter fullscreen mode Exit fullscreen mode

The agent's wallet automatically handles the payment negotiation, making API services truly frictionless.

ERC-8004 integration provides onchain agent reputation. Your agents can prove their track record and gain access to higher-value operations based on historical performance:

curl http://127.0.0.1:3100/v1/erc8004/agent-info/<agent-address> \
  -H "Authorization: Bearer wai_sess_<token>"
Enter fullscreen mode Exit fullscreen mode

Multi-Chain Agent Strategies

Real AI trading agents need to work across multiple chains. WAIaaS supports 18 networks across EVM and Solana, with automatic bridging when strategies require cross-chain execution.

Here's an agent executing a cross-chain arbitrage strategy:

# 1. Check prices on both chains
curl http://127.0.0.1:3100/v1/actions/jupiter-swap/quote \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{"inputMint": "SOL", "outputMint": "USDC", "amount": "1"}'

curl http://127.0.0.1:3100/v1/actions/zerox-swap/quote \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{"sellToken": "ETH", "buyToken": "USDC", "sellAmount": "0.6"}'

# 2. Bridge assets to optimal chain
curl -X POST http://127.0.0.1:3100/v1/actions/lifi/bridge \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "fromChain": "solana",
    "toChain": "ethereum",
    "fromToken": "USDC",
    "toToken": "USDC",
    "amount": "1000"
  }'

# 3. Execute optimal trade
curl -X POST http://127.0.0.1:3100/v1/actions/zerox-swap/swap \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{"sellToken": "USDC", "buyToken": "ETH", "sellAmount": "1000"}'
Enter fullscreen mode Exit fullscreen mode

The agent handles all the complexity — quote comparison, bridge execution, and final trades — while WAIaaS ensures each step complies with your security policies.

Quick Start: Give Your Agent a Wallet

Step 1: Install and initialize WAIaaS

npm install -g @waiaas/cli
waiaas init
waiaas start
Enter fullscreen mode Exit fullscreen mode

Step 2: Create wallets and sessions

waiaas quickset --mode mainnet
Enter fullscreen mode Exit fullscreen mode

Step 3: Set up MCP integration

waiaas mcp setup --all
Enter fullscreen mode Exit fullscreen mode

Step 4: Configure policies

waiaas quickstart
# Follow prompts to set spending limits and token whitelist
Enter fullscreen mode Exit fullscreen mode

Step 5: Test with Claude
Open Claude Desktop and ask: "What's my wallet balance?" Your agent now has full blockchain capabilities.

What's Next

WAIaaS transforms AI agents from observers to participants in the crypto economy. Your agents can now execute complex DeFi strategies, pay for services automatically, and operate with the security controls you need for production use.

Ready to give your AI agent a wallet? Check out the WAIaaS GitHub repository for full documentation and examples. Visit waiaas.ai to explore all capabilities and join the community building the future of AI-powered finance.

Top comments (0)