forked from moonbeam-foundation/moonbeam-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbalances.js
34 lines (29 loc) · 813 Bytes
/
balances.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
const Web3 = require('web3');
/*
-- Define Provider & Variables --
*/
// Provider
const providerRPC = {
development: 'http://localhost:9933',
moonbase: 'https://rpc.testnet.moonbeam.network',
};
const web3 = new Web3(providerRPC.development); //Change to correct network
// Variables
const addressFrom = 'ADDRESS-FROM-HERE';
const addressTo = 'ADDRESS-TO-HERE';
/*
-- Balance Call Function --
*/
const balances = async () => {
const balanceFrom = web3.utils.fromWei(
await web3.eth.getBalance(addressFrom),
'ether'
);
const balanceTo = web3.utils.fromWei(
await web3.eth.getBalance(addressTo),
'ether'
);
console.log(`The balance of ${addressFrom} is: ${balanceFrom} ETH`);
console.log(`The balance of ${addressTo} is: ${balanceTo} ETH`);
};
balances();