metamask-extension
metamask-extension copied to clipboard
[Bug]: Internal JSON RPC Error
Describe the bug
MetaMask cannot connect properly to my local Foundry Anvil network My setup: Solidity compiler 0.8.22 Foundry nightly-a839414d0bcf069bf2d226260f259c4f4dc4047d
I could not call the following function in my NftSales contract with MetaMask connecting to Foundry Anvil via RPC 8545! But RemixIDE + injectedProvider MetaMask + Foundry Anvil OR Hardhat Live Node works perfectly.
My Contract:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract NftSales {
function getBalances() public view returns (uint256[] memory out) {
address sender = msg.sender;
address tis = address(this);
out = new uint256[](7);
out[0] = sender.balance;
out[1] = token.balanceOf(sender);
out[2] = uint256(token.decimals());
out[3] = erc721.balanceOf(sender);
out[4] = tis.balance;
out[5] = token.balanceOf(tis);
out[6] = erc721.balanceOf(tis);
}
}
When I called that function in my NextJs13.5.4 + ethers.js 6.8.0, I got Internal JSON RPC Error
, but everything went fine with RemixIDE + FoundryProvider + Local Foundry Anvil. So something went wrong in the RPC...
After following the notes about how to connect Metamask to a local network https://docs.metamask.io/wallet/how-to/get-started-building/run-devnet/ Here are the setting for Anvil:
http://127.0.0.1:8545/(or http://localhost:8545).
Anvil chain ID 31337 ... or in hexadecimal format: 0x7a69
It seems to have something to do with the returned array of uint256....
Expected behavior
no error
Screenshots/Recordings
No response
Steps to reproduce
Deploy my little simplified contract above by RemixIDE + injectedProvider MetaMask + Foundry Anvil Then deploy those:
https://github.com/AuroraLantean/foundry-d2/blob/main/src/ERC20Token.sol
https://github.com/AuroraLantean/foundry-d2/blob/main/src/ERC721Token.sol
https://github.com/AuroraLantean/foundry-d2/blob/main/src/ERC721Sales.sol
Parameters to deploy SalesContract: priceInWeiEth = 1e15; priceInWeiToken = 100e6
Error messages or log output
creation of MyContract errored: Returned error: {"jsonrpc":"2.0","error":"[ethjs-query]
while formatting outputs from RPC
'{\"value\":{\"code\":-32603,\"data\":{\"code\":-32003,\"message\":
\"invalid chain id for signer\"}}}'","id":5474309128726098}
Error from the MetaMask
MetaMask - RPC Error: Internal JSON-RPC error.
Object { code: -32603, message: "Internal JSON-RPC error.", data: {…} }
Error: execution reverted (unknown custom error) (action="call", data="0x89c62b640000000000000000000000000000000000000000000000000000000000000000", reason=null, transaction={ "data": "0x00113e08", "to": "0x93C7a6D00849c44Ef3E92E95DCEFfccd447909Ae" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.8.0)
Version
MetaMask Version 11.2.0
Build type
None
Browser
Firefox
Operating system
Linux
Hardware wallet
No response
Additional context
No response
Severity
No response
Hey @AuroraLantean!
Thank you for reporting this! I will pass this on to the team!
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.
This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions.