home / skills / openclaw / skills / cardano-wallet

cardano-wallet skill

/skills/sarthib7/cardano-wallet

This skill generates, restores, and manages Cardano wallets with QR funding, balance checks, and encrypted backups for OpenClaw agents.

npx playbooks add skill openclaw/skills --skill cardano-wallet

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

Files (12)
SKILL.md
4.3 KB
---
name: cardano-wallet
description: Generate, manage, and fund Cardano wallets for OpenClaw agents
homepage: https://masumi.network
user-invocable: true
metadata: {"openclaw": {"requires": {"bins": ["node"], "env": []}, "emoji": "💳"}}
---

# Cardano Wallet Skill for OpenClaw

**Generate, restore, and manage Cardano wallets with QR code funding support**

## Overview

The Cardano Wallet skill provides tools for AI agents to:
- Generate new Cardano wallets (24-word mnemonic)
- Restore wallets from existing mnemonics
- Generate QR codes for easy wallet funding
- Check wallet balances (requires Blockfrost API key)
- Securely backup wallet credentials

## Tools

### `cardano_generate_wallet`
Generate a new Cardano wallet with 24-word mnemonic phrase.

**Parameters:**
- `network` (optional): "Preprod" or "Mainnet" (default: "Preprod")

**Returns:**
- `address`: Cardano address (addr1...)
- `vkey`: Payment verification key
- `credentialsPath`: Path to encrypted credentials

**Example:**
```typescript
const wallet = await cardano_generate_wallet({ network: 'Preprod' });
console.log('Address:', wallet.address);
```

### `cardano_restore_wallet`
Restore a wallet from existing mnemonic phrase.

**Parameters:**
- `mnemonic` (required): 24-word mnemonic phrase
- `network` (optional): "Preprod" or "Mainnet"
- `agentIdentifier` (optional): Identifier to save credentials

**Example:**
```typescript
const wallet = await cardano_restore_wallet({
  mnemonic: 'word1 word2 ... word24',
  network: 'Preprod'
});
```

### `cardano_generate_funding_qr`
Generate QR code for wallet funding. Returns QR code as data URL.

**Parameters:**
- `address` (optional): Cardano address
- `agentIdentifier` (optional): Wallet identifier
- `network` (optional): "Preprod" or "Mainnet"

**Returns:**
- `qrDataUrl`: QR code as data URL (can be displayed in image)
- `address`: Wallet address
- `faucetUrl`: Preprod faucet URL (if Preprod network)

**Example:**
```typescript
const qr = await cardano_generate_funding_qr({
  agentIdentifier: 'my-wallet',
  network: 'Preprod'
});
// Display qr.qrDataUrl as image
```

### `cardano_get_wallet_balance`
Get wallet balance in ADA and lovelace. Requires Blockfrost API key.

**Parameters:**
- `agentIdentifier` (required): Wallet identifier
- `network` (optional): "Preprod" or "Mainnet"
- `blockfrostApiKey` (optional): Blockfrost API key (or use env var)

**Environment Variables:**
- `BLOCKFROST_API_KEY`: Blockfrost API key
- `BLOCKFROST_PREPROD_API_KEY`: Preprod API key
- `BLOCKFROST_MAINNET_API_KEY`: Mainnet API key

**Example:**
```typescript
const balance = await cardano_get_wallet_balance({
  agentIdentifier: 'my-wallet',
  network: 'Preprod'
});
console.log('Balance:', balance.ada, 'ADA');
```

### `cardano_backup_wallet`
Securely backup wallet credentials (encrypted).

**Parameters:**
- `agentIdentifier` (required): Wallet identifier
- `network` (optional): "Preprod" or "Mainnet"

**Returns:**
- `backupData`: Encrypted backup JSON

## Wallet Funding Workflow

1. **Generate wallet:**
   ```typescript
   const wallet = await cardano_generate_wallet({ network: 'Preprod' });
   ```

2. **Generate QR code:**
   ```typescript
   const qr = await cardano_generate_funding_qr({
     address: wallet.address,
     network: 'Preprod'
   });
   ```

3. **Display QR code** (for human to scan and fund)

4. **For Preprod:** Use faucet at https://docs.cardano.org/cardano-testnet/tools/faucet

5. **Check balance:**
   ```typescript
   const balance = await cardano_get_wallet_balance({
     agentIdentifier: 'wallet-id',
     network: 'Preprod',
     blockfrostApiKey: 'your-api-key'
   });
   ```

## Credential Storage

Credentials are stored encrypted at:
- `~/.openclaw/credentials/cardano-wallet/`

Files are encrypted with AES-256-GCM and have permissions 600 (owner read/write only).

## Security Notes

- **Never share your mnemonic** - it provides full access to your wallet
- **Backup your mnemonic securely** - use `cardano_backup_wallet` or save manually
- **Use Preprod for testing** - Mainnet uses real ADA
- **Encryption key**: Set `MASUMI_ENCRYPTION_KEY` environment variable for secure encryption

## Dependencies

- `@meshsdk/core`: Wallet operations
- `qrcode`: QR code generation
- `@blockfrost/blockfrost-js`: Balance queries (optional)

## Examples

See `examples/wallet-generation.ts` for complete examples.

Overview

This skill lets OpenClaw agents generate, restore, and manage Cardano wallets, including QR code support for easy funding. It supports Preprod and Mainnet, encrypted credential storage, and balance checks via Blockfrost. The skill is focused on secure wallet lifecycle operations for agent-driven workflows.

How this skill works

The skill exposes functions to create a 24-word mnemonic wallet, restore from a mnemonic, produce a funding QR code, query balances, and produce encrypted backups. Credentials are stored encrypted (AES-256-GCM) under the agent's credentials directory and can be identified by an agentIdentifier. Balance queries use Blockfrost APIs when an API key is provided or set via environment variables.

When to use it

  • Automating wallet creation for agents that need a dedicated Cardano address
  • Provisioning test wallets on Preprod and sharing a QR for manual funding
  • Restoring agent wallets from a known 24-word mnemonic
  • Checking wallet balances programmatically for payout or monitoring logic
  • Creating encrypted backups of wallet credentials before redeployments

Best practices

  • Always use Preprod for testing; avoid Mainnet unless you intend to handle real ADA
  • Never log or share the 24-word mnemonic; treat it as a secret
  • Set MASUMI_ENCRYPTION_KEY in the environment to protect stored credentials
  • Provide Blockfrost API keys via environment variables to avoid embedding secrets
  • Use agentIdentifier to organize and retrieve wallet credentials reliably

Example use cases

  • Generate a new Preprod wallet for an agent, produce a funding QR, and have a human scan the QR to fund it
  • Restore an agent wallet from a 24-word mnemonic and resume on-chain operations
  • Programmatically check an agent's wallet balance before initiating a transaction
  • Create an encrypted backup of wallet credentials before migrating an agent to another host
  • Integrate QR generation into an agent onboarding UI for simple funding flow

FAQ

Do I need a Blockfrost API key to use the skill?

No for wallet generation and QR creation, but yes for balance queries; set keys via BLOCKFROST_* env vars or pass blockfrostApiKey.

Where are credentials stored and how are they protected?

Credentials are stored under ~/.openclaw/credentials/cardano-wallet/, encrypted with AES-256-GCM, and file permissions are set to owner read/write.