UserNotFoundException thrown for an existing Relay API Key

There's a lot of functionality potential in Defender, so it's understandable to have some questions about which credentials point to what component!

Defender API Key/Secret and Team API Key/Secret refer to the same thing.

A Relayer can also have its own API key/secret.

You can create a Relayer and use it via an Autotask without ever creating credentials for that Relayer. The Autotask will have the Relayer's credentials securely/automatically available to it by specifying the Relayer's ID).

If, however, you would like to send/sign transactions with a Relayer (as when deploying a contract via Relayer, for one example), you need to use the relay-client package, supplying the Relayer's key/secret.

Following the steps in the link above will illustrate the necessary steps to make this happen:

  1. Supply your Team API key/secret to instantiate the relay-client
  2. Send a request via the client to create a Relayer
  3. Send a request via the client to create a key for that Relayer

Having finished those steps, you can then run ethers.js functions using the Relayer by specifying the Relayer object:

  const credentials = {apiKey: process.env.RELAYER_KEY, apiSecret: process.env.RELAYER_SECRET};
  const provider = new DefenderRelayProvider(credentials);
  const relaySigner = new DefenderRelaySigner(credentials, provider, { speed: 'fast' });
  
  const MyContract = await ethers.getContractFactory("SimpleRegistry");
  const myContract = await MyContract.connect(relaySigner).deploy().then(f => f.deployed());

Note that in this latter example, it's the Relayer key that is supplied.