I am encountering an error when attempting to call the approve method of a contract on the Ethereum blockchain through my decentralized application (DApp). The error message I'm receiving is:
index.js:50 Uncaught (in promise) Error: Unknown Ethereum address
{
"originalError": {}
}
This error occurs suddenly without any changes made to my code. Here is the relevant code snippet where the error is being triggered:
approve = async () => {
const tokenContractInstance = await getContractInstance("seedifyToken");
const addresses = await getContractAddresses();
const { web3Data, isPaused } = this.state;
if (isPaused) return this.popup("error", "Staking is paused");
if (!web3Data?.isLoggedIn) {
return this.popup("error", "Please connect to metamask");
}
console.log("web3Data while approve staking", web3Data);
console.log("web3Data.account[0] while approve staking", web3Data.accounts[0].address);
//console.log("web3Data", web3Data.accounts[0]);
await tokenContractInstance.methods
.approve(addresses[this.state.activeContract], this.state.totalSupply)
.send({ from: web3Data.accounts[0].address })
.on("transactionHash", (hash) => {
//console.log("hash", hash);
this.setState({ txnHash: hash });
return this.popup("process");
})
.on("receipt", (receipt) => {
//console.log("receipt", receipt);
this.getUserData(this.state.web3Data);
window.removeEventListener("receipt", this.approve);
return this.popup(
"success",
"Your staking is approved . You can invest now !",
true
);
})
.on("error", (error) => {
//console.log(error);
window.removeEventListener("error", this.withdraw);
// return this.popup("error", error.message);
return this.onTransactionError(error);
});
};
I've checked the address being passed to the approve method to ensure it's valid. I've reviewed my code for any recent changes that might have caused this error, but I haven't found anything. I've searched online for similar issues but haven't found a solution that applies to my situation. Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you!