-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (33 loc) · 819 Bytes
/
index.js
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
var contractABI = null;
var contractAddress = null;
var account0 = null;
var VoteTrackerContract = null;
$.ajax({
url: "./build/contracts/VoteTracker.json",
async: false,
dataType: "json",
delay: 500,
success: function (json) {
assignVariable(json);
}
});
function assignVariable(data) {
contractABI = data.abi;
contractAddress = data.networks[5777].address;
}
web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:7545"));
web3.eth.getAccounts().then(function (result) {
account0 = result[2];
console.log(result);
});
setTimeout(function delay() {
VoteTrackerContract = new web3.eth.Contract(
contractABI,
contractAddress,
{ from: account0, gas:3000000 }
);
}, 1000);
setTimeout(function delay() {
console.log(account0);
Object.freeze(account0);
}, 4000);