Ethereum Implementation Specification¶
The solidity implementation of ChainBridge should consist of a central Bridge contract, and will delegate specific functionality to handlers. Fungible and non-fungible compatibility should be focused on ERC20 and ERC721 tokens.
Transfer Flow¶
As Source Chain¶
-
Some user calls the
deposit
function on the bridge contract. AdepositRecord
is created on the bridge and a call is delgated to a handler contract specified by the providedresourceID
. -
The specified handler's
deposit
function validates the parameters provided by the user. If successful, adepositRecord
is created on the handler. -
If the call delegated to the handler is succesful, the bridge emits a
Deposit
event. -
Relayers parse the
Deposit
event and retrieve the associatedDepositRecord
from the handler to construct a message.
As Destination Chain¶
-
A Relayer calls
voteProposal
on the bridge contract. If aproposal
corresponding with the parameters passed in does not exist, it is created and the Relayer's vote is recorded. If the proposal already exists, the Relayer's vote is simply recorded. -
Once we have met some vote threshold for a
proposal
, the bridge emits aProposalFinalized
event. -
Upon seeing a
ProposalFinalized
event, Relayers call theexecuteDeposit
function on the bridge.executeDeposit
delegates a call to a handler contract specified by the associatedresourceID
. -
The specified handler's
executeDeposit
function validates the parameters provided and makes a call to some contract to complete the transfer.