Helper functions and scripts for using the Gas Station Network. Develop and test your GSN application with minimal setup.
Provides methods for:
-
Deploying a
RelayHub
instance -
Funding a recipient
-
Query a recipient’s or relayer owner’s GSN balance
-
Running and registering a relayer
-
Withdrawing a relayer’s revenue
The GSN Helpers come in two flavors: a command-line interface and a JavaScript library, providing high flexibility.
The following samples show how to use each to deploy the RelayHub
contract, fund a recipient and then start a relayer server.
$ npx oz-gsn deploy-relay-hub --ethereumNodeURL http://localhost:8545
Deploying singleton RelayHub instance
RelayHub deployed at 0xd216153c06e857cd7f72665e0af1d7d82172f494
$ npx oz-gsn fund-recipient --recipient <address> --amount 50000000
Recipient <address> balance is now 50000000 wei
$ npx oz-gsn run-relayer --ethereumNodeURL http://localhost:8545 --quiet
Starting relayer
~/.cache/gsn-nodejs/gsn-relay-v0.2.1
-EthereumNodeUrl http://localhost:8545
-RelayHubAddress 0xd216153c06e857cd7f72665e0af1d7d82172f494
-Port 8090
-Url http://localhost:8090
Relay is funded and ready!
const {
deployRelayHub,
runRelayer,
fundRecipient,
} = require('@openzeppelin/gsn-helpers');
const web3 = new Web3('http://localhost:8545');
await deployRelayHub(web3);
await runRelayer(web3, { quiet: true });
await fundRecipient(web3, { recipient: <address>, amount: 50000000 });
Note
|
All of these actions require a local blockchain to be running in the background on port 8545. |
-
Head to Preparing a Testing Environment to quickstart your project with ready-to-use GSN setup scripts.
-
For detailed usage information, take a look at the API Reference.