-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a custom paymaster to accept gas payments.
- Loading branch information
1 parent
db14e26
commit d09a974
Showing
7 changed files
with
293 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.7; | ||
|
||
//"import" it into our project for Truffle to generate artifacts | ||
import "@opengsn/paymasters/contracts/WhitelistPaymaster.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
const CaptureTheFlag = artifacts.require('CaptureTheFlag') | ||
const WhitelistPaymaster = artifacts.require('WhitelistPaymaster') | ||
|
||
module.exports = async function (deployer) { | ||
module.exports = async function (deployer, network, accounts) { | ||
const forwarder = require('../build/gsn/Forwarder').address | ||
await deployer.deploy(CaptureTheFlag, forwarder) | ||
|
||
console.log(`Deployed CTF at ${CaptureTheFlag.address} with forwarder ${forwarder}`) | ||
|
||
await deployer.deploy(WhitelistPaymaster) | ||
const relayHubAddress = require('../build/gsn/RelayHub.json').address | ||
const paymaster = await WhitelistPaymaster.deployed() | ||
await paymaster.setRelayHub(relayHubAddress) | ||
await paymaster.setTrustedForwarder(forwarder) | ||
|
||
// This is the first ganache address, when started with "ganache-cli -d" | ||
// you can add your metamask address here. | ||
await paymaster.whitelistSender('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1') | ||
|
||
|
||
// you can also add addresses by running `truffle console` and then running: | ||
// const pm = await WhitelistPaymaster.deployed() | ||
// pm.whitelistSender('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1') | ||
|
||
await web3.eth.sendTransaction({from: accounts[0], to: paymaster.address, value: 1e18}) | ||
console.log(`1 ETH deposited to Paymaster(${WhitelistPaymaster.address})`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.