const add1 = "0x2BCD25D8D7bB17206d83cb359Fbacf16aBD2796C"
const add2 = "0xca257dc2e925c67d396725a48ffb8a913f3e3ce8"
const url = "<https://bsc-dataseed1.defibit.io>"
// const url = "<https://api.avax.network/ext/bc/C/rpc>"
const ethers = require("ethers")
const provider = new ethers.providers.JsonRpcProvider(url)
const minErc20Abi = [
{
constant: true,
inputs: [
{
name: "_owner",
type: "address",
},
],
name: "balanceOf",
outputs: [
{
name: "balance",
type: "uint256",
},
],
type: "function",
},
{
constant: true,
inputs: [],
name: "name",
outputs: [
{
name: "",
type: "string",
},
],
type: "function",
},
// get token symbol
{
constant: true,
inputs: [],
name: "symbol",
outputs: [
{
name: "",
type: "string",
},
],
type: "function",
},
{
constant: true,
inputs: [],
name: "decimals",
outputs: [{ name: "", type: "uint8" }],
payable: false,
stateMutability: "view",
type: "function",
},
];
const getBalance = async(add) => {
const balance = await provider.getBalance(add)
console.log(ethers.utils.formatEther(balance))
}
getBalance(add1)
const getTokenInfo = async (add, ca) => {
const contract = new ethers.Contract(ca, minErc20Abi, provider)
const balance = await contract.balanceOf(add)
console.log(ethers.utils.formatEther(balance))
}
getTokenInfo(add1, "0x2dfF88A56767223A5529eA5960Da7A3F5f766406")