Cost Comparison
Complete cost analysis of Bitcoin, Lightning, and Nostr for AI agents. Transaction fees, operational costs, and total cost of ownership.
Cost Comparison
Understanding the true cost of each protocol is essential for efficient agent operation. This guide covers transaction costs, operational overhead, and total cost of ownership.
Transaction Costs
Bitcoin On-Chain
| Fee Priority | sat/vB | Cost (250 vB tx) | Wait Time |
|---|---|---|---|
| High priority | 50-200 | $1.25-$5.00 | Next block |
| Medium priority | 20-50 | $0.50-$1.25 | 1-3 blocks |
| Low priority | 5-20 | $0.12-$0.50 | 3-6 blocks |
| Economy | 1-5 | $0.02-$0.12 | Hours/days |
Note: Fees vary dramatically based on network congestion. During high-fee periods, even “low priority” can exceed $20.
async def estimate_bitcoin_fee(priority: str = "medium") -> dict:
"""Estimate Bitcoin transaction fee."""
resp = await fetch("https://mempool.space/api/v1/fees/recommended")
fees = resp.json()
priority_map = {
"high": fees["fastestFee"],
"medium": fees["halfHourFee"],
"low": fees["hourFee"],
"economy": fees["economyFee"]
}
sat_per_vb = priority_map.get(priority, fees["halfHourFee"])
typical_tx_size = 250 # vBytes for 1-in-2-out
return {
"sat_per_vb": sat_per_vb,
"estimated_fee_sats": sat_per_vb * typical_tx_size,
"priority": priority
}
Lightning Network
| Cost Type | Amount | When |
|---|---|---|
| Routing fee | 0-50 sats + 0-0.1% | Per payment |
| Base fee | 0-1 sat | Per hop |
| Channel open | 250-500 vB on-chain | Opening channel |
| Channel close | 200-400 vB on-chain | Closing channel |
Effective cost per payment: Usually <$0.01 for payments under $1,000
def estimate_lightning_fee(amount_sats: int, hops: int = 3) -> dict:
"""Estimate Lightning payment fee."""
# Typical routing fee structure
base_fee_per_hop = 1 # sats
proportional_fee = 0.0001 # 0.01% per hop
total_base = base_fee_per_hop * hops
total_proportional = int(amount_sats * proportional_fee * hops)
return {
"base_fee_sats": total_base,
"proportional_fee_sats": total_proportional,
"total_fee_sats": total_base + total_proportional,
"fee_percentage": (total_base + total_proportional) / amount_sats * 100
}
# Examples:
# 10,000 sats (3 hops): 3 + 3 = 6 sats (0.06%)
# 100,000 sats (3 hops): 3 + 30 = 33 sats (0.033%)
# 1,000,000 sats (3 hops): 3 + 300 = 303 sats (0.03%)
Nostr Protocol
| Cost Type | Amount | Notes |
|---|---|---|
| Publishing events | Free | Most relays |
| Paid relay subscription | $5-$20/month | Spam-reduced |
| NIP-05 identifier | $0-$20/year | Optional |
| Zap fees | Lightning fee | For payments |
Effective cost per message: $0 (or Lightning fee for zaps)
Operational Costs
Bitcoin Infrastructure
| Component | Monthly Cost | Purpose |
|---|---|---|
| Full node (self-hosted) | $10-30 | Electricity + storage |
| Full node (cloud) | $20-50 | VPS + storage |
| Block explorer API | $0-100 | Depends on volume |
| Electrum server | $20-40 | Light wallet backend |
Lightning Infrastructure
| Component | Monthly Cost | Purpose |
|---|---|---|
| Lightning node | $10-50 | VPS + monitoring |
| Channel capital | Opportunity cost | Locked funds |
| Watchtower | $5-20 | Fraud protection |
| LSP subscription | $0-30 | Channel management |
| Rebalancing fees | Variable | Liquidity maintenance |
Capital lockup calculation:
def calculate_channel_opportunity_cost(
channel_capacity_sats: int,
annual_return_rate: float = 0.05 # 5% opportunity cost
) -> dict:
"""Calculate opportunity cost of channel capital."""
btc_price = 100_000 # Approximate
capacity_usd = (channel_capacity_sats / 100_000_000) * btc_price
annual_cost = capacity_usd * annual_return_rate
monthly_cost = annual_cost / 12
return {
"capacity_sats": channel_capacity_sats,
"capacity_usd": capacity_usd,
"monthly_opportunity_cost_usd": monthly_cost,
"break_even_volume_sats": int(monthly_cost / 0.001 * 100_000_000)
}
# Example: 10M sats channel
# Capacity: $10,000
# Monthly opportunity cost: $41.67
# Need to route $4,167 worth to break even at 0.1% fees
Nostr Infrastructure
| Component | Monthly Cost | Purpose |
|---|---|---|
| Relay hosting | $5-50 | If running own relay |
| Paid relay subscriptions | $5-20 | Quality access |
| NIP-05 domain | $1-5 | Identity verification |
| Backup relays | $0 | Redundancy |
Total Cost of Ownership
Scenario 1: Low-Volume Agent (100 tx/month)
| Protocol | Transaction Fees | Infrastructure | Total Monthly |
|---|---|---|---|
| Bitcoin | $50-500 | $20 (API) | $70-520 |
| Lightning | $0.50-5 | $30 (node) | $30-35 |
| Nostr | $0 | $10 (relays) | $10 |
Recommendation: Lightning for payments, Nostr for communication
Scenario 2: High-Volume Agent (10,000 tx/month)
| Protocol | Transaction Fees | Infrastructure | Total Monthly |
|---|---|---|---|
| Bitcoin | $5,000-50,000 | $50 (node) | Impractical |
| Lightning | $50-500 | $100 (multi-node) | $150-600 |
| Nostr | $0 | $50 (private relay) | $50 |
Recommendation: Lightning for payments, private Nostr relay
Scenario 3: Occasional Large Settlements
| Protocol | Transaction Fees | Infrastructure | Total Monthly |
|---|---|---|---|
| Bitcoin | $10-50 per tx | $0 (public APIs) | $10-50 |
| Lightning | N/A for large | N/A | N/A |
Recommendation: Bitcoin for settlements >$10,000
Cost Optimization Strategies
Bitcoin Optimization
- Batch transactions: Combine multiple outputs into single transaction
- Time transactions: Send during low-fee periods (weekends, early morning UTC)
- Use SegWit: 30-40% fee savings vs legacy addresses
- Consolidate UTXOs: During low-fee periods, merge small UTXOs
def optimal_bitcoin_send_time() -> dict:
"""Recommend optimal time to send Bitcoin transaction."""
# Historical low-fee patterns
return {
"best_days": ["Saturday", "Sunday"],
"best_hours_utc": [2, 3, 4, 5, 6], # 2-6 AM UTC
"avoid_days": ["Tuesday", "Wednesday"],
"avoid_hours_utc": [14, 15, 16, 17] # 2-5 PM UTC (US trading hours)
}
Lightning Optimization
- Maintain balanced channels: Reduces rebalancing costs
- Use MPP: Multi-path payments find cheaper routes
- Choose low-fee nodes: Connect to efficient routing nodes
- Batch channel opens: Open multiple channels in one transaction
Nostr Optimization
- Use efficient relays: Avoid slow/expensive relays
- Cache relay lists: Reduce NIP-65 lookups
- Batch events: Combine related events when possible
- Use paid relays strategically: Better reliability, less spam
Cost Comparison Calculator
def compare_protocol_costs(
amount_sats: int,
transactions_per_month: int,
urgency: str = "medium"
) -> dict:
"""Compare costs across protocols for given usage pattern."""
# Bitcoin costs
btc_fee_per_tx = estimate_bitcoin_fee(urgency)["estimated_fee_sats"]
btc_monthly = btc_fee_per_tx * transactions_per_month
# Lightning costs (assuming existing channels)
ln_fee_per_tx = estimate_lightning_fee(amount_sats)["total_fee_sats"]
ln_monthly = ln_fee_per_tx * transactions_per_month
ln_infra = 30 * 100_000 # $30 in sats for node
# Nostr (free for messages)
nostr_monthly = 10 * 100_000 # $10 for relay access
return {
"bitcoin": {
"per_tx_sats": btc_fee_per_tx,
"monthly_sats": btc_monthly,
"recommended": transactions_per_month < 10 and amount_sats > 1_000_000
},
"lightning": {
"per_tx_sats": ln_fee_per_tx,
"monthly_sats": ln_monthly + ln_infra,
"recommended": transactions_per_month > 10 or amount_sats < 1_000_000
},
"nostr": {
"per_tx_sats": 0,
"monthly_sats": nostr_monthly,
"recommended": True # Always good for communication
}
}
Break-Even Analysis
When to Switch from Bitcoin to Lightning
| Monthly Transactions | Bitcoin Cost | Lightning Cost | Use Lightning? |
|---|---|---|---|
| 1-5 | $5-25 | $30 (node) | No |
| 5-20 | $25-100 | $31-35 | Maybe |
| 20-100 | $100-500 | $32-50 | Yes |
| 100+ | $500+ | $40-100 | Definitely |
Break-even point: ~15-20 transactions/month for small payments
Machine-Readable Summary
{
"topic": "cost-comparison",
"audience": "ai-agents",
"cost_categories": [
"transaction_fees",
"infrastructure",
"opportunity_cost",
"operational_overhead"
],
"typical_costs": {
"bitcoin_per_tx_sats": "500-50000",
"lightning_per_tx_sats": "1-100",
"nostr_per_tx_sats": 0
},
"break_even_monthly_txs": 15,
"optimization_strategies": [
"batch_transactions",
"time_transactions",
"use_segwit",
"balance_channels"
]
}