Skip to content

Instantly share code, notes, and snippets.

@agrcrobles
Created January 29, 2018 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrcrobles/e03151b27ad4753827de227929677db3 to your computer and use it in GitHub Desktop.
Save agrcrobles/e03151b27ad4753827de227929677db3 to your computer and use it in GitHub Desktop.
Deploy voting contract
var Migrations = artifacts.require('./Migrations.sol');
module.exports = function(deployer) {
deployer.deploy(Migrations, { gas: 4612388 });
};
var Voting = artifacts.require('./Voting.sol');
module.exports = function(deployer) {
deployer.deploy(Voting, [
'Genesis',
'Alpha',
'Wild Hair',
'Nerd Glasses',
'Big Shades',
'Purple Eye Shadow',
'Do-rag',
'Wild White Hair',
'Luxurious Beard'
]);
};

voting-deploy

Overview

When Voting.sol contract is deployed on the blockchain it initialized the list of super heroes as well as the total number of tokens available for "sale".

Getting started in localhost

# JSON-RPC node can be running and configured in `truffle.js` with your local network IP ( `127.0.0.1` )

npm i -g ganache-cli

# run local eth
ganache-cli

Build and deploy contracts

npm i -g truffle

# generates json files abstraction
# Writing artifacts to ./build/contracts
truffle compile

# deploy the contracts
truffle migrate --network development

Optional: copy local contracts to mobile dapp

yarn copy-local

For more information about truffle see ganache-cli

Getting started in ropsten

  • An account and an API is necessary to getting started

  • Edit truffle.js configuration

  • Run

truffle compile
truffle migrate --network ropsten

See intructions: http://truffleframework.com/tutorials/using-infura-custom-provider

More info see:

https://medium.com/@guccimanepunk/how-to-deploy-a-truffle-contract-to-ropsten-e2fb817870c1

https://ethereum.stackexchange.com/questions/23279/steps-to-deploy-a-contract-using-metamask-and-truffle

Deployed info

https://ropsten.etherscan.io/address/0x25cee65ac493a0c965f12a2d0c46fe82e09d6d44

Running migration: 1_initial_migration.js
================================
BLOCK CHANGED: #26c345 0xa24cb60cb5a83ae4551d807aeb8e44eaaf66d321e02bdb52a68585cf6eb48169
================================
  Deploying Migrations...
  ... 0x17e2cb87112928003db97b914ffea56f88e71264ae6073d1d6791ee8c4cd5fca
================================
BLOCK CHANGED: #26c346 0x97f3d5785174596f8a8b19a33a09a0c5e8f598a8f1aaec998491afff040b8a66
================================
================================
BLOCK CHANGED: #26c347 0x6ded48fd91957271958e49ab6f3b0c33a25561d66a32b2b2e8afc9b46f38c58d
================================
  Migrations: 0x25cee65ac493a0c965f12a2d0c46fe82e09d6d44
Saving successful migration to network...
================================
BLOCK CHANGED: #26c348 0x8098a920058b242545144d5d90ae070381495d95dda315c9c284ca7575e691b2
================================
  ... 0x6b436779ce8cbb9e97a8b73b128980626e2d35f5721612e1421ca5281d0abd6d
================================
BLOCK CHANGED: #26c349 0x946a15f08627382c186757926a2f2805bff82b885423490bd1e5d0d94386f480
================================
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying Voting...
================================
BLOCK CHANGED: #26c34a 0x8b2e10e9a0a063575e2595d6c447eff9cf17300d0399b2779db9121e052a4008
================================
  ... 0xe036a605987a60df918aef57d93a66db19bda4c3d7748d1c501224377585a9f5
================================
BLOCK CHANGED: #26c34b 0x7d5d0e935ba19007400449afa8a8bde79f9a6231c888feccfe2f4848851efd56
================================
================================
BLOCK CHANGED: #26c34c 0xe6b5a68790ac1c4796583cda1a5611f01352f4be21db6b50fdaed0cce1837253
================================
  Voting: 0xbb5f4afe9e81a6f60218dd1df25b74ad54fedcc8
Saving successful migration to network...
  ... 0xa532eb4fd7312f03d4cb109d64a2b42364ab91a4379add31d8d66be0bcdba6e0
================================
BLOCK CHANGED: #26c34d 0xacc110bd7db53797faa84f8b66bba99e24a052f85be776c845ad852494effe3d
================================
================================
BLOCK CHANGED: #26c34e 0xfb359ceebbc07d405ac8d0e598cf673218a675d522ccb5e3dd31d3cf16390296
================================
Saving artifacts...

More info see

License

MIT @ zetta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment