Bitcoin Precompiles
Last updated
Last updated
A blockchain precompile refers to a set of special, pre-defined functions built into the native blockchain client software. These precompiles are available to blockchain developers via smart contract calls and can be used for a variety of use cases.
The common use case for these features in an EVM execution clients is to perform complex cryptographic operations such as hashing, digital signature verification, and mathematical operations.
On Sova we have created our own set of "Bitcoin precompiles". These precompiles have the ability to interact with the Bitcoin network via and rpc connection to a full Bitcoin node. Every node connected to the Sova Network is responsible for running a full Bitcoin node for the purpose of validating the chain and also broadcasting Bitcoin transactions if necessary.
You can think of a precompile as a "pre-deployed" contract on the Sova blockchain. Precompiles are special in that at the genesis of the chain, the 'contract logic' is already apart of every validator. Our Bitcoin precompile 'contract' allows Solidity developers to integrate directly with a Bitcoin node.
Essentially a precompile is a "predeployed" contract on the Sova blockchain and at the genesis of the chain, the precompile is apart of every validator. On the Sova network, all Bitcoin precompiles are located at address 0x0000000000000000000000000000000000000999
. This address accepts a bytes payload consisting of a 4-byte method identifier followed by additional data required for the specific Bitcoin action.
sendrawtransaction
0x00000001
Signed raw transaction data
Sends a raw Bitcoin transaction
decoderawtransaction
0x00000002
Signed raw transaction data
Decode a raw Bitcoin transaction
verifysignature
0x00000003
Signed raw transaction data
Verifies the unlocking scripts in a signed transaction
convertaddress
0x00000004
EVM address
Converts a Sova address to corresponding BTC address
createandsignrawtransaction
0x00000005
See decoding scheme for input data structure
Create and sign a BTC transaction using network keys
When writing smart contracts for the Sova Network you can import as a dependency in your smart contract:
When using , one way to interact with the precompile is to use . Here are example for how to call precompiles using cast: