For the past few days I am below error from metamask. It occurs sometimes and sometimes the transaction is successful. It occurs when I try to transfer tokens from one account to another. The approve function works but when it comes to transfer tokens to another account then this error arises. My scenario is that I have two contracts. Both of them are tokens and I want the user to exchange tokens with the previous token to the new tokens. So, I first call approve function from web3 to give the second contract ability to tranfer tokens on behalf of the user then the transfer function which is in the second method is called. So the approve function is successful but when I try to call the tranfer function which is called within the success response of the approve function then this below error occurs.
code: -32603
message: "Cannot set properties of undefined (setting 'loadingDefaults')"
I am using React as frontend and web3 for connecting with solidity. For test accounts I am using Ganache.
Truffle v5.4.14 (core: 5.4.14)
Solidity - 0.8.9 (solc-js)
Node v16.11.0
Web3.js v1.5.3