Skip to main content

ERC20 router dapp Solidity API

Diamond

constructor

constructor(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) public payable

fallback

fallback() external payable

Governable

Provides modifiers for securing methods behind a governance vote

onlyConsensus

function onlyConsensus(struct LibGovernance.Storage gs, bytes32 _ethHash, bytes[] _signatures) internal view

Verifies the message hash against the signatures. Requires a majority.

Parameters

NameTypeDescription
gsstruct LibGovernance.Storage
_ethHashbytes32hash to verify
_signaturesbytes[]governance hash signatures

onlyConsensusNonce

modifier onlyConsensusNonce(bytes32 _ethHash, bytes[] _signatures)

Verifies the message hash against the signatures. Requires a majority. Burns a nonce.

Parameters

NameTypeDescription
_ethHashbytes32hash to verify
_signaturesbytes[]governance hash signatures

onlyConsensusHash

modifier onlyConsensusHash(bytes32 _ethHash, bytes[] _signatures)

Verifies the message hash against the signatures. Requires a majority. Burns the hash.

Parameters

NameTypeDescription
_ethHashbytes32hash to verify
_signaturesbytes[]governance hash signatures

SingletonFactory

This contract is to be deployed by a single-purpose wallet on all supported networks. It serves as a CREATE2 factory and lets us have the same Diamond addresses across networks. Which in turn allows the diamond to produce the same WrappedCollection addresses across networks.

OwnerZeroAddress

error OwnerZeroAddress()

TargetAddressOccupied

error TargetAddressOccupied()

InitializationFailed

error InitializationFailed()

constructor

constructor(address owner_) public

Sets owner address who can use deploy()

Parameters

NameTypeDescription
owner_addressowner address

deploy

function deploy(bytes initCode_, bytes32 salt_, bytes initializer_) external payable returns (address payable deployedContractAddress)

Deploys a contract and optionally calls an initialization method

Parameters

NameTypeDescription
initCode_bytesinitCode for the contract to be deployed
salt_bytes32hash salt for CREATE2
initializer_bytesEncoded function call on the newly deployed contract

WrappedToken

constructor

constructor(string _tokenName, string _tokenSymbol, uint8 decimals_) public

@notice Construct a new WrappedToken contract @param _tokenName The EIP-20 token name @param tokenSymbol The EIP-20 token symbol @param decimals The number of decimals used to get the token's user representation

decimals

function decimals() public view returns (uint8)

_Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5.05 (505 / 10 ** 2).

Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the default value returned by this function, unless it's overridden.

NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}._

mint

function mint(address _account, uint256 _amount) public

Mints _amount of tokens to the _account address

Parameters

NameTypeDescription
_accountaddressThe address to which the tokens will be minted
_amountuint256The _amount to be minted

burnFrom

function burnFrom(address _account, uint256 _amount) public

Burns _amount of tokens from the _account address

Parameters

NameTypeDescription
_accountaddressThe address from which the tokens will be burned
_amountuint256The _amount to be burned

pause

function pause() public

Pauses the contract

unpause

function unpause() public

Unpauses the contract

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 _amount) internal virtual

ChainIdUpdaterFacet

chainId

function chainId() external view returns (uint8)

setChainId

function setChainId(uint8 chainId_, bytes[] signatures_) external

@notice Sets the chain id @param chainId_ The chain id to set

computeSetChainId

function computeSetChainId(uint8 chainId_) internal view returns (bytes32)

@param chainId_ the new chain id @return Hash message represeting the setchainid operation

DiamondCutGovernableFacet

diamondCut

function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata, bytes[] _signatures) external

Add/replace/remove any number of functions and optionally execute a function with delegatecall

Parameters

NameTypeDescription
_diamondCutstruct IDiamondCut.FacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init
_signaturesbytes[]

computeDiamondCutMessage

function computeDiamondCutMessage(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) internal view returns (bytes32)

@notice Computes the bytes32 ethereum signed message hash of the signature

DiamondCutSimpleFacet

This facet is being attached on the diamond during construction, then, within the same transaction, it is used to remove itself and add all the other facets (including DiamondCutGovernableFacet). This way we always have the same init code accross networks and CREATE2 yields the same address.

diamondCut

function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) external

Add/replace/remove any number of functions and optionally execute a function with delegatecall

Parameters

NameTypeDescription
_diamondCutstruct IDiamondCut.FacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

DiamondLoupeFacet

facets

function facets() external view returns (struct IDiamondLoupe.Facet[] facets_)

Gets all facets and their selectors.

Return Values

NameTypeDescription
facets_struct IDiamondLoupe.Facet[]Facet

facetFunctionSelectors

function facetFunctionSelectors(address _facet) external view returns (bytes4[] _facetFunctionSelectors)

Gets all the function selectors supported by a specific facet.

Parameters

NameTypeDescription
_facetaddressThe facet address.

Return Values

NameTypeDescription
_facetFunctionSelectorsbytes4[]The selectors associated with a facet address.

facetAddresses

function facetAddresses() external view returns (address[] facetAddresses_)

Get all the facet addresses used by a diamond.

Return Values

NameTypeDescription
facetAddresses_address[]

facetAddress

function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_)

Gets the facet that supports the given selector.

