我收到此错误
ERC1155:转移到非 ERC1155Receiver 实现者
当尝试转移到智能合约时,我发现了这个文档 https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155但仍然不知道如何解决这个问题,我是否必须在我的持有者 token 1155 中抽象 IERC1155Receiver
接口(interface)
最佳答案
接收合约需要基于ERC-721实现onERC1155BatchReceived()
函数定义。
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)"));
}
}
关于solidity - 使用 Solidity 0.8 中的代币 erc1155 进行安全传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68662387/