Hi, I am currently working on a DEX with hardhat and everything works well so far. But if I switch to Moralis Binance Smart Chain I am getting always RPC json error. But the code is the same I tested on hardhat. I am using Speed Node the free version.
For example, I am calling the following function:
const exchangeAddress = await this.state.factory.getPair(
token1Address,
token2Address
);
but getting
inpage.js:1 MetaMask - RPC Error: Internal JSON-RPC error.
{code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
code: -32603
data: {code: -32000, message: 'execution reverted'}
message: "Internal JSON-RPC error."
[[Prototype]]: Object
Expected result is: 0x0000000000000000000000000000000000000000
My browser looks like this:
Connecting to Metamask or chain via:
connectToWeb3 = async () => {
try {
if (window.ethereum) {
window.web3 = new Web3(window.ethereum);
//await window.ethereum.enable();
window.ethereum.on('chainChanged', (chainId: string) =>
window.location.reload()
);
} else if (window.web3) {
window.web3 = new Web3(window.web3.currentProvider);
} else {
window.alert(
'Non-Ethereum browser detected. You should consider trying Metamask'
);
}
} catch (err) {
console.log('INnnnn');
console.log(err);
}
};