Smart Contract Interaction
Bridging E2E Flow
The user creates an order using the Escrow smart contract on the source chain.
The order details are stored in the
orders
mapping.An
OrderPlaced
event is emitted.The Operator service, listening for the
OrderPlaced
event, detects the new order.The Market Maker (MM) calls the
transferTo
function on the PaymentRegistry smart contract on the destination chain, using details from theOrderPlaced
event.The PaymentRegistry contract records the transaction details and transfers the funds to the user on the destination chain.
The Operator service, listens for the
Transfer
event from the PaymentRegistry contract.Once the
Transfer
event is detected, the MM can either begin the proof process immediately or wait for better gas prices and batch proof their order fulfillments.When the proof process begins, the Operator service receives data specifying which order is being proved.
The Operator service calculates which storage slots in the PaymentRegistry smart contract hold the transaction details, serving as proof that the MM has fulfilled the order.
These storage slots are sent to the Storage Proofs to be made available in the Facts Registry smart contract on the source chain.
The Operator webhook receives a
status: DONE
confirmation from the Storage Proofs.The Operator relays the storage slots back to the Escrow smart contract using it's
getValuesFromSlots
function.getValuesFromSlots
calls the Facts Registry smart contract to retrieve the values stored in the given slots on the destination chain from the PaymentRegistry smart contract.getValuesFromSlots
then callsconvertBytes32toNative
to convert the retrieved values.The slot values are converted into their native types.
The
proveOrderFulfillment
function is called, which checks the values from the Facts Registry and compares them to the data stored in theorders
mapping.If the data matches,
proveOrderFulfillment
updates the order status to proved and records the source chain address of the MM.The MM calls the
withdrawProved
function to receive payment (including the amount bridged + fee) for the proved order.
Last updated