Solidity
持有者和最大供應量未在 Ropsten Etherscan 上更新
我已經為 erc721 代幣創建了合約。該合約繼承了 open-zeppelin ERC721 智能合約。當我在 remix 上部署我的契約時,我可以正確查看供應量,但是 ropsten 上的最大供應量和持有者數量始終為 0。誰能指出是什麼問題。我的程式碼如下:
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/token/ERC721/ERC721.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/utils/Counters.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/access/Ownable.sol"; contract CryptoGogos is Ownable, ERC721 { using Counters for Counters.Counter; Counters.Counter private _tokenIds; //Counter is a struct in the Counters library uint constant total_supply =7777; //refers to the combined token amounts uint public entered_supply; string public check_name; string internal _tokenURI; address _address; constructor() ERC721("CryptoGogos", "CGG") public { _address = msg.sender; } //Cards is actually to create a mapping of token id to their tokenURI struct Cards{ string name; uint supply; //refers to the total supply of each token string cat; uint card_id; //series number in our case string description; string image_url; } Cards[] private card; mapping(uint =>Cards) public tokeninfo; /*tokenURI is the url for metadata in json format. bytes32 array is used to receive parsed json data for minting in the following order: params[0] = name params[1] = supply params[2] = category params[3] = description params[4] = image url */ function drawCard(uint _supply) public { require(_supply<total_supply, "Input supply is not less than total supply of cards."); _tokenIds.increment(); uint newNftTokenId = _tokenIds.current(); Cards memory c; c.card_id = newNftTokenId; c.supply = _supply; (string memory tu, string memory n, string memory d,string memory ct,string memory i) = getTokenURI(_supply); c.name = n; _tokenURI = tu; c.description = d; c.cat= ct; c.image_url = i; card.push(c); tokeninfo[newNftTokenId] = c; _safeMint(_address,newNftTokenId) ; _setTokenURI(newNftTokenId,_tokenURI); } //passing supply which is user inputted paramter function getTokenURI(uint _supply) internal view returns (string memory ,string memory , string memory , string memory , string memory ){ string memory t1="This is token URI"; string memory n1 = "token name"; string memory d1= "token description"; string memory _c1="token category"; string memory _i ="image url"; return (t1,n1,d1,_c1,_i); } function _safeMint(address to, uint256 tokenId) internal override onlyOwner { _safeMint(to, tokenId, ""); } function viewCategory(uint _tokenid) public view returns (string memory) { return (tokeninfo[_tokenid].cat); } function viewNumberofCards() public view returns (uint) { return _tokenIds.current(); } function viewName(uint _tokenid) public view returns (string memory){ return (tokeninfo[_tokenid].name); } function viewDescription(uint _tokenid) public view returns (string memory){ return (tokeninfo[_tokenid].description); } function viewImageUrl(uint _tokenid) public view returns (string memory){ return (tokeninfo[_tokenid].image_url); } function viewtokenURI() public view returns (string memory){ return (_tokenURI); } function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenIds.current(); } }
這不是您的程式碼的問題,而是 Etherscan 的問題。事實上,由於未知原因,Etherscan 在兩週內不再跟踪 Ropsten
totalSupply
和ERC20 和 ERC721 代幣。holders
您可以在這個 Wrapped Ether ERC20 令牌上看到同樣的問題:https ://ropsten.etherscan.io/token/0xc778417e063141139fce010982780140aa0cd5ab 。
在這個 DAI ERC20 令牌上:https ://ropsten.etherscan.io/token/0xad6d458402f60fd3bd25163575031acdce07538d