safeTransfer with token erc1155 in solidity 0.8
safeTransfer with token erc1155 in solidity 0.8
我收到这个错误
ERC1155: transfer to non ERC1155Receiver implementer
当尝试转移到智能合约时,我找到了这个文档 https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155 但仍然不知道如何解决这个问题我是否必须在我的持有人令牌 1155[= 中抽象 IERC1155Receiver
接口13=]
接收合约需要根据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)"));
}
}
我收到这个错误
ERC1155: transfer to non ERC1155Receiver implementer
当尝试转移到智能合约时,我找到了这个文档 https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155 但仍然不知道如何解决这个问题我是否必须在我的持有人令牌 1155[= 中抽象 IERC1155Receiver
接口13=]
接收合约需要根据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)"));
}
}