OpenClaw Plugin: Connect WAIaaS to LangChain, CrewAI, and Any AI Framework
OpenClaw Plugin: Connect WAIaaS to LangChain, CrewAI, and Any AI Framework Your AI agent can browse the web, write code, and manage files - but can it swap tokens? The OpenClaw plugin is WAIaaS's answer to that question: a drop-in wallet toolkit that connects your existing AI agent framework to real blockchain wallets, without rewriting your agent from scratch. The Problem: AI Agents Are Financially Stranded You've built an agent. Maybe it's a LangChain chain, a CrewAI crew, or something you rolled yourself on top of an LLM API. It can reason, plan, and call tools. But the moment you need it to do anything with money - pay for an API, swap tokens, send funds to a counterparty - you hit a wall. Blockchains don't have a "tool call" interface. Signing a transaction requires private keys, RPC connections, nonce management, gas estimation, and a dozen other things that have nothing to do with your agent's actual job. Most developers either give up, hardcode a single wallet with no security controls, or spend weeks building financial plumbing that isn't their core product. The result is agents that are powerful reasoners but financially stranded. They can think about money, but they can't touch it. What WAIaaS Does Differently WAIaaS is a self-hosted Wallet-as-a-Service daemon - you run it alongside your agent, and it handles all the wallet infrastructure: key storage, transaction signing, policy enforcement, DeFi integrations, multi-chain support. Your agent talks to it over HTTP or through a tool interface. The OpenClaw plugin is specifically designed for agent frameworks. Instead of exposing a raw REST API, it wraps WAIaaS capabilities into structured tools that LangChain, CrewAI, AutoGPT, or any framework that supports tool use can call directly. The plugin exposes 5 tool categories: wallet , transfer , defi , nft , and utility . Each category maps to a natural set of things an agent might need to do in the course of completing a task. Getting WAIaaS Running Before your agent can use OpenClaw, you need the WAIaaS daemon running. The fastest path is Docker: docker run -d \ --name waiaas \ -p 127.0.0.1:3100:3100 \ -v waiaas-data:/data \ -e WAIAAS_AUTO_PROVISION=true \ ghcr.io/waiaas/waiaas:latest # Grab the auto-generated master password docker exec waiaas cat /data/recovery.key Or if you prefer the CLI: npm install -g @waiaas/cli waiaas init --auto-provision waiaas start waiaas quickset # Creates wallets + sessions automatically Either way, you end up with a daemon listening on http://127.0.0.1:3100 and a session token that looks like wai_sess_eyJhbGciOiJIUzI1NiJ9... . That token is what your agent will use to authenticate. The daemon itself has 39 REST API route modules under the hood, but you won't need to interact with most of them directly - OpenClaw handles that abstraction for you. How the OpenClaw Tool Categories Work OpenClaw's 5 tools (wallet , transfer , defi , nft , utility ) each act as a gateway to a category of operations. Your agent calls a tool, passes parameters, and gets back structured results. The daemon handles everything else: signing, broadcasting, confirming. wallet - Query wallet state: address, balances, transaction history, open sessions. transfer - Move assets: native tokens, ERC-20/SPL tokens, NFTs. The daemon's 7-stage pipeline (validate → auth → policy → wait → execute → confirm) runs in the background, so your agent just submits a transfer and polls for completion. defi - Execute DeFi actions against any of the 15 integrated protocol providers, including Aave v3, Jupiter swap, Lido staking, Jito staking, Hyperliquid, Kamino, Pendle, Polymarket, and others. Your agent doesn't need to know how Jupiter's routing API works - it calls the DeFi tool with intent, and OpenClaw + WAIaaS handles the execution. nft - Read NFT metadata, list holdings (EVM ERC-721/ERC-1155 and Solana Metaplex), and transfer NFTs. utility - Supporting operations: encode calldata, resolve assets, check provider status, interact with x402 payment endpoints. A Real Example: LangChain Agent with a Wallet Here's what wiring OpenClaw into a LangChain-style agent looks like. First, your agent gets the OpenClaw tools registered as part of its tool set. Then it can call them like any other tool. Before the agent does anything financial, you'll want to verify the wallet is funded and know what it's working with. Using the TypeScript SDK directly (which OpenClaw wraps), the pattern looks like this: import { WAIaaSClient } from '@waiaas/sdk'; const client = new WAIaaSClient({ baseUrl: 'http://127.0.0.1:3100', sessionToken: process.env.WAIAAS_SESSION_TOKEN, }); // Agent checks its own balance before deciding whether to proceed const balance = await client.getBalance(); console.log(Balance: ${balance.balance} ${balance.symbol} (${balance.chain}/${balance.network})); When the agent decides to execute a transfer, it submits the transaction and polls for confirmation: const sendResult = await client.sendToken({ type: 'TRANSFER', to: 'recipient-address', amount: '0.001', }); console.log(Transaction submitted: ${sendResult.id} (status: ${sendResult.status})); // Poll for confirmation const POLL_TIMEOUT_MS = 60_000; const startTime = Date.now(); while (Date.now() - startTime setTimeout(resolve, 1000)); } The agent doesn't know or care about private keys, RPC nodes, or gas pricing. It submits intent, waits for result. Policy Guardrails: Don't Give Your Agent Unlimited Access This is worth stopping on, because it's the part most developers skip and later regret. When you give an agent a wallet, you're giving it the ability to move real money. WAIaaS's policy engine is what keeps that from being terrifying. The policy engine has 21 policy types with 4 security tiers: INSTANT (execute immediately), NOTIFY (execute and alert you), DELAY (queue for N seconds, cancellable), and APPROVAL (require human sign-off). Policies follow default-deny: if you haven't explicitly allowed something, it's blocked. A sensible starting policy for an agent wallet: 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": " ", "type": "SPENDING_LIMIT", "rules": { "instant_max_usd": 100, "notify_max_usd": 500, "delay_max_usd": 2000, "delay_seconds": 900, "daily_limit_usd": 5000 } }' This single policy means: under $100 goes through immediately, $100-$500 notifies you but proceeds, $500-$2000 waits 15 minutes (during which you can cancel), and anything over $2000 requires your explicit approval. Your agent can still operate autonomously for routine tasks, but large moves get human review. You'll also want to add an ALLOWED_TOKENS policy so the agent can only move tokens you've explicitly approved, and a CONTRACT_WHITELIST if it's going to call DeFi protocols. Without these, those operations are blocked by default - which is the right default. DeFi Actions: What Your Agent Can Actually Do With the defi OpenClaw tool and the 15 protocol providers integrated into WAIaaS, an agent can: - Swap tokens on Jupiter (Solana) or 0x/LI.FI (EVM) - Supply and borrow on Aave v3 - Stake SOL via Jito or ETH via Lido - Open and manage perpetual positions on Hyperliquid (with leverage limits enforced by PERP_MAX_LEVERAGE policy) - Earn yield on Kamino or Pendle - Trade on Polymarket prediction markets - Bridge assets cross-chain via LI.FI or Across The DeFi action call via the REST API looks like this - and OpenClaw wraps this pattern so your agent can invoke it through tool calling: curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \ -H "Content-Type: application/json" \ -H "Authorization: Bearer wai_sess_ " \ -d '{ "inputMint": "So11111111111111111111111111111111111111112", "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "amount": "1000000000" }' Before any of this executes, the transaction runs through the 7-stage pipeline. Stage 3 is the policy check - if the action violates any configured policy (wrong token, too large, wrong network, wrong venue), it gets blocked before any signing happens. Stage 4 handles the delay/approval wait if required. Stage 5 is execution. Your agent waits for the pipeline to complete. Dry Run First If your agent is being cautious or you want to validate a transaction before committing, the dry-run API lets you simulate without executing: curl -X POST http://127.0.0.1:3100/v1/transactions/send \ -H "Content-Type: application/json" \ -H "Authorization: Bearer wai_sess_ " \ -d '{ "type": "TRANSFER", "to": "recipient-address", "amount": "0.1", "dryRun": true }' This runs all validation stages and returns what would happen - including policy decisions and estimated outcomes - without touching the chain. Useful for agents that need to reason about feasibility before committing. Error Handling: What Your Agent Needs to Handle WAIaaS returns structured errors, which means your agent can make intelligent decisions when something goes wrong rather than just logging an unhandled exception: import { WAIaaSClient, WAIaaSError } from '@waiaas/sdk'; try { const tx = await client.sendToken({ to: '...', amount: '1.0' }); } catch (error) { if (error instanceof WAIaaSError) { console.error(API Error: [${error.code}] ${error.message}); // error.code examples: INSUFFICIENT_BALANCE, POLICY_DENIED, TOKEN_EXPIRED } } POLICY_DENIED means the agent tried something the policy engine blocked - the agent should not retry, and probably should surface this to the user. INSUFFICIENT_BALANCE means the agent needs to either acquire funds or reduce the amount. TOKEN_EXPIRED means the session needs to be refreshed by whoever manages sessions (typically your orchestration layer, not the agent itself). Structured errors make your agent a better reasoner about financial operations, not just a blind executor. Quick Start Summary Here's the minimal path to an agent with a wallet: Step 1: Start the daemon npm install -g @waiaas/cli waiaas init --auto-provision &&
Comments
No comments yet. Start the discussion.