-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
37 lines (32 loc) · 852 Bytes
/
app.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
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[0];
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);