If facet is not found return address(0).

Parameters

NameTypeDescription
_functionSelectorbytes4The function selector.

Return Values

NameTypeDescription
facetAddress_addressThe facet address.

GovernanceFacet

Handles the management of governance members

state

function state(bytes data_) external

sets the state for the Governance facet

This state method is never attached on the diamond

Parameters

NameTypeDescription
data_bytesabi encoded data - the list of governance members.

updateMember

function updateMember(address account_, bool status_, bytes[] signatures_) external

@notice Adds/removes a member account @param account_ The account to be modified @param status_ Whether the account will be set as member or not @param signatures_ The signatures of the validators authorizing this member update

computeMemberUpdateMessage

function computeMemberUpdateMessage(address account_, bool status_) internal view returns (bytes32)

Computes the bytes32 ethereum signed message hash of the member update message

isMember

function isMember(address member_) external view returns (bool)

Return Values

NameTypeDescription
[0]boolTrue/false depending on whether a given address is member or not

membersCount

function membersCount() external view returns (uint256)

Return Values

NameTypeDescription
[0]uint256The count of members in the members set

memberAt

function memberAt(uint256 index_) external view returns (address)

Return Values

NameTypeDescription
[0]addressThe address of a member at a given index

administrativeNonce

function administrativeNonce() external view returns (uint256)

Return Values

NameTypeDescription
[0]uint256The current administrative nonce

ReceiverFacet

receive

receive() external payable

RouterFacet

@notice Handles the bridging of ERC20 tokens

StateData

struct StateData {
uint8 chainId;
address teleport;
address feeTokenCollector;
address deliveryAgent;
bytes32 dAppId;
}

state

function state(bytes data_) external

sets the state for the Router facet

This state method is never attached on the diamond

Parameters

NameTypeDescription
data_bytesAbi encoded LibRouter.NativeCurrency and StateData

_egress

function _egress(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, bytes extraOptionalArgs_) internal returns (bytes, uint256, bytes)

@notice Send tokens to another chain via Teleport. @param transferData_ Object holding data necessary for the transfer

  • targetChainId_ Our Abridge ID of the destination chain
  • feeToken_ Address of the token the user is paying fee in
  • token_ Address of the token to bridge, or address(0) if bridging native currency
  • amount_ Amount of the bridged tokens
  • receiver_ Address who will receive the tokens on the destination chain @param deliveryFeeData_ Object holding data necessary for deducting from msg.value to delivery agent @dev We determine the action for the ERC20 contract and build the appropriate payload bytes payload: { uint256 header, bytes envelope: { bytes msg.sender, bytes receiver, bytes action: { enum TargetAction, bytes token, bytes _lockMint() | _burnUnlock() | _burnMint() }, uint256 deliveryFee } }

egress

function egress(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, bytes extraOptionalArgs_) public payable

egressWithProvider

function egressWithProvider(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, address providerAddress_, bytes extraOptionalArgs_) public payable

egressWithPermit

function egressWithPermit(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, struct IRouter.PermitData permitData, bytes extraOptionalArgs_) external payable

@notice Send tokens to another chain via Teleport using an using an EIP-2612 permit. @param transferData_ Object holding data necessary for the transfer

  • targetChainId_ Our Abridge ID of the destination chain
  • feeToken_ Address of the token the user is paying fee in
  • token_ Address of the token to bridge, or address(0) if bridging native currency
  • amount_ Amount of the bridged tokens
  • receiver_ Address who will receive the tokens on the destination chain @param deliveryFeeData_ Object holding data necessary for deducting from msg.value to delivery agent @param permitData struct containing the permit data deadline_ The deadline for the provided permit v_ The recovery id of the permit's ECDSA signature r_ The first output of the permit's ECDSA signature s_ The second output of the permit's ECDSA signature

_isNativeCurrency

function _isNativeCurrency(address tokenAddress_) internal pure returns (bool)

@param tokenAddress_ The address of the token contract @return Checks if the supplied token address is representing the native network currency

_lockMint

function _lockMint(address tokenAddress_, uint256 amount_) internal returns (bytes)

@param tokenAddress_ The ERC20 contract address, or address(0) if native currency @param amount_ Amount of the bridged tokens @return Payload for sending native tokens to a non-native chain @dev bytes payload: {uint256 amount, uint8 chainId, string tokenName, string tokenSymbol, uint8 tokenDecimals}

_burnUnlock

function _burnUnlock(address tokenAddress_, uint256 amount_) internal returns (bytes)

@param tokenAddress_ The ERC20 contract address @param amount_ Amount of the bridged tokens @return Payload for sending non-native tokens to their native chain @dev bytes payload: {uint256 amount}

_burnMint

function _burnMint(uint8 nativeChainId_, address tokenAddress_, uint256 amount_) internal returns (bytes)

@param tokenAddress_ The ERC20 contract address @param nativeChainId_ Native Abridge chain id of the token @param amount_ Amount of the bridged tokens @return Payload for sending non-native tokens to a non-native chain @dev bytes payload: {uint256 amount, uint8 chainId, string tokenName, string tokenSymbol, uint8 tokenDecimals}

_collectDeliveryFee

