MetaMask - RPC Error: already known

I’m connecting to MetaMask using:

    await window.ethereum.enable()
    let gsnProvider = await RelayProvider.newProvider({
      provider: window.ethereum,
      config: gsnConfig

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

which successfully connects and allows arbitrary message signing. When I call a contract function MM pulls up the “GSN” view, as expected.

    contract = contract.connect(signer)
    await contract.claimEscrow(owner)

But when I hit send I get the error:

MetaMask - RPC Error: already known 

The GSN tx info in MM is:

o: 0xded0deacb9d0083377c4b5215a79a885d1c773a4
data: 0xa54c35db00000000000000000000000000...
from: 0x9eb83cd76caba00fcd30ec7927a4f9f67c8be55a
value: 0
nonce: 0
gas: 500000
   pctRelayFee:  90
   baseRelayFee: 0
gasPrice: 1200000000
paymaster: 0x43d66E6Dce20264F6511A0e8EEa3f570980341a2
paymasterData: 0x
clientId: 1
forwarder: 0x956868751Cc565507B3B58E53a6f9f41B56bed74
relayWorker: 0x33315c80dc2359b500...

I’ve tried making the transactions with multiple fresh accounts which shouldn’t have any nonce to start out with. Has anyone ran into this before?

Additionally, when I set the RelayProviders log level to debug:

"message":"Etherscan API URL is not set on this server!Returned error: execution reverted: Legal relay transaction

It turns out the transactions were actually going through, just a weird RPC error.

TL;DR: everything is ok, the transaction gets through, its only a misleading error message.

Long Explanation:

The client is paranoid: it receives a transaction from the relayer and verify its correctness, but is very afraid the relayer would try to cheat, and not put it on chain…
So the client goes ahead, and submit it to the blockchain, just to make sure.
It doesn’t cause any problem, and only has a side-effect of this harmless error message.

We do need to find a better way to verify the relayer doesn’t cheat but without making metamask report it as an error.

1 Like