Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Bitcoin plugin with Taproot and Ark #1553

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

tiero
Copy link

@tiero tiero commented Dec 29, 2024

🤖 Bitcoin for AI Agents

This PR enables Eliza agents to handle Bitcoin transactions autonomously through @arklabs/wallet-sdk integration. Agents can now receive payments for services, pay other agents, and manage their Bitcoin wallets with both on-chain and Layer 2 (Ark protocol) support.

🚨 WARNING

Caution: Until an external audit is completed, it is strongly recommended not to use this integration on the main Bitcoin network with more than a negligible amount of BTC.

🔑 Configuration

The plugin requires the following environment variables:

# Required
BITCOIN_PRIVATE_KEY=           # Your Bitcoin private key in WIF format
BITCOIN_NETWORK=              # Network type: bitcoin, testnet, regtest, signet, or mutinynet

# Optional - for Ark L2 support
ARK_SERVER_URL=              # Ark protocol server URL
ARK_SERVER_PUBLIC_KEY=       # Ark server public key for L2 operations

🚀 Available Actions

  1. SHOW_BITCOIN_ADDRESSES
// Get both on-chain and off-chain addresses
const addresses = await runtime.triggerAction("SHOW_BITCOIN_ADDRESSES");
// Returns: { onchain: "bc1...", offchain: "ark1..." }
  1. BALANCE
// Check wallet balance with USD conversion
const balance = await runtime.triggerAction("BALANCE");
// Returns formatted balance with on-chain/off-chain breakdown and USD values
  1. COINS
// List available UTXOs (both on-chain and virtual)
const coins = await runtime.triggerAction("COINS");
// Returns detailed UTXO information
  1. SEND_BITCOIN
// Send Bitcoin with various denomination options
await runtime.triggerAction("SEND_BITCOIN", {
  recipient: "bc1...",
  amount: "0.001",           // BTC amount
  amountUSD: "100",         // USD amount (alternative)
  amountSats: "100000"      // Satoshi amount (alternative)
});

🔍 Key Benefits for Agents

  1. Autonomous Financial Operations

    • Agents can receive payments for API calls, content generation, or other services
    • Automated payment processing for inter-agent service exchanges
    • Self-managed wallet with balance monitoring
  2. Flexible Payment Options

    • Support for both on-chain and Layer 2 transactions
    • USD-denominated transactions with automatic conversion
    • Real-time price awareness for fee estimation
  3. Enhanced Security

    • Private key management through environment variables
    • Support for Taproot addresses (P2TR)
    • Optional Layer 2 integration for lower fees and faster transactions

📋 Implementation Status

  • Core Bitcoin functionality
  • Ark protocol L2 integration
  • USD denomination support
  • BIP21 URI support
  • Silent Payments support (coming soon)
  • External security audit
  • Complete documentation

🧪 Testing

cd packages/plugin-bitcoin
pnpm test

📚 Example Usage

Here's how to integrate the Bitcoin plugin into your agent:

import { bitcoinPlugin } from "@elizaos/plugin-bitcoin";

const character = {
  // ... other character config
  plugins: [bitcoinPlugin],
};

Basic Transaction Flow

// 1. Check balance
const balance = await runtime.triggerAction("balance");
console.log("Current balance:", balance);

// 2. List available UTXOs
const coins = await runtime.triggerAction("coins");
console.log("Available coins:", coins);

// 3. Send payment
await runtime.triggerAction("SEND_BITCOIN", {
  recipient: "bc1...",
  amountUSD: "50", // Send $50 worth of BTC
});

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tiero! Welcome to the ai16z community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now a ai16z contributor!

@odilitime odilitime changed the base branch from main to develop December 29, 2024 19:43
@odilitime odilitime added the Plugin_new Mark PRs that are a new plugin label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plugin_new Mark PRs that are a new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants