Running Defender Autotask locally for testing and development

Hey there,

I am looking to a tutorial who explains how run defender on local machine to be able to test on machine . It will be help me with my debugging

ty

1 Like

Hi @Bolo,

You can have a look at the following documentation for how to run your Autotask script in a local development environment:
https://docs.openzeppelin.com/defender/autotasks#local-development

Feel free to ask any questions.

Feedback on the documentation is appreciated. :pray:

Hi @Bolo,

I just wanted to check that you were able to get this setup so that you could test locally?

hey there. didn’t have time. I will give a shout tomorow

1 Like

following up on this, i'm trying to figure out a way to setup an instance of OZ's Relayer API service on my local ganache instance for development and testing purposes (without autotask).

Ideally what im thinking is a script that starts the relayer service on a local port which provides me the Relayer API endpoints I can call from my code. I've seen these old helpers that OZ used to maintain but seems like they have a different smart contract interface than the current ERC2771Recipient contracts used for forwarders and relayers (maybe I'm confused here so any guidance is greatly appreciated)

My app is python based, so was planning on writing a custom client for calling the HTTP endpoints directly instead of using the defender-relay-client JS package, unless there's already a python client floating around

Hey @shanexavier313,

The approach you're proposing sounds interesting. We don't have anything like that since Relayer is a custom-made system we've created to handle multiple cases for handling resubmissions, cancelling, policies, expiration, provider infrastructure, etc. so it's not that easy to just provide a plug-and-run package in which you can add your JSON-RPC provider.

Also, I have no information about a defender-relay-client for python, so if you build something like that, it'd be amazing.

Just curious, why would you like to run your own Relayer instance? I'd like to know if there's any workaround I can provide to you.

Best

Hey @ernestognw thanks for the response.

I really just want a fully provisioned local environment for developing my dapp against the Relayer, like in unit tests or in local development. Otherwise I either have to mock the calls to the Relayer (which is fine for testing but not ideal for local, since I want smart contract transactions to actually work when developing locally on ganache or similar) or I have to implement logic that directly submits a transaction via metamask when in local, but uses the Relayer API when in prod-like environments.

I could point my local dev env at a testnet Relayer but that makes it difficult to give our devs a fresh enviroment for development when they spin up the app on their machines

Honestly what would probably be the slickest is a docker image i could throw in a docker-compose.yml file (which is a tall ask but I would be happy to contribute to developing). But a cli tool like what OpenGSN has would be work or a script etc.

Hey @shanexavier313,

I understand the need, however, a rough effort estimate for this seems difficult to ship right now since our relayer architecture is not decoupled from all of the infrastructure we're running behind Defender. I added a note for this so we can consider it when planning future features.

Curious, do you think there can be an alternative to not expose all of the relayers architecture? If this is for testing purposes, maybe we can aim to provide testing helpers within our defender-relay-client, and that might be easier to consider than dockerizing the whole Relayer component.

Also another idea I'm having is to run an official OZ Defender ganache testnet (not a commitment, just throwing ideas :stuck_out_tongue_winking_eye:)

Sorry for not being able to provide a workaround here, but we always appreciate your thoughts as we move forward with the roadmap

Both of those would work. I think an official OZ Defender ganache testnet would work best as it could be used by developers not using the defender-relay-client package (for example, I would like to write a python client to call the Defender API since my dapp is python based)