Failed to get a token for the API key when using Polygon Mainnet

I'm on the free plan but it allows me to have up to 5 Relayers. I have set up my Polygon Mainnet Relayer and also transferred MATIC to the account. I'm using Node JS to call a Signer but the above error is thrown. The same was working in the Polygon Test with the corresponding Key & Secret. What am I doing wrong?

:computer: Environment

Polygon Mainnet with MATIC

:memo:Details

:1234: Code to reproduce

Hi @krcnow,

Could you share the error you are getting?

Hey, this is what I'm getting when I use my Mainnet key.

Having the same issue. Except my problem is with Polygon Mumbai.

Did you ever figure out what the problem was?

Hi @mpaler,

Are you using the relayer via the API or from with an Autotask? Do you mind sharing your code also?

Hi @dylkil

I was trying to use Alchemy as a provider as follows:

// Entrypoint for the Autotask
export async function handler(event) {

  // Pull in alchemy node api key from Defender secrets store.
  // const { alchemyMumbai } = event.secrets;

  // Initialize defender relayer provider and signer
  //const provider = new ethers.providers.AlchemyProvider(network="maticmum", alchemyMumbai);
  
  // Uncomment to use the native defender provider, instead of Alchemy or Infura.
  const provider = new DefenderRelayProvider(event);
  const signer = new DefenderRelaySigner(event, provider, { speed: 'fast' });
  return main(signer);
}

It worked locally when I upped the local version of Ethers.

I'm almost certain the problem was with the Ethers version provided by OZ Defender.

Please compare the versions alchemy-provider.js

OZ Defender version 5.0.13

Current Ethers release 5.5.3

Hope that helps.

Thanks for sharing your code and doing some digging, it does look like ethers version is whats causing your issue. We will look into bumping it to latest.

1 Like

@dylkil curious if you have an update on the status of this?

@mpaler this issue should be resolved now, apologies for not getting back sooner

1 Like