-
Notifications
You must be signed in to change notification settings - Fork 3
/
bridge.js
32 lines (22 loc) · 1.02 KB
/
bridge.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
const ethers = require('ethers');
const Blockchains = require('./blockchains.js');
const SOURCE_ADDRESS = '0x55DbDAB581c4D5318901e9e35608444Cc2A3142d'; // User account
const TARGET_ADDRESS = '0xFd21DE119266Fc442cEFF47119B0dB0f530736d6'; // Manager contract (SKALE)
const blockchains = new Blockchains();
blockchains.printBlockNumber('KOVAN');
blockchains.printBlockNumber('SKALE');
async function sync() {
let kovanBalance = await blockchains.getBalance('KOVAN', SOURCE_ADDRESS);
console.log("Balance on source: " + ethers.utils.formatEther(kovanBalance));
let skaleBalance = await blockchains.getSupply('SKALE');
console.log("Balance on target: " + ethers.utils.formatEther(skaleBalance));
if (kovanBalance.gt(skaleBalance)) {
console.log("Source balance is greater, starting syncing...");
blockchains.mintRaw('SKALE', TARGET_ADDRESS, kovanBalance.sub(skaleBalance));
} else {
console.log("Source and target balance in sync, no need for extra action.");
}
}
setInterval(function() {
sync();
}, 3000);