Error: API key and secret are required - defender-sdk

i'm following the Relay Gasless tutorial and i'm getting an error in the moment to run yarn relay.

Error: API key and secret are required

but, the api key and secret are filled normally

const client = new Defender(creds);

async function handler(event) {

// Parse webhook payload
if (!event.request || !event.request.body) throw new Error(Missing payload);
const { request, signature } = event.request.body;
console.log(Relaying, request);

// Initialize Relayer provider and signer, and forwarder contract
const creds = { ... event };

const client = new Defender(creds);

const provider = client.relaySigner.getProvider();

const signer = client.relaySigner.getSigner(provider, { speed: 'fast' });
const forwarder = new ethers.Contract(ForwarderAddress, ForwarderAbi, signer);

// Relay transaction!
const tx = await relay(forwarder, request, signature);
console.log(Sent meta-tx: ${tx.hash});
return { txHash: tx.hash };
}

const { handler } = require('../action/index.js')

// Run autotask code locally using the Relayer API key and secret
if (require.main === module) {
require('dotenv').config()
const { RELAYER_API_KEY: apiKey, RELAYER_API_SECRET: apiSecret } = process.env

const payload = require('fs').readFileSync('tmp/request.json')
handler({ apiKey, apiSecret , request: { body: JSON.parse(payload) } })
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
}

1 Like

I got the problem.

In the Index.js in this peace of code:

  const accepts = !whitelist || whitelist.includes(request.to);
  if (!accepts) throw new Error(`Rejected request to ${request.to}`);

  // Validate request on the forwarder contract
  const valid = await forwarder.verify(request, signature);
  if (!valid) throw new Error(`Invalid request`);

  
  // Send meta-tx through relayer to the forwarder contract
  const gasLimit = (parseInt(request.gas) + 50000).toString();
  return await forwarder.execute(request, signature, { gasLimit });

const valid = await forwarder.verify(request, signature);

forwarder.verify is throwing a error with
reason: 'too many arguments: passed to contract',
code: 'UNEXPECTED_ARGUMENT',
count: 2,
expectedCount: 1

in the same way,

return await forwarder.execute(request, signature, { gasLimit });

reason: 'too many arguments: passed to contract',
code: 'UNEXPECTED_ARGUMENT',
count: 3,
expectedCount: 1

Someone can help me ?