# Simulating secrets locally

**URL:** <https://forum.openzeppelin.com/t/simulating-secrets-locally/21762>\
**Category:** Defender\
**Tags:** autotasks\
**Created:** [December 28, 2021, 4:13am UTC](https://forum.openzeppelin.com/t/simulating-secrets-locally/21762 "2021-12-28T04:13:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptrwtts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ptrwtts/32/11790_2.png) [@ptrwtts](https://forum.openzeppelin.com/u/ptrwtts)\
**Post date:** [December 28, 2021, 4:13am UTC](https://forum.openzeppelin.com/t/simulating-secrets-locally/21762/1 "2021-12-28T04:13:45Z")

</div>

I'm running an Autotask locally, following the examples, and it's working great. However when I tried to utilize the secrets feature, it wasn't clear how to simulate it locally. Is there an example somewhere? I assume there's a way to pull it from my local .env, but I can't figure it out. Thanks!

---

<div class="post-metadata">

**Author:** ![spalladino](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/spalladino/32/22_2.png) [@spalladino](https://forum.openzeppelin.com/u/spalladino)\
**Post date:** [December 28, 2021, 1:47pm UTC](https://forum.openzeppelin.com/t/simulating-secrets-locally/21762/2 "2021-12-28T13:47:35Z")

</div>

Hey @ptrwtts! Secrets [just get injected into the Autotask `event` payload](https://docs.openzeppelin.com/defender/autotasks#secrets), so it depends on how you're invoking your Autotask locally. For instance, in [this example](https://github.com/OpenZeppelin/defender-autotask-examples/blob/master/relay/src/client.js), all you would have to do is:

```auto
// Entrypoint for the Autotask
exports.handler = async function(event) {
  const relayer = new Relayer(event);
  const { secrets } = event;
  return exports.main(relayer, secrets);  
}

// To run locally (this code will not be executed in Autotasks)
if (require.main === module) {
  require('dotenv').config();
  const { API_KEY: apiKey, API_SECRET: apiSecret } = process.env;
  const secrets = JSON.parse(process.env.SECRETS); // Example for loading a secrets JSON from an env var
  exports.handler({ apiKey, apiSecret, secrets })
    .then(() => process.exit(0))
    .catch(error => { console.error(error); process.exit(1); });
}

```
