Channel

Git Source

Inherits: UserConfig

A channel is a logical connection over cross-chain network. It used for cross-chain message transfer.

  • Accepts messages to be dispatched to destination chains, constructs a Merkle tree of the messages.
  • Dispatches verified messages from source chains.

State Variables

dones

msgHash => isDispathed.

mapping(bytes32 => bool) public dones;

count

message count.

uint256 public count;

__self

Self contract address cache.

address private immutable __self = address(this);

Functions

constructor

Init code.

constructor(address dao) UserConfig(dao);

LOCAL_CHAINID

Fetch local chain id.

function LOCAL_CHAINID() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256chainId Local chain id.

_send

Send message.

function _send(address from, uint256 toChainId, address to, uint256 gasLimit, bytes calldata encoded)
    internal
    returns (bytes32);

Parameters

NameTypeDescription
fromaddressUser application contract address which send the message.
toChainIduint256The Message destination chain id.
toaddressUser application contract address which receive the message.
gasLimituint256Gas limit for destination user application used.
encodedbytesThe calldata which encoded by ABI Encoding.

_recv

Only message.to's config relayer could relay this message.

Receive messages.

function _recv(Message calldata message, bytes calldata proof) internal returns (bytes32);

Parameters

NameTypeDescription
messageMessageReceived message info.
proofbytesMessage proof of this message.

Events

MessageAccepted

Notifies an observer that the message has been accepted.

event MessageAccepted(bytes32 indexed msgHash, Message message);

Parameters

NameTypeDescription
msgHashbytes32Hash of the message.
messageMessageAccepted message info.

MessageDispatched

Notifies an observer that the message has been dispatched.

event MessageDispatched(bytes32 indexed msgHash, bool dispatchResult);

Parameters

NameTypeDescription
msgHashbytes32Hash of the message.
dispatchResultboolThe message dispatch result.