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.
Install dependencies.
yarn
Prepare the following params in .env
:
ADMIN_KEY
: private key of an account with testnet ether. Use this account to deployCounter
and interact withRelayHub
(deposit forPayMaster
).ETHERSCAN_TOKEN
: required if you want to deploy and verify your ownCounter
.INFURA_URL
: create a free Infura account and get a testnet URL.
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
Optionally verify the Counter
contract (example).
# The forwarder's address is passed in as an argument
npx hardhat verify --network rinkeby \
0x566B67A276f1a5E8148970e2141ad08F6078B0a3 \
0x83A54884bE4657706785D7309cf46B58FE5f6e8a
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
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.