The Issue -
is there a way to run npx oz-gsn run-relayer command with a custom node? I understand there is a flag i can use, which is --ethereumNodeURL but its execution gives me the following error -
Could not connect to node (Error: Found no accounts with sufficient balance (10000000000000000000 wei)).
is there some way i could specify my account details here? giving in just the address in --from flag doesnt work.
I was wondering if there is some way npx oz-gsn run-relayer command could pick the network object from networks.js file from the directory?
What I am trying to do -
I’d like to use GSN in a DApp deployed on a public network - Matic network, RPC for which is https://testnet2.matic.network
I understand a Relayer contract is required to be deployed on this network and as far as the docs have guided me, the oz-gsn tool has commands for the same (gsn-helpers). I’m just stuck on how to use this tool to deploy and run a relayer on a custom network.
Hey @abcoathup!
i’m not running a node, Matic is a public network (ethereum plasma side chain) - that i’d like to connect to.
So the end goal is to enable meta transactions on matic network using GSN. For which i believe at the minimum i’d need
A running relayer on a host (off-chain)
the relay hub contract
and working relayer in the network.
Questions:
the documentation say there is supposed to be a single address for the relay hub contract on all networks - was wondering if that will be true for networks where it isn’t deployed yet ie., Matic network?
let’s say we have deployed a relay hub contract on matic, now for the requirement of a relayer on matic - is it the registerRelayer command i have to use?
I may be missing something here, about the process, please correct me if i’m wrong
I have only used the GSN on ganache-cli and on Rinkeby.
I haven't tried this on a public network that didn't already have the RelayHub deployed.
I will need some help from the community on answering your questions.
the documentation say there is supposed to be a single address for the relay hub contract on all networks - was wondering if that will be true for networks where it isn’t deployed yet ie., Matic network?
I assume the same process that was used to deploy on other public networks to get a single address can be used to have the same address on any Ethereum based network.
let’s say we have deployed a relay hub contract on matic, now for the requirement of a relayer on matic - is it the registerRelayer command i have to use?
Okay, so this process is something GSN does for developers on different networks or are there certain steps I'd need to follow to deploy an instance of RelayHub on Matic?
So i guess the first step would be to get a RelayHub contract instance on Matic, then:
For using GSN on a testnet, you should run a real relayer, and not the script via gsn-helpers, since it’s meant to be used for local development or testing.
Deploy RelayHub
You can build your own script, importing the gsn-helpers.
You should create a simple JavaScript file that creates a new web3 object, pointing to the Matic network, and using an offline signer: this could be either by using the hdwallet provider, or by registering the private key on the web3 object (see https://web3js.readthedocs.io/en/v1.2.2/web3-eth-accounts.html#wallet-add).
Once you have a web3 object, you can just import the gsn-helpers package, and call deployRelayHub:
If you want to run it on a server for the entire Matic network, (which would be awesome by the way), and you need help with the setup, this guide could help:
Register the Relayer
Then you need to register the relayer.
Same as before: if you set up a JavaScript file that initializes the web3 object with a signer, you can call into the gsn-helpersregisterRelay method:
Fund dapp (Recipient contract)
Finally, you need to fund their app (i.e. recipient contract).
You need to do the same as the previous step, but this time calling into fundRecipient:
Alternatively, you could just modify the commands so they can receive another option (like a private key or mnemonic) and use it to create a web3 object that has offline signing.
Awesome! @abcoathup, Thank you for this answer, gonna try this out super soon. Thank you so much. Will report back on this thread if I stumble upon something
Also, was wondering, if running a relayer is only about getting a reachable URL - is it independent of the network RelayHub is deployed on?
if yes, then is there a general purpose Relayer available, URL for which can be used directly?