function _collectDeliveryFee(uint8 targetChainId_, address token_, uint256 amount_, bytes receiver_, uint256 deliveryFee_, uint256 deliveryFeeExpiry_, bytes deliveryFeeSignature_) internal

@notice Sends the signed amount of delivery fee to the delivery agent @param targetChainId_ Our Abridge ID of the destination chain @param token_ Address of the token to bridge @param amount_ Amount of the bridged tokens @param receiver_ Address who will receive the tokens on the destination chain @param deliveryFee_ Amount to deduct from msg.value and transfer to the delivery agent @param deliveryFeeExpiry_ Block after which the delivery fee signature should be considered invalid @param deliveryFeeSignature_ Deliver agent's signature for the delivery fee

_computeDeliveryFeeHash

function _computeDeliveryFeeHash(uint8 targetChainId_, address token_, uint256 amount_, bytes receiver_, uint256 deliveryFee_, uint256 deliveryFeeDeadline_) internal view returns (bytes32)

Computes the bytes32 ethereum signed message hash of the delivery fee of an egress operation

_collectFee

function _collectFee(address feeToken_) internal

@notice Send the fee amount in custom token to the fee token collector address @param feeToken_ Address of the token to bridge

onTeleportMessage

function onTeleportMessage(uint8 sourceChainId_, bytes transmissionSender_, bytes32 dAppId_, bytes payload_) external

@notice Receive tokens from another chain via Teleport. @param sourceChainId_ Abridge Chain ID the teleport message comes from @param transmissionSender_ Sender address of the teleport message @param dAppId_ dAppId for the teleport message @param payload_ Data payload of teleport message @dev header is a placeholder for future proofing

_unlock

function _unlock(address tokenAddress_, uint256 amount_, address receiver_) internal

@notice Release previously locked native tokens. @param tokenAddress_ The ERC20 contract address, or address(0) if native currency @param amount_ Amount of the bridged tokens to be unlocked @param receiver_ The address to receive the tokens

_mint

function _mint(bytes nativeAddress_, uint256 amount_, address receiver_, uint8 nativeChainId_, string tokenName_, string tokenSymbol_, uint8 decimals_) internal

@notice Mint wrapped versions of non-native tokens. Deploys a new token contract if necessary. @param nativeAddress_ The ERC20 contract address on the native chain @param amount_ Amount of the bridged tokens to be minted @param receiver_ The address to receive the tokens @param nativeChainId_ Our Abridge chain ID for the native network @param tokenName_ Name for the wrapped token @param tokenSymbol_ Symbol for the wrapped token @param decimals_ The number of decimals used to get the token's user representation

_deployWrappedToken

function _deployWrappedToken(uint8 sourceChain_, bytes nativeToken_, string tokenName_, string tokenSymbol_, uint8 decimals_) internal returns (address)

@notice Deploys a wrapped version of a native token to the current chain @param sourceChain_ Our Abridge chain ID for the native chain @param nativeToken_ ERC20 contract address on the native chain @param tokenName_ Name for the wrapped token @param tokenSymbol_ Symbol for the wrapped token @param decimals_ The number of decimals used to get the token's user representation

nativeToWrappedToken

function nativeToWrappedToken(uint8 chainId_, bytes nativeToken_) public view returns (address)

@param chainId_ Our Abridge chain ID for the native chain @param nativeToken_ ERC20 contract address on the native chain @return The address of the wrapped counterpart of nativeToken in the current chain

wrappedToNativeToken

function wrappedToNativeToken(address wrappedToken_) public view returns (struct LibRouter.NativeTokenWithChainId)

@param wrappedToken_ ERC20 contract address of the wrapped token @return The chainId and address of the original token

serviceFee

function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) public view returns (uint256)

@return Required fee amount for bridging

_bytesToAddress

function _bytesToAddress(bytes addressAsBytes) internal pure returns (address addr)

@param addressAsBytes value of type bytes @return addr addressAsBytes value converted to type address

_addressToBytes

function _addressToBytes(address addr) internal pure returns (bytes)

@param addr value of type address @return addr value converted to type bytes

deliveryFeeNonce

function deliveryFeeNonce(address sender_) external view returns (uint256)

@param sender_ Address that initiates a bridging operation for which we collect delivery fee @return the current nonce for the sender_ address

getTeleport

function getTeleport() external view returns (address)

@return The address of the teleport contract

TeleportUpdaterFacet

setTeleport

function setTeleport(address teleportAddress, bytes[] signatures_) external

@notice Sets the teleport address @param teleportAddress The teleport address to set

computeSetTeleport

function computeSetTeleport(address teleportAddress_) internal view returns (bytes32)

@param teleportAddress_ the new teleport address @return Hash message representing the setTeleport operation

UtilityFacet

state

function state(bytes data_) external

Calls the state functions of other diamond facets

This state method is never attached on the diamond. This method is to be delegatecall-ed from diamondCutGovernableFacet.diamondCut and takes as parameter the encoded call data for the state methods of any other diamond facets.

pauseToken

function pauseToken(address tokenAddress_, bytes[] signatures_) external

@notice Pauses a given token contract @param tokenAddress_ The token contract @param signatures_ The array of signatures from the members, authorising the operation

unpauseToken

function unpauseToken(address tokenAddress_, bytes[] signatures_) external

