Leveraging OpenZeppelin with Sound and Gigantic Steps

@jaureguino I think you can try to change your gas limit in truffle.config to 300000 or even more and you will see if that is the problem.
In your truffle.config.js you have 30 000 not 300 000
I tried to deploy your contract and the cost was:

2 Likes

@paulinablaszk you are so very kind,

Do you mean something like this :point_down:
new%20truffle

1 Like

I think it should work :slight_smile:

I just changed ganache as follows :point_down: and will do a test

It did not work… This is what I got :point_down:
last%20error

:man_facepalming:t2: What to do? What to do? :man_shrugging:

I found out there is a bug on Web3 listed here :point_down: https://stackoverflow.com/questions/52956509/uncaught-error-returned-values-arent-valid-did-it-run-out-of-gas

Which I partially fixed with truffle migrate --reset

And here the other bug https://github.com/trufflesuite/ganache/issues/960

  networks: {
    development: {
      host: "localhost",
      port: 7545,
      gas: 10000000,
      gasPrice: 10,
      network_id: "*",
    },
  },
  compilers: {
    solc: {
      settings: {
        optimizer: {
          enabled: true, // Default: false
          runs: 1000     // Default: 200
        },
        evmVersion: "homestead"  // Default: "byzantium"
      }
    }
  }
};

plus truffle compile --all

Testing… more to come…

1 Like

Greetings everyone,

You are probably familiarized with the latest TFF_Token.sol contract :point_down:

pragma solidity ^0.5.0;

import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol';
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';

/**
 * @title TFF_Token http://estudios-amazonia.com/TheFaustFlick_WP.pdf
 * @dev ERC721 metadata minting logic leveraging openzeppelin-solidity v2.1.2
 * @dev ERC721 facilitates preventing: a) double-voting per token and
 * b) disabling trading during voting periods.
 */

contract TFF_Token is ERC721Full, ERC721MetadataMintable, Ownable {

// With Local Ganache Wallet
// address private Owner = 0x8045B92162Bb607454f8CF4CC44CBD9dff518495;
// With Kovan Metamask Wallet
  address private Owner = 0x14193178f8d8f20990988556B869eF28135826f7;
  string private Name = "TheFaustFlick";
  string private Symbol = "TFF";
  string private TokenURI = "http://thefaustflick.com/images/TFF_Token.png";
  uint256 private TokenId;
  uint8[4] private MintStage;
  uint256[4] private TokensToMint;

  // Constructor
  constructor() ERC721Full(Name, Symbol) public {
    TokenId = 1;
    for (uint8 counter = 0; counter <= 3; counter++) { MintStage[counter] = 0; }
    TokensToMint[0] = 500000;
    TokensToMint[1] = 3000000;
    TokensToMint[2] = 3000000;
    TokensToMint[3] = 3500000;
    Mint_TFF(0);
  }

  /**
   * @dev TFF Minter function * Warning * Review White Paper * Get last
   * TokenId to figure out next logically correct Mint_TFF(_Stage) value
   */
  function Mint_TFF(uint8 _Stage) public onlyOwner returns (bool) {
    if (MintStage[_Stage] == 0) {
      uint256 tokensToMint = TokensToMint[_Stage];
      for (uint256 counter = 1; counter <= tokensToMint; counter++) {
        mintWithTokenURI(Owner, TokenId, TokenURI);
        TokenId = TokenId.add(1);
      }
      MintStage[_Stage] = 1;
      return true;
    }
  }

  /**
   * @dev Gets Last TokenId function * Useful to determine how many TFF Tokens
   * have been minted. Helps figure the next logically correct Mint_TFF() Value
   */
  function GetLastTokenId() public view returns (uint256) {
      return TokenId;
  }

  function GetTokenURI() public view returns (string memory) {
      return TokenURI;
  }
}

Here is my truffle-congif.js file :point_down:

const path = require("path");
require('dotenv').config();
const devmnem = process.env.DEVMNEN;
const kovmnem = process.env.KOVMNEN;
const key = process.env.INFURA_API_KEY;
const HDWalletProvider = require("truffle-hdwallet-provider");

module.exports = {
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    development: {
      provider: function() {
        return new HDWalletProvider(devmnem, "http://127.0.0.1:7000/");
    },
    network_id: 5777,
    gas: 10000000000,
    gasPrice: 1,
    },
    kovan: {
      provider: function() {
        return new HDWalletProvider(kovmnem, 'https://kovan.infura.io/v3/' + key);
    },
      network_id: 42,
      gas: 4700000,
      gasPrice: 1,
    },
    ropsten: {
      provider: function() {
        return new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/' + key);
    },
      network_id: 3,
      gas: 4700000,
      gasPrice: 21,
    },
    rinkeby: {
      provider: function() {
        return new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io/v3/' + key);
    },
      network_id: 4,
      gas: 4700000,
      gasPrice: 21,
    },
    mainnet: {
      provider: function() {
        return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/v3' + key);
    },
      network_id: 1,
      gas: 4700000,
      gasPrice: 5,
    }
  },
  compilers: {
    solc: {
      settings: {
        optimizer: {
          enabled: true, // Default: false
          runs: 1000     // Default: 200
        },
        evmVersion: "homestead"  // Default: "byzantium"
      }
    }
  }
};

