A minimal escrow bot for Telegram that accepts BTC to a generated deposit address and releases to the seller when the buyer issues a release command.
- Generates a unique P2WPKH deposit address per escrow (BIP84)
- Tracks confirmed deposits via Esplora (mempool.space by default)
- Buyer-only release command sweeps all confirmed UTXOs to the seller
- Testnet by default; supports mainnet with
NETWORK=mainnet
- Create a bot via BotFather and copy the token.
- Copy the environment variables to a local
.envfile and fill in values:
# .env
TELEGRAM_BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
NETWORK=testnet
# ESPLORA_URL=https://mempool.space/testnet/api
# FEE_RATE_SATVBYTE=10
MIN_CONFIRMATIONS=1
MONITOR_INTERVAL_MS=30000
# SEED_MNEMONIC="... 24 words ..."- Install dependencies and start the bot:
npm install
npm startOn first start the bot creates a BIP39 mnemonic and stores it under data/ using node-persist. To migrate to another machine, copy the data/ folder or set SEED_MNEMONIC in .env.
/newescrow <seller_btc_address>: Creates a new escrow and returns the deposit address./status <escrow_id>: Shows status and confirmed funded amount (sats)./release <escrow_id>: Buyer releases funds to seller. Broadcasts a sweep transaction.
- Confirmations: Esplora
confirmedimplies ≥ 1 confirmation. You can adjust polling viaMONITOR_INTERVAL_MS. - Fees: Uses Esplora recommended fees, or override with
FEE_RATE_SATVBYTE. - Network: Test with
NETWORK=testnet. For mainnet, setNETWORK=mainnet. - Security: This is a minimal demo. For production, add authentication, admin controls, multi-sig, dispute flow, and robust error handling.
MIT