Sova Docs
  • Sova Developer Docs
  • Documentation
    • Intro
    • How It Works
    • Node Design & Architecture
    • Sova Whitepaper
  • TECHNOLOGY
    • Bitcoin Precompiles
    • Double Spend Protection
    • For Frontend Developers
    • For Solidity Developers
  • Contributing
  • NETWORK INFORMATION
    • Connecting to Sova
    • OP Chain Configuration
    • Sova Contracts
  • Node Operators
    • Running Sova
  • Community & Support
    • Frequently Asked Questions (FAQ)
Powered by GitBook
On this page
  • Overview
  • Technical Details
  • Smart Contracts
  • Foundry
  • sendrawtransaction
  • decoderawtransaction
  • verifysignature
  • convertaddress
  • createandsignrawtransaction
  1. TECHNOLOGY

Bitcoin Precompiles

PreviousSova WhitepaperNextDouble Spend Protection

Last updated 2 days ago

Overview

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.

Technical Details

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.

Name
Method ID (bytes)
Data (bytes)
Description

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

Smart Contracts

When writing smart contracts for the Sova Network you can import as a dependency in your smart contract:

import {SovaBitcoin} from "@sova-network/src/lib/SovaBitcoin.sol";

Foundry

sendrawtransaction

cast call 0x0000000000000000000000000000000000000999 \
--data 0x00000001${raw_tx_hex} \
--rpc-url http://localhost:8545

decoderawtransaction

cast call 0x0000000000000000000000000000000000000999 \
--data 0x00000002${raw_tx_hex} \
--rpc-url http://localhost:8545

verifysignature

cast call 0x0000000000000000000000000000000000000999 \
--data 0x00000003${raw_tx_hex} \
--rpc-url http://localhost:8545

convertaddress

cast call 0x0000000000000000000000000000000000000999 \
--data 0x00000004${eth_address} \
--rpc-url http://localhost:8545

createandsignrawtransaction

cast call 0x0000000000000000000000000000000000000999 \
--data 0x00000005${abi_encoded_params} \
--rpc-url http://localhost:8545

When using , one way to interact with the precompile is to use . Here are example for how to call precompiles using cast:

SovaNetwork/contracts
Foundry
cast