0

I am trying to deploy Smart-contract(ERC721) on my private ethereum network.

But I have this issue.d Here is my genesis.

{
    "config": {
        "chainId": 3333,
        "homesteadBlock": 1,
        "eip150Block": 2,
        "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "eip155Block": 3,
        "eip158Block": 3,
        "byzantiumBlock": 4,
        "constantinopleBlock": 5,
        "clique": {
          "period": 5,
          "epoch": 30000
        }
      },
      "nonce": "0x0",
      "timestamp": "0x5d29c706",
      "extraData": "0x00000000000000000000000000000000000000000000000000000000000000000044b84dc52f7f9551ee3285b7f193ec67bcabf30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "gasLimit": "0xC1C960",
      "difficulty": "0x1",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "coinbase": "0x0000000000000000000000000000000000000000",
      "number": "0x0",
        "gasUsed": "0x0",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "alloc"      : {
        "0x12CA9233383Ab9a15473b9a0c4E70eB68EF3bBbC": {
            "balance":"100000000000000000000"
        },
        "0x951e32829cB884e7E8c91Ea130942DF663503F64": {
            "balance":"100000000000000000000"
        },
        "0x9e693059a0CAb71f88Fd8fCaF303520541298eEE": {
            "balance":"100000000000000000000"
        },
        "0xB23B97c9d1703d4D381bD95bE9576F1787239d09": {
            "balance":"100000000000000000000"
        },
        "0xE9Ae8A724c92Fd83E88fAA463B327421F7db7B72": {
            "balance":"100000000000000000000"
        }
    }
  }

I tried with truffle, but it has the same issue.

Here is my smartcontract

pragma solidity ^0.5.0;

import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Enumerable.sol";
import "../node_modules/openzeppelin-solidity/contracts/access/roles/MinterRole.sol";

contract FanTheBase is ERC721, ERC721Metadata, ERC721Enumerable {


    constructor () ERC721Metadata("FanTheBase", "FTB") public {
        // solhint-disable-previous-line no-empty-blocks
    }

    struct Color {
        uint8 red;
        uint8 green;
        uint8 blue;
    }

    Color[] colors;

    function mint() public {
        Color memory _color = Color(uint8(now), uint8(now-1000), uint8(now-5500));
        uint _id = colors.push(_color);
        _mint(msg.sender, _id);
    }

    function getColorFromId(uint id) public view returns (uint8, uint8, uint8){
        return (colors[id].red, colors[id].green, colors[id].blue);
    }

}

it works with ganache or ropsten Test Network. But it gives me an error when I am trying to deploy it on private network.

I created POA on the aws, I needed to check the smart contract will work on private network before deploying on POA.

  • Instead of import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; you could have import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; or use the new naming import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; – abcoathup Aug 19 at 5:56
1

The error states that either the deployment is always failing or it exceeds the gas limit.

You may want to try deploying to ganache-cli local testnet as I suspect that your deployment is failing on a revert and you will want to see the reason message. Alternatively you could share your smart contract code.


I deployed the following sample ERC721 using the OpenZeppelin Contracts implementation to Rinkeby using Remix and the gas was: 2,842,493

https://rinkeby.etherscan.io/tx/0x3428fd9210e59c94c89c1397bd6df962ed018573ead524cbf085b1dc22034e37

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC721/ERC721Full.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/drafts/Counters.sol";

contract GameItem is ERC721Full {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721Full("GameItem", "ITM") public {
    }

    function awardItem(address player, string memory tokenURI) public returns (uint256) {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

If you are creating ERC721 tokens you may want to look at the OpenZeppelin Contracts implementation to see if this meets your needs. See the documentation for details: https://docs.openzeppelin.com/contracts/2.x/tokens#ERC721

If you have questions on using OpenZeppelin you can ask in the Community Forum: https://forum.openzeppelin.com/

Disclosure: I am the Community Manager at OpenZeppelin

  • I edited my question. As you can see, my smart contract is not complex. I can deploy it with genache or Ropsten Test network. but it does not work with private network. – Sheng Yu Aug 17 at 8:16
  • I deployed your contract to Ropsten and it used 2,819,225 gas. It would appear that the issue is deploying to your PoA network as the gas appears to be less than the limit shown in the error message. You could try deploying a simple contract to your PoA. – abcoathup Aug 19 at 5:53
1

There are only two possibilities:

a) Your contract deployment reverts, spending all gas

b) Your deployment is too complicated (does it have a for loop?)

To debug this, keep deleting code from your contract until the deployment works. Then add code back until it works. Continue this process exhaustively until you identify the line of code causing the problem.

(Or get an expert to do it for you.)

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.