A modular framework for creating Bitcoin transactions with OP_RETURN outputs for BRC-20 operations, specifically designed for the test_opi operation.
# Install dependencies
npm install
# Copy and configure environment
cp .env.example .env
# Edit .env with your Bitcoin RPC settings and keys🎯 Main command:
npm run interactiveThis command launches the interactive mode that guides you through all available test scenarios.
# Interactive mode (recommended)
npm run interactive
# Test Bitcoin connection
npm run start test-connection
# Execute a specific scenario
npm run start execute single-op-return
npm run start execute two-outputs --tick test_opi --amount 10
npm run start execute external-address --external-address bc1q... --value 1000
# Dry-run mode (without broadcast)
npm run start execute single-op-return --dry-run
# Display configuration
npm run start configCreate a .env file with:
# Bitcoin RPC Configuration
BITCOIN_RPC_USER=your_rpc_user
BITCOIN_RPC_PASSWORD=your_rpc_password
BITCOIN_RPC_HOST=127.0.0.1
BITCOIN_RPC_PORT=8332
# Test OPI Configuration
WIF_OPI_TEST=your_wif_private_key
ADDRESS_OPI_TEST=your_test_funded_address
PUBKEY_OPI_TEST=your_public_key_hex
# Network Configuration
BITCOIN_NETWORK=testnet
FEE_RATE=10- Single OP_RETURN : Transaction with only an OP_RETURN output
- Two Outputs : OP_RETURN + 1200 sats to test address
- External Address : OP_RETURN + amount to external address
- Three Outputs : OP_RETURN in position 0 + 2 other outputs
# Interactive mode (recommended)
npm run interactive
# Individual scenarios
npm run scenario:1 # Single OP_RETURN
npm run scenario:2 # Two Outputs
npm run scenario:3 # External Address
npm run scenario:4 # Three Outputs
# Tests
npm run test # All tests
npm run test:unit # Unit tests
npm run test:integration # Integration tests
# Examples
npm run example:basic # Basic example
npm run example:advanced # Advanced example- Modular architecture : Easily extensible
- 4 predefined test scenarios
- Intuitive CLI interface with interactive mode
- Bitcoin RPC support for finalization and broadcast
- Smart UTXO management
- Multi-network support (mainnet, testnet, regtest)
- P2TR (Taproot) support with .equals error fixes
- Complete logging with Winston
- BRC-20 validation compliant with standards
The project generates OP_RETURN messages in BRC-20 format:
{
"p": "brc-20",
"op": "test_opi",
"tick": "test_opi",
"amt": "10"
}- Private keys are never logged
- Strict Bitcoin address validation
- Robust error handling
- Support for different address types (P2PKH, P2WPKH, P2TR)
For any questions or issues:
- Check logs in
logs/test_opi.log - Validate your configuration with
npm run start validate-config - Test Bitcoin connection with
npm run start test-connection - Consult the complete documentation in
docs/README.md
MIT License - see the LICENSE file for more details.
💡 Tip: Always start with npm run interactive for a guided experience!