Skip to main content

Bridge contract methods

These are all the public methods exposed by the underlying Bridge contract from which both the BridgeHome and BridgeForeign contracts inherit.

Asset methods

function assetResolve(uint256 chainId, address contractLocal) view returns (address)

In the BridgeHome contract (running on the BPX chain), it queries the assets database and returns the remote token contract address by provided remote chain ID and local token contract address.

In the BridgeForeign contract (running on other chains), it just returns theĀ contractLocal parameter.

Message methods

function messageCheckSignatures(uint256 chainId, bytes32 messageHash, tuple(uint8 v, bytes32 r, bytes32 s)[8] signatures, uint64 sigEpoch) view returns (address[8])

Checks the signatures of a cross-chain message before actually posting it for execution.

function messageGetRelayers(uint256 chainId, bytes32 messageHash, uint64 epoch) view returns (address[8])

Returns addresses of 8 relayers delegated to sign a given message in the given epoch.

function messageProcess(bytes message, tuple(uint8 v, bytes32 r, bytes32 s)[8] signatures, uint64 sigEpoch) payable

Executes a signed cross-chain message and transfers funds to the destination wallet. The function is payable and requires a bridge fee which will go to the relayers as their earnings. The fee amount must meet both conditions:

  • The fee must be greater than or equal to the gas price of the current transaction (tx.gasprice) multiplied by 21000
  • The fee must be divisible by 8

Relayer methods

function relayerActivate(uint256 chainId) payable

Activates the caller wallet as a bridge relayer. Activation takes effect from the next epoch after the current one. The function is payable and requires a relayer stake deposit. The amount of the required stake can be checked by the relayerGetStake method.

function relayerDeactivate(uint256 chainId)

Deactivates the caller wallet as a bridge relayer. Deactivation takes effect from the next epoch after the current one.

function relayerGetBalance(uint256 chainId, address relayerAddr) view returns (uint256)

Returns the entire relayer balance (deposited stake + all earnings).

function relayerGetStake(address relayerAddr) view returns (uint256)

Returns the stake amount required to become a bridge relayer.

function relayerGetStatus(uint256 chainId, address relayerAddr) view returns (bool, uint64)

Returns whether the relayer is active or not (bool) and from which epoch it has its current activation status (uint64).

function relayerGetWithdrawalMax(uint256 chainId, address relayerAddr) view returns (uint256)

Returns the relayer balance available for withdrawal. For an active relayer, these will be be only earnings. For an inactive relayer, it will be a stake + all earnings.

function relayerWithdraw(uint256 chainId, address to, uint256 value)

Withdraws funds from the caller relayer balance. The amount of funds that can be withdrawn can be checked using the relayerGetWithdrawalMax method.

Transfer methods

function transfer(uint256 dstChainId, address dstAddress) payable

Initiates the transfer of a native token. This function is payable and transaction should have the value to be transferred by the bridge.

function transferERC20(address srcContract, uint256 dstChainId, address dstAddress, uint256 value)

Initiates an ERC-20 token transfer. The bridge contract must be approved to perform an ERC-20 transfer from caller wallet (ERC-20 approve() method).