From Zero to Deploy

Ok I’m trying to recap all the steps, please tell me if is all correct:

1)Install Openzeppelin/cli

npm install --global @openzeppelin/cli

2)Setup my Project

mkdir my-project
cd my-project
npm init -y

3)Initialize OpenZeppelin SDK project:

openzeppelin init

4)Write the contract

SimpleToken.sol

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is ERC20, ERC20Detailed {

    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
        _mint(msg.sender, 80000000 * (10 ** uint256(decimals())));
    }
}

I want to create 80.000.000 tokens… this is right?

5)Compiling my contract

openzeppelin create

6)Use mnemonics to generate a 12 word mnemonic

npx mnemonic

7)Create Infura account to interact with public Ethereum nodes

8)Install dotenv

npm install --save-dev dotenv

9)Configure gitignore

# Dependency directory
node_modules

# local env variables
.env

# truffle build directory
build

10)Configure .env

INFURA_PROJECT_ID="ENTER INFURA PROJECT ID"
DEV_MNEMONIC="ENTER 12 WORD SEED PHRASE"

11)Install HD Wallet Provider

npm install truffle-hdwallet-provider

12)Configure ‘networks.js’

'use strict';

var HDWalletProvider = require("truffle-hdwallet-provider");

var mnemonic = "word1 word2 word3 etc...";

module.exports = {
  networks: {
    mainnet: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/<INFURA_Access_Token>")
      },
      gas: 5000000,
      gasPrice: 5e9,
      network_id: 1
    }
  }
};

13)Finally deploy!

openzeppelin push --network mainnet

14)I forgot to feed the production address

All correct? Any tips? ENV part is just for development/test right? Is useless for mainnet deploy? Thank you very much.

1 Like

Hi @Michael,

Do you want to deploy a non-upgradeable contract or an upgradeable contract?

  • If you want a non-upgradeable contract then you should use truffle and I can help with some instructions on how to do this.

  • If you want an upgradeable contract then you use OpenZeppelin SDK and you can use Deploy your contracts to a public network but the SimpleToken contract needs to be upgradeable.

1 Like

Hello @abcoathup,
A non-upgradeable contract is good for me. Thank you for your precious help.

1 Like

Hi @Michael,

I will write up some instructions on how to deploy to a public network using truffle tomorrow. It is fairly similar to the Deploy your contracts to a public network (using OpenZeppelin SDK).

1 Like

Thank you very much !!!

1 Like

Hi @Michael,

I have written instructions on how to deploy to a public network using truffle.

Feel free to ask all the questions that you need.