Docs
Reference
Bridge
TokenVault

TokenVault

This vault holds all ERC20 tokens (but not Ether) that users have deposited. It also manages the mapping between canonical ERC20 tokens and their bridged tokens.

CanonicalERC20

struct CanonicalERC20 {
  uint256 chainId;
  address addr;
  uint8 decimals;
  string symbol;
  string name;
}

isBridgedToken

mapping(address => bool) isBridgedToken

bridgedToCanonical

mapping(address => struct TokenVault.CanonicalERC20) bridgedToCanonical

canonicalToBridged

mapping(uint256 => mapping(address => address)) canonicalToBridged

BridgedERC20Deployed

event BridgedERC20Deployed(uint256 srcChainId, address canonicalToken, address bridgedToken, string canonicalTokenSymbol, string canonicalTokenName, uint8 canonicalTokenDecimal)

EtherSent

event EtherSent(address to, uint256 destChainId, uint256 amount, bytes32 signal)

EtherReceived

event EtherReceived(address from, uint256 amount)

ERC20Sent

event ERC20Sent(address to, uint256 destChainId, address token, uint256 amount, bytes32 signal)

ERC20Received

event ERC20Received(address to, address from, uint256 srcChainId, address token, uint256 amount)

init

function init(address addressManager) external

sendEther

function sendEther(uint256 destChainId, address to, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable

Transfers Ether to this vault and sends a message to the destination chain so the user can receive Ether.

Ether is held by Bridges on L1 and by the EtherVault on L2, not TokenVaults.

Parameters

NameTypeDescription
destChainIduint256The destination chain ID where the to address lives.
toaddressThe destination address.
gasLimituint256
processingFeeuint256@custom:see Bridge
refundAddressaddress
memostring

sendERC20

function sendERC20(uint256 destChainId, address to, address token, uint256 amount, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable

Transfers ERC20 tokens to this vault and sends a message to the destination chain so the user can receive the same amount of tokens by invoking the message call.

Parameters

NameTypeDescription
destChainIduint256The destination chain ID where the to address lives.
toaddressThe destination address.
tokenaddressThe address of the token to be sent.
amountuint256The amount of token to be transferred.
gasLimituint256@custom:see Bridge
processingFeeuint256@custom:see Bridge
refundAddressaddressThe fee refund address. If this address is address(0), extra fees will be refunded back to the to address.
memostring

receiveERC20

function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external

This function can only be called by the bridge contract while invoking a message call.

Parameters

NameTypeDescription
canonicalTokenstruct TokenVault.CanonicalERC20The canonical ERC20 token which may or may not live on this chain. If not, a BridgedERC20 contract will be deployed.
fromaddressThe source address.
toaddressThe destination address.
amountuint256The amount of tokens to be sent. 0 is a valid value.