Skip to main content

🛠️ SDK Guide

The CLAW Wallet SDK provides a simple, object-oriented way to interact with the service in JavaScript or TypeScript.

Quick Start

1. Installation

Node.js (NPM)

npm install @claw_wallet/claw-wallet-sdk

Python (PyPI)

pip install claw-wallet

2. Initialization

import { AgentWallet } from '@claw_wallet/claw-wallet-sdk';

const wallet = new AgentWallet({
apiKey: process.env.AGENT_WALLET_API_KEY,
apiUrl: 'http://localhost:3000'
});

Core Methods

Wallet Operations

  • wallet.create(name, chain?): Create a new wallet.
  • wallet.getBalance(address, chain?): Get single balance.
  • wallet.getAllBalances(address): Get balances on all chains.
  • wallet.send(from, to, value, chain?): Broadcast a transaction.

Identity Operations

  • wallet.createIdentity(walletAddress, name, type?): Provision ERC-8004.
  • wallet.getIdentity(agentId): Get identity details.

Real-Time Events

wallet.on('tx.confirmed', (data) => {
console.log('Transaction confirmed!', data.hash);
});

wallet.on('policy.hitl', (data) => {
console.log('Action requires approval:', data.request_id);
});

Error Handling

The SDK uses standard error classes:

try {
await wallet.send(...);
} catch (err) {
if (err.type === 'PolicyError') {
console.error('Blocked by policy:', err.message);
}
}