I am getting the following error when trying to call a smart contract method from react app.
index.ts:261 Uncaught (in promise) Error: invalid BigNumber string (argument="value", value="NaN", code=INVALID_ARGUMENT, version=bignumber/5.6.2)
at e.value (index.ts:261:28)
at e.value (index.ts:273:20)
at e.value (index.ts:277:21)
at Function.value (bignumber.ts:238:27)
at Function.value (bignumber.ts:250:30)
at a.value (number.ts:25:27)
at array.ts:71:19
at Array.forEach (<anonymous>)
at x (array.ts:54:12)
at a.value (tuple.ts:54:16)
It is throwing this error before the request even reaches the metamask. The weird thing about this error is it is only happening in a few system and in others it is working fine. We tried using the same metamask account for both systems, for one where it was failing and one where it was not but the same account request goes through fine in one system and in one it fails.
const requestService = async (selectedId, id, capacity, limit, account) => {
const res = await P2P.methods
.requestService(
parseInt(selectedId),
parseInt(id),
parseInt(capacity),
ethers.utils.parseEther(String(limit))
)
.send({
from: account,
gas: 2000000,
});
return res;
};
This is the method that is giving me errors. I am using the following dependencies:-
{
"name": "name",
"version": "0.1.0",
"private": true,
"dependencies": {
"@hookform/resolvers": "^2.9.3",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"bootstrap": "^5.1.3",
"ethers": "^5.6.9",
"http": "^0.0.1-security",
"https": "^1.0.0",
"mdbreact": "^5.2.0",
"metamask-logo": "^2.5.0",
"os": "^0.1.2",
"react": "^18.2.0",
"react-bootstrap": "^2.4.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.33.0",
"react-icons": "^4.4.0",
"react-router-dom": "^6.3.0",
"react-scripts": "4.0.3",
"react-toastify": "9.0.3",
"react-yup": "^1.24.0",
"reactstrap": "^9.1.1",
"stream": "^0.0.2",
"stream-browserify": "^3.0.0",
"url": "^0.11.0",
"web-vitals": "^2.1.4",
"web3": "^1.7.4"
},
"devDependencies": {
"react-error-overlay": "6.0.9"
},
"scripts": {
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}