Hey i have to build a ERC20 contract and using alchemy sdk to send transactions onchain
For eg mint or burn tokens. But i am not able to send a transaction as its showing an error of cannot estimate gas
const API_KEY = process.env.API_KEY;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const CONTRACT_ADDRESS = process.env.CONTRACT_ADDRESS;
// provider - Alchemy
const alchemyProvider = new ethers.providers.AlchemyProvider(network="maticmum", API_KEY);
// signer - you
const signer = new ethers.Wallet(PRIVATE_KEY, alchemyProvider);
// contract instance
const helloWorldContract = new ethers.Contract(CONTRACT_ADDRESS, ABI, signer);
async function main() {
// console.log(helloWorldContract);
const message = await helloWorldContract.symbol();
console.log("The message is: " + message);
const a=await signer.getGasPrice()
console.log(a.toString());
console.log("Updating the message...");
const tx = await helloWorldContract.mint(100);
await tx.wait();
// const message2 = await helloWorldContract.balanceOf(CONTRACT_ADDRESS);
// console.log("The message is: " + message2);
}
main();
And the error i am facing is
var error = new Error(message);
^
<ref *1> Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT"
I have gone through docs but cannot find the reason.
Chain used - Polygon_mumbai
Or if there is any other method/framework that can do this other than this sdk, please recommend