BTC-Relay itself is a smart contract of Ethereum. The function of this contract is to verify certain transactions on Bitcoin and provide verification information to other DApp users on Ethereum. Relayer is a group of users who obtain block header data from Bitcoin and has an account address on the Ethereum network. The Relayer who submits block header data to the BTC-Relay contract as soon as possible can receive Ethereum transaction fee rewards. After the BTC-Relay smart contract obtains the block header data, it can verify a transaction based on the principle of SPV proof. When a transaction in the Bitcoin network does occur, it can trigger a specific transaction or smart contract execution on the Ethereum network.
Examples of BTC-Relay usage scenarios
- Alice and Bob agree to use the BTCSwap contract to conduct transactions. Alice wants to buy Bob's eth, and Bob sends his eth to the BTCSwap contract
- Alice sends bitcoin to Bob, she hopes that the BTCSwap contract can know this so that the BTCSwap contract can release Bob’s previous eth
- Alice calls btcrelay.relayTx() through the bitcoin transaction information and the BTCSwap contract address. After btcrelay verifies that the transaction is passed, it triggers the processTransaction method in the BTCSwap contract
- The BTCSwap contract confirms that the btcrelay address is a legal address after being triggered, and then releases Bob's eth before