fuel-core
Version:
Essential javascript architecture for the Fuel side chain
71 lines (52 loc) • 2.73 kB
JavaScript
const { Wallet, providers, utils, dbs } = require('../index');
(async ()=>{
let privateKey = process.env.test_privateKey3; // test_privateKey3
const wallet = new Wallet({
signer: new utils.SigningKey(privateKey),
provider: new providers.InfuraProvider('rinkeby', '3cfef7d48afb4f26be007e5c07260d9a'), // 'https://rinkeby.infura.io/v3/3cfef7d48afb4f26be007e5c07260d9a'),
network: 'rinkeby',
chainId: 4,
});
const moonTokenAddress = '0xbfc17f07bcfa17772d2a37b25664eeeb9042dcfb';
const brickTokenAddress = '0xa12106d1feb066fc43c84abe4866e053fc876c74';
await wallet.sync();
await wallet.listen(async () => {
console.log('Balance', utils.formatEther(await wallet.balance(brickTokenAddress)));
});
try {
// console.log(await wallet.inputs(moonTokenAddress));
// console.log(await wallet.inputs(brickTokenAddress));
console.log(wallet.address);
console.log('moon', (await wallet.balance(moonTokenAddress)));
console.log('brick', (await wallet.balance(brickTokenAddress)));
// await wallet.deposit(utils.parseEther('1000000'), moonTokenAddress, { confirmations: 1 });
// await wallet.deposit(utils.parseEther('1000000'), brickTokenAddress, { confirmations: 1 });
await wallet.deposit(utils.parseEther('1500'), brickTokenAddress);
// console.log('moon id', await wallet.tokenID(moonTokenAddress));
// console.log('brick id', await wallet.tokenID(brickTokenAddress));
console.log('moon', (await wallet.balance(moonTokenAddress)));
console.log('brick', (await wallet.balance(brickTokenAddress)));
// console.log(await wallet.rate(utils.parseEther('1500'), brickTokenAddress, moonTokenAddress));
console.log(await wallet.swap(utils.parseEther('1500'), brickTokenAddress, moonTokenAddress));
// await wallet.transfer(utils.parseEther('1000000'), moonTokenAddress, wallet.address);
// await wallet.transfer(utils.parseEther('1000000'), brickTokenAddress, wallet.address);
console.log('moon', (await wallet.balance(moonTokenAddress)));
console.log('brick', (await wallet.balance(brickTokenAddress)));
// console.log(wallet.address);
// console.log(await wallet.balance(brickTokenAddress));
// await wallet.transfer(50000, brickTokenAddress, wallet.address);
// console.log(await wallet.balance(brickTokenAddress));
// await wallet.faucet();
// console.log(await wallet.balance(moonTokenAddress));
// await wallet.deposit(50000, brickTokenAddress);
// console.log(await wallet.balance(brickTokenAddress));
} catch (err) {
console.error(err);
}
// await db.close();
/*
await faucet();
await transfer(500, tokens.fakeDai, address);
console.log('done!');
*/
})();