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

InputEncoding

Git Source

Title: Input Encoding Library

Defines the encoding of inputs added by core trustless and permissionless contracts, such as portals.

Functions

encodeEtherDeposit

Encode an Ether deposit.

function encodeEtherDeposit(
    address sender,
    uint256 value,
    bytes calldata execLayerData
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
senderaddressThe Ether sender
valueuint256The amount of Wei being sent
execLayerDatabytesAdditional data to be interpreted by the execution layer

Returns

NameTypeDescription
<none>bytesThe encoded input payload

decodeEtherDeposit

Decode an Ether deposit.

function decodeEtherDeposit(bytes calldata payload)
    internal
    pure
    returns (EtherDeposit memory deposit);

Parameters

NameTypeDescription
payloadbytesThe encoded input payload

Returns

NameTypeDescription
depositEtherDepositThe decoded Ether deposit

encodeErc20Deposit

Encode an ERC-20 token deposit.

function encodeErc20Deposit(
    IERC20 token,
    address sender,
    uint256 value,
    bytes calldata execLayerData
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
tokenIERC20The token contract
senderaddressThe token sender
valueuint256The amount of tokens being sent
execLayerDatabytesAdditional data to be interpreted by the execution layer

Returns

NameTypeDescription
<none>bytesThe encoded input payload

decodeErc20Deposit

Decode an ERC-20 token deposit.

function decodeErc20Deposit(bytes calldata payload)
    internal
    pure
    returns (Erc20Deposit memory deposit);

Parameters

NameTypeDescription
payloadbytesThe encoded input payload

Returns

NameTypeDescription
depositErc20DepositThe decoded ERC-20 token deposit

encodeErc721Deposit

Encode an ERC-721 token deposit.

baseLayerData should be forwarded to token.

function encodeErc721Deposit(
    IERC721 token,
    address sender,
    uint256 tokenId,
    bytes calldata baseLayerData,
    bytes calldata execLayerData
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
tokenIERC721The token contract
senderaddressThe token sender
tokenIduint256The token identifier
baseLayerDatabytesAdditional data to be interpreted by the base layer
execLayerDatabytesAdditional data to be interpreted by the execution layer

Returns

NameTypeDescription
<none>bytesThe encoded input payload

decodeErc721Deposit

Decode an ERC-721 token deposit.

function decodeErc721Deposit(bytes calldata payload)
    internal
    pure
    returns (Erc721Deposit memory deposit);

Parameters

NameTypeDescription
payloadbytesThe encoded input payload

Returns

NameTypeDescription
depositErc721DepositThe decoded ERC-721 token deposit

encodeSingleErc1155Deposit

Encode an ERC-1155 single token deposit.

baseLayerData should be forwarded to token.

function encodeSingleErc1155Deposit(
    IERC1155 token,
    address sender,
    uint256 tokenId,
    uint256 value,
    bytes calldata baseLayerData,
    bytes calldata execLayerData
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
tokenIERC1155The ERC-1155 token contract
senderaddressThe token sender
tokenIduint256The identifier of the token being transferred
valueuint256Transfer amount
baseLayerDatabytesAdditional data to be interpreted by the base layer
execLayerDatabytesAdditional data to be interpreted by the execution layer

Returns

NameTypeDescription
<none>bytesThe encoded input payload

decodeErc1155SingleDeposit

Decode an ERC-1155 single token deposit.

function decodeErc1155SingleDeposit(bytes calldata payload)
    internal
    pure
    returns (Erc1155SingleDeposit memory deposit);

Parameters

NameTypeDescription
payloadbytesThe encoded input payload

Returns

NameTypeDescription
depositErc1155SingleDepositThe decoded ERC-1155 single token deposit

encodeBatchErc1155Deposit

Encode an ERC-1155 batch token deposit.

baseLayerData should be forwarded to token.

function encodeBatchErc1155Deposit(
    IERC1155 token,
    address sender,
    uint256[] calldata tokenIds,
    uint256[] calldata values,
    bytes calldata baseLayerData,
    bytes calldata execLayerData
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
tokenIERC1155The ERC-1155 token contract
senderaddressThe token sender
tokenIdsuint256[]The identifiers of the tokens being transferred
valuesuint256[]Transfer amounts per token type
baseLayerDatabytesAdditional data to be interpreted by the base layer
execLayerDatabytesAdditional data to be interpreted by the execution layer

Returns

NameTypeDescription
<none>bytesThe encoded input payload

decodeErc1155BatchDeposit

Decode an ERC-1155 batch token deposit.

function decodeErc1155BatchDeposit(bytes calldata payload)
    internal
    pure
    returns (Erc1155BatchDeposit memory deposit);

Parameters

NameTypeDescription
payloadbytesThe encoded input payload

Returns

NameTypeDescription
depositErc1155BatchDepositThe decoded ERC-1155 batch token deposit