@notice Unpauses a given token contract @param tokenAddress_ The token contract @param signatures_ The array of signatures from the members, authorising the operation

computeTokenActionMessage

function computeTokenActionMessage(enum IUtility.TokenAction _action, address _tokenAddress) internal view returns (bytes32)

@param _action denotes pause or unpause @param _tokenAddress The token address @return Hash message represeting the pause/unpause token operation

setWrappedToken

function setWrappedToken(uint8 nativeChainId_, bytes nativeToken_, address wrappedToken_, bytes[] signatures_) external

@notice Adds an existing token contract to use as a WrappedToken @param nativeChainId_ The native Abridge chain id for the token @param nativeToken_ The address in the native network @param wrappedToken_ The wrapped token address in this network @param signatures_ The array of signatures from the members, authorising the operation

computeSetWrappedTokenMessage

function computeSetWrappedTokenMessage(uint8 nativeChainId_, bytes nativeToken_, address wrappedToken_) internal view returns (bytes32)

@notice Computes the Eth signed message to use for extracting signature signers for toggling a token state @param nativeChainId_ The native Abridge chain id for the token @param nativeToken_ The address in the native network @param wrappedToken_ The wrapped token address in this network

unsetWrappedToken

function unsetWrappedToken(address wrappedToken_, bytes[] signatures_) external

@notice Removes a wrapped-native token pair from the bridge @param wrappedToken_ The wrapped token address in this network @param signatures_ The array of signatures from the members, authorising the operation

computeUnsetWrappedTokenMessage

function computeUnsetWrappedTokenMessage(address wrappedToken_) internal view returns (bytes32)

@notice Computes the Eth signed message to use for extracting signature signers for toggling a token state @param wrappedToken_ The wrapped token address in this network

setTeleportSenders

function setTeleportSenders(struct IUtility.TeleportSender[] senders_, bytes[] signatures_) external

@notice Set the allowed state for the specified teleport senders @param senders_ Array of chainId and sender @param signatures_ The array of signatures from the members, authorising the operation

computeSetTeleportSenders

function computeSetTeleportSenders(struct IUtility.TeleportSender[] senders_) internal view returns (bytes32)

@param senders_ Array of chainId and sender @return Hash message represeting the setTeleportSenders operation

dappId

function dappId() external view returns (bytes32)

@return Get the bridge dAppId

setDappId

function setDappId(bytes32 dappId_, bytes[] signatures_) external

@notice Set the bridge dAppId @param dappId_ the bridge dAppId to set @param signatures_ The array of signatures from the members, authorising the operation

computeSetDappId

function computeSetDappId(bytes32 dappId_) internal view returns (bytes32)

@param dappId_ dAppId hash @return Hash message represeting the setDappId operation

setFeeToken

function setFeeToken(address feeToken_, uint256 amount_, bytes[] signatures_) external

@notice Adds, updates or removes an accepted fee token @param feeToken_ Address of the fee token to change @param amount_ New amount to set; if 0 the token will no longer be accepted for paying fees

computeSetFeeToken

function computeSetFeeToken(address feeToken_, uint256 amount_) internal view returns (bytes32)

@param feeToken_ Address of the fee token to change @param amount_ New amount to set @return Hash message represeting the setFeeToken operation

feeAmountByToken

function feeAmountByToken(address feeToken_) external view returns (uint256)

@param feeToken_ Address of the fee token to look-up @return The fee amount in the given token

feeTokens

function feeTokens() external view returns (address[])

@return The addresses of all accepted fee tokens

feeTokenCollector

function feeTokenCollector() external view returns (address)

@return Get the address that will collect fees in custom tokens

setFeeTokenCollector

function setFeeTokenCollector(address feeTokenCollector_, bytes[] signatures_) external

@notice Set the address that will collect fees in custom tokens @param feeTokenCollector_ the address to send fee tokens to @param signatures_ The array of signatures from the members, authorising the operation

computeSetFeeTokenCollector

function computeSetFeeTokenCollector(address feeTokenCollector_) internal view returns (bytes32)

@param feeTokenCollector_ the address to send fee tokens to @return Hash message represeting the setFeeTokenCollector operation

deliveryAgent

function deliveryAgent() external view returns (address)

@return Get the address of the agent that will receive funds for completing a bridging operation

setDeliveryAgent

function setDeliveryAgent(address deliveryAgent_, bytes[] signatures_) external

@notice Set the address of the agent that will receive funds for completing a bridging operation @param deliveryAgent_ the address of the agent that will receive funds for completing a bridging operation @param signatures_ The array of signatures from the members, authorising the operation

computeSetDeliveryAgent

function computeSetDeliveryAgent(address deliveryAgent_) internal view returns (bytes32)

@param deliveryAgent_ the address of the agent that will receive funds for completing a bridging operation @return Hash message represeting the setDeliveryAgent operation

Test1Facet

state

function state(bytes _input) external pure

f1

function f1() external pure returns (string)

f2

function f2() external pure returns (string)

f3

function f3() external pure returns (string)

Test2Facet

TestEvent

event TestEvent(uint256)

serviceFee

function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) public returns (uint256 fee)

f2

function f2() external pure returns (string)

Test3Facet

f3

function f3() external pure returns (string)

f1337

