OpenClaw Plugin
The OpenClaw Plugin provides 29 native tools for multi-chain wallet management, trading, and market data directly within AI coding assistants like Claude Code. The plugin defaults to self-custody mode — private keys are generated and encrypted locally on your device, never sent to any server.
Architecture Overview
The OpenClaw ecosystem has a dual-layer architecture:
| Layer | Package | Purpose |
|---|---|---|
| SDK | @loomlay/openclaw-wallet-sdk | Programmatic TypeScript interface for building applications |
| Plugin | @loomlay/openclaw-wallet-plugin | Native tools for AI agents |
The SDK is designed for developers building applications. The Plugin wraps the SDK and exposes its functionality as discrete tools that AI agents can invoke directly.
The Plugin depends on the SDK internally. When you install the plugin, the SDK is included as a peer dependency.
Installation
npm install @loomlay/openclaw-wallet-pluginConfiguration
Zero Configuration (Recommended)
The plugin works out of the box with no configuration required. On first use, it automatically:
- Registers for a new API key (saved to
~/.loomlay/credentials.json) - Generates wallet keys locally on your device
- Encrypts keys with your passphrase (saved to
~/.loomlay/wallet.json) - Registers only public addresses with the API
import { wallet_create, wallet_unlock } from '@loomlay/openclaw-wallet-plugin';
// First use: auto-registers API key, creates local wallet
const wallet = await wallet_create();
// → Keys generated on YOUR device, encrypted with passphrase
// → Public addresses registered with API for balance lookups
// Unlock wallet for signing operations
await wallet_unlock({ passphrase: 'your-passphrase' });
// All trades sign locally — private key never sent to serverAPI Key Resolution Order
The plugin checks for API keys in this order:
LOOMLAY_API_KEYenvironment variable (highest priority)- Stored credentials (
~/.loomlay/credentials.json) - Auto-register new account (if no key found)
Passphrase Resolution Order
For signing operations (swaps, transfers), the passphrase is resolved:
LOOMLAY_WALLET_PASSPHRASEenvironment variable (highest priority, recommended)- In-memory cache (set via
wallet_unlock) - Error thrown with instructions
Environment Variables (Optional)
# Override auto-registration
export LOOMLAY_API_KEY=agent_your_key_here
# Set wallet passphrase (avoids passphrase appearing in conversation logs)
export LOOMLAY_WALLET_PASSPHRASE=your-secure-passphrase
# Optional: Custom API base URL
export LOOMLAY_BASE_URL=https://api.loomlay.comProgrammatic Configuration (Optional)
import { initPlugin, initPluginAsync } from '@loomlay/openclaw-wallet-plugin';
// Sync: Requires existing key from env or stored credentials
initPlugin({
apiKey: 'agent_your_key_here',
baseUrl: 'https://api.loomlay.com' // Optional
});
// Async: Supports auto-registration
const { client, registration } = await initPluginAsync();Disable Auto-Registration
If you want to require explicit API key configuration:
import { initPluginAsync } from '@loomlay/openclaw-wallet-plugin';
// Throws error if no key found instead of auto-registering
const { client } = await initPluginAsync({ autoRegister: false });Store your API key in environment variables or let the plugin manage it automatically. API keys start with agent_ prefix.
Available Tools (29)
The plugin provides 29 tools organized into 8 categories:
Wallet (5 tools)
| Tool | Description |
|---|---|
wallet_create | Create a new multi-chain wallet (keys stored locally in self-custody mode). Returns Solana and EVM addresses plus a 12-word seed phrase shown only once. |
wallet_get | Get wallet addresses and current balances across all chains. |
wallet_export_keys | Export private keys. In self-custody mode, decrypts locally using passphrase. In custodial mode, requires seed phrase. |
wallet_unlock | Cache passphrase in memory for signing operations. Required before swaps/transfers in self-custody mode. |
wallet_import | Import an existing seed phrase into a local self-custody wallet. Encrypts locally and registers addresses with API. |
Trading (5 tools)
| Tool | Description |
|---|---|
swap | Execute a token swap. Supports flexible amounts: "1.5", "$100", "50%", or "max". |
swap_quote | Get a swap quote without executing. Shows expected output, minimum received, and price impact. |
transfer | Transfer tokens to another address on any supported chain. |
bridge | Bridge tokens between different chains (e.g., Solana to Base). |
bridge_quote | Get a bridge quote showing fees and estimated completion time. |
Tokens (4 tools)
| Tool | Description |
|---|---|
token_search | Search for tokens by name, symbol, or address. Returns matches with safety scores. |
token_price | Get current USD price for any token. |
token_details | Get detailed token information including market data and safety analysis. |
token_chart | Get OHLCV chart data for technical analysis. |
Portfolio (2 tools)
| Tool | Description |
|---|---|
portfolio_get | Get combined portfolio across all chains with total USD value. |
portfolio_history | Get transaction history with optional chain filtering. |
DEX (7 tools)
| Tool | Description |
|---|---|
dex_trending | Get trending trading pairs sorted by trending score. |
dex_volume | Get top trading pairs by 24h volume. |
dex_gainers | Get top price gainers (24h). |
dex_losers | Get top price losers (24h). |
dex_new | Get newly created pairs (< 24 hours old). |
dex_pumpfun | Get Pumpfun trending pairs (Solana only, bonding curve tokens). |
dex_query | Advanced DEX query with custom filters, ranking, and timeframes. |
Tokenize (2 tools)
| Tool | Description |
|---|---|
tokenize_launch | Launch a new token on Solana with automatic pool creation. One token per account. |
tokenize_info | Get information about your launched token including mint and pool addresses. |
Fees (2 tools)
| Tool | Description |
|---|---|
fees_status | Get fee status including generated, claimed, and unclaimed amounts. |
fees_claim | Claim accumulated trading fees from your launched token (platform pays gas). |
RPC (2 tools)
| Tool | Description |
|---|---|
rpc_call | Make a direct RPC call to any supported chain. |
rpc_chains | Get list of supported chains for RPC access. |
Skill System
The plugin includes a skill file (SKILL.md) that teaches AI agents how to use the tools safely and effectively.
What the Skill Teaches
The skill provides guidance on:
- Core Workflow - A structured approach: Authenticate, Understand, Validate, Execute, Verify, Document
- Security Best Practices - Seed phrase handling, transaction safety, API key management
- Quote-Before-Trade Pattern - Always get quotes and show expected outcomes before executing
- Error Handling - Recovery patterns for rate limits, insufficient funds, and network errors
- Chain-Specific Behaviors - Differences between Solana and EVM chains
Key Safety Principles
The skill enforces these safety principles for AI agents:
Security comes first. Wallets contain real value.
Every action involving funds should be deliberate,
verified, and explained to the user before execution.
Quality Gate Checklist:
- User explicitly requested this action
- Quote shown and confirmed for trades
- Address validated for transfers
- Sufficient balance confirmed
- Slippage/price impact acceptable
- Transaction hash provided after execution
Accessing the Skill
// Import from the package
import skillContent from '@loomlay/openclaw-wallet-plugin/skill';
// Or read the file directly
// node_modules/@loomlay/openclaw-wallet-plugin/skill/SKILL.mdUsage Example
Self-Custody Workflow
import {
wallet_create,
wallet_unlock,
wallet_get,
swap,
swap_quote,
dex_trending
} from '@loomlay/openclaw-wallet-plugin';
// 1. Create wallet (keys generated and encrypted locally)
const wallet = await wallet_create();
if (wallet.success) {
console.log('Solana Address:', wallet.data.wallet.solanaAddress);
console.log('EVM Address:', wallet.data.wallet.evmAddress);
// IMPORTANT: Save the seed phrase securely - shown only once
console.log('Seed Phrase:', wallet.data.seedPhrase);
}
// 2. Unlock wallet for signing (or set LOOMLAY_WALLET_PASSPHRASE env var)
await wallet_unlock({ passphrase: 'my-secure-passphrase' });
// Check balance
const balance = await wallet_get();
if (balance.success) {
console.log('SOL Balance:', balance.data.balances.solana.sol);
}
// Get a quote before trading
const quote = await swap_quote({
inputToken: 'SOL',
outputToken: 'USDC',
amount: '$100'
});
if (quote.success) {
console.log('Expected Output:', quote.data.outputAmount, 'USDC');
console.log('Price Impact:', quote.data.priceImpact, '%');
}
// Execute the swap after confirming the quote
const result = await swap({
inputToken: 'SOL',
outputToken: 'USDC',
amount: '$100'
});
// Get trending tokens
const trending = await dex_trending({
chain: 'solana',
minLiquidity: 10000,
limit: 20
});Using the Tools Registry
import { tools } from '@loomlay/openclaw-wallet-plugin';
// Call tools by name
const wallet = await tools.wallet_get();
const trending = await tools.dex_trending({ chain: 'solana' });Response Format
All tools return a standardized response:
interface ToolResponse<T> {
success: boolean;
data?: T; // Present when success is true
error?: {
message: string;
code?: string;
retryAfter?: number; // For rate limit errors
};
}Success Response
{
success: true,
data: {
// Tool-specific data
}
}Error Response
{
success: false,
error: {
message: "Rate limited",
code: "RATE_LIMITED",
retryAfter: 30
}
}Amount Formats
Trading tools accept flexible amount formats:
| Format | Example | Description |
|---|---|---|
| Decimal | "1.5" | Exact token amount |
| USD | "$100" | Dollar value (auto-converts) |
| Percentage | "50%" | Percentage of balance |
| Max | "max" | Entire balance |
Supported Chains
| Chain | Swaps | Bridges | RPC |
|---|---|---|---|
| Solana | Yes | Yes | Yes |
| Ethereum | Yes | Yes | Yes |
| Base | Yes | Yes | Yes |
| Arbitrum | Yes | Yes | Yes |
| Optimism | Yes | Yes | Yes |
| Polygon | Yes | Yes | Yes |
| BSC | Yes | Yes | Yes |
Plugin Manifest
The openclaw.plugin.json file describes all tools in a machine-readable format:
{
"name": "@loomlay/openclaw-wallet-plugin",
"tools": [
{
"name": "swap",
"description": "Execute a token swap...",
"parameters": { ... },
"returns": { ... }
}
]
}This manifest enables plugin systems and AI agents to discover and understand available tools programmatically.
Security Notes
Seed Phrase Security: The seed phrase is returned only once when creating a wallet. It cannot be retrieved later. Store it securely offline. Never log it, include it in error messages, or store it in databases.
Self-Custody Security
In self-custody mode (default), your keys are protected by:
- Local encryption: PBKDF2-SHA512 (600k iterations) + AES-256-GCM
- File permissions:
~/.loomlay/wallet.jsonwith0600(owner read/write only) - No key transmission: Private keys never sent to any server
- Transaction validation: Fee payer verified before signing
- Key zeroing: Private key buffers zeroed after signing
Set LOOMLAY_WALLET_PASSPHRASE as an environment variable to keep your passphrase out of conversation logs.
General
- API Key - Store in environment variables, never hardcode
- Seed Phrase - Returned once from
wallet_create, store offline securely - Quotes First - Always get quotes before executing trades
- Verify Addresses - Double-check recipient addresses for transfers
- Check Price Impact - High price impact (>1%) indicates significant market movement
Related Pages
- SDK Overview - Full TypeScript SDK documentation
- Getting Started - SDK setup and first steps
- Trading - Detailed swap, transfer, and bridge documentation
- Market Data - DEX data and market analysis tools
- Error Handling - Error types and recovery patterns
- Rate Limits - API rate limit information