CLI Tools (opnet-cli)
opnet-cli is the unified command-line interface for OPP_NET. It handles wallet management, contract deployment, interaction, PoW mining, and chain queries.
Installation
# Build from source
git clone https://github.com/opnet-protocol/opshrew.git
cd opshrew
cargo build --release -p opnet-cli
# Binary at target/release/opnet-cli
# With GPU mining support
cargo build --release -p opnet-cli --features gpuGlobal Options
| Flag | Description | Default |
|---|---|---|
-p, --network | Network: regtest, testnet, testnet4, mainnet | testnet |
--jsonrpc-url | Override RPC endpoint | Auto per network |
--wallet-file | HD wallet keystore path | ~/.alkanes/opnet.json |
--passphrase | Keystore passphrase | Prompts if omitted |
Wallet Management
# Create a new HD wallet
opnet-cli wallet create -p testnet4
# Show wallet info (address, pubkey)
opnet-cli wallet info -p testnet4 --passphrase "mypass"
# The wallet uses BIP86 taproot derivation:
# m/86'/coin'/0'/0/{index}
# coin = 0 (mainnet), 1 (testnet/regtest)
# Keystore: AES-256-GCM encrypted BIP39 mnemonicChain Queries
# Get latest block number
opnet-cli block-number -p testnet4
# Get chain ID
opnet-cli chain-id -p testnet4
# Get epoch info
opnet-cli info -p testnet4
# Get total contract count
opnet-cli contract-count -p testnet4
# Get gas info
opnet-cli gas -p testnet4
# Get transaction info
opnet-cli get-tx --hash <TX_HASH> -p testnet4
# Get transaction receipt
opnet-cli get-receipt --hash <TX_HASH> -p testnet4Contract Queries
# Simulate a contract call (read-only)
opnet-cli call \
--contract <32_BYTE_ADDRESS_HEX> \
--calldata <SELECTOR_AND_ARGS_HEX> \
-p testnet4
# Get contract bytecode
opnet-cli get-code --contract <ADDRESS_HEX> -p testnet4
# Get contract storage slot
opnet-cli get-storage --contract <ADDRESS_HEX> --key <KEY_HEX> -p testnet4
# Get contract deployer pubkey
opnet-cli get-deployer --contract <ADDRESS_HEX> -p testnet4
# Derive contract P2OP address offline
opnet-cli derive-address <PUBKEY_HEX> <WASM_FILE> <SALT_HEX>Contract Deployment
# Deploy a contract (commit/reveal)
opnet-cli deploy <WASM_FILE> \
-p testnet4 \
--fee-rate 1.0 \
--passphrase "mypass"
# This will:
# 1. Mine a PoW challenge (35-bit difficulty)
# 2. Create a commit transaction
# 3. Create a reveal transaction with the WASM payload
# 4. Broadcast both transactionsContract Interaction
# Interact with a deployed contract
opnet-cli interact <CONTRACT_SEED_HEX> <CALLDATA_HEX> \
-p testnet4 \
--fee-rate 1.0 \
--passphrase "mypass"
# The contract seed is the 32-byte address/seed, NOT h160.
# Calldata format: 4-byte selector + ABI-encoded arguments.
# Selectors = SHA256(signature) first 4 bytes, little-endian.Mining
# Mine a single epoch challenge (CPU)
opnet-cli mine -p testnet4 --passphrase "mypass"
# Mine continuously
opnet-cli mine-loop -p testnet4 --passphrase "mypass"
# Mine offline (no RPC needed)
opnet-cli mine-offline \
--target <HEX_TARGET> \
--epoch <EPOCH_NUMBER> \
--pubkey <XONLY_PUBKEY> \
--difficulty 35
# Regtest: generate blocks
opnet-cli generatetoaddress 10 <BTC_ADDRESS> -p regtestSelectors
OPP_NET contracts use SHA256-based selectors (not keccak256 like Solidity). The selector is the first 4 bytes of SHA256(signature), read as little-endian.
# Example: computing the selector for "name"
# SHA256("name") = 82a3537f...
# First 4 bytes: [0x82, 0xa3, 0x53, 0x7f]
# Little-endian: 7f53a382
# Selector: 7f53a382Note: Legacy OP_NET contracts (btc-vision/AssemblyScript) may use different selector schemes. Use the selector convention that matches your contract's framework.
Default RPC Endpoints
| Network | Default URL |
|---|---|
| testnet / testnet4 | https://rpc.oppnet.dev/testnet4 |
| mainnet | https://rpc.oppnet.dev/mainnet |
| regtest | https://rpc.oppnet.dev/regtest |