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

From the error message, it seems like there might be an issue with the authentication process for the API key. Have you checked that the API key is valid and properly authorized for the Polygon Mainnet environment?
In terms of testing, try implementing UAT (User Acceptance Testing) to ensure that your code works properly before deploying it to the live environment. what is uat testing? UAT testing involves testing your software in a real-world scenario with end-users to ensure that it meets their needs and expectations. It can help to identify issues and improve the overall user experience.