function f1337() external pure returns (string)

Test4Facet

TestEvent

event TestEvent(uint256)

callOnce

function callOnce(uint256 _var, bytes[] _signatures) external

IDiamondCut

FacetCutAction

enum FacetCutAction {
Add,
Replace,
Remove
}

FacetCut

struct FacetCut {
address facetAddress;
enum IDiamondCut.FacetCutAction action;
bytes4[] functionSelectors;
}

DiamondCut

event DiamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata)

IDiamondCutGovernable

diamondCut

function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata, bytes[] _signatures) external

Add/replace/remove any number of functions and optionally execute a function with delegatecall

Parameters

NameTypeDescription
_diamondCutstruct IDiamondCut.FacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init
_signaturesbytes[]Governance members' signatures authorizing the operation

IDiamondCutSimple

diamondCut

function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) external

Add/replace/remove any number of functions and optionally execute a function with delegatecall

Parameters

NameTypeDescription
_diamondCutstruct IDiamondCut.FacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

ICommonErrors

NoDirectCall

error NoDirectCall()

TransferFailed

error TransferFailed(string message)

AccountIsAddressZero

error AccountIsAddressZero()

NoValueAllowed

error NoValueAllowed()

IRouterErrors

UnknownDestination

error UnknownDestination()

Used when the destination is not supported by the router

WrongValue

error WrongValue()

Used when the value is not wrong

DeliveryFeeSignatureExpired

error DeliveryFeeSignatureExpired()

Used when the delivery fee signature has expired

InvalidDeliveryFeeSigner

error InvalidDeliveryFeeSigner()

Used when the delivery fee signer is invalid

UnsupportedFeToken

error UnsupportedFeToken()

Used when an unsupported fee token is encountered

FeeTokenCollectorAddressNotSet

error FeeTokenCollectorAddressNotSet()

Used when the fee token collector address is not set

UnknownTeleport

error UnknownTeleport()

Used when an unknown teleport is encountered

UnknownDAppId

error UnknownDAppId()

Used when an unknown DApp ID is encountered

UnknownSender

error UnknownSender()

Used when an unknown sender is encountered

UnknownFormat

error UnknownFormat()

Used when an unknown format is encountered

ShouldContainSender

error ShouldContainSender()

Used to make sure a transaction should contain a sender

WrongAddressLength

error WrongAddressLength()

Used when an address has an incorrect length

IncorrectTargetAction

error IncorrectTargetAction()

Used when an incorrect target action is encountered

DeliveryFeeFailed

error DeliveryFeeFailed(string message)

Used when a delivery fee fails with a specific message

Parameters

NameTypeDescription
messagestringThe error message

UnlockFailed

error UnlockFailed(string message)

Used when an unlock fails with a specific message

Parameters

NameTypeDescription
messagestringThe error message

AddressOccupied

error AddressOccupied()

Used when an address is already occupied

IDiamondLoupeFacetErrors

ExceededMaxFacets

error ExceededMaxFacets()

ILibDiamondErrors

FunctionDoesNotExist

error FunctionDoesNotExist()

NoSelectorsInFacetToCut

error NoSelectorsInFacetToCut()

FunctionAlreadyExists

error FunctionAlreadyExists()

CantReplaceImmutableFn

error CantReplaceImmutableFn()

CantReplaceWithSameFn

error CantReplaceWithSameFn()

CantReplaceNonexistentFn

error CantReplaceNonexistentFn()

RemoveFacetAddressMustBeZero

error RemoveFacetAddressMustBeZero()

CantRemoveNonexistentFn

error CantRemoveNonexistentFn()

CantRemoveImmutableFn

error CantRemoveImmutableFn()

IncorrectFacetCutAction

error IncorrectFacetCutAction()

InitIsAddress0AndCalldataNotEmpty

error InitIsAddress0AndCalldataNotEmpty()

CalldataIsEmpty

error CalldataIsEmpty()

InitFunctionReverted

error InitFunctionReverted()

ContractHasNoCode

error ContractHasNoCode(string checkCase)

LibDiamond__InitIsNotFacet

error LibDiamond__InitIsNotFacet()

ITeleportFacetErrors

OnlyValidProviderCalls

error OnlyValidProviderCalls()

Used to make sure the function is only called by the teleport contract.

TransmissionNotSupportedByAnyProvider

error TransmissionNotSupportedByAnyProvider()

Used when there's not provider that supports the specified transmission.

ProviderCannotBeZeroAddress

error ProviderCannotBeZeroAddress()

Used when the provided provider address is the zero address.

InvalidProvider

error InvalidProvider()

Used when the provided provider address is not supported by the provider selector.

SourceChainNotSupported

error SourceChainNotSupported()

Thrown when a message is received from an unknown source chain.

InvalidTeleportSender

error InvalidTeleportSender()

Thrown when a message is received from an invalid teleport sender.

TargetChainNotSupported

error TargetChainNotSupported()

Thrown when a message is being send to an unknown target chain.

InvalidChainId

error InvalidChainId()

InvalidSenderAddress

error InvalidSenderAddress()

DuplicateChainId

error DuplicateChainId()

IFeeCalculatorFacetErrors

NothingToClaim

error NothingToClaim()

InsufficientFeeAmount

