soliditymetamaskbrave-browser

Ethers.js Contract call works from Brave browser but fails from Metamask Goerli Testnet


Contract - 0xaB9d2D124E70Be7039d7CCba9AFd06AdC1Bc60C0 All the failed transactions are called from Metamask, and all the successes are called from the Brave browser.

It's a basic, "update a contract property" call, nothing crazy.

It has always worked from Brave Browser, but I was getting Error: cannot estimate gas; transaction errors from Chrom/MetaMask, so I added the provider.getGasPrice()

async function SendMessage() {
        contract = new ethers.Contract(contractAddress, abi, wallet);
        let gasEst = await provider.getGasPrice();
        console.log(ethers.utils.formatUnits(gasEst, 'gwei'));
        return contract.SendRequest(message, { gasLimit: 1000000, gasPrice: gasEst });
    }

Any help would be appreciated, thanks!


Solution

  • There is no contract on the 0xaB9d2D... address on the Ethereum mainnet (Etherscan link). So when you send it a transaction on the mainnet, it's a simple transfer between two end user addresses (in your case, you're sending value of 0 ETH) and the data field is ignored.

    However, on the Goerli testnet (Etherscan link), there is a contract deployed on this address. Assuming this contract doesn't implement the SendRequest() function, nor the fallback() special function, it rejects all incoming transfers that are trying to execute a function that is not defined in this contract (in your case SendRequest()).