Skip to main content

subrail-cli Reference

subrail-cli is a comprehensive command-line interface and tooling suite for interacting with Bitcoin and the Alkanes metaprotocol. It provides wallet management, smart contract deployment, token operations, AMM functionality, and advanced blockchain analysis capabilities.

To get started, clone the repository from: https://github.com/subfrost/subfrost

Features

Wallet Management

  • HD Wallet Support (BIP39)
  • Multi-Network Support (mainnet, testnet, signet, regtest)
  • Encrypted Wallet Storage (GPG or PBKDF2)
  • UTXO Management
  • Transaction Construction
  • Fee Estimation

Alkanes Metaprotocol Integration

  • Smart Contract Deployment (WASM)
  • Token Operations (deploy, mint, transfer)
  • AMM/DEX Functionality
  • Advanced Contract Execution
  • Commit-Reveal Transactions (Envelopes)
  • Transaction Preview and Simulation

Blockchain Analysis Tools

  • Runestone Decoder
  • Transaction Tracing
  • Contract Inspection (WASM disassembly and fuzzing)
  • Balance Queries
  • Block Data Access

Installation

  1. Clone the repository:

    git clone https://github.com/subfrost/subfrost
    cd subfrost
  2. Build the project:

    cargo build --release -p subrail-cli

    The binary will be available at target/release/subrail-cli.

Command Reference

Global Options

  • --provider <PROVIDER>: Network provider (mainnet, signet, localhost, or custom URL)
  • --wallet-file <PATH>: Path to wallet file (supports .asc for GPG or .json for PBKDF2)
  • --passphrase <PASS>: Passphrase for non-interactive encryption
  • --log-level <LEVEL>: Logging level (error, warn, info, debug, trace)

Wallet Commands

# Wallet management
subrail-cli wallet create [--mnemonic <MNEMONIC>]
subrail-cli wallet restore <MNEMONIC>
subrail-cli wallet info
subrail-cli wallet balance [--addresses <ADDRESSES>]
subrail-cli wallet addresses [--count <N>]
subrail-cli wallet sync

# Transaction operations
subrail-cli wallet send <ADDRESS> <AMOUNT> [--fee-rate <RATE>] [--change <ADDRESS>]
subrail-cli wallet send-all <ADDRESS> [--fee-rate <RATE>] [--change <ADDRESS>]
subrail-cli wallet create-tx <ADDRESS> <AMOUNT> [--fee-rate <RATE>] [--change <ADDRESS>]
subrail-cli wallet broadcast-tx <TX_HEX>

# UTXO management
subrail-cli wallet utxos
subrail-cli wallet freeze-utxo <TXID> <VOUT>
subrail-cli wallet unfreeze-utxo <TXID> <VOUT>
subrail-cli wallet history [--limit <N>]

Alkanes Commands

# Token operations
subrail-cli alkanes deploy-token --name <NAME> --symbol <SYMBOL> --cap <CAP> --amount-per-mint <AMOUNT> --reserve-number <NUM>
subrail-cli alkanes send-token --token <ID> --amount <AMOUNT> --to <ADDRESS> [--change <ADDRESS>]
subrail-cli alkanes balance [--address <ADDRESS>]
subrail-cli alkanes token-info <TOKEN_ID>

# Smart contract operations
subrail-cli alkanes deploy-contract <WASM_FILE> --calldata <DATA>
subrail-cli alkanes execute --calldata <DATA> [--edicts <EDICTS>]

# AMM operations
subrail-cli alkanes create-pool --calldata <DATA> --tokens <TOKENS>
subrail-cli alkanes add-liquidity --calldata <DATA> --tokens <TOKENS>
subrail-cli alkanes remove-liquidity --calldata <DATA> --token <TOKEN> --amount <AMOUNT>
subrail-cli alkanes swap --calldata <DATA> --token <TOKEN> --amount <AMOUNT>

# Analysis and simulation
subrail-cli alkanes simulate-advanced --target <CONTRACT> --inputs <INPUTS> [--tokens <TOKENS>]
subrail-cli alkanes preview-remove-liquidity --token <TOKEN> --amount <AMOUNT>
subrail-cli alkanes inspect <ALKANE_ID> [--disasm] [--fuzz] [--meta] [--codehash]

Blockchain Query Commands

# RPC operations
subrail-cli metashrew height
subrail-cli bitcoind getblockcount
subrail-cli bitcoind generatetoaddress --nblocks <N> --address <ADDRESS>

# Blockchain data
subrail-cli view getbytecode <CONTRACT_ID>
subrail-cli view getblock <HEIGHT>
subrail-cli view protorunesbyaddress <ADDRESS>
subrail-cli view spendablesbyaddress <ADDRESS>
subrail-cli view trace <TXID:VOUT>

# Transaction analysis
subrail-cli runestone <TXID_OR_HEX> [--raw] [--preview]
subrail-cli inspect-alkane <ALKANE_ID> [--disasm] [--fuzz] [--meta] [--codehash]

Wallet Security

  • Always backup your mnemonic phrase securely
  • Use strong passphrases for wallet encryption
  • Store wallet files in secure locations
  • Regularly backup wallet files
  • Test wallet restoration before relying on backups