error InsufficientFeeAmount()

IGovernanceFacetErrors

NotAValidMember

error NotAValidMember()

MemberListEmpty

error MemberListEmpty()

AccountAlreadyAdded

error AccountAlreadyAdded()

WouldBecomeMemberless

error WouldBecomeMemberless()

InvalidNumberOfSignatures

error InvalidNumberOfSignatures()

InvalidSigner

error InvalidSigner()

WrongSignersOrder

error WrongSignersOrder()

HashAlreadyUsed

error HashAlreadyUsed()

IWrappedTokenErrors

BurnAmountExceedsAllowance

error BurnAmountExceedsAllowance()

TokenTransferWhilePaused

error TokenTransferWhilePaused()

ITeleportUpdaterFacetErrors

InvalidNewTeleportAddress

error InvalidNewTeleportAddress()

IUtilityFacetErros

WrappedTokenAddressMustNeNonZero

error WrappedTokenAddressMustNeNonZero()

IDiamondErrors

IDiamondLoupe

Facet

struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}

facets

function facets() external view returns (struct IDiamondLoupe.Facet[] facets_)

Gets all facet addresses and their four byte function selectors.

Return Values

NameTypeDescription
facets_struct IDiamondLoupe.Facet[]Facet

facetFunctionSelectors

function facetFunctionSelectors(address _facet) external view returns (bytes4[] facetFunctionSelectors_)

Gets all the function selectors supported by a specific facet.

Parameters

NameTypeDescription
_facetaddressThe facet address.

Return Values

NameTypeDescription
facetFunctionSelectors_bytes4[]

facetAddresses

function facetAddresses() external view returns (address[] facetAddresses_)

Get all the facet addresses used by a diamond.

Return Values

NameTypeDescription
facetAddresses_address[]

facetAddress

function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_)

Gets the facet that supports the given selector.

If facet is not found return address(0).

Parameters

NameTypeDescription
_functionSelectorbytes4The function selector.

Return Values

NameTypeDescription
facetAddress_addressThe facet address.

IERC165

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool)

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier, as specified in ERC-165

Return Values

NameTypeDescription
[0]booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

IGovernance

MemberUpdated

event MemberUpdated(address member, bool status)

An event emitted once member is updated

updateMember

function updateMember(address _account, bool _status, bytes[] _signatures) external

@notice Adds/removes a member account @param _account The account to be modified @param _status Whether the account will be set as member or not @param _signatures The signatures of the validators authorizing this member update

isMember

function isMember(address _member) external view returns (bool)

Return Values

NameTypeDescription
[0]boolTrue/false depending on whether a given address is member or not

membersCount

function membersCount() external view returns (uint256)

Return Values

NameTypeDescription
[0]uint256The count of members in the members set

memberAt

function memberAt(uint256 _index) external view returns (address)

Return Values

NameTypeDescription
[0]addressThe address of a member at a given index

administrativeNonce

function administrativeNonce() external view returns (uint256)

Return Values

NameTypeDescription
[0]uint256The current administrative nonce

IReceiver

Received

event Received(address, uint256)

receive

receive() external payable

IRouter

TargetAction

enum TargetAction {
Unlock,
Mint
}

DeliveryFeeData

struct DeliveryFeeData {
uint256 fee;
uint256 expiry;
bytes signature;
}

PermitData

struct PermitData {
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}

TransferData

struct TransferData {
uint8 targetChainId_;
address feeToken_;
address token_;
uint256 amount_;
bytes receiver_;
}

LockMint

event LockMint(uint8 targetChain, address token, uint256 amount, bytes receiver)

An event emitted once a Lock transaction is executed

BurnMint

event BurnMint(uint8 targetChain, address token, uint256 amount, bytes receiver)

An event emitted once a Burn transaction is executed

BurnUnlock

event BurnUnlock(uint8 targetChain, address token, uint256 amount, bytes receiver)

An event emitted once a BurnAndTransfer transaction is executed

Unlock

event Unlock(address token, uint256 amount, address receiver)

An event emitted once an Unlock transaction is executed

Mint

event Mint(address token, uint256 amount, address receiver)

An even emitted once a Mint transaction is executed

WrappedTokenDeployed

event WrappedTokenDeployed(uint8 sourceChain, bytes nativeToken, address wrappedToken)

An event emitted once a new wrapped token is deployed by the contract

TeleportSet

event TeleportSet(address teleport)

An event emitted when setting the teleport address

DeliveryFeeCollected

event DeliveryFeeCollected(address user, address agent, uint256 amount)

An event emitted when delivery fee has been transfered to the delivery agent

FeeTokensCollected

event FeeTokensCollected(address feeToken, address user, address collector, uint256 amount)

An event emitted when fees are paid in custom token

nativeToWrappedToken

function nativeToWrappedToken(uint8 chainId_, bytes nativeToken_) external view returns (address)

wrappedToNativeToken

function wrappedToNativeToken(address wrappedToken_) external view returns (struct LibRouter.NativeTokenWithChainId)

serviceFee

function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)

deliveryFeeNonce

function deliveryFeeNonce(address sender_) external view returns (uint256)

egress

function egress(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, bytes extraOptionalArgs_) external payable

egressWithProvider

