Last active
August 20, 2018 15:03
-
-
Save enriquefynn/194ea8a71107c96d6714b2c031124762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const solc = require('solc') | |
const Web3 = require('web3'); | |
const web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); | |
const address = web3.eth.accounts[0]; | |
const code = fs.readFileSync('Voting.sol').toString() | |
const compiledCode = solc.compile(code) | |
const abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface) | |
const byteCode = compiledCode.contracts[':Voting'].bytecode | |
const VotingContract = web3.eth.contract(abiDefinition) | |
const deployedContract = VotingContract.new(['Rama','Nick','Jose'], { | |
data: byteCode, | |
from: web3.eth.accounts[0], gas: 4712388 | |
}, (err, contract) => { | |
if (contract.totalVotesFor !== undefined) | |
contract.totalVotesFor.call('Rama', console.log) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment