🐬Message Dispatching using Yaru and Yaho
For relaying arbitrary message between Ethereum/Goerli and Gnosis Chain, several contracts need to be deployed on top of the current AMB deployments: Yaho, Yaru, AMB Message Relay, AMB Adapter, and Hashi. The addresses from this article are for Goerli <-> Gnosis Chain.
Prerequisite
For Goerli->Gnosis Direction:
Optional: Deploy Hashi Module for Safe that will be called by Yaru, i.e. Safe on Gnosis Chain.
Deploy AMB Message Relay on Goerli, with constructor
_amb: AMB address on Goerli, _yaho: Yaho address on Goerli
.Deploy AMB Adapter on Gnosis Chain, with constructor
_amb: AMB address on Gnosis Chain, _reporter: AMB Message Relay on Goerli, _chainId: bytes32(5)
.
In the current deployment,
gas
is added as a parameter indispatchMessagesToAdapters()
to justify the amb's gas requirement. It is not added into the official hashi code at the moment as it might raise incompatibility issue for other adapters. Please be aware that these contracts might be changed anytime.
Workflow: Ethereum -> Gnosis Chain
User calls
Yaho.dispatchMessagesToAdapters
. ExampleYaho calls AMB Message Relay
relayMessages
which will eventually callsstoreHashes
from AMB Adapter on Gnosis Chain.AMB Message Relay calls AMB
requireToPassMessage
, and the message will be relayed to AMB on Gnosis Chain.Once the AMB Adapter
storeHashes
is called,MessageDispatched
event will be emitted and user needmessageId
data from the event. ExampleUser calls
Yaru.executeMessages
withmessageId
andmessage
as parameters. Example
Initiate Transaction
Create function calldata for the contract you want to call on Gnosis Chain.
Optional: Create transaction calldata for Hashi Module.
This step is only needed when Safe is used.
Create message with format below: With Safe:
Without Safe:
Call
Yaho.dispatchMessagesToAdapters([message],[AMB_Message_Relay_Address],[AMB_Adapter_Address])
using Safe or EOA.Once the transaction is created, you need to collect
messsage Id
fromMessageDispatched
event emitted from Yaho.
Claim Transaction
After the message is relayed to Gnosis Chain by AMB bridge, you can proceed to claim your transaction. Make sure that your message is stored by checking if the AMB Adapter contract emits HashStored
event with the correct message Id
.
Call
Yaru.executeMessages([message],[messageId],[Safe_from_Goerli or EOA from Goerli that calls Yaho],[AMB_Adapter_Address on Gnosis Chain])
Implement your hook
For a successful message execution to happen, the contract specified as message recipient on the destination chain must implement a hook to process correctly the message.data
. The hook must revert unless the msg.sender
matches the expected Yaru
contract, Yaru.sender()
matches the expected sender, and Yaru.adapters()
matches the desired set of oracles that must have agreed on the reported hash.
Contract | Address | Chain |
---|---|---|
Yaho | Goerli | |
AMB Message Relay | Goerli | |
AMB Adapter for Message Relay | GC | |
Yaru | GC |
Workflow: Gnosis Chain -> Ethereum
User calls
Yaho.dispatchMessagesToAdapters
. ExampleYaho calls AMB Message Relay
relayMessages
which will eventually callsstoreHashes
from AMB Adapter on Gnosis Chain.AMB Message Relay calls AMB
requireToPassMessage
, andUserRequestsForSignature
event will be emitted.User calls AMB Helper contract's
getSignature
with theencodedData
as parameters obtained from step3, the function will return signature.TutorialUser calls AMB on Goerli's
executeSignature
withencodedData
andsignature
as parameters. ThestoreHashes
from AMB Adapter will be called,MessageDispatched
event will be emitted and user needmessageId
data from the event. ExampleUser calls
Yaru.executeMessages
withmessageId
andmessage
as parameters. Example
Contract | Address | Chain |
---|---|---|
Yaho | GC | |
AMB Message Relay | GC | |
AMB Helper | GC | |
AMB Adapter for Message Relay | Goerli | |
Yaru | Goerli | |
Hashi | Goerli |
Last updated