User Configurations
Several tips for our bridge builders are given here!
Consumer
Deployment parameters
Remember to pass anchor
to your contract constructor to match the fundamental requirement of implementing BoolConsumerBase.sol
.
In addition, when updating consumer
in a deployed Anchor, the Anchor contract will validate the consumer's configuration as follows:
Hence, please DO NOT misconfigure your consumer contract!
Alternatively, you can design an additional function in your consumer contract to update the address of the anchor. However, we do not recommend implementing this function in your contract since in terms of the users' trust, anchor
should never be changed after the deployment.
Send cross-chain messages to Anchor
Each consumer contract implemented BoolConsumerBase.sol
should have inherited the following internal function _sendToAnchor
. It is the intermediary to send cross-chain messages to the connected Anchor contract.
A consumer contract must define an upper-level function to implement this core internal function and several tips are provided to implement _sendToAnchor
:
pack the data to be executed on the destination chain into
payload
, such as usingabi.encode
to pack the target function's parameters.pass the correct
dstAnchor
since cross-chain messages can only be transmitted to remote anchors within the same AMT bridge.request
extraFeed
from our primary contracts based on the value ofcrossType
: eitherPURE_MESSAGE
orVALUE_MESSAGE
.
Leave
extraFeed
blank ifPURE_MESSAGE
selected.VALUE_MESSAGE
has not been enabled yet.
Receive a Message from Anchor
A consumer contract must override
receiveFromAnchor
and define corresponding logic to parsepayload
sent from its corresponding Anchor.Two basic operations should be included in the override function: decode payload and forward decoded data to subsequent functions.
One can use the provided modifier
onlyAnchor
to restrict the accessibility ofreceiveFromAnchor
.
Anchor
Transfer the ownership of the Anchor
contract
Anchor
contractThe default owner is the initial deployer of an Anchor. One can use
owner
to inquire about the address of the current owner.The most important role played by the owner is to update the connected
consumer
.The interface for transferring the ownership of an anchor can be found at
transferOwnership
.
Last updated