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:

LayerPackagePurpose
SDK@loomlay/openclaw-wallet-sdkProgrammatic TypeScript interface for building applications
Plugin@loomlay/openclaw-wallet-pluginNative 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-plugin

Configuration

Zero Configuration (Recommended)

The plugin works out of the box with no configuration required. On first use, it automatically:

  1. Registers for a new API key (saved to ~/.loomlay/credentials.json)
  2. Generates wallet keys locally on your device
  3. Encrypts keys with your passphrase (saved to ~/.loomlay/wallet.json)
  4. 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 server

API Key Resolution Order

The plugin checks for API keys in this order:

  1. LOOMLAY_API_KEY environment variable (highest priority)
  2. Stored credentials (~/.loomlay/credentials.json)
  3. Auto-register new account (if no key found)

Passphrase Resolution Order

For signing operations (swaps, transfers), the passphrase is resolved:

  1. LOOMLAY_WALLET_PASSPHRASE environment variable (highest priority, recommended)
  2. In-memory cache (set via wallet_unlock)
  3. 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.com

Programmatic 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)

ToolDescription
wallet_createCreate 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_getGet wallet addresses and current balances across all chains.
wallet_export_keysExport private keys. In self-custody mode, decrypts locally using passphrase. In custodial mode, requires seed phrase.
wallet_unlockCache passphrase in memory for signing operations. Required before swaps/transfers in self-custody mode.
wallet_importImport an existing seed phrase into a local self-custody wallet. Encrypts locally and registers addresses with API.

Trading (5 tools)

ToolDescription
swapExecute a token swap. Supports flexible amounts: "1.5", "$100", "50%", or "max".
swap_quoteGet a swap quote without executing. Shows expected output, minimum received, and price impact.
transferTransfer tokens to another address on any supported chain.
bridgeBridge tokens between different chains (e.g., Solana to Base).
bridge_quoteGet a bridge quote showing fees and estimated completion time.

Tokens (4 tools)

ToolDescription
token_searchSearch for tokens by name, symbol, or address. Returns matches with safety scores.
token_priceGet current USD price for any token.
token_detailsGet detailed token information including market data and safety analysis.
token_chartGet OHLCV chart data for technical analysis.

Portfolio (2 tools)

ToolDescription
portfolio_getGet combined portfolio across all chains with total USD value.
portfolio_historyGet transaction history with optional chain filtering.

DEX (7 tools)

ToolDescription
dex_trendingGet trending trading pairs sorted by trending score.
dex_volumeGet top trading pairs by 24h volume.
dex_gainersGet top price gainers (24h).
dex_losersGet top price losers (24h).
dex_newGet newly created pairs (< 24 hours old).
dex_pumpfunGet Pumpfun trending pairs (Solana only, bonding curve tokens).
dex_queryAdvanced DEX query with custom filters, ranking, and timeframes.

Tokenize (2 tools)

ToolDescription
tokenize_launchLaunch a new token on Solana with automatic pool creation. One token per account.
tokenize_infoGet information about your launched token including mint and pool addresses.

Fees (2 tools)

ToolDescription
fees_statusGet fee status including generated, claimed, and unclaimed amounts.
fees_claimClaim accumulated trading fees from your launched token (platform pays gas).

RPC (2 tools)

ToolDescription
rpc_callMake a direct RPC call to any supported chain.
rpc_chainsGet 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:

  1. Core Workflow - A structured approach: Authenticate, Understand, Validate, Execute, Verify, Document
  2. Security Best Practices - Seed phrase handling, transaction safety, API key management
  3. Quote-Before-Trade Pattern - Always get quotes and show expected outcomes before executing
  4. Error Handling - Recovery patterns for rate limits, insufficient funds, and network errors
  5. 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.md

Usage 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:

FormatExampleDescription
Decimal"1.5"Exact token amount
USD"$100"Dollar value (auto-converts)
Percentage"50%"Percentage of balance
Max"max"Entire balance

Supported Chains

ChainSwapsBridgesRPC
SolanaYesYesYes
EthereumYesYesYes
BaseYesYesYes
ArbitrumYesYesYes
OptimismYesYesYes
PolygonYesYesYes
BSCYesYesYes

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.json with 0600 (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

  1. API Key - Store in environment variables, never hardcode
  2. Seed Phrase - Returned once from wallet_create, store offline securely
  3. Quotes First - Always get quotes before executing trades
  4. Verify Addresses - Double-check recipient addresses for transfers
  5. Check Price Impact - High price impact (>1%) indicates significant market movement

Related Pages