-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommands.js
More file actions
40 lines (34 loc) · 1.32 KB
/
Copy pathcommands.js
File metadata and controls
40 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//Main Code
function call()
{
Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.accounts;
fs = require('fs');
code = fs.readFileSync('Voting.sol').toString();
solc = require('solc');
compiledCode = solc.compile(code);
abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface);
VotingContract = web3.eth.contract(abiDefinition);
byteCode = compiledCode.contracts[':Voting'].bytecode;
deployedContract = VotingContract.new(['Rama','Nick','Jose'],{data: byteCode, from: web3.eth.accounts[0], gas: 4700000});
// console.log("Address is:");
var waitTill = new Date(new Date().getTime() + seconds * 1000);
while(waitTill > new Date()){}
deployedContract.address;
// console.log(address);
// contractInstance = VotingContract.at(deployedContract.address);
// const name = 'Will Robinson';
// console.warn(`Danger ${name}! Danger!`);
}
function call2()
{
var a = call();
console.log(a.deployedContract);
}
// call()
call2()
// contractInstance = VotingContract.at(deployedContract.address)
// contractInstance.totalVotesFor.call('Rama')
// contractInstance.voteForCandidate('Rama', {from: web3.eth.accounts[0]})
// contractInstance.voteForCandidate('Rama', {from: web3.eth.accounts[0]})