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:
Setting approval for individual, many, and all ids
Allowing the creation of an
aERC20
token for a specific id, allowing users to transmute ERC1155A token ids to anaERC20
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.
Name | Description |
---|---|
| address actioning the expenditure of 1155 from msg.sender to an operator |
| uint256 id of the 1155 |
| 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.
Name | Description |
---|---|
| address actioning the expenditure of 1155 from msg.sender to an operator |
| uint256[] ids of the 1155 |
| 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.
Name | Description |
---|---|
| address actioning the expenditure of 1155 from msg.sender to an operator |
| 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.
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.
transmuteToERC20 / transmuteBatchToERC20
This function converts specified amount(s) of ERC1155A token(s) to corresponding registered ERC20 token(s).
name | description |
---|---|
| address of the user transmuting |
| uint256 ERC1155A id |
| uint256 amount to transmute |
| 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).
name | description |
---|---|
| address of the user transmuting |
| uint256 ERC1155A id |
| uint256 amount to transmute |
| address to send the ERC1155 tokenId to |
Last updated