0

I have created ERC-721 standard but on etherscan (Ropsten) it's still showing ERC-20 standard in overview Below are my contract code, please share your thought if I'm doing something wrong.



contract ERC721Token {

 function name() external view returns (string memory);
   function symbol() external view returns (string memory);
   function totalSupply() external view returns (uint256);
   function balanceOf(address _owner) external view returns (uint balance);
   // Functions that define ownership
   function ownerOf(uint256 _tokenId) external returns (address owner);
   function approve(address _to, uint256 _tokenId) external returns (bool success); 
   function takeOwnership(uint256 _tokenId) external returns (bool success); 
   function transfer(address _to, uint256 _tokenId) external returns (bool success); 
   function tokenOfOwnerByIndex(address _owner, uint256 _index) external returns (uint tokenId);
   // Token metadata
   function tokenMetadata(uint256 _tokenId) external returns (string memory infoUrl);
   // Events
   event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
   event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}

contract TestToken is ERC721Token {

  string  public name;
  string  public symbol;
  uint8   public decimals;
  uint256 public totalTokens;
   mapping(address => uint) private balances;
   mapping(uint256 => address) private tokenOwners;
   mapping(uint256 => bool) private tokenExists;
   mapping(address => mapping (address => uint256)) private allowed;
   mapping(address => mapping(uint256 => uint256)) private ownerTokens;

  constructor(
        uint256 _totalTokens,
        string memory _tokenName,
        uint8 _decimalsPoints,
        string memory _tokenSymbol
        ) public {
        balances[msg.sender] = _totalTokens;
        symbol = _tokenSymbol;
        name = _tokenName;
        decimals = _decimalsPoints;
        totalTokens = 100000000 * (10 ** uint256(decimals));
        emit Transfer(address(0), msg.sender, totalTokens);
    }



   function totalSupply() public view returns (uint256){
       return totalTokens;
   }
   function balanceOf(address _owner) public view returns (uint){
       return balances[_owner];
   }
   function ownerOf(uint256 _tokenId) public returns (address){
       require(tokenExists[_tokenId]);
       return tokenOwners[_tokenId];
   }

  function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
    require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
    balances[_to] += _value;
    balances[_from] -= _value;
    allowed[_from][msg.sender] -= _value;
    emit Transfer(_from, _to, _value);
    return true;
  }

  function approve(address _spender, uint256 _value) public returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
  }

  function takeOwnership(uint256 _tokenId) public returns(bool success){
      require(tokenExists[_tokenId]);
      return true;
  }

  function transfer(address _to, uint256 _value) public returns (bool success) {
    require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
    //require(_to != 0x0);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    emit Transfer(msg.sender, _to, _value);
    return true;
  }
  function tokenOfOwnerByIndex(address _owner, uint256 _index) public returns (uint _tokenId) {
      return 5;
  }
  function tokenMetadata(uint256 _tokenId) public returns (string memory infoUrl) {
     require(tokenExists[_tokenId]);
     return "ss";
  }
}



1

This is not erc721 standard this is erc20 standard function. For the etherscan to recognise your contract as erc72 your contract interface must implement the erc721 contract standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md. I don't see your safeTransfer function or ApprovalForAll event.

The etherscan recognises your contract as erc20 because in your interface you implemented erc20 standard: https://github.com/ethereum/EIPs/issues/20

  • I changed as per erc721.org it's working but now the token balance is not transfer into the token owner's account, while deploying contract. m using this in constructor(){ ` emit Transfer(address(0), _msgSender(), totalTokens) ` } – Heartbeat Jan 3 at 13:19
  • 1
    @heartbeat i think u should ask that on another question about this because this is not relevent to the question. it Is ok to ask many question but create seperate question each please i can’t read the code in the comment and i don’t understand the issue. So create a separate question maybe i will see if i can help. And btw add more detail the bug what did you do, what have you try and the code – haxerl Jan 3 at 13:42
  • all right, will do – Heartbeat Jan 3 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.