Burn an Index token
To burn one or more Index tokens, use the safeTransferFrom
or safeBatchTransferFrom
method directly from the Index token collection itself, as follows:
from
->address
calling thesafeTransferFrom
/safeBatchTransferFrom
functionto
-> index contractaddress
(representing the Item extensionaddress
)objectId/Ids
->objectId
of the specific index to be burn, or an array ofobjectIds
of the various index tokens to burn in the case of asafeBatchTransferFrom
amount
-> amount of the index token to burn, or an array of amounts that represent the various index tokens (corresponding to their specificobjectId
in the array of the previous input) to burn
Regarding the data
input:
in case of
safeTransferFrom
-> thepayload
can be an address that represents the one who will receive the tokens after burning the index. The payload can also be empty (with a length == 0) or0x0000000000000000000000000000000000000000
; in both cases, the tokens corresponding to the burned Index will be sent to the one who sent the Index to be burned.in case of
safeBatchTransferFrom
-> the payload must be an array of bytes (and therefore abytes[ ]
type) of the same length of the objectIds array you are sending, so there must be necessarily one bytes element for eachobjectId
sent. Each element of the bytes array represents the address of the receiver of that specific tokens amount returned by the burn. Each address can be equal to0x0000000000000000000000000000000000000000
; in this case, the tokens corresponding to the burned Index will be sent to the one who sent the Index to be burned.
The onERC1155Received/onERC1155BatchReceived
function takes care of burning the Index token amount that arrives in the Index extension contract. It calls inside the _onSingleReceived
function, retrieves the tokens linked to the objectId(s)
of the Index token(s) to be burned and calculates the relative amounts as:
Then it transfers the tokens via _safeTransfer
:
Please refer to Index Frontend integration for more details.
Last updated