CLI tool that replicates the Simplicity Web IDE functionality for deploying contracts with witness data.
Based on: https://github.com/BlockstreamResearch/simplicity-webide
This tool provides command-line access to:
- Generate P2TR addresses for Simplicity contracts
- Compute correct sighash for transactions
- Build complete transactions with witness data
- Deploy contracts to Liquid testnet
Default Constants
- Internal Key:
0xf5919fa64ce45f8306849072b26c1bfdd2937e6b81774796ff372bd1eb5362d2(same as Web IDE, can be overridden withSIMPLICITY_INTERNAL_KEYenv var) - Genesis Hash:
a771da8e52ee6ad581ed1e9a99825e5b3b7992225534eaa2ae23244fe26ab1c1(Liquid testnet, can be overridden with-g)
cargo install --path .Or install directly from GitHub:
cargo install --git https://github.com/iajhff/simplicitytxtoolsimplicity_tx_tool address <contract.simf>Output:
- P2TR address for the contract
- CMR (Commitment Merkle Root)
Example:
simplicity_tx_tool address p2pk_embedded.simfsimplicity_tx_tool sighash <contract.simf> <txid> <vout> <value> <destination> <fee> [-g <genesis_hash>]Arguments:
contract.simf: SimplicityHL contract filetxid: Funding transaction IDvout: Output index (usually 0)value: Input value in satoshisdestination: Destination address (tex1...)fee: Fee in satoshis-g <genesis_hash>: (Optional) Genesis hash in hex. Default: Liquid testnet
Output: 32-byte hex sighash
Examples:
# Use default Liquid testnet genesis hash
simplicity_tx_tool sighash p2pk_embedded.simf cbb3ac22... 0 100000 tex1q... 1000
# Override with Bitcoin mainnet genesis hash
simplicity_tx_tool sighash p2pk_embedded.simf cbb3ac22... 0 100000 bc1q... 1000 \
-g 6fe28c0ab6f1b372c1a6a246ae63f74f931e83651e085ae689cd6190000000000simplicity_tx_tool sign <privkey_wif> <sighash>Arguments:
privkey_wif: Private key in WIF format (from elements-cli dumpprivkey)sighash: 32-byte hex sighash (from sighash command)
Output: 64-byte hex BIP-340 Schnorr signature
Example:
simplicity_tx_tool sign cSJofGp2qowy... 2f6b093e917fb945...simplicity_tx_tool build-tx <contract.simf> <txid> <vout> <value> <destination> <fee> <witness.wit> [-g <genesis_hash>]Arguments:
- Same as sighash command, plus:
witness.wit: Witness file with signatures-g <genesis_hash>: (Optional) Genesis hash in hex. Default: Liquid testnet
Output: Complete transaction hex ready to broadcast
Examples:
# Use default Liquid testnet genesis hash
simplicity_tx_tool build-tx p2pk_embedded.simf cbb3ac22... 0 100000 tex1q... 1000 witness.wit
# Override with custom genesis hash
simplicity_tx_tool build-tx p2pk_embedded.simf cbb3ac22... 0 100000 bc1q... 1000 witness.wit \
-g 6fe28c0ab6f1b372c1a6a246ae63f74f931e83651e085ae689cd6190000000000simplicity_tx_tool address contract.simfCopy the P2TR address.
Go to https://liquidtestnet.com/faucet and send funds to your address.
simplicity_tx_tool sighash contract.simf <txid> <vout> <value> <destination> <fee>Copy the sighash output.
simplicity_tx_tool sign <privkey_wif> <sighash>Copy the signature.
cat > witness.wit << 'EOF'
{
"YOUR_WITNESS_NAME": {
"value": "0xYOUR_SIGNATURE",
"type": "Signature"
}
}
EOFsimplicity_tx_tool build-tx contract.simf <txid> <vout> <value> <destination> <fee> witness.witCopy the transaction hex.
curl -X POST "https://blockstream.info/liquidtestnet/api/tx" -d "<tx_hex>"Or use elements-cli:
elements-cli -chain=liquidtestnet sendrawtransaction <tx_hex>Override the default internal key using the SIMPLICITY_INTERNAL_KEY environment variable:
# Use BIP-341 standard NUMS point (compatible with 'simply' tool)
export SIMPLICITY_INTERNAL_KEY=50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0
simplicity_tx_tool address contract.simf
# Custom NUMS point (for privacy or testing)
export SIMPLICITY_INTERNAL_KEY=<your_32_byte_nums_point_hex>
simplicity_tx_tool address contract.simfThe -g flag allows you to specify which blockchain network to target:
Liquid testnet (default):
a771da8e52ee6ad581ed1e9a99825e5b3b7992225534eaa2ae23244fe26ab1c1
Liquid mainnet:
1466275836220db2944ca059a3a10ef6fd2ea684b0688d2c3792968888a206003
Bitcoin mainnet:
6fe28c0ab6f1b372c1a6a246ae63f74f931e83651e085ae689cd6190000000000
Why it matters: The genesis hash is included in the sighash computation, making signatures network-specific. A signature created for Liquid testnet will not be valid on Bitcoin mainnet or Liquid mainnet, and vice versa. This prevents replay attacks across different networks.
This tool uses the same libraries as the Simplicity Web IDE:
- simfony: SimplicityHL compiler
- simplicity-lang: Rust Simplicity implementation
- elements: Elements/Liquid transaction handling
It replicates the Web IDE's transaction building logic exactly:
- Compiles SimplicityHL to Simplicity bytecode
- Computes CMR (Commitment Merkle Root)
- Creates transaction environment with real transaction data
- Computes sighash using
ElementsEnv::c_tx_env().sighash_all()with genesis hash - Builds complete transaction with witness data
- Rust toolchain
- SimplicityHL contracts (.simf files)
- Witness data (.wit files) with valid signatures
- elements-cli for key management and destination addresses
- curl for broadcasting (or elements-cli)
- CLI-based: No browser required
- Same logic: Uses identical transaction building code
- Built-in signing: BIP-340 Schnorr signing included (same as Web IDE)
- Same output: Generates identical transactions
GPLv2
Based on the Simplicity Web IDE by Blockstream Research: https://github.com/BlockstreamResearch/simplicity-webide