agentskills.codes

Bitcoin Lightning wallet for agents — balances, invoices, payments, BTC/USD swaps, QR codes, price conversion, and transaction history via the Blink API. All output is JSON.

Install

mkdir -p .claude/skills/blink && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15062" && unzip -o skill.zip -d .claude/skills/blink && rm skill.zip

Installs to .claude/skills/blink

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Bitcoin Lightning wallet for agents — balances, invoices, payments, BTC/USD swaps, QR codes, price conversion, and transaction history via the Blink API. All output is JSON.
173 charsno explicit “when” trigger

About this skill

Blink Skill

Bitcoin Lightning wallet operations via the Blink API. Enables agents to check balances, receive payments via invoices, send payments over Lightning, track transactions, and monitor prices.

What is Blink?

Blink is a custodial Bitcoin Lightning wallet with a GraphQL API. Key concepts:

  • API Key — authentication token (format: blink_...) with scoped permissions (Read, Receive, Write)
  • BTC Wallet — balance denominated in satoshis
  • USD Wallet — balance denominated in cents (stablecoin pegged to USD)
  • Lightning Invoice — BOLT-11 payment request string (lnbc...) used to receive payments
  • Lightning Address — human-readable address (user@domain) for sending payments without an invoice
  • LNURL — protocol for interacting with Lightning services via encoded URLs

Environment

  • Requires bash and Node.js 18+.
  • Requires BLINK_API_KEY environment variable with appropriate scopes.
  • For WebSocket subscriptions: Node 22+ (native) or Node 20+ with --experimental-websocket.
  • Zero runtime npm dependencies. Only Node.js built-in modules are used (node:util, node:fs, node:path, node:child_process).

Use this skill for concrete wallet operations, not generic Lightning theory.

Getting Started

1. Get your API key

  1. Create a free account at dashboard.blink.sv.
  2. Go to API Keys and create a key with the scopes you need.
  3. Set it in your environment:
export BLINK_API_KEY="blink_..."

API Key Scopes:

  • Read — query balances, transaction history, price, account info
  • Receive — create invoices
  • Write — send payments (use with caution)

Tip: Start with Read + Receive only. Add Write when you need to send payments.

2. Verify it works

node {baseDir}/scripts/balance.js

If you see JSON with your wallet balances, you're ready.

3. Staging / Testnet (recommended for first-time setup)

To use the Blink staging environment (signet) instead of real money:

export BLINK_API_URL="https://api.staging.blink.sv/graphql"

Create a staging API key at dashboard.staging.blink.sv. The staging environment uses signet bitcoin (no real value) — perfect for testing payment flows safely.

