This repository was archived by the owner on Jul 28, 2022. It is now read-only.
File tree 5 files changed +58
-2
lines changed
5 files changed +58
-2
lines changed Original file line number Diff line number Diff line change
1
+ //SPDX-License-Identifier: MIT
2
+ pragma solidity ^ 0.7.6 ;
3
+ pragma experimental ABIEncoderV2;
4
+
5
+ //"import" it into our project for Truffle to generate artifacts
6
+ import "@opengsn/paymasters/contracts/WhitelistPaymaster.sol " ;
7
+
8
+ import "@opengsn/contracts/src/RelayHub.sol " ;
9
+
Original file line number Diff line number Diff line change 1
1
const CaptureTheFlag = artifacts . require ( 'CaptureTheFlag' )
2
+ const WhitelistPaymaster = artifacts . require ( 'WhitelistPaymaster' )
3
+ const RelayHub = artifacts . require ( 'RelayHub' )
2
4
3
5
4
6
module . exports = async function ( deployer ) {
5
7
const forwarder = require ( '../build/gsn/Forwarder' ) . address
6
8
await deployer . deploy ( CaptureTheFlag , forwarder )
7
9
8
- console . log ( `Deployed CTF at ${ CaptureTheFlag . address } with forwarder ${ forwarder } ` )
10
+ await deployer . deploy ( WhitelistPaymaster )
11
+ const relayHubAddress = require ( '../build/gsn/RelayHub.json' ) . address
12
+ const paymaster = await WhitelistPaymaster . deployed ( )
13
+ await paymaster . setRelayHub ( relayHubAddress )
14
+ await paymaster . setTrustedForwarder ( forwarder )
15
+ // This is the first ganache address, when started with "ganache-cli -d"
16
+ await paymaster . whitelistSender ( '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1' )
17
+
18
+ // to add more addresses to the whitelist, open truffle console and run:
19
+ // const pm = await WhitelistPaymaster.deployed()
20
+ // pm.whitelistSender('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1')
21
+
22
+ console . log ( `RelayHub(${ relayHubAddress } ) set on Paymaster(${ WhitelistPaymaster . address } )` )
23
+ const relayHub = await RelayHub . at ( relayHubAddress )
24
+ await relayHub . depositFor ( paymaster . address , { value : 1e18 . toString ( ) } )
25
+ console . log ( `1 ETH deposited to Paymaster(${ WhitelistPaymaster . address } )` )
9
26
}
Original file line number Diff line number Diff line change 6
6
"dependencies" : {
7
7
"@opengsn/cli" : " ^2.2.2" ,
8
8
"@opengsn/contracts" : " ^2.2.2" ,
9
+ "@opengsn/paymasters" : " ^2.2.2-rc.1" ,
9
10
"@opengsn/provider" : " ^2.2.2" ,
10
11
"browserify" : " ^17.0.0" ,
11
12
"ethers" : " ^5.3.0" ,
Original file line number Diff line number Diff line change 1
1
const ethers = require ( 'ethers' )
2
+ const { formatEther } = require ( 'ethers/lib/utils' )
2
3
const { RelayProvider } = require ( '@opengsn/provider' )
4
+ const paymasterArtifact = require ( '../build/contracts/WhitelistPaymaster.json' )
5
+ let whitelistPaymasterAddress
6
+
7
+ // In truffle console run:
8
+ // const pm = await WhitelistPaymaster.deployed()
9
+ // pm.whitelistSender('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1')
3
10
4
11
const paymasterAddress = require ( '../build/gsn/Paymaster' ) . address
5
12
const contractArtifact = require ( '../build/contracts/CaptureTheFlag.json' )
@@ -27,7 +34,7 @@ async function initContract() {
27
34
provider : window . ethereum ,
28
35
config : {
29
36
//loggerConfiguration: { logLevel: 'error' },
30
- paymasterAddress
37
+ paymasterAddress : whitelistPaymasterAddress
31
38
}
32
39
} ) . init ( )
33
40
Original file line number Diff line number Diff line change 586
586
dependencies :
587
587
" @openzeppelin/contracts" " ^3.4.0-solc-0.7"
588
588
589
+ " @opengsn/dev@^2.2.2 " :
590
+ version "2.2.2"
591
+ resolved "https://registry.yarnpkg.com/@opengsn/dev/-/dev-2.2.2.tgz#29c22828d9cf7f53ebcb716f096a284bcfb803c2"
592
+ integrity sha512-2SW0/nufKlbVVg4P/G94YuwvuYe4BNBqfq9EciT31nIFiIc+xmBwRNAB05GQhUdL6l6eeTdCXQN7+78R6u7NoA==
593
+ dependencies :
594
+ " @opengsn/cli" " ^2.2.2"
595
+ " @opengsn/contracts" " ^2.2.2"
596
+ " @opengsn/provider" " ^2.2.2"
597
+ " @opengsn/relay" " ^2.2.2"
598
+
599
+ " @opengsn/paymasters@^2.2.2-rc.1 " :
600
+ version "2.2.2-rc.1"
601
+ resolved "https://registry.yarnpkg.com/@opengsn/paymasters/-/paymasters-2.2.2-rc.1.tgz#add7677548d6011d6a82ec1b2c399e6ae3b8dbdd"
602
+ integrity sha512-iNRTrzz//7rUCgIwQ6aLhobkpvaKeDmSXmaEXH1SQPe7I+HQG4s2ejela4XsFmxuXKdC+sOxXdVgvvuFG+W0lQ==
603
+ dependencies :
604
+ " @opengsn/common" " ^2.2.2"
605
+ " @opengsn/contracts" " ^2.2.2"
606
+ " @opengsn/dev" " ^2.2.2"
607
+ " @opengsn/provider" " ^2.2.2"
608
+ " @openzeppelin/contracts" " ^3.4.0-solc-0.7"
609
+ ethereumjs-util "^6.1.0"
610
+
589
611
" @opengsn/provider@^2.2.2 " :
590
612
version "2.2.2"
591
613
resolved "https://registry.yarnpkg.com/@opengsn/provider/-/provider-2.2.2.tgz#f10d51449195c5729a6d23eb0c0933356d16f1cd"
You can’t perform that action at this time.
0 commit comments