safeTransferFrom/safeBatchTransferFrom
function so that the token can be correctly wrapped and unwrappedmintItems
function.safeTransferFrom
/ safeBatchTransferFrom
function to the ERC1155 Deck Wrapper contract, which implements onERC1155Received
and onERC1155BatchReceived
.CreateItem
-> data for wrapping an ERC1155.reserveArrays
-> boolean value that expresses whether the wrap is to be reserved (true) or unreserved (false). CreateItem
and reserveArrays
must be the same; each CreateItem
must correspond to its sequentially equivalent value in reserveArrays
.CreateItem
struct must be passed, as follows: Header
-> composed of address
host
, string
name
, string
symbol
and string
uri.
Pass as empty; these parameters are automatically populated by the contract. See here for more info.collection
-> encoded token address of the ERC1155 being wrapped.id
-> id of the ERC1155 being wrapped.accounts
-> receiver(s) of the Deck Item. Pass as address(0)
to set as msg.sender
, or pass as any other address(es).amounts
-> quantity of the ERC1155 to wrap. Must be expressed in 0 decimals if you're wrapping a 0 decimal 1155 token, or in 18 decimals if you're wrapping an 18 decimal 1155 token. For example, pass as 1 if wrapping 1 of a 0 decimal ERC1155; as 2 if wrapping 2 of a 0 decimal ERC1155; as 1e18 if wrapping 1 of an 18 decimal ERC1155; etc.amounts
to multiple accounts
. The lengths of the amounts
and accounts
arrays must be the same; each amount
value must correspond to its sequentially equivalent account
value.Six Zerions (id 10) are wrapped by an address; the first three reserved, the other three unreserved.CreateItem1
Header -> - host:0x00..
, - name: " ", symbol: " ", uri: " " collection -> 0x00000000000000000000000074ee68a33f6c9f113e22b3b77418b75f85d07d22 id -> 10 accounts -> 0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4 amounts -> 3CreateItem2
Header -> - host:0x00..
, - name: " ", symbol: " ", uri: " " collection -> 0x00000000000000000000000074ee68a33f6c9f113e22b3b77418b75f85d07d22 id -> 10 accounts -> 0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4 amounts -> 3reserveArray: [true, false]
mintItems
function, multiple different ERC1155 tokens can be wrapped in a single transaction by passing multiple CreateItem
structs at once.mintItems
function returns the created itemIds
.onERC1155Received
safeTransferFrom
function to send the token to the ERC1155 Deck Wrapper contract, which calls the onERC1155Received
function. data
parameter of safeTransferFrom
must contain the following encoded parameters:Uint256 [] values
-> the amount of newly wrapped Deck Items to send to each receiver address. The values must be expressed in 0 decimals (such as 1, 2, 3 and so on) if wrapping a 0 decimal ERC1155, or in 18 decimals (1e18,2e18 and so on) if wrapping an 18 decimal ERC1155.Address[] receivers
-> receiver(s) of the Deck Item. values []
and receivers[]
must be the same; each value in values[]
must correspond to its sequentially equivalent value in receivers[]
.Bool reserve
-> boolean value that expresses whether the wrap is to be reserved (true) or unreserved (false). values
and receivers
are analogous to the amounts
and accounts
parameters of the mintItems
function.2 Parallels are sent (id 10144) to be wrapped as Deck Items with reservations to the ERC1155 Deck Wrapper contract, usingsafeTransferFrom
with the following encodeddata
:
Uint256 [] values
-> 2Address[] receivers
-> 0x82465CB46506563f66285f18da7adD332e813A42Bool reserve
-> true
onERC1155BatchReceived
safeBatchTransferFrom
function to send the tokens to the ERC1155 Deck Wrapper contract, which calls the onERC1155BatchReceived
function. data
parameter of the safeBatchTransferFrom
function must be a bytes[]
. For each id being wrapped, each element of the array must contain the following encoded parameters:Uint256 [] values
-> the amount of the Deck Item (in 0 decimals) to send to each receiver address. Address[] receivers
-> receiver addresses for the Deck Item. values []
and receivers[]
must be the same; each value in values[]
must correspond to its sequentially equivalent value in receivers[]
.Bool reserve
-> boolean value that expresses whether the wrap is to be reserved (true) or unreserved (false). 2 Parallels (id 10144) are wrapped with reserve; and 3 Zerions are wrapped with reserve (id 10).The holder address usessafeBatchTransferFrom
to send the token with the following encodeddata
:data1:
Uint256 [] values
-> 2Address[] receivers
-> 0x82465CB46506563f66285f18da7adD332e813A42Bool reserve
-> truedata2:
Uint256 [] values
-> 3Address[] receivers
-> 0x82465CB46506563f66285f18da7adD332e813A42Bool reserve
-> true
reserve
corresponds to a such a quantity.reserve
, only the address that wrapped it (i.e. the msg.sender
of the mintItems
/safeTransferFrom
/safeBatchTransferFrom
function) can unwrap and retrieve it for the following 10 days (in blocks). Each reserve
corresponds to a struct: address
unwrapper
-> msg.sender
of the mintItems
/safeTransferFrom/safeBatchTransferFrom
function.uint256
timeout
-> blocks for which the ERC1155 is reserved. Equal to block.number + reserveTimeInBlocks
, where reserveTimeInBlocks
is the number of blocks that are estimated to correspond to 10 days.unwrapper
address transfers the Deck Item to another account, that account will be unable to unwrap it until the end of the 10 day reservation period, at which point it becomes unreserved and can be unwrapped by anyone.reserveDataKey
(bytes32
) is created every time a reservation is generated.reserveDataKeys
, each time a quantity of ERC1155s is wrapped with a reserve, a ReserveData
event is emitted:unlockReserves
function:address[]
owners
-> address of the unwrapper
.address[]
tokenAddress
-> address of the original ERC1155 to unlock.uint256[]
tokenIds
-> id of the original ERC1155 to unlock.uint256[]
amounts
-> reserved amount to unlock. Must be equal to the total reserved amount; you can't partially unlock a reservation.unlockReserves
to unlock multiple reserves at once.burn
function, or in batch mode, by using the burnBatch
function. address
account
-> address of the Deck Item holder.uint256
itemId
-> id of the Deck Item to unwrap (burn).uint256
amount
-> amount of Deck Item to unwrap (burn).bytes
data
-> data in bytes format that must contain the following encoded parameters:address
tokenAddress
-> token address of the original ERC1155.uint256
tokenId
-> id of the original ERC1155.address
receiver
-> address that will receive the original ERC1155. Pass as address(0)
to set as msg.sender
, or pass as any other address.bytes32[]
reserveDataKeys
-> reserve key to be unwrapped. Pass as empty (0x00..
) if unwrapping (burning) a quantity of unreserved ERC1155s.bytes
data
-> eventual optional data to perform a safeTransferFrom
.1)2 (in 18 decimals) Zerion Deck Items are unwrapped (burned) to retrieve 2 unreserved Zerions (id10).
account
->0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4
itemId
-> id of the Bored Ape Deck Item, for example 583149398095120659341456634amount
->200000000000000000000000000
data
->data = web3.eth.abi.encodeParameters( ["address", "uint256", "address", "bytes32[]", "bytes"], ["0x74EE68a33f6c9f113e22B3B77418B75f85d07D22", "10", "0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4", "0x00..", "0x"] );
2)2 (in 18 decimals) Parallel Deck Items are unwrapped (burned) to retrieve 2 reserved Parallels (id10144).
account
->0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4
itemId
-> id of the Parallel Deck Item, for example9717612899372047983059638622121
amount
->200000000000000000000000000
data
->data = web3.eth.abi.encodeParameters( ["address", "uint256", "address", "bytes32[]", "bytes"], ["0x76BE3b62873462d2142405439777e971754E8E77", "10144", "0x998093DF3d61dDDae8F4a84e02e12c78b3751cC4", "0x66ca656de9e6ad847f83f20e17f774cef9394447dc3887c958f5426ae09b5730", "0x"] );
burnBatch
, multiple Deck Items can be unwrapped at once—even multiple Deck Items from different Decks. uint256[]
itemId
and uint256[]
amount
-> arrays of values; you can unwrap multiple tokens at once.bytes
data
->the data
parameter in bytes format is an encoded value that represents a bytes[]
(one for each Deck Item involved in the operation) containing the five parameters explained above in the burn section.burn
/burnBatch
, if you unwrap (burn) a reserved quantity less than your total reserved quantity, the entire reserve is automatically unreserved. For example, if your reserved amount is 10 and you unwrap 3, the other 7 tokens automatically become unreserved, and can be unwrapped by anyone. reserveDataKeys
must still be passed at the time of unwrapping. And since the reservation is expired but not yet dissolved, anyone can pass that key to unwrap the tokens.ReserveDataUnlocked
event is emitted:1) ERC1155s wrapped Parallel id 10144, unreservedParallel Deck ItemtotalSupply
0.9e18A Parallel Deck Item holder can unwrap one (id 10144) by burning at least 0.51e18.2)ERC1155s wrapped Parallel id 10144 & Parallel id 15255, both unreservedParallel Deck ItemstotalSupply
0.6e18A Parallel Deck Item holder can unwrap one by burning at least 0.51e18.
1e18-Deck Item total supply
. amounts
parameter of the mintItems
/safeTransferFrom
function whenever more of that ERC1155 is wrapped.1)Parallel Deck Items totalSupply 0.3e18When you wrap your Parallel, you obtain 0.7e18 Parallel Deck Item and you have to pass 0.7e18 as amounts parameter of mintItems/safeTransferFrom2)Parallel Deck Items totalSupply 0.1e18When you wrap 2 Parallel ERC1155s, you obtain 1.9e18 Parallel Deck Items, and you have to pass 0.9e18 as amounts parameter for the first one, and 1e18 for the second one ofmintItems
/safeTransferFrom
.
totalSupply
is equal to 1e18.burn
function of the Interoperable Item Interface (ERC20 face of the Item). Recall that an Item has two faces, allowing it to work simultaneously as an ERC1155 (using its Main Interface) and as an ERC20 (using its Interoperable Interface).