-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiy.js
88 lines (81 loc) · 1.75 KB
/
diy.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
var Web3=require('web3');
var web3=new Web3(Web3.givenProvider || "http://127.0.0.1:8545/");
async function run() {
accounts = await web3.eth.getAccounts();
//Get list of addresses generated by Ganache (local development blockchain)
console.log(accounts);
const balance = await web3.eth.getBalance(accounts[0]);
//Print Ether balance in wei of first address of `accounts` array
console.log(balance);
}
run();
var cAddress="0x174ef088f013d32c2b9ea2cd8cf75ecf3bf68462";
var abi=[
{
"constant": false,
"inputs": [],
"name": "claimAmount",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "deposit",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "IamAlive",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
}
],
"name": "setRecovery",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
var myContract=new web3.eth.Contract(abi,cAddress);
var weiValue = web3.utils.toWei("0.01",'ether');
myContract.methods.deposit().send({from: accounts[0]})
.on('transactionHash', function(hash){
})
.on('receipt', function(receipt){
})
.on('confirmation', function(confirmationNumber, receipt){
})
.on('error', console.error);