Here is my .env file :point_down:

KOVMNEN="[MNEMONIC]"
INFURA_API_KEY='b765cde076c04e2193620ea99d8dc786'

Should [MNEMONIC] be taken from the 12 words generated at https://iancoleman.io/bip39/ such as :point_down:
generate
select

And the derived address obtained here :point_down:
derived%20key
should be used :point_right: https://faucet.kovan.network/ to get some ETH ?

And should it also be assigned to address private Owner in TFF_Token.sol ?

Could anyone confirm/deny/correct?

Thanks a lot!

Special thanks to @nventuro for putting me on the right path… I think…

g.a.

Hello jaureguino!

The mnemonic comes from any ETH related wallet, Metamask can retrieve you the mnenomic, MyEtherWallet can, but using that tool will work as well. For production you would want to use a more securely obtained private key though.

The faucet depends on what testnet you’re on. Which network will you be deploying to if not your local ganache network?

The private key you use will affect who is marked as the owner of the contract, yes.

Hopefully that answers your questions.

1 Like

Dear @IvanTheGreatDev,

Thanks a lot for your response which in fact answers my questions. The TFF_Token.sol contract has been compiled and migrated into Kovan successfully. The following are the top 5 lines of the contract :point_down:

pragma solidity ^0.5.0;

import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol';
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';

When trying to verify, I got the following error :point_down:

I found this :point_right: https://ethereum.stackexchange.com/questions/64654/truffle-compile-gives-parser-error-error-parsing-openzeppelin-solidity-contract

@nventuro,

I noticed that https://www.npmjs.com/package/openzeppelin-solidity was “published” 19 hours ago,
published

Therefore, I have re-installed and compiled :point_down:
reinstalled

and updated "openzeppelin-solidity": "2.1.3" and "solc": "^0.5.0" in package.json as :point_down:
updated%20package

I just re-deployed :point_down:
deploying

and I am still getting the same error when verifying the contract at Kovan… :point_down:

any thoughts?

g.a.

Etherscan won't be able to resolve the imports (see the error message). You'll need to use a tool such as truffle-flattener to get a single file with all of the source code, or alternatively use ZeppelinOS's verify command, which will do all of that for you.

Thanks @nventuro,

I could not get the ZeppelinOs´s verify command working for me, so I ended up doing as follows:
truffle-flattener ./contracts/TFF_Token.sol > ./contracts/FTFF_Token.sol
copy ./contracts/TFF_Token.sol ./development/TFF_Token.sol
del ./contracts/TFF_Token.sol
rename ./contracts/FTFF_Token.sol ./contracts/TFF_Token.sol
truffle compile --all
truffle migrate --network kovan --reset

And I got the following error while verifying

I manually removed all the pragma solidity ^0.5.0; from ./contracts/TFF_Token.sol, except the one on the first line. Then I did:

truffle compile --all
truffle migrate --network kovan --reset

When veryfying at https://kovan.etherscan.io/ which file should I use?

./contracts/TFF_Token.sol
or
./client/src/contracts/TFF_Token.json

I tried both, separately of course, and it did not verify with either,

Then I found :point_down: here :point_right: https://github.com/nomiclabs/truffle-flattener
limitations

So I checked :point_right: https://github.com/BlockCatIO/solidity-flattener and found :point_down:
solidity

So it seems that I need to install Python 3.5+ and pip on my windows 7

Dear @nventuro,

I have been unable to get solidity-flattener nor parity installed/working property.

Could you please let walk me through using ZeppelinOs´s verify command ?

g.a.

Project Update

During testing we realized that transfer() function only does so with one tokenId at a time :point_right: https://medium.com/horizongames/going-beyond-erc20-and-erc721-9acebd4ff6ef which significantly hampers purchasing ability; therefore we have decided to revert back to the ERC20 solution.

We will leverage the openzeppelin-solidity/contracts/token/ERC20/ERC20Pausable.sol contract so that we can pause trading during voting period, thus avoid double-voting.

We are so pleased and grateful that the Zeppelin Team that already thought and delivered the Pausable functionality.

Cheers and more to come!

Cheers Everybody!

The initial phase of our project has been completed successfully, not without your terrific development work and support :+1:; the pausable functions were thoroughly tested and worked just as expected. :muscle:t2:

All the best for all of you. I will certainly be coming back as we start working on our phase two.

Keep up the great work!

More to come!

g.a.

2 Likes