safeTransfer with token erc1155 in solidity 0.8

Viewed 584
1 Answers

The receiving contract needs to implement the onERC1155BatchReceived() function based on the ERC-721 definition.

pragma solidity ^0.8;

contract MyContract {
    function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns(bytes4) {
        // here you can (but don't have to) define your own logic - emit an event, set a storage value, ...

        // this is the required return value described in the EIP-721
        return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
    }
}
Related