Smart Contract Support
IBVM provides full EVM compatibility, allowing developers to deploy and execute Solidity smart contracts.
Contract Deployment
To deploy a contract on IBVM:
Compile Solidity code to EVM bytecode
Submit a deployment transaction with:
Zero recipient address
Contract bytecode as data
Initial value (if any)
The system creates a new contract account with:
Address: $Address = H(sender || nonce)$
Code: The deployed bytecode
Storage: Initialized empty
Balance: The transferred value
Contract Execution
Smart contracts on IBVM execute using the same semantics as Ethereum:
Contracts can be called by users or other contracts
Execution follows EVM rules and opcodes
Gas limits prevent infinite loops or excessive computation
State changes are applied atomically
Bitcoin-Specific Precompiles
IBVM extends the standard EVM precompiled contracts with Bitcoin-specific functions:
BTCVerify (0x10): Verify Bitcoin signatures
Input: Bitcoin public key, signature, message
Cost: 3000 gas
BTCHash (0x11): Bitcoin-style double-SHA256 hashing
Input: Data to hash
Cost: 30 + 6 * (data length / 32) gas
BTCTxVerify (0x12): Verify Bitcoin transaction inclusion
Input: Transaction, block header, Merkle proof
Cost: 25000 gas
Implementation example for BTC Verify:
function verifyBitcoinSignature(
bytes memory pubkey,
bytes memory signature,
bytes32 messageHash
) public view returns (bool) {
(bool success, bytes memory result) = address(0x10).staticcall(
abi.encodePacked(pubkey, signature, messageHash)
);
require(success, "BTCVerify call failed");
return abi.decode(result, (bool));
}
Interoperability Features
IBVM includes special features for Bitcoin interoperability:
BTC Bridge Contract: Interface for deposit/withdrawal of BTC
deposit(address recipient): Records BTC deposits
withdraw(uint256 amount, bytes btcAddress): Initiates withdrawals
BTCRelay Contract: Tracks Bitcoin headers and validates proofs
submitBlockHeader(bytes header): Submits new Bitcoin headers
verifyTx(bytes txBytes, bytes proof, uint256 blockHeight): Verifies transactions
Fee Market Contract: Manages the dynamic fee mechanism
getCurrentBaseFee(): Returns current base fee
estimateGasPrice(uint256 priority): Estimates gas price for desired priority
Last updated