GSN Client Side with Metamask fails

I have a Relay Server up and running. I also have my GSN-enabled contract (ERC20) deployed on Mumbai Testnet.
When I run the following on the client-side (React using create-react-app)

const gsnConfig = {
            forwarderAddress:this.state.forwarder,
            paymasterAddress:this.state.payMaster,
            preferredRelays:[this.state.preferredRelay],            
            loggerConfiguration: {
                logLevel: 'debug'
            }
        }
       
var newRelayProvider = await RelayProvider.newProvider({provider:window.ethereum,
    config:gsnConfig}).init()

const provider = new ethers.providers.Web3Provider(newRelayProvider);
const signer = provider.getSigner();

var contractObjNew = new ethers.Contract(this.state.contract,
    erc20ABI,
    signer);

let transferAmount = 10;  
  
var txt = await contractObjNew.transfer(this.state.storeWallet,
    transferAmount);

I get the following console (browser) output - without any MetaMask sign prompting:

calling sendAsync{"method":"eth_sendTransaction","params":[{"gas":"0xfe0e","from":"ADDR","to":"ADDR","data":"RAWDATA"}],"id":8,"jsonrpc":"2.0"}
KnownRelaysManager.ts:115 fetchRelaysAdded: found 181 events
KnownRelaysManager.ts:125 fetchRelaysAdded: found unique relays: ["0x27F3bd92f388C8194da3CF9fAe18aB052384902B","0x3DaC433361eFF8C6A0417783619aCc3296D4C178","0x7c0665FE2B413620436Be5a0cCec277F9115657E","0x9Ce7DfE700A51c78344535BfE9B51E597083a508"]

Followed by an awkward pause of a gazillion seconds (like 30 secs) and the following error:

MetaMask - RPC Error: JsonRpcEngine: Response has no error or result for request:
inpage.js:1 
{
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "latest",
      "topics": [
        [
          "0x77f2d8afec4b9d82ffa0dea525320620292bd1067f575964994d5c4501479aed"
        ],
        [
          "0x00000000000000000000000027f3bd92f388c8194da3cf9fae18ab052384902b",
          "0x0000000000000000000000003dac433361eff8c6a0417783619acc3296d4c178",
          "0x0000000000000000000000007c0665fe2b413620436be5a0ccec277f9115657e",
          "0x0000000000000000000000009ce7dfe700a51c78344535bfe9b51e597083a508"
        ]
      ],
      "address": "0x6646cd15d33ce3a6933e36de38990121e8ba2806"
    }
  ],
  "jsonrpc": "2.0",
  "id": 2853543403,
  "origin": "http://localhost:3000",
  "tabId": 2256
} 
{code: -32603, message: 'JsonRpcEngine: Response has no error or result for…igin": "http://localhost:3000",\n  "tabId": 2256\n}', data: {…}}
code: -32603
data:
request:
id: 2853543403
jsonrpc: "2.0"
method: "eth_getLogs"
origin: "http://localhost:3000"

Hey, this seems like some kind of RPC error. There are some extra fields that are required in the config for Mumbai. The recommended client configuration can be found here: Mumbai Testnet | Documentation

Thank you @digglehopper, adding that configuration helped. I now am able to sign and send the transaction to the relay.

There was one additional roadblock in using my own preferred relay server. I had to configure the look-up blocks to a larger number but otherwise, it all worked.

the lookup window on the client should match the “registrationBlockRate” of the relayer
(that is, the client’s “relayLookupWindowBlocks” should be slightly larger (e.g. 10%) than the relayer’s “registrationBlockRate”

2 Likes