How to test/use the GSN network locally

One final question I have is about how to test/use the GSN network locally.

When writing tests for GSN I noticed OZ use a scripts which has a setups up a relay hub but I dont understand how you guys setup up the hub when unit testing locally? Is there a simple open source RelayHub which is possible to write tests against in some form and should be used?

Also are there public GSN relayers which can be used, I noticed that openzeppelin-gsn-provider provides nice utilities for wrapping an existing web3Provider but documentation is light or hard to find what/if any relayURL should be used? Is the goal to run your on relayer service?

Thanks for all your help on this topic.

1 Like

Hi @jamesmorgan,

I suggest having a look at the documentation on Testing Setup.

I haven’t looked at the testing side, so apologies for not having more detail.
The OpenZeppelin Contracts tests themselves are usually a good source of information.

There are public relayers running on mainnet and rinkeby that you can use.
I assume at this stage, for a production dapp, to ensure availability you may want to run your own relayer (though ideally there would be multiple relayers so you wouldn’t need to run your own).

1 Like

Hello @jamesmorgan!

So nice to hear you are using GSN! So a couple notes: you don’t need to set the relayURL that should be used. The gsn provider actually gets a list of a relayURLs from the RelayHub smart contract! So no need to actually input the relayURL yourself. This means that your smart contract will automatically be finding and selecting an available relay, so no worries if a particular relay of your choice goes down- there are always others. :slight_smile:

Definitely check out as @abcoathup mentioned. There is plenty of detail in there. You can even launch your own GSN relayHub and Relayer on your local machine to test against with the command npx oz-gsn run-relayer --quiet. It’s very smooth and easy to do!


Hi @jamesmorgan,

Just checking how you got on with this?