Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IErc20Portal

Git Source

Inherits: IPortal

Title: ERC-20 Portal interface

Functions

depositErc20Tokens

Transfer ERC-20 tokens to an application contract and add an input to the application's input box to signal such operation. The caller must allow the portal to withdraw at least value tokens from their account beforehand, by calling the approve function in the token contract. Only ERC-20 compliant tokens are supported. The portal rejects deposits of fee-on-transfer ERC-20 tokens: It computes the difference between balances before and after the transfer. If the difference is not equal to the transfer amount, it reverts with an appropriate custom error. The portal also ensures the return value of transferFrom is true, as specified in the ERC-20 standard. Empty or ill-formed return values are not accepted and a low-level generic error is raised in those cases.

May raise Erc20TransferFailed, Erc20TransferDecreasedApplicationBalance, or Erc20TransferValueIsNotBalanceDelta.

function depositErc20Tokens(
    IERC20 token,
    address appContract,
    uint256 value,
    bytes calldata execLayerData
) external;

Parameters

NameTypeDescription
tokenIERC20The ERC-20 token contract
appContractaddressThe application contract address
valueuint256The amount of tokens to be transferred
execLayerDatabytesAdditional data to be interpreted by the execution layer

Errors

Erc20TransferFailed

Failed to transfer ERC-20 tokens to application

error Erc20TransferFailed();

Erc20TransferDecreasedApplicationBalance

ERC-20 transfer decreased application balance

error Erc20TransferDecreasedApplicationBalance(
    uint256 balanceBefore, uint256 balanceAfter
);

Parameters

NameTypeDescription
balanceBeforeuint256The application balance before the transfer
balanceAfteruint256The application balance after the transfer

Erc20TransferValueIsNotBalanceDelta

ERC-20 transfer value is different from application balance delta

error Erc20TransferValueIsNotBalanceDelta(uint256 value, uint256 balanceDelta);

Parameters

NameTypeDescription
valueuint256The transfer value
balanceDeltauint256The application balance delta (after - before)