How to fix ERC20 token approve problem using web3js in polygon mainnet?

23 Views Asked by At

There is my own ERC20 token called XFI in several chains - Sepolia, Polygon mumbai and Polygon mainnet. And to transfer XFI to vault contract, user should be approve XFI first by using "Add XFI" button in our website UI.

The problem is that it does not work in only Polygon mainnet, while it works well in Sepolia and Polygon mumbai testnet.

In my opinion, it no matter XFI contract, because it does not also work in the case of using USDT approve instead of XFI one. And web3 code, abi and project environment is the same too. The difference is only chain id, contract and address.

Here is approve part of the code.

const xxx: any = new _web3.eth.Contract(XFI, xfiAddress);
const aaveVault = new _web3.eth.Contract(AaveVault, vaultAddress);
const amountXXX= _web3.utils.toWei(xxxAmountOfVault, 'ether');
await xxx.methods.approve(vaultAddress, amountXXX.toString()).send({from: account});
  • package.json "web3": "^4.3.0"

  • Error

Here is error string

How to fix the problem? I'd like to listen to the great opinion of web3 professors and experienced one.

0

There are 0 best solutions below