Bool Network
  • Introduction
    • What is Bool Network
    • Key features and benefits
    • Roadmap and Milestones
  • INTEROPERABILITY PROTOCOL
    • Overview
    • Architecture
    • Dynamic Hidden Committee (DHC)
      • Security trust flow
      • Lifecycle
      • Messaging Layer
    • Self Custody
      • Channels
      • Workflow
      • Escape Hatch
  • USER GUIDE
    • Beta Testnet
      • Getting Started
      • Network Information
      • Wallet Setup
      • Token Faucet
      • DHC Update
      • Node Server
        • Recommend List
        • Purchase Guide
      • Node Setup
        • DHC Node Setup
          • Local LAN Configuration for SGX
          • Run a chain via snapshot
        • Case Study
      • Node Management
        • For DHC Voter
        • For DHC Owner
  • EVM Ecosystem
    • Getting Started
      • Arbitrary Message Transmission
    • AMT Bridges
      • Network configuration
      • Create committees
      • Build a bridge
      • Bind Consumer to Anchor
      • Other operations
    • Smart Contracts
      • Primary Contracts
        • AnchorFactory
        • Messenger
        • Interfaces
          • IAnchorFactory
          • IMessenger
      • On-chain endpoint: Anchor
        • Anchor.sol
        • IAnchor.sol
      • BoolConsumerBase
        • BoolConsumerBase.sol
        • IBoolConsumerBase.sol
    • User Configurations
    • Application Examples
      • HelloWeb3.sol
    • Technical Reference
      • Chain IDs
      • Deployment Addresses
        • Devnet
        • Testnet
        • Alpha Mainnet
      • Faucet
  • Applications
    • B² Bool Bridge
      • B² Bool Bridge (Particle)
      • B² Bool Bridge (MetaMask)
    • Bool Swap
      • Pool Configuration
      • Deployment Addresses
        • Alpha Mainnet
  • Develop guide
    • Network Configuration
    • System Configuration
    • Testnet
      • Bool Chain
        • Node operators
        • Validators
      • DHC Nodes
        • Prerequisites
        • Quick Start
  • Advanced Tutorials
    • Token Bridge
  • Community and Support
    • Media Kit
    • FAQ
  • Official Links
    • GitHub
    • Twitter
    • Telegram
    • Discord
    • Youtube
    • Medium
Powered by GitBook
On this page
  • Consumer
  • Deployment parameters
  • Send cross-chain messages to Anchor
  • Receive a Message from Anchor
  • Anchor
  • Transfer the ownership of the Anchor contract
  1. EVM Ecosystem

User Configurations

Several tips for our bridge builders are given here!

Consumer

Deployment parameters

import "./base/BoolConsumerBase.sol";

contract UserMock is BoolConsumerBase {
    ...
    constructor(address anchor_) BoolConsumerBase(anchor_) {}
    ...
}

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:

require(
    IBoolConsumerBase(consumer_).anchor() == address(this),
    "Anchor: ANCHOR_MISMATCH"
);

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.

function _sendToAnchor(
    address payable refundAddress,
    bytes32 crossType,
    bytes memory extraFeed,
    uint32 dstChainId,
    address dstAnchor,
    bytes memory payload
) internal virtual returns (bytes32 txUniqueIdentification)

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 using abi.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.

  • Leave extraFeed blank if PURE_MESSAGE selected.

  • VALUE_MESSAGE has not been enabled yet.

Receive a Message from Anchor

modifier onlyAnchor() {
    require(msg.sender == anchor, "BoolConsumerBase: NOT_ANCHOR");
    _;
}

function receiveFromAnchor(
    bytes memory payload
) external virtual override {}
  • A consumer contract must override receiveFromAnchor and define corresponding logic to parse payload 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 of receiveFromAnchor.

Anchor

Transfer the ownership of the Anchor contract

  • The most important role played by the owner is to update the connected consumer.

PreviousIBoolConsumerBase.solNextApplication Examples

Last updated 7 months ago

requestextraFeed from our primary contracts based on the value ofcrossType: either or .

The default owner is the initial deployer of an Anchor. One can use to inquire about the address of the current owner.

The interface for transferring the ownership of an anchor can be found at .

owner
transferOwnership
PURE_MESSAGE
VALUE_MESSAGE