Docs
Reference
Contract documentation
tokenvault
ERC20Vault

ERC20Vault

This vault holds all ERC20 tokens (excluding 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;
}

BridgeTransferOp

struct BridgeTransferOp {
  uint256 destChainId;
  address to;
  address token;
  uint256 amount;
  uint256 gasLimit;
  uint256 fee;
  address refundTo;
  string memo;
}

isBridgedToken

mapping(address => bool) isBridgedToken

bridgedToCanonical

mapping(address => struct ERC20Vault.CanonicalERC20) bridgedToCanonical

canonicalToBridged

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

BridgedTokenDeployed

event BridgedTokenDeployed(uint256 srcChainId, address ctoken, address btoken, string ctokenSymbol, string ctokenName, uint8 ctokenDecimal)

TokenSent

event TokenSent(bytes32 msgHash, address from, address to, uint256 destChainId, address token, uint256 amount)

TokenReleased

event TokenReleased(bytes32 msgHash, address from, address token, uint256 amount)

TokenReceived

event TokenReceived(bytes32 msgHash, address from, address to, uint256 srcChainId, address token, uint256 amount)

VAULT_INVALID_TO

error VAULT_INVALID_TO()

VAULT_INVALID_TOKEN

error VAULT_INVALID_TOKEN()

VAULT_INVALID_AMOUNT

error VAULT_INVALID_AMOUNT()

VAULT_INVALID_USER

error VAULT_INVALID_USER()

VAULT_INVALID_FROM

error VAULT_INVALID_FROM()

VAULT_INVALID_SRC_CHAIN_ID

error VAULT_INVALID_SRC_CHAIN_ID()

VAULT_MESSAGE_NOT_FAILED

error VAULT_MESSAGE_NOT_FAILED()

VAULT_MESSAGE_RELEASED_ALREADY

error VAULT_MESSAGE_RELEASED_ALREADY()

onlyValidAddresses

modifier onlyValidAddresses(uint256 chainId, bytes32 name, address to, address token)

init

function init(address addressManager) external

Initializes the contract with the address manager.

Parameters

NameTypeDescription
addressManageraddressAddress manager contract address.

sendToken

function sendToken(struct ERC20Vault.BridgeTransferOp opt) 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
optstruct ERC20Vault.BridgeTransferOpOption for sending ERC20 tokens.

receiveToken

function receiveToken(struct ERC20Vault.CanonicalERC20 ctoken, address from, address to, uint256 amount) external payable

Receive bridged ERC20 tokens and Ether.

Parameters

NameTypeDescription
ctokenstruct ERC20Vault.CanonicalERC20Canonical ERC20 data for the token being received.
fromaddressSource address.
toaddressDestination address.
amountuint256Amount of tokens being received.

onMessageRecalled

function onMessageRecalled(struct IBridge.Message message) external payable

Releases deposited ERC20 tokens back to the user on the source ERC20Vault with a proof that the message processing on the destination Bridge has failed.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message that corresponds to the ERC20 deposit on the source chain.

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

Checks if the contract supports the given interface.

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier.

Return Values

NameTypeDescription
[0]booltrue if the contract supports the interface, false otherwise.

ProxiedERC20Vault

Proxied version of the parent contract.