Sova Docs
  • Sova Developer Hub
  • Documentation
    • Intro
    • How It Works
    • Node Design & Architecture
    • Sova Whitepaper
    • Network Info
  • Developers
    • Contributing
    • For Frontend Developers
    • For Solidity Developers
    • Bitcoin Precompiles
    • Double Spend Protection
  • Node Operators
    • Dev Node
  • Community & Support
    • Frequently Asked Questions (FAQ)
Powered by GitBook
On this page
  • What is a Precompile?
  • Overview
  • Available Precompiles
  • Usage
  • sendrawtransaction
  • decoderawtransaction
  • verifysignature
  • convertaddress
  • createandsignrawtransaction
  1. Developers

Bitcoin Precompiles

PreviousFor Solidity DevelopersNextDouble Spend Protection

Last updated 1 month ago

What is a Precompile?

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.

Overview

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 any additional data required for the specific Bitcoin action.

Additionally, import to import and use these precompiles in your solidity contracts.

Available Precompiles

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

Usage

For Foundry users, one way to interact with the precompile is to use . Below are examples for each precompile call using cast. Another way is to import SovaNetwork/contracts as a dependency in your smart contract.

import {SovaBitcoin} from "@SovaNetwork/contracts/lib/SovaBitcoin.sol";

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
https://github.com/SovaNetwork/contracts
cast