Following on from Using Gas Station Network starter kit on a local network this guide is using Gas Station Network starter kit on a public testnet (specifically Rinkeby)
Change App.js to use public network
In App.js
change the web3 context from ganache-cli
to Infura by uncommenting Infura and commenting out the local network.
// get GSN web3
const context = useWeb3Network(`wss://rinkeby.infura.io/ws/v3/${infuraToken}`, {
pollInterval: 15 * 1000,
gsn: {
signKey,
},
});
// const context = useWeb3Network('http://127.0.0.1:8545', {
// gsn: {
// dev: true,
// signKey,
// },
// });
Deploy Counter to public network
The following guide walks through the process of deploying to a public network, though most of the setup is already done for us in the starter kit:
https://docs.openzeppelin.com/sdk/2.5/public-deploy
Test account
npx mnemonics
will generate a 12 word seed phrase suitable for development testing
$ npx mnemonics
npx: installed 15 in 4.617s
<< 12 WORD SEED PHRASE WILL BE HERE >>
Configure .env
Create a .env
file in your project directory with the contents being the mnemonic just generated
MNEMONIC="ENTER 12 WORD SEED PHRASE"
Configure truffle-config.js
Fix typo of MNEMONIC to match value in .env
(https://github.com/OpenZeppelin/starter-kit-gsn/pull/13)
const mnemonic = process.env.MNEMONIC;
Fund test account
Fund test account on Rinkeby
Get the default account using openzeppelin accounts
$ npx openzeppelin accounts
? Pick a network rinkeby
Accounts for rinkeby:
Default: 0x4924b7e51F71f2D3a57711C7a2Ac8a5ca3b2DBED
All:
- 0: 0x4924b7e51F71f2D3a57711C7a2Ac8a5ca3b2DBED
Add Rinkeby Ether, you can use https://faucet.rinkeby.io/ or you can request test Ether from the MetaMask faucet. (https://faucet.metamask.io)
Import into MetaMask
Hack: Get the private key for the default account using ganache-cli
$ ganache-cli -a 1 -m "ENTER 12 WORD SEED PHRASE"
Copy the private key and import into MetaMask
Deploy Contract
Deploy Counter.sol on Rinkeby
$ npx openzeppelin create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate Counter
? Pick a network rinkeby
✓ Contract Counter deployed
All contracts have been deployed
? Do you want to call a function on the instance after creating it? Yes
? Select which function * initialize(num: uint256)
? num (uint256): 72
✓ Setting everything up to create contract instances
✓ Instance created at 0x227984286964861BBFb45AFBf1EC9B2a57c65C89
0x227984286964861BBFb45AFBf1EC9B2a57c65C89
Fund Recipient
Fund Recipient using GSN Dapp Tool
Open https://gsn.openzeppelin.com/recipients in a browser with MetaMask (or other web3 provider)
Paste Counter address on Rinkeby
Deposit 0.1 Rinkeby ETH
Use Dapp
Refresh Dapp and increase/decrease counter using Gas Station Network