BSC Relayer
Relayers are responsible to submit Cross-Chain Communication Packages between the two blockchains. Due to the heterogeneous parallel chain structure, two different types of Relayers are created.
Relayers for BC-to-BSC communication referred to as BSC Relayers are a standalone process that can be run by anyone, and anywhere, except that Relayers must register themselves onto BSC and deposit a certain amount of BNB. Only relaying requests from the registered Relayers will be accepted by BSC.
GitHub Implementation link: https://github.com/binance-chain/bsc-relayer
Config Files: https://github.com/binance-chain/bsc-relayer-config
Monitor and Parse Cross Chain Event
As a BSC relayer, it must have proper configurations on the following three items:
A BSC relayer is required to parse all block results and pick out all events with event type “IBCPackage” from endBlock event table. This is an cross chain package event example:
BSC relayer should iterate all the attributes and parse the attribute value:
Split the value with “::” and get a 4-length string array
Follow the following table to parse the 4 elements:
Filter out attributes with mismatched destination chain CrossChainID.
Build Tendermint Header and Query Cross Chain Package
If a cross chain package event is found at height H, wait for block H+1 and call the following rpc methods to build the above Header object:
Header Encoding in golang:
Add dependency on go-amino v0.14.1
Add dependency on tendermint v0.32.3:
Example golang code to encode Header:
Query Cross Chain Package With Merkle Proof
Query height: H
Query path: /store/ibc/key
Follow the table to build a 14-length byte array as query key:
Assemble the above parameters to the following rpc call.
Call Build-In System Contract
function syncTendermintHeader(bytes calldata header, uint64 height)
Call syncTendermintHeader of TendermintLightClient contract to sync BC header. The contract address is 0x0000000000000000000000000000000000001003. The “header” is the encoding result of Header and the height should be H+1
Deliver Cross Chain Package
Call handlePackage of crosschain contract(0x0000000000000000000000000000000000002000) to deliver the cross chain packages:
Incentives Mechanism
Last updated
Was this helpful?