Hey @jrocco2! The relayer client is not meant to be used from a dapp, since it requires embedding the API key and secret into it, so anyone who can access your dapp would be able to extract them and freely control your relayer - which you definitely don’t want to.
If you want to send txs from your dapp via your relayer, a good pattern is to set up an Autotask with a webhook that receives requests from your end users, validates the request, and then in turn calls the relayer to send the requested tx. This allows you to whitelist whichever txs you need for your dapp.
Check out this workhsop where we used that pattern for implementing gasless meta txs!
Thank you for your response! I’m now using Autotask to talk to my Relay. I’m using Axios and the unique link generated by defender. Now all my tasks are getting through and executing successfully on the defender side. However, when the Autotask is finished I return the transaction hash like this: return { transactionHash : receipt.transactionHash }. But it only comes back sometimes other times I get an error in the client saying Cors Error MissingAllowOriginHeader even though Defender executes the task perfectly every time. Any thoughts on what is causing it to break 50% of the time for the same task?
Also receiving this error when i try in a different browser (Firefox)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.defender.openzeppelin.com/autotasks/… (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)
Probably better not to do it at all. According to @spalladino. But just as an FYI if you comment out “global.crypto = require(‘crypto’);” it will work. But then you will hit the CORS error like me so best not to bother.
Yea what I wanted to do is importing in Relayer into my react app, and use it as a gas station, so my users can connect to and use my Contract without using their own wallet and without paying for their own transactions with gas all done from the frontend without a server backend