EIPs Explained

ERC-8002 · Draft · ERC · 2025-08-07

ERC-8002: Simplified Payment Verification Gateway

A draft singleton contract that acts as a permissionless Bitcoin light client on Ethereum: anyone submits Bitcoin block headers, the contract tracks the most-work chain, and dApps verify that a Bitcoin transaction was confirmed using a Merkle proof.

What problem does it solve?

Bitcoin has very limited programmability, so native BTC cannot easily take part in Ethereum DeFi. Most "BTC on Ethereum" today relies on a wrapped token issued by a custodian or a federation that you must trust.

ERC-8002 proposes a shared, trustless building block: a single on-chain Simplified Payment Verification (SPV) gateway. It lets any Ethereum contract ask, "Was this Bitcoin transaction included in the Bitcoin main chain with at least N confirmations?" without trusting an oracle. That is enough for one-way use cases such as accepting native BTC as loan collateral, and the authors see it as a foundation for future trust-minimized two-way bridges.

How it works

  • Header relay: anyone calls addBlockHeader(raw) (or the optional addBlockHeaderBatch) with an 80-byte Bitcoin block header. The contract checks that:
    • the previous-block hash points to a known header;
    • the timestamp is greater than the median of the previous 11 blocks;
    • the double-SHA256 of the header is at or below the target implied by Bitcoin's difficulty adjustment (every 2016 blocks, clamped to 4x / 1/4x).
  • Main chain: each header's work is (2**256 - 1) / (target + 1). The contract tracks cumulative work and treats the chain with the most work as the main chain, handling reorganizations. It emits BlockHeaderAdded and, when the tip changes, MainchainHeadUpdated.
  • Transaction proof: checkTxInclusion(merkleProof, blockHash, txId, txIndex, minConfirmations) returns true only if the block is on the main chain with enough confirmations and the Merkle path rebuilds the block's Merkle root.
  • Bootstrapping: rather than replaying all of Bitcoin from genesis (estimated by the authors at around 100 ETH of gas at 1 gwei), the gateway is initialized permissionlessly from a chosen header, height and cumulative work. That starting point is trusted.
  • Getters expose the main-chain head and height, header data, block status and confirmations, and hash-by-height lookups.

Sample code

A contract that releases a loan only after a Bitcoin payment has 6 confirmations:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface ISPVGateway {
    function checkTxInclusion(
        bytes32[] memory merkleProof,
        bytes32 blockHash,
        bytes32 txId,
        uint256 txIndex,
        uint256 minConfirmationsCount
    ) external view returns (bool);
    function getMainchainHeight() external view returns (uint64);
}

contract BtcCollateralDesk {
    ISPVGateway public immutable spv;
    mapping(bytes32 => bool) public used;   // prevent reusing the same BTC tx

    constructor(ISPVGateway _spv) { spv = _spv; }

    function claim(bytes32[] calldata proof, bytes32 blockHash, bytes32 txId, uint256 txIndex) external {
        require(!used[txId], "already used");
        require(spv.checkTxInclusion(proof, blockHash, txId, txIndex, 6), "not confirmed");
        used[txId] = true;
        // A real protocol must also parse the raw BTC tx to check outputs and amounts.
        // ... release funds
    }
}

Things to know

  • Status: Draft. No canonical deployment address is defined yet (the spec still says "TODO"), and deployment method and test cases are unfinished.
  • Inclusion alone does not tell you what the transaction did. Protocols must also verify the raw transaction's outputs (recipient script and amount) against txId.
  • There is no built-in finality. Each consumer chooses its own confirmation threshold, and deep Bitcoin reorgs remain possible.
  • Security rests on Bitcoin's proof-of-work: an attacker with majority hash power could feed the contract a fraudulent chain. The initial checkpoint is also a trust point that users of a given deployment should verify.
  • The "no more than 2 hours in the future" timestamp rule cannot be enforced on-chain and is omitted.
  • Bitcoin serializes integers little-endian, while the gateway stores header fields big-endian; mind byte order when preparing txId and proofs.

#bitcoin #spv #light-client #bridge #interop

Details

Authors
Artem Chystiakov (@arvolear), Oleh Komendant (@Hrom131)
Status
Draft
Type
Standards Track / ERC
Created
2025-08-07

Machine-readable: Markdown · JSON