Creating a Paymaster
A Paymaster holds ETH and can implement any business logic to decide whether to accept or reject a meta transaction. For example, accepting only transactions by whitelisted users, or to the contracts methods required for onboarding users, or only transactions that include a repayment in tokens to the Paymaster, etc.
A Paymaster is useful for any party willing to pay for a relayed transaction to a given address using the GSN network.
This guide is for developers who want to setup a paymaster wallet to sponsor all transactions to a given smart contract.
Implementation of Paymaster
We provided an implementation of the Paymaster which allows for multiple payable address.
You can refer to the source code of our Paymaster here.
Deploying Paymaster
Pre-requisite
We will only show example for the wallet and one must change the command accordingly if using another method
Deploying via OpenAttestation CLI
Simply run the following command. You may replace the <paymaster-name>
with a suitable name (the name does not matter).
This will deploy the paymaster on the ropsten
network. You should see a similar output when the deployment is successful:
Save YOUR paymaster address for future reference
After deploying your paymaster, you will need to fund it so that the paymaster will be able to pay for relayed transactions made. We can use this command to transfer 1 ETH to the paymaster for now. Replace <paymaster-address>
with your own paymaster's address and <value>
with the amount you want to send.
There will be no prompting to key in you password, just key it in after command finishes loading
You can read more about ethers-cli
here.
Paymaster Configuration
The paymaster is ready. You have to wait for clients to deploy their gsn capable document store before proceeding further.
In order to authorize your paymaster to pay for your contract we will need to configure the paymaster deployed earlier. We can use the add-target
method to do so. You need to replace <paymaster-address>
with your own paymaster and <target-address>
with the address off the contract you intend to allow payment for.
You should see a similar output if the call is successful:
You can check if a contract is supported by the paymaster by using the following command:
Additional Resource
Below is a list of additional resources for more information: