This document defines the high level bridge implementation.
The ETH bridge facilitates the transfer of ETH from Ethereum to be represented as the native token on Fuel.
- User starts a deposit by calling
depositETH()
onFuelMessagePortal
which accepts an amount of ETH that gets custodied while bridged - The Fuel client sees an outgoing message event emitted on the
FuelMessagePortal
and adds a correspondingInputMessage
to the UTXO set with the designated recipient - The recipient can now spend the amount value in the input message like any other input
- User starts a withdrawal by creating a transaction that creates a
MessageOut
receipt, via theSMO
opcode, with a specific amount of ETH - The
messageId
s from allMessageOut
receipts in a block are put into a merkle tree and included in the block header, which gets committed to theFuelChainState
contract - After a finalization period, the user calls
relayMessage
on theFuelMessagePortal
contract with a block inclusion proof that is cross verified with theFuelChainState
contract, which then sends the ETH to the message recipient
The ERC-20 bridge facilitates the transfer of ERC-20 tokens from Ethereum to be represented as tokens on Fuel.
- User starts a deposit by calling the
deposit()
function on theFuelERC20Gateway
(after they have approved token transfer toFuelERC20Gateway
) - The
FuelERC20Gateway
transfers tokens to itself to custody while they are bridged - The
FuelERC20Gateway
creates a message in theFuelMessagePortal
to be relayed on Fuel with theMessageToContractPredicate
as the recipient so that anyone can spend theInputMessage
on the user's behalf but with guarantees that the spending transaction correctly relays the message data - The Fuel client sees an outgoing message event emitted on the
FuelMessagePortal
and adds a correspondingInputMessage
to the UTXO set with the designated recipient predicate - A transaction is built and submitted by either the user or a third party that meets the requirements of the
MessageToContractPredicate
recipient - A single call is made from the transaction script to the intended target Fuel token contract specified in the messages data field. This function verifies the sender of the
InputMessage
, parses the data from theInputMessage
data field and mints the appropriate amount of tokens
- User starts a withdrawal by calling
withdraw
on the token specificBridgeFungibleToken
contract, sending the coins to withdraw along with it - The
BridgeFungibleToken
contract looks to see what coins it was sent, burns them and then creates aMessageOut
receipt via theSMO
opcode - The
messageId
s from allMessageOut
receipts in a block are put into a merkle tree and included in the block header, which gets committed to theFuelChainState
contract - After a finalization period, the user calls
relayMessage
on theFuelMessagePortal
contract with a block inclusion proof that is cross verified with theFuelChainState
contract, which then calls to theFuelERC20Gateway
with the abi specified in the message data - The
FuelERC20Gateway
verifies it’s being called by theFuelMessagePortal
and releases the specified amount of tokens to the specified address