home / skills / bankrbot / claude-plugins / sdk-wallet-operations

sdk-wallet-operations skill

/x402-sdk-dev/skills/sdk-wallet-operations

This skill helps you initialize and configure BankrClient for a two-wallet setup, including environment variables and wallet address derivation.

npx playbooks add skill bankrbot/claude-plugins --skill sdk-wallet-operations

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.0 KB
---
name: Bankr x402 SDK - Wallet Operations
description: This skill should be used when the user asks to "set up the SDK", "initialize BankrClient", "configure wallet", "set up payment wallet", "connect wallet to Bankr", "get wallet address", "set up environment variables", "configure private key", "two wallet setup", "separate payment and trading wallets", or needs help with SDK client initialization, two-wallet configuration, wallet address derivation, environment setup, or BankrClient options.
version: 1.1.0
---

# SDK Wallet Operations

Initialize and configure the BankrClient with proper wallet setup.

## Two-Wallet System

| Wallet | Purpose | Required |
|--------|---------|----------|
| Payment (`privateKey`) | Signs x402 micropayments ($0.01/request) | Yes |
| Context (`walletAddress`) | Receives swapped tokens, NFTs | No (defaults to payment wallet) |

## Basic Setup

```typescript
import { BankrClient } from "@bankr/sdk";

const client = new BankrClient({
  privateKey: process.env.BANKR_PRIVATE_KEY as `0x${string}`,
});

const result = await client.promptAndWait({
  prompt: "What are my balances?",
});
```

## Separate Wallets (Recommended)

For enhanced security, use different wallets for payments and receiving:

```typescript
const client = new BankrClient({
  // Hot wallet with minimal USDC for payments
  privateKey: process.env.PAYMENT_WALLET_PK as `0x${string}`,
  // Cold/trading wallet receives tokens
  walletAddress: process.env.RECEIVING_WALLET,
});
```

## Configuration Options

| Option | Type | Required | Description |
|--------|------|----------|-------------|
| `privateKey` | `0x${string}` | Yes | Payment wallet private key |
| `walletAddress` | `string` | No | Override receiving wallet |
| `baseUrl` | `string` | No | API endpoint (default: production) |
| `timeout` | `number` | No | Request timeout ms (default: 600000) |

## SDK Methods

| Method | Description |
|--------|-------------|
| `promptAndWait()` | Submit prompt and wait for result |
| `prompt()` | Submit prompt, return immediately |
| `pollJob()` | Poll until job completes |
| `getJobStatus()` | Check job status once |
| `cancelJob()` | Cancel pending/processing job |
| `getWalletAddress()` | Get context wallet address |

## Per-Request Override

```typescript
// Override wallet for a single request
const result = await client.promptAndWait({
  prompt: "Swap 0.1 ETH to USDC",
  walletAddress: "0xDifferentWallet...",
});
```

## Environment Setup

```bash
# Required
BANKR_PRIVATE_KEY=0x...your_payment_wallet_key...

# Optional
BANKR_WALLET_ADDRESS=0x...your_receiving_wallet...
```

## Security Best Practices

1. **Never commit private keys** - Use environment variables
2. **Minimize payment wallet balance** - Keep only $1-2 USDC
3. **Use separate wallets** - Payment (hot) vs receiving (cold)
4. **Rotate keys periodically** - If payment wallet compromised

## Related Skills

- **sdk-capabilities**: Full list of supported operations
- **sdk-job-management**: Async job handling and polling

Overview

This skill helps initialize and configure the BankrClient SDK with secure wallet operations for payment and receiving flows. It explains single- and two-wallet setups, environment variables, and client options to get a working BankrClient quickly. The goal is a minimal, secure integration for micropayments and token receipt workflows.

How this skill works

It creates a BankrClient instance with a required payment private key and an optional receiving wallet address. The skill covers initializing the client, overriding wallet per request, and configuring baseUrl and timeout options. It also outlines methods you will use (promptAndWait, prompt, pollJob, getJobStatus, cancelJob, getWalletAddress) to drive requests and manage jobs.

When to use it

  • Setting up the SDK or initializing BankrClient for the first time
  • Configuring environment variables and private key handling
  • Creating a two-wallet architecture (payment vs receiving)
  • Deriving or retrieving the current context wallet address
  • Overriding wallet address for a single request

Best practices

  • Always supply the payment private key via environment variables, never commit keys to source control
  • Use two wallets: a hot payment wallet with minimal balance and a cold receiving wallet for tokens
  • Keep the payment wallet balance minimal (e.g., $1–$2 USDC) to limit exposure
  • Rotate payment keys periodically and revoke if compromised
  • Use per-request walletAddress overrides when you need temporary routing of assets

Example use cases

  • Basic initialization with a single wallet to start sending micropayment requests
  • Recommended two-wallet setup: payment privateKey for signing, walletAddress for receiving swaps and NFTs
  • Per-request override to route a specific swap or payout to a different receiving address
  • Adjust baseUrl and timeout for non-production endpoints or long-running jobs
  • Call getWalletAddress() to confirm the context/receiving wallet your client will use

FAQ

Do I always need two wallets?

No. A single wallet can act as both payment and receiving wallet, but using two wallets improves security by limiting funds in the hot payment wallet.

Where should I store the private key?

Store the payment private key in environment variables (e.g., BANKR_PRIVATE_KEY) and never commit it. Use secrets management when available.