Deploy ERC721 failed on private chain

Hello,

I used the code from openzepplin. It is okay to deploy on public chain and test chain but failed on private chain. Is there any smart contract I hv deploy first ?

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol";

contract MyNFT is ERC721Full, ERC721Mintable {
    constructor() ERC721Full("MyNFT", "MNFT") public {
    }
}
1 Like

Hi, the most up to date way to deploy an ERC721 with respect to open zeppelin smart contract can be found here. https://docs.openzeppelin.com/contracts/3.x/erc721

2 Likes

Hello Aizea,
Yes, the code can be deployed and work in public chain and test chain- ropsten, kovan, and Rinkey, But cannot deploy on my private chain so I doubt whether any contract address in openzepplin contract should I hv to deploy on private chain like ERC820

1 Like

Hi @kennethhutw,

Welcome to the community :wave:

Can you share the errors that you get when deploying to your private chain and also give some more information about your private chain?

What tool did you use to deploy? What EVM version is your private chain?

I generally wouldn’t expect issues deploying a contract extending from OpenZeppelin Contracts (the only exception is ERC777 where you need to deploy the ERC1820 registry first).

hello abcoathup,
Thanks for asking , I use remix to deploy ERC721. I only get transaction failed no further information. I deployed EnumerableMap, EnumerableSet, SafeMath successfully on vm and privatechain, only deploy ERC721 failed

My dev environment as following :
geth - 1.7.3-stable-4bb3c89d

myNFT - https://drive.google.com/file/d/1454wXTKxgpwFz6As97zTwbyt_HZqM6uA/view?usp=sharing

genesis.json - https://drive.google.com/file/d/1N5Dgsd5zh7urZikx0mxdfY06mmdWBlh-/view?usp=sharing

hello @abcoathup ,
Thanks for asking and reply , I use remix to deploy ERC721. I only get transaction failed no further information. I deployed EnumerableMap, EnumerableSet, SafeMath successfully on vm and privatechain, only deploy ERC721 failed.

I doubt three points.

  1. ERC165 - _registerInterface do I need to deploy any contract for this ?

    function _registerInterface(bytes4 interfaceId) internal virtual {
       require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
     function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    

    }

    constructor(string memory name_, string memory symbol_) public {
    _name = name_;
    _symbol = symbol_;
    // register the supported interfaces to conform to ERC721 via ERC165
    _registerInterface(_INTERFACE_ID_ERC721);
    _registerInterface(_INTERFACE_ID_ERC721_METADATA);
    _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }
    

secondly - abi in ERC721 contract. it looks like a feature in solidity, right ? Is abi internal variable ? if yes, which version of geth support this new feature ?

 function tokenURI(uint256 tokenId)
     public
     view
      override 
    returns (string memory)
  {
       require(
          _exists(tokenId),
          "ERC721Metadata: URI query for nonexistent token"
     );

     string memory _tokenURI = _tokenURIs[tokenId];

      // If there is no base URI, return the token URI.
      if (bytes(_baseURI).length == 0) {
        return _tokenURI;
     }
     // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
      if (bytes(_tokenURI).length > 0) {
          return string(abi.encodePacked(_baseURI, _tokenURI));
      }
     // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
      return string(abi.encodePacked(_baseURI, tokenId.toString()));
  }

thirdly - enable EIPs what eips I missed in genesis.json

        "miningMethod" : "NoProof",
        "homesteadForkBlock": "0x00",
     	"EIP150ForkBlock": "0x00",
	    "EIP158ForkBlock": "0x00",
	    "byzantiumForkBlock": "0x00",
	    "constantinopleForkBlock": "0x00",

My dev environment as following :
geth - 1.7.3-stable-4bb3c89d

myNFT - https://drive.google.com/file/d/1454wXTKxgpwFz6As97zTwbyt_HZqM6uA/view?usp=sharing

genesis.json - https://drive.google.com/file/d/1N5Dgsd5zh7urZikx0mxdfY06mmdWBlh-/view?usp=sharing

1 Like

hello @abcoathup I resolved. This is because we don’t enable istanbulBlock EIP in genesis.json. However, I don’t understand why istanbulBlock EIP will cause this issue.

Do you know why ?

Best Wishes
Kenneth

1 Like

Hi @kennethhutw,

I’m glad you were able to resolve.

If your private chain is using a different EVM version then you would need to specify this version when you compile.

I am not sure which EIP would cause the issue, I had a quick look through: An overview of the upcoming Istanbul hard fork

1 Like

Hello @abcoathup ,

Thank you very much for your reply

1 Like