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 the safeTransferFrom/safeBatchTransferFrom function

  • to -> index contract address (representing the Item extension address)

  • objectId/Ids -> objectId of the specific index to be burn, or an array of objectIds of the various index tokens to burn in the case of a safeBatchTransferFrom

  • amount -> amount of the index token to burn, or an array of amounts that represent the various index tokens (corresponding to their specific objectId in the array of the previous input) to burn

Regarding the data input:

  • in case of safeTransferFrom -> the payload 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) or 0x0000000000000000000000000000000000000000; 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 a bytes[ ] type) of the same length of the objectIds array you are sending, so there must be necessarily one bytes element for each objectId 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 to 0x0000000000000000000000000000000000000000; 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:

theCollection.burn(objectId, value)
for(uint256 i = 0; i < tokens[objectId].length; i++) {
    uint256 tokenValue = (amounts[objectId][i] * value) / 1e18;

Then it transfers the tokens via _safeTransfer:

if(tokens[objectId][i] == address(0)) {
    (bool result,) = receiver.call{value:tokenValue}("");
    require(result, "ETH transfer failed");
} else {
    _safeTransfer(tokens[objectId][i], receiver, tokenValue);

Please refer to Index Frontend integration for more details.

Last updated