OpenZeppelin/workshops

Error: API key and secret are required

EduardoMelo00 opened this issue · 1 comments

i'm running and following the workshop but right now i'm getting this error:

Error: API key and secret are required
at getClient (/Users/edu/Documents/relayopenzeppellin/workshops/25-defender-metatx-api/node_modules/@openzeppelin/defender-sdk/lib/index.js:16:15)
at get relaySigner (/Users/edu/Documents/relayopenzeppellin/workshops/25-defender-metatx-api/node_modules/@openzeppelin/defender-sdk/lib/index.js:58:16)
at handler (/Users/edu/Documents/relayopenzeppellin/workshops/25-defender-metatx-api/action/index.js:36:27)
at Object. (/Users/edu/Documents/relayopenzeppellin/workshops/25-defender-metatx-api/scripts/relay.js:11:3)
at Module._compile (node:internal/modules/cjs/loader:1434:14)

someone can help me ? 

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)
})
}

add team api key and paste in .env file from defender it might help :)