Skip to content

shawlu95/GSN-with-HardHat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GSN with HardHat

Demonstrate increment the Counter usign a gasless user. This repo is meant to be used only on testnet (not local chain). All examples are using Rinkeby.

Setup

Install dependencies.

yarn

Enviroment Params

Prepare the following params in .env:

  • ADMIN_KEY: private key of an account with testnet ether. Use this account to deploy Counter and interact with RelayHub (deposit for PayMaster).
  • ETHERSCAN_TOKEN: required if you want to deploy and verify your own Counter.
  • INFURA_URL: create a free Infura account and get a testnet URL.

Deploy Counter

Deploy and verify the contract. This step has been donw with Rinkeby network so you may reuse the contracts. If you choose to deploy your own contract, you need to setup the network in hardhat.config.js, and then setup the deployed address in address.js.

npx hardhat run scripts/deploy.js --network rinkeby

Verify Counter

Optionally verify the Counter contract (example).

# The forwarder's address is passed in as an argument
npx hardhat verify --network rinkeby \
  0x566B67A276f1a5E8148970e2141ad08F6078B0a3 \
  0x83A54884bE4657706785D7309cf46B58FE5f6e8a

Fund Paymaster

This repo uses the accept-everything pay master. If the pay master runs out of fund, you need to deposit some ether for your paymaster, by interacting with the RelayHub. Make sure your ADMIN_KEY account has enough ether.

npx hardhat run scripts/fund.js --network rinkeby

Test

The test simple creates a new gasless user on the fly, and use the gasless user to increment the counter.

npx hardhat test --network rinkeby

Results:

  Test Counter
    ✓ Increment count from gasless user (10320ms)


  1 passing (12s)

Check events on etherscan.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published