ERC1155A

Introduction

ERC1155A is a Superform extension of the ERC1155 standard which introduces valuable additional functionality. This contract is abstract and is implemented in SuperPositions.

Key features include single id approvals, range-based approvals, and the ability to convert between ERC20 tokens and the native ERC1155A token format.

Core Concepts

There are two major components of ERC1155A:

  1. Setting approval for individual, many, and all ids

  2. Allowing the creation of an aERC20 token for a specific id, allowing users to transmute ERC1155A token ids to an aERC20 and vice-versa for better composability

Approvals

Users can either approve individual ERC1155A ids through setApprovalForOne, range-based through setApprovalForMany, and all ids through setApprovalForAll. This functionality was added to ERC1155 to create better UX and security around the standard while allowing the management of multiple ids simultaneously.

The allowance for any given id can be checked at any time by calling allowance for a user, operator, and an id.

setApprovalForOne

This function is used to set an approval for an individual id. After a single approval for an id is set, it can be increased via increaseAllowance and decreased via decreaseAllowance, which take in the same parameters although the amount passed is just the increment.

function setApprovalForOne(
    address operator,
    uint256 id,
    uint256 amount) public virtual
NameDescription

operator

address actioning the expenditure of 1155 from msg.sender to an operator

id

uint256 id of the 1155

amount

uint256 amount being approved

setApprovalForMany

This function is used to set an approval for multiple ids at a time. To change the allowances of multiple ids at a time, increaseAllowanceForMany and decreaseAllowanceForMany can be called, which take in the same parameters although the amount passed is just the increment.

function setApprovalForMany(
    address operator,
    uint256[] memory ids,
    uint256[] memory amounts) public virtual
NameDescription

operator

address actioning the expenditure of 1155 from msg.sender to an operator

ids

uint256[] ids of the 1155

amount

uint256[] amounts being approved

setApprovalForAll

This function is inherited from ERC1155, and provides the spender with allowance for all currently existing and future ERC1155 ids in the contract.

function setApprovalForAll(
    address operator,
    bool approved) public virtual
NameDescription

operator

address actioning the expenditure of 1155 from msg.sender to an operator

approved

bool to indicate if the address is approved spend ids

Transmuting to ERC20

ERC1155A allows for token ids to be transmuted to ERC20s, and vice-versa to allow for better composability. Token ids must be registered before they can be transmuted.

registerERC20

This function allows the creation of an ERC20 token representations for a specific ERC1155A token id if it hasn't already been created yet.

function registerAERC20(
    uint256 id
) external payable virtual override returns (address)

getERC20Address

This function provides the ability to query the address of the ERC20 token associated with a specific ERC1155A token id if it has been registered.

function getAERC20Address(
    uint256 id
) external view virtual override returns (address)

transmuteToERC20 / transmuteBatchToERC20

This function converts specified amount(s) of ERC1155A token(s) to corresponding registered ERC20 token(s).

function transmuteToERC20(
    address owner,
    uint256 id,
    uint256 amount,
    address receiver
) external override

function transmuteBatchToERC20(
    address owner,
    uint256[] memory ids,
    uint256[] memory amounts,
    address receiver
) external override
namedescription

owner

address of the user transmuting

id

uint256 ERC1155A id

amount

uint256 amount to transmute

receiver

address to send the transmuted ERC20 tokens

transmutetoERC1155A / transmuteBatchToERC1155A

This function converts specified amount(s) of ERC20 token(s) to their corresponding ERC1155A tokenId(s).

function transmuteToERC1155A(
    address owner,
    uint256 id,
    uint256 amount,
    address receiver
) external override

function transmuteBatchToERC1155A(
    address owner,
    uint256[] memory ids,
    uint256[] memory amounts, 
    address receiver
) external override
namedescription

owner

address of the user transmuting

id

uint256 ERC1155A id

amount

uint256 amount to transmute

receiver

address to send the ERC1155 tokenId to

Last updated