UNPKG

axie-ronin-ethers-js-tools

Version:

A set of functions that make it easier for developers to interact with their Axies on the Ronin network and the maketplace.

42 lines (41 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = account; const contracts_1 = require("../lib/contracts"); const contracts_2 = require("@roninbuilders/contracts"); async function account(taskArgs, hre) { if (hre.network.name != 'ronin' && hre.network.name != 'saigon') { throw new Error('Network not supported'); } try { const accounts = await hre.ethers.getSigners(); const signer = accounts[0]; const address = signer.address.toLowerCase(); console.log('Address:', address.replace('0x', 'ronin:')); // get RON balance const balance = await hre.ethers.provider.getBalance(address); const balanceInEther = hre.ethers.utils.formatEther(balance); console.log('RON:', balanceInEther); // get WETH balance const wethContract = await (0, contracts_1.getWETHContract)(signer); const wethBalance = await wethContract.balanceOf(address); const wethBalanceInEther = hre.ethers.utils.formatEther(wethBalance); console.log('WETH:', wethBalanceInEther); // WETH allowance const allowance = await wethContract.allowance(address, contracts_2.MARKETPLACE_GATEWAY_V2.address); console.log('Marketplace WETH has allowance:', !allowance.eq(0)); // get axie contract const axieContract = await (0, contracts_1.getAxieContract)(hre.ethers.provider); // get axies balance for the address const axiesBalance = await axieContract.balanceOf(address); console.log('Axies:', hre.ethers.BigNumber.from(axiesBalance).toString()); // get USDC balance const usdcContract = await (0, contracts_1.getUSDCContract)(hre.ethers.provider); const usdcBalance = await usdcContract.balanceOf(address); const usdcBalanceFormated = hre.ethers.utils.formatUnits(usdcBalance, 6); console.log('USDC balance: ', usdcBalanceFormated); } catch (error) { console.error(error); } }