-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (24 loc) · 1.01 KB
/
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
import { composeAPI, generateAddress } from '@iota/core'
const iota = composeAPI({
// provider: 'https://nodes.testnet.iota.org:443'
provider: 'https://field.carriota.com:443'
})
iota.getNodeInfo()
.then(info => {
console.log(info);
if (Math.abs(info['latestMilestoneIndex'] - info['latestSolidSubtangleMilestoneIndex']) > 3) {
console.log('\r\nNode is probably not synced!');
} else {
console.log('\r\nNode is probably synced!');
GetMyBalance();
}
})
.catch(err => { console.log("get NodeInfo error=" + err) });
function GetMyBalance() {
let MySeed = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
const myaddress1 = generateAddress(MySeed, 1);
console.log("My address1: " + myaddress1)
iota.getBalances([myaddress1], 100).then(({ balances }) => {
console.log("Balance: " + balances)
}).catch(err => { console.log("getBances err: " + err) })
}