function egressWithProvider(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, address providerAddress_, bytes extraOptionalArgs_) external payable

egressWithPermit

function egressWithPermit(struct IRouter.TransferData transferData_, struct IRouter.DeliveryFeeData deliveryFeeData_, struct IRouter.PermitData permitData, bytes extraOptionalArgs_) external payable

getTeleport

function getTeleport() external view returns (address)

IRouterDiamond

ISingletonFactory

deploy

function deploy(bytes initCode_, bytes32 salt_, bytes initializer_) external payable returns (address payable deployedContractAddress)

ITeleport

Interface for the Teleport contract, which allows for cross-chain communication and messages transfer using different providers.

TransmissionFees

event TransmissionFees(uint256 serviceFee)

Emitted when collecting fees

Parameters

NameTypeDescription
serviceFeeuint256The amount of service fee collected

transmit

function transmit(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload) external payable

Transmits a message to the specified target chain ID. The message will be delivered using the most suitable provider.

Parameters

NameTypeDescription
targetChainIduint8The ID of the target chain
transmissionReceiverbytesThe address of the receiver on the target chain
dAppIdbytes32The ID of the dApp on the target chain
payloadbytesThe message payload

transmitWithArgs

function transmitWithArgs(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external payable

Selects a provider to bridge the message to the target chain

Parameters

NameTypeDescription
targetChainId_uint8The chainID where the message should be delivered to
transmissionReceiver_bytesThe address of the contract in the target chain to receive the transmission
dAppId_bytes32ID for the dApp that the message belongs to
payload_bytesThe dApp-specific message data
extraOptionalArgs_bytesExtra optional arguments to be passed to the provider. This allow for specific provider configurations. Send bytes('') if not needed

transmitWithProvider

function transmitWithProvider(uint8 targetChainId, bytes transmissionReceiver, bytes32 dAppId, bytes payload, address providerAddress, bytes extraOptionalArgs_) external payable

Transmits a message to the specified target chain ID. The message will be delivered using the specified provider.

Parameters

NameTypeDescription
targetChainIduint8The ID of the target chain
transmissionReceiverbytesThe address of the receiver on the target chain
dAppIdbytes32The ID of the dApp on the target chain
payloadbytesThe message payload
providerAddressaddressThe address of the provider to use
extraOptionalArgs_bytes

deliver

function deliver(address providerAddress, bytes args) external

Delivers a message to this chain.

Parameters

NameTypeDescription
providerAddressaddress
argsbytesThe message arguments, which depend on the provider. See the provider's documentation for more information.

teleportFee

function teleportFee() external view returns (uint256)

Returns the currently set teleport fee.

Return Values

NameTypeDescription
[0]uint256The teleport fee amount

providerFee

function providerFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)

Returns the fee for the automatic selected provider.

Return Values

NameTypeDescription
[0]uint256The provider fee amount

providerFee

function providerFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)

Returns the fee for the stated provider.

Return Values

NameTypeDescription
[0]uint256The provider fee amount

serviceFee

function serviceFee(uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)

Returns the currently set service fee.

Return Values

NameTypeDescription
[0]uint256The service fee amount

serviceFee

function serviceFee(address providerAddress_, uint8 targetChainId_, bytes transmissionReceiver_, bytes32 dAppId_, bytes payload_, bytes extraOptionalArgs_) external view returns (uint256)

Returns the currently set service fee.

Return Values

NameTypeDescription
[0]uint256The service fee amount

DappTransmissionReceive

struct DappTransmissionReceive {
bytes teleportSender;
uint8 sourceChainId;
bytes dappTransmissionSender;
address dappTransmissionReceiver;
bytes32 dAppId;
bytes payload;
}

onProviderReceive

function onProviderReceive(struct ITeleport.DappTransmissionReceive args) external

Notifies the teleport that the provider has received a new message. Teleport should invoke the related dapps.

Parameters

NameTypeDescription
argsstruct ITeleport.DappTransmissionReceiveThe arguments of the message.

configProviderSelector

function configProviderSelector(bytes configData, bytes[] signatures_) external

configProvider

function configProvider(bytes configData, address providerAddress, bytes[] signatures_) external

ITeleportDApp

onTeleportMessage

function onTeleportMessage(uint8 _sourceChainId, bytes _transmissionSender, bytes32 _dAppId, bytes _payload) external

Called by a Teleport contract to deliver a verified payload to a dApp

Parameters

NameTypeDescription
_sourceChainIduint8The Abridge chainID where the transmission originated
_transmissionSenderbytesThe address that invoked transmit() on the source chain
_dAppIdbytes32an identifier for the dApp
_payloadbytesa dApp-specific byte array with the message data

ITeleportUpdaterFacet

setTeleport

function setTeleport(address teleportAddress, bytes[] signatures_) external

IUtility

TokenPaused

event TokenPaused(address account_, address token_)

TokenUnpaused

event TokenUnpaused(address account_, address token_)

WrappedTokenSet

event WrappedTokenSet(uint8 nativeChainId_, bytes _nativeToken, address wrappedToken_)

WrappedTokenUnset

event WrappedTokenUnset(address wrappedToken_)

TeleportSenderSet

event TeleportSenderSet(struct IUtility.TeleportSender[] senders_)

