账号A先在ERC721中对合约地址ApproveAll,然后账号A调用函数some(合约地址,某个nftID)
contract Town is IERC721Receiver,ERC165{
constructor(){}
function some(address nft,uint256 _tokenId) public {
IERC721(nft).transferFrom(msg.sender,address(this), _tokenId);
}
function onERC721Received(
address,
address from,
uint256,
bytes calldata
) external pure override returns (bytes4) {
require(from == address(0x0), "Cannot send tokens to Barn directly");
return IERC721Receiver.onERC721Received.selector;
}
}
错误提示为“
Reason provided by the contract: "ERC721: transfer caller is not owner nor approved"
```”
谢谢大哥们解答