How can I use defender-relay-client in web-browser?

:computer: Environment

I’m using Defender-relay-client locally
:memo:Details

but i didn’t find instructions about web-browser option. when i included Defender-relay-client in dependence in web-browser app, or just browserify ,the error throw at “$ browserify -r ./node_modules/defender-relay-client/lib/ethers > bundle-defender.js
Error: Can’t walk dependency graph: Cannot find module ‘aws-sdk’ from ‘.\node_modules\defender-relay-client\lib\autotask\index.js’”
How can i solve this kind of problem or should we wait until web-browser instructions added to the Doc?
:1234: Code to reproduce

1 Like

Hey @loophe! The defender-relay-client is meant to be used along your secret API keys to send transactions via your relayer. This means that anyone who accesses your webapp would have the info required to send txs from your relayer on your behalf. This is why we built the relay-client to be used only from nodejs (ie server-side) environments.

That said, we’d love to know what’s your use case for bundling the relay-client in your app! In the meantime, as a workaround, you can call an Autotask via a webhook, and have the autotask send the tx through the relayer. This also gives you more fine-grained control on what txs you send via your relayer!

2 Likes

Well, I will consider webhook function seriously for safty reason. :cowboy_hat_face:
We bundling the relay-client to webapp just for testing usage and I found Defender could hold funds in address so web visitor don’t need pay for the transaction fees, that make a huge convenience for user.

1 Like

@loophe if it helps, we ran a workshop on meta-txs last week, which covered the use case of hitting an autotask via webhook and using it to send a tx via a relayer. You can check out the recording here:

2 Likes