DappIdSet

event DappIdSet(bytes32 dappId_)

FeeTokenSet

event FeeTokenSet(address feeToken_, uint256 amount_)

FeeTokenCollectorSet

event FeeTokenCollectorSet(address feeTokenCollector_)

DeliveryAgentSet

event DeliveryAgentSet(address deliveryAgent_)

Subroutine

struct Subroutine {
address contractAddress;
bytes callParams;
}

TeleportSender

struct TeleportSender {
uint8 chainId;
bytes senderAddress;
}

TokenAction

enum TokenAction {
Pause,
Unpause
}

pauseToken

function pauseToken(address tokenAddress_, bytes[] signatures_) external

unpauseToken

function unpauseToken(address tokenAddress_, bytes[] signatures_) external

setWrappedToken

function setWrappedToken(uint8 nativeChainId_, bytes _nativeToken, address wrappedToken_, bytes[] signatures_) external

unsetWrappedToken

function unsetWrappedToken(address wrappedToken_, bytes[] signatures_) external

setTeleportSenders

function setTeleportSenders(struct IUtility.TeleportSender[] senders_, bytes[] signatures_) external

dappId

function dappId() external view returns (bytes32)

setDappId

function setDappId(bytes32 dappId_, bytes[] signatures_) external

setFeeToken

function setFeeToken(address feeToken_, uint256 amount_, bytes[] signatures_) external

feeAmountByToken

function feeAmountByToken(address feeToken_) external view returns (uint256)

feeTokens

function feeTokens() external view returns (address[])

feeTokenCollector

function feeTokenCollector() external view returns (address)

setFeeTokenCollector

function setFeeTokenCollector(address feeTokenCollector_, bytes[] signatures_) external

deliveryAgent

function deliveryAgent() external view returns (address)

setDeliveryAgent

function setDeliveryAgent(address deliveryAgent_, bytes[] signatures_) external

LibDiamond

DIAMOND_STORAGE_POSITION

bytes32 DIAMOND_STORAGE_POSITION

DiamondStorage

struct DiamondStorage {
mapping(bytes4 => bytes32) facets;
mapping(uint256 => bytes32) selectorSlots;
uint16 selectorCount;
mapping(address => bool) validFacets;
}

diamondStorage

function diamondStorage() internal pure returns (struct LibDiamond.DiamondStorage ds)

DiamondCut

event DiamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata)

diamondCut

function diamondCut(struct IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata) internal

addFacetSelector

function addFacetSelector(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal returns (uint256, bytes32)

replaceFacetSelector

function replaceFacetSelector(address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal

removeFacetSelector

function removeFacetSelector(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, bytes4[] _selectors, struct LibDiamond.DiamondStorage ds) internal returns (uint256, bytes32)

addReplaceRemoveFacetSelectors

function addReplaceRemoveFacetSelectors(uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, enum IDiamondCut.FacetCutAction _action, bytes4[] _selectors) internal returns (uint256, bytes32)

initializeDiamondCut

function initializeDiamondCut(struct LibDiamond.DiamondStorage ds, address _init, bytes _calldata) internal

enforceHasContractCode

function enforceHasContractCode(address _contract, string checkCase) internal view

LibGovernance

Storage

struct Storage {
struct Counters.Counter administrativeNonce;
struct EnumerableSet.AddressSet membersSet;
mapping(bytes32 => bool) hashesUsed;
}

governanceStorage

function governanceStorage() internal pure returns (struct LibGovernance.Storage gs)

updateMember

function updateMember(struct LibGovernance.Storage gs, address account_, bool status_) internal

Adds/removes a validator from the member set

isMember

function isMember(struct LibGovernance.Storage gs, address member_) internal view returns (bool)

Returns true/false depending on whether a given address is member or not

membersCount

function membersCount(struct LibGovernance.Storage gs) internal view returns (uint256)

Returns the count of the members

memberAt

function memberAt(struct LibGovernance.Storage gs, uint256 index_) internal view returns (address)

Returns the address of a member at a given index

LibRouter

NativeCurrency

struct NativeCurrency {
string name;
string symbol;
uint8 decimals;
}

NativeTokenWithChainId

struct NativeTokenWithChainId {
uint8 chainId;
bytes contractAddress;
}

Storage

struct Storage {
struct LibRouter.NativeCurrency nativeCurrency;
mapping(uint8 => mapping(bytes => address)) nativeToWrappedToken;
mapping(address => struct LibRouter.NativeTokenWithChainId) wrappedToNativeToken;
mapping(uint8 => bytes) bridgeAddressByChainId;
mapping(address => uint256) feeAmountByToken;
struct EnumerableSet.AddressSet feeTokens;
mapping(address => struct Counters.Counter) deliveryFeeNonces;
uint8 chainId;
address teleport;
address deliveryAgent;
address feeTokenCollector;
bytes32 dAppId;
}

setFeeToken

function setFeeToken(address feeToken_, uint256 amount_) internal

Adds, updates or removes an accepted fee token

setTokenMappings

function setTokenMappings(uint8 sourceChain_, bytes nativeToken_, address deployedToken) internal

sets the wrapped to native token mapping

routerStorage

function routerStorage() internal pure returns (struct LibRouter.Storage ds)