If BLINK_API_URL is not set, production (https://api.blink.sv/graphql) is used by default.

API key auto-detection

Scripts automatically resolve BLINK_API_KEY using this order:

  1. process.env.BLINK_API_KEY (checked first)
  2. Shell rc files: ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.zshrc — scanned for an export BLINK_API_KEY=... line only

No source ~/.profile prefix is needed. The rc file scan uses a targeted regex that reads only the BLINK_API_KEY export line — no other data is extracted from these files.

Optional: CLI wrapper (full GitHub repo only)

If you have cloned the full GitHub repo, you can optionally install a blink CLI command:

npm install   # install dev dependencies (eslint, prettier)
npm link      # creates global 'blink' command
blink --help  # verify

Note: npm link modifies global npm state. This is optional — all functionality is available by running scripts directly with node {baseDir}/scripts/<script>.js. The ClawHub-installed version does not require or use npm link.

Agent Safety Policy

These rules are mandatory for any AI agent using this skill:

  1. Ask before spending. Never execute pay-invoice, pay-lnaddress, pay-lnurl, or swap-execute without explicit user confirmation of the amount and recipient.
  2. Dry-run first. For swaps, always run with --dry-run before executing for real unless the user explicitly says to skip it.
  3. Check balance before sending. Always run balance before any payment or swap to verify sufficient funds.
  4. Probe fees before paying. Run fee-probe before pay-invoice to show the user the fee cost.
  5. Use minimum scopes. Only request Write-scoped API keys when send operations are actually needed.
  6. Never log or display the API key. Treat BLINK_API_KEY as a secret. Do not echo it, include it in messages, or write it to files.
  7. Prefer staging for testing. When the user is testing or learning, suggest setting BLINK_API_URL to the staging endpoint.
  8. Respect irreversibility. Warn the user that Lightning payments and swaps cannot be reversed once executed.

Bitcoin Units

  • BTC wallet amounts are always in satoshis (sats). 1 BTC = 100,000,000 sats.
  • USD wallet amounts are always in cents. $1.00 = 100 cents.
  • When displaying amounts to users, use the formatted fields from output JSON (e.g. btcBalanceUsdFormatted, usdBalanceFormatted).
  • Do not perform manual BTC-to-USD conversion math — use blink price <sats> or the btcBalanceUsd field from balance output instead.
  • For swap amounts, the --unit flag controls interpretation: sats for BTC, cents for USD.

Workflow

  1. Pick the operation path first:
  • Receive payments (invoice creation, QR codes, payment monitoring).
  • Send payments (invoice pay, Lightning Address, LNURL, BTC or USD wallet).
  • Swap between wallets (BTC <-> USD internal conversion).
  • Read-only queries (balance, transactions, price, account info).
  1. Configure API access from blink-api-and-auth:
  • Set BLINK_API_KEY with the correct scopes for your operation.
  • Optionally set BLINK_API_URL for staging/testnet.
  • Verify connectivity with blink balance.
  1. For sending payments, follow payment-operations:
  • Check balance before sending.
  • Probe fees with blink fee-probe.
  • Choose BTC or USD wallet with --wallet flag.
  • Execute payment and verify in transaction history.
  1. For receiving payments, follow invoice-lifecycle:
  • Create BTC or USD invoice.
  • Parse two-phase output (invoice created, then payment resolution).
  • Generate QR code and send to payer.
  • Monitor via auto-subscribe, polling, or standalone subscription.
  1. For swapping between wallets, follow swap-operations:
  • Quote first with blink swap-quote.
  • Review quote terms (amountIn/amountOut, exchange rate).
  • Execute with blink swap-execute (use --dry-run first).
  • Verify settlement from postBalance/balanceDelta.
  1. Apply safety constraints:
  • Use minimum API key scopes for the task.
  • Test on staging before production.
  • Always check balance before sending.
  • Payments are irreversible once settled.

Quick Commands

# Check balances
blink balance

# Create BTC invoice (auto-subscribes to payment)
blink create-invoice 1000 "Payment for service"

# Pay a Lightning invoice
blink pay-invoice lnbc1000n1...

# Pay from USD wallet
blink pay-invoice lnbc1000n1... --wallet USD

# Get current BTC/USD price
blink price

# Swap 1000 sats to USD
blink swap-execute btc-to-usd 1000

# Get swap quote without executing
blink swap-quote usd-to-btc 500 --unit cents

Core Commands

Check Wallet Balances

blink balance

Returns JSON with all wallet balances (BTC in sats, USD in cents), wallet IDs, pending incoming amounts, and a pre-computed USD estimate for the BTC wallet. Use btcBalanceUsd for the BTC wallet's USD value — do not calculate it yourself.

Create Lightning Invoice (BTC)

blink create-invoice <amount_sats> [--timeout <seconds>] [--no-subscribe] [memo...]

Generates a BOLT-11 Lightning invoice for the specified amount in satoshis. Returns the paymentRequest string that can be paid by any Lightning wallet. The BTC wallet ID is resolved automatically.

Auto-subscribe: After creating the invoice, the script automatically opens a WebSocket subscription and waits for payment. It outputs two JSON objects to stdout:

  1. Immediately{"event": "invoice_created", ...} with paymentRequest, paymentHash, etc.
  2. When resolved{"event": "subscription_result", "status": "PAID"|"EXPIRED"|"TIMEOUT", ...}

The agent should read the first JSON to share the invoice/QR with the user right away, then wait for the second JSON to confirm payment.

  • amount_sats — amount in satoshis (required)
  • --timeout <seconds> — subscription timeout (default: 300). Use 0 for no timeout.
  • --no-subscribe — skip WebSocket auto-subscribe, just create the invoice and exit
  • memo... — optional description attached to the invoice (remaining args joined)

Create Lightning Invoice (USD)

blink create-invoice-usd <amount_cents> [--timeout <seconds>] [--no-subscribe] [memo...]

Creates a Lightning invoice denominated in USD cents. The sender pays in BTC/Lightning, but the received amount is locked to a USD value at the current exchange rate. Credited to the USD wallet. Expires in ~5 minutes due to exchange rate lock.

Auto-subscribe: Same two-phase output as create-invoice — first JSON is the created invoice, second JSON is the payment resolution (PAID/EXPIRED/TIMEOUT).

  • amount_cents — amount in USD cents, e.g. 100 = $1.00 (required)
  • --timeout <seconds> — subscription timeout (default: 300). Use 0 for no timeout.
  • --no-subscribe — skip WebSocket auto-subscribe, just create the invoice and exit
  • memo... — optional description attached to the invoice (remaining args joined)

Check Invoice Status

blink check-invoice <payment_hash>

Checks the payment status of a Lightning invoice by its payment hash. Use after creating an invoice to detect when it has been paid. Returns status: PAID, PENDING, or EXPIRED.

  • payment_hash — the 64-char hex payment hash from create-invoice output (required)

Pay Lightning Invoice

blink pay-invoice <bolt11_invoice> [--wallet BTC|USD]

Pays a BOLT-11 Lightning invoice from the BTC or USD wallet. Returns payment status: SUCCESS, PENDING


Content truncated.

Search skills

Search the agent skills registry