RPC Reference

OPP_NET exposes a JSON-RPC 2.0 API at rpc.opnet.dev/<network>. Methods prefixed with btc_ are handled by the metashrew indexer (opshrew views). Methods prefixed with bitcoin_ are proxied to the underlying bitcoind via btcrpc-proxy.

Endpoints

NetworkURL
Mainnethttps://rpc.opnet.dev/mainnet
Testnet4https://rpc.opnet.dev/testnet4
Regtesthttps://rpc.opnet.dev/regtest

Chain State

btc_blockNumber

Returns the latest indexed block height.

// Request
{"jsonrpc":"2.0","method":"btc_blockNumber","params":[],"id":1}

// Response
{"jsonrpc":"2.0","result":"0x16b2","id":1}  // hex-encoded height

btc_chainId

Returns the 32-byte chain ID (network genesis hash or OP_NET chain identifier).

// Response
{"jsonrpc":"2.0","result":"0x0000017f85106b1f...","id":1}

btc_getBlockByNumber

Returns block metadata by height. Params: [height_hex]

Returns: block_hash, timestamp, tx_count, opnet_tx_count, gas_used.

btc_getBlockByHash

Returns block metadata by hash. Params: [block_hash_hex]

Contracts

btc_call

Simulate a read-only contract call without persisting state.

// Request
{"jsonrpc":"2.0","method":"btc_call","params":{
  "to": "contract_address_32bytes_hex",
  "calldata": "selector_and_args_hex"
},"id":1}

// Response
{"jsonrpc":"2.0","result":"0x...exit_data...","id":1}

btc_getCode

Get contract WASM bytecode. Params: [contract_address_hex]

btc_getStorageAt

Read a 32-byte storage slot. Params: [contract_address_hex, key_hex]

btc_getDeployer

Get the deployer's x-only public key for a contract. Params: [contract_address_hex]

btc_contractCount

Total number of deployed contracts. No params.

// Response
{"jsonrpc":"2.0","result":"0x0fb2","id":1}  // 4018 contracts

btc_contractAtIndex

Get contract address by sequential index. Params: [index] (number or hex)

Transactions

btc_getTransactionByHash

Get transaction info. Params: [tx_hash_hex]

Returns: height, tx_index, tx_type, contract_address.

btc_getTransactionReceipt

Get execution receipt. Params: [tx_hash_hex]

Returns: status, gas_used, exit_data, events.

Traces

btc_getTrace

Full execution trace for a transaction. Params: [tx_hash_hex]

Returns: callType, target, caller, calldata, success, gasUsed, exitData, storageWrites, events, subCalls.

btc_getBlockTraces

All traces for a block. Params: [height_hex]

Mining / Epochs

btc_getEpochTemplate

Get the current epoch's PoW challenge. No params.

Returns: epoch_number, target_checksum.

btc_submitEpoch

Validate a PoW solution (read-only). Params: [epoch_number, salt_hex, pubkey_hex]

btc_getEpochByNumber

Get epoch data. Params: [epoch_number]

Gas

btc_gas

Gas info for latest block (or specific height). Params: [height_hex?]

Bitcoin Core (Proxied)

Methods prefixed with bitcoin_ are proxied directly to the underlying bitcoind via btcrpc-proxy. These include:

The bitcoin_ prefix is stripped before forwarding. For example, bitcoin_getblockcount is forwarded asgetblockcount.

UTXOs (via Esplora)

btc_getUTXOs

Get UTXOs for a Bitcoin address. Params: [address]

Returns normalized format: transactionId, outputIndex, value, scriptPubKey.

Osprey REST API

osprey provides a REST API for the block explorer and protocol analytics. All endpoints are served under rpc.oppnet.dev/<network>/explorer/api/v1.

Explorer Endpoints

MethodPathDescription
GET/blocksList recent blocks with OP_NET metadata
GET/tx/{txid}Transaction details including contract interactions
GET/tx/{txid}/traceFull execution trace tree (calls, subcalls, storage writes)
GET/address/{addr}Address activity: contract deployments, interactions, transfers
GET/contractsList all deployed contracts with metadata
GET/statsNetwork statistics: total contracts, transactions, gas usage

OppSwap Endpoints

MethodPathDescription
GET/swap/poolsAll liquidity pools with reserve data
GET/swap/tokensToken list with prices and metadata
GET/swap/volumeVolume analytics (24h, 7d, 30d)

SLOHM Endpoints

MethodPathDescription
GET/slohm/overviewProtocol dashboard: OHM price, index, TVL, APY
GET/slohm/rebasesRebase history with distribute amounts and index changes
GET/slohm/bondsActive bond markets with prices, capacity, and vesting terms
GET/slohm/treasury/historyTreasury balance over time: reserves, risk-free value, backing per OHM
# Example: fetch recent blocks from the explorer
curl https://rpc.oppnet.dev/regtest/explorer/api/v1/blocks

# Example: get trace for a transaction
curl https://rpc.oppnet.dev/regtest/explorer/api/v1/tx/abc123.../trace

# Example: get all OppSwap pools
curl https://rpc.oppnet.dev/regtest/explorer/api/v1/swap/pools