-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallFitup.js
96 lines (64 loc) · 2.26 KB
/
callFitup.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import Fitup from "./build/contracts/Fitup.json";
import Web3 from "web3";
const web3 = new Web3("http://127.0.0.1:8545");
const networkId = await web3.eth.net.getId();
const deployedNetwork = Fitup.networks[networkId];
console.log('deployedNetworkAddress: ', deployedNetwork.address);
var contract = new web3.eth.Contract(Fitup.abi, deployedNetwork.address);
const accounts = await web3.eth.getAccounts();
const someOrganisation = "0xCD5705135bB0A5A50aA714027Ab75975Bb75A963"
function createBet() {
console.log("Running createBet")
contract.methods.createBet(someOrganisation).send({ from: "0x3006212ef095D93936Cb88EB469Cc1f2361825c7", value:2000000000000000000, gas:3000000 }, function (err, res) {
if (err) {
console.log("An error occured", err)
return
}
console.log("Hash of the transaction: " + res)
})
}
async function getBet() {
await contract.methods.getBet("0x3006212ef095D93936Cb88EB469Cc1f2361825c7").call(function (err, res) {
if (err) {
console.log("An error occured", err)
return
}
console.log("Bet Data: " + res)
})
}
function getBalance() {
contract.methods.getBalance().call(function (err, res) {
if (err) {
console.log("An error occured", err)
return
}
console.log("Bet Data: " + res)
})
}
function payoutBet() {
contract.methods.payoutBet(true, accounts[0]).send({ from: accounts[0] }, function (err, res) {
if (err) {
console.log("An error occured", err)
return
}
console.log("Hash of the transaction: " + res)
console.log(res)
})
}
async function getBetCount() {
const betCount = await contract.methods.getBetCount().call(function (err, res) {
if (err) {
console.log("An error occured", err)
return
}
console.log("Bet Data: " + res)
})
}
async function addNgo(){
const ngo= await contract.methods.addNgo("CODE", "0x62497C5D0264dDBf2337fE2C08ac9A0E16360a03").send({from: "0x6be2AD9611e1585f89D56C74DDcB75484Cd893Ba"}, function(err, res){
if (err) {
console.log("An error occured", err)
return
}
})
}