Skip to content

validitylabs/SnapshotToken

Repository files navigation

Snowflake Solidity

News flash: No more need using the initShell scripts anymore, because we are using npx right now!

Checklist for new projects

  • Update dependencies in package.json via yarn upgdate
  • Update hashes in ./tools/hashChecker.js for the zeppelin files you want to use
    • ATTENTION!!! audit the zeppelin code to verify the SHA hashes
  • Use most recent version of solc in package.json, because it will define the used solidity version in the project and will be used for linting and compiling in VSCode and our run scripts
  • Ensure you are using the same solidity version in config/solcpiler.json too (determine version here).
  • Use the correct NodeJS version on your machine (NVM)
  • Update the ./config/*.json files and use the correct file name pattern

Linter

Please use this solidity VSCode plugin to ensure your contracts follows the solidity style and security guides. yarn test only runs, if no linter issues detected!

All security rules should be implemented according ConsenSys Guide for Smart Contracts.

All style guide rules should be implemented according Solidity Style Guide.

For more information look into the Solhint docs.

TODO

@TODO: yarn add eth-gas-reporter (replace execution time in terminal output!)

Requirements

The server side scripts requires NodeJS 8 to work properly. Go to NVM and follow the installation description.

Use correct NodeJS version for this project

Before installing any dependencies (yarn install), ensure, you are using the right node version.

nvm install
nvm use

NVM supports both Linux and OS X, but that’s not to say that Windows users have to miss out. There is a second project named nvm-windows which offers Windows users the possibility of easily managing Node environments.

nvmrc support for windows users is not given, please make sure you are using the right Node version (as defined in .nvmrc) for this project!

Yarn is required to be installed globally to minimize the risk of dependency issues. Go to Yarn and choose the right installer for your system.

For the Rinkeby and MainNet deployment, you need Geth on your machine. Follow the installation instructions for your OS.

Depending on your system the following components might be already available or have to be provided manually:

  • Python 2.7 Version only! Windows users should put python into the PATH by cheking the mark in installation process. The windows build tools contain python, so you don't have to install this manually.
  • GIT, should already installed on *nix systems. Windows users have to install GIT manually.
  • On Windows systems, PowerShell is mandatory
  • On Windows systems, windows build tools are required (already installed via package.json)
  • make (on Ubuntu this is part of the commonly installed sudo apt-get install build-essential)
  • On OSX the build tools included in XCode are required

Every command must be executed from within the projects base directory!

Setup

Open your terminal and change into your project base directory. From here, install all needed dependencies.

yarn install

This will install all required dependecies in the directory node_modules.

Compile, migrate, test and coverage

To compile, deploy and test the smart contracts, go into the projects root directory and use the task runner accordingly.

# Compile contract
yarn compile

# Migrate contract
yarn migrate

# Test the contract
yarn test

# Run coverage tests
yarn coverage

Infura Testnet Deployment - Ropsten, Rinkeby, & Kovan

create a .secrets.json file in the config directory of this project and insert the following with your Infura API key and mnemonic. Double check and make sure that file name is included in the .gitignore file list. Never commit and push your mnemonics!

{
    "rinkeby": {
        "host": "https://rinkeby.infura.io/<APIKEY>",
        "mnemonic": "<MNEMONIC>"
    }
}

@TODO: Define deployment steps

  • Run yarn test to ensure all is running
  • Check config files
    • ./contracts/deployment/contracts/*.js (from, otherAddresses, ...)
    • ./contracts/config/networks.json (gas, gasPrice)
  • Start local test node and unlock fromAccount
  • Ensure fromAccount have enought ETH
  • Start deployment (yarn deploy-rinkeby / yarn deploy-mainnet)
  • Verify Contract code on etherscan

Rinkeby testnet deployment

Start local Rinkeby test node in a separate terminal window and wait for the sync is finished.

yarn geth-rinkeby

Now you can connect to your local Rinkeby Geth console.

geth attach ipc://<PATH>/<TO>/Library/Ethereum/rinkeby/geth.ipc

# e.g.
# geth attach ipc://Users/patrice/Library/Ethereum/rinkeby/geth.ipc

Upon setup the node does not contain any private keys and associated accounts. Create an account in the web3 Geth console.

web3.personal.newAccount()

Press [Enter] twice to skip the password (or set one but then later it has to be provided for unlocking the account).

Read the address and send some Rinkeby Ether to pay for deployment and management transaction fees.

web3.eth.accounts

You can obtain Rinkeby testnet Ether from the faucet by pasting your address in social media and pasting the link.

Connect to your rinkeby Geth console and unlock the account for deployment (2700 seconds = 45 minutes).

> personal.unlockAccount(web3.eth.accounts[0], "", 2700)

Ensure, all config files below ./config/ folder is setup properly. The from address will be used for the deployment, usually accounts[0].

After exiting the console by <STRG> + <D>, simply run yarn migrate-rinkeby. This may take several minutes to finish.

You can monitor the deployment live via Rinkeby

After all, your smart contract can be found on etherscan: https://rinkeby.etherscan.io/address/<REAL_CONTRACT_ADDRESS_HERE>

MainNet deployment

This is the production deployment, so please doublecheck all properties in the config files below config folder!

For the MainNet deployment, you need a Geth installation on your machine. Follow the installation instructions for your OS.

Start local MainNet Ethereum node in a separate terminal window and wait for the sync is finished.

geth --syncmode "fast" --rpc

Now you can connect to your local MainNet Geth console.

geth attach ipc://<PATH>/<TO>/Library/Ethereum/geth.ipc

# e.g.
# geth attach ipc://Users/patrice/Library/Ethereum/geth.ipc

While syncing the blockchain, you can monitor the progress by typing web3.eth.syncing. This shows you the highest available block and the current block you are on. If syncing is done, false will be returned. In this case, you can web3.eth.blockNumber and compare with the latest BlockNumber on Etherscan.

Upon setup the node does not contain any private keys and associated accounts. Create an account in the web3 Geth console.

web3.personal.newAccount("<YOUR_SECURE_PASSWORD>")

Enter <YOUR_SECURE_PASSWORD> and Press [Enter] to finish the account creation.

Read the address and send some real Ether to pay for deployment and management transaction fees.

web3.eth.accounts

Connect to your MainNet Geth console and unlock the account for deployment (240 seconds = 4 minutes).

personal.unlockAccount(web3.eth.accounts[0], "<YOUR_SECURE_PASSWORD>", 240)

Ensure, all config files below ./config/ folder is setup properly. The from address will be used for the deployment, usually accounts[0].

After exiting the console by <STRG> + <D>, simply run yarn migrate-mainnet. This may take several minutes to finish.

You can monitor the deployment live via Etherscan

After all, your smart contract can be found on etherscan: https://etherscan.io/address/<REAL_CONTRACT_ADDRESS_HERE>

Contract Verification

The final step for the Rinkeby / MainNet deployment is the contract verificationSmart contract verification.

This can be dome on Etherscan or Rinkeby Etherscan.

  • Click on the Contract Creation link in the to column
  • Click on the Contract Code link

Fill in the following data.

Contract Address:       <CONTRACT_ADDRESS>
Contract Name:          <CONTRACT_NAME>
Compiler:               v0.4.19+commit.c4cbbb05
Optimization:           YES
Solidity Contract Code: <Copy & Paste from ./build/bundle/IcoCrowdsale_all.sol>
Constructor Arguments:  <ABI from deployment output>

Visit Solc version number page for determining the correct version number for your project.

  • Confirm you are not a robot
  • Hit verify and publish button

Now your smart contract is verified.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published