注意:此为一份ERC721合约样例的简要声明。 contract ERC721 { // ERC20 compatible functions function name() constant returns (string name); function symbol() constant returns (string symbol); function totalSupply() constant returns (uint256 totalSupply); function balanceOf(address _owner) constant r...
-- 1.CryptoKitties Deployed Contract. 2.XXXXERC7213.ERC721ExampleDeed--> 参考文献 EIPS-165 EIPS-721 ☛深入浅出区块链- 系统学习区块链,打造最好的区块链技术博客。 ☛ 我的知识星球为各位解答区块链技术问题,欢迎加入讨论。 ☛ 关注公众号“深入浅出区块链技术”第一时间获取区块链技术信息。
import "./erc721.sol"; contract ZombieOwnership is ZombieAttack, ERC721 { function balanceOf(address _owner) public view returns (uint256 _balance) { return ownerZombieCount[_owner]; } function ownerOf(uint256 _tokenId) public view returns (address _owner) { return zombieToOwner[_tokenId]...
所以在讲 ERC721 的主合约之前,我们会花两讲在引用的库合约和接口合约上。ERC721 相关库 Address 库 Address 库是 Address 变量相关函数的合集,包括判断某地址是否为合约,更安全的 function call。ERC721 用到其中的 isContract():这个函数利用了非合约地址 account.code 的长度为 0 的特性,从而区分某个...
// contracts/GameItem.sol// SPDX-License-Identifier: MITpragmasolidity^0.6.0;import"@openzeppelin/contracts/token/ERC721/ERC721.sol";import"@openzeppelin/contracts/utils/Counters.sol";contractGameItemisERC721{usingCountersforCounters.Counter; Counters.Counterprivate_tokenIds;constructor()publicERC721("...
ERC721Pausable: A primitive to pause contract operation. ERC721Burnable: A way for token holders to burn their own tokens. ERC721Wrapper: Wrapper to create an ERC-721 backed by another ERC-721, with deposit and withdraw methods. Useful in conjunction with ERC721Votes. This core set of con...
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(...
在合约地址上使用附加数据(input data)0x01ffc9a701ffc9a700000000000000000000000000000000000000000000000000000000和 gas 30,000 进行STATICCALL调用,相当于contract.supportsInterface(0x01ffc9a7)。 如果调用失败或返回false , 说明合约不兼容ERC-165标准 如果返回true,则使用输入数据0x01ffc9a7ffffffff000000000000000000000000000...
pragmasolidity^0.8.0;import"./utils/introspection/IERC165.sol";/*** @dev Required interface of an ERC721 compliant contract.*/interfaceIERC721isIERC165{// ===事件===// 代币转移事件,当发生代币转移时触发eventTransfer(addressindexedfrom,addressindexedto,uint256indexedtokenId);// 代币授权事件...
contract MyNFT is ERC721Enumerable,Ownable {} 使用is将我们需要用到的文件方法继承到这份主合约中,这样,我们就能使用来自继承到合约的所有方法了。 using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; ...