I want to convert bigNumber to Ether unit. I used the formatEther keyword but I keep getting "Typeerror: formatEther is not a function.
Here's the code:
const axios = require("axios");
const BigNumber = require("bignumber.js");
const formatEther = require("ethers");
// copy-paste your URL provided in your Alchemy.com dashboard
const ALCHEMY_URL =
"......";
axios
.post(ALCHEMY_URL, {
jsonrpc: "2.0",
id: 1,
method: "eth_getBalance",
params: [
"0xC..................", // Ethereum address
"latest", // get latest account balance of the address
],
})
.then((response) => {
const result = BigNumber(response.data.result);
const numberString = formatEther(result);
console.log(numberString);
});