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.zipInstalls 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.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
bashand Node.js 18+. - Requires
BLINK_API_KEYenvironment 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
- Create a free account at dashboard.blink.sv.
- Go to API Keys and create a key with the scopes you need.
- 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:
process.env.BLINK_API_KEY(checked first)- Shell rc files:
~/.profile,~/.bashrc,~/.bash_profile,~/.zshrc— scanned for anexport 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 linkmodifies global npm state. This is optional — all functionality is available by running scripts directly withnode {baseDir}/scripts/<script>.js. The ClawHub-installed version does not require or usenpm link.
Agent Safety Policy
These rules are mandatory for any AI agent using this skill:
- Ask before spending. Never execute
pay-invoice,pay-lnaddress,pay-lnurl, orswap-executewithout explicit user confirmation of the amount and recipient. - Dry-run first. For swaps, always run with
--dry-runbefore executing for real unless the user explicitly says to skip it. - Check balance before sending. Always run
balancebefore any payment or swap to verify sufficient funds. - Probe fees before paying. Run
fee-probebeforepay-invoiceto show the user the fee cost. - Use minimum scopes. Only request Write-scoped API keys when send operations are actually needed.
- Never log or display the API key. Treat
BLINK_API_KEYas a secret. Do not echo it, include it in messages, or write it to files. - Prefer staging for testing. When the user is testing or learning, suggest setting
BLINK_API_URLto the staging endpoint. - 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 thebtcBalanceUsdfield frombalanceoutput instead. - For swap amounts, the
--unitflag controls interpretation:satsfor BTC,centsfor USD.
Workflow
- 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).
- Configure API access from blink-api-and-auth:
- Set
BLINK_API_KEYwith the correct scopes for your operation. - Optionally set
BLINK_API_URLfor staging/testnet. - Verify connectivity with
blink balance.
- For sending payments, follow payment-operations:
- Check balance before sending.
- Probe fees with
blink fee-probe. - Choose BTC or USD wallet with
--walletflag. - Execute payment and verify in transaction history.
- 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.
- 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-runfirst). - Verify settlement from
postBalance/balanceDelta.
- 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:
- Immediately —
{"event": "invoice_created", ...}withpaymentRequest,paymentHash, etc. - 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 exitmemo...— 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 exitmemo...— 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 fromcreate-invoiceoutput (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.