Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: API key and secret are required #44

Open
EduardoMelo00 opened this issue May 24, 2024 · 1 comment
Open

Error: API key and secret are required #44

EduardoMelo00 opened this issue May 24, 2024 · 1 comment

Comments

@EduardoMelo00
Copy link

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

@Agam1708
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants