BridgeRouter
Contract code: https://github.com/nomad-xyz/monorepo/blob/main/packages/contracts-bridge/contracts/BridgeRouter.sol
The BridgeRouter contract is the entry point for the token bridge application and implements its interface, per the Router pattern. It enables users to “send” tokens from Chain A to Chain B via a lock-and-mint mechanism.
Sending and Receiving Tokens
Sending
The sending side logic is implemented in the send function:
// ======== External: Send Token =========
/**
* @notice Send tokens to a recipient on a remote chain
* @param _token The token address
* @param _amount The token amount
* @param _destination The destination domain
* @param _recipient The recipient address
*/
function send(
address _token,
uint256 _amount,
uint32 _destination,
bytes32 _recipient,
bool /*_enableFast - deprecated field, left argument for backwards compatibility */
) external;Receiving
The receiving side logic is implemented in the handle function:
Lock-and-Mint Mechanism
The BridgeRouter enforces the following strict invariant:
The amount locked on the chain where the token originates must always be equal to the circulation of representational tokens minted on all destination chains.
You can see this in the codebase here:
Enrolling Custom Representations
The BridgeRouter enables custom tokens to be enrolled by calling enrollCustom:
Last updated