Nethereum.GSN
NuGet:
Nethereum.GSN| Source:src/Nethereum.GSN/
Nethereum.GSN
Gas Station Network is the ultimate solution for Ethereum decentralized applications. It removes the barrier between users and dApps but increases the complexity of dApps.
Pre-requirements
- Contract should be GSN-capable
- Contract should have positive balance in RelayHub. It can be done via CLI or
RelayHubHelperin the projectRelayHubHelper.DepositRelayHub(
"ED3...", // Private key of sender
"https://rinkeby.infura.io/v3/...", // RPC Endpoint
"0xD216153c06E857cD7f72665E0aF1d7D82172F494", // RelayHub address (https://gsn.openzeppelin.com/relays)
"0x...", // Contract address
Nethereum.Web3.Web3.Convert.ToWei(1) // Amount
);
Getting started
In order to add GSN support to Nethereum Web3 instance, follow the next steps:
- Initialize Web3 with
RpcClientparamenter onlyvar client = new RpcClient(new Uri("https://rinkeby.infura.io/v3/..."));
web3 = new Web3(client); - Initialize
GSNTransactionManagervar options = new GSNOptions { UseGSN = true };
var relayClient = new RelayClient(options.HttpTimeout);
var relayHubManager = new RelayHubManager(options, web3.Eth, relayClient);
var transactionManager = new GSNTransactionManager(
options,
relayHubManager,
web3.Eth,
web3.Client,
relayClient,
new DefaultRelayPolicy(),
"ED3..." // Private key of sender
); - Set Interceptor of Web3 instance
web3.Client.OverridingRequestInterceptor = new GSNTransactionInterceptor(transactionManager);