Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
fix: suggested grammar nits

Co-authored-by: Sarah Schwartz <[email protected]>
  • Loading branch information
hoshiyari420 and sarahschwartz authored Aug 7, 2024
1 parent 7d6bb92 commit 35dc457
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions content/tutorials/permissionless-paymaster/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ You will:

## Project

The similar integration code is [available on GitHub here](https://github.com/ondefy/permissionless-multisigner-paymaster/blob/main/deploy/interact.ts).
A similar version of the integration code is [available on GitHub here](https://github.com/ondefy/permissionless-multisigner-paymaster/blob/main/deploy/interact.ts).

::callout{icon="i-heroicons-exclamation-circle"}
This tutorial does not contain the entire frontend code require for the Dapp.
Instead it covers all the important part required by the Dapp to integrate this paymaster easily.
This tutorial does not contain the entire frontend code required for the Dapp.
Instead it covers just the important parts required by the Dapp to integrate this paymaster easily.
::

## Overview
The permissionless multi-signer paymaster serves as a public good, enabling ZKsync Dapps to seamlessly sponsor gas for their users through signature verification.
Dapps can begin utilizing this paymaster by simply depositing funds and adding a signer address. Thus removing the need to deploy paymaster at all.
Dapps can begin utilizing this paymaster by simply depositing funds and adding a signer address. Thus removing the need to deploy a paymaster at all.

There are 2 primary actors involved:

Expand All @@ -46,11 +46,11 @@ There are 2 primary actors involved:
**Signers**: Managed by the Dapp or a trusted third party like Zyfi API. A signer’s signature is required to access gas funds by the Dapp’s user.

## Multi-signer
This paymaster allows manager to set multiple signers through which users can have access to the gas funds. Hence, one-to-many relantionship.
This paymaster allows the manager to set multiple signers through which users can have access to the gas funds. Hence, it is a one-to-many relationship.
![manager-signer-relation-diagram](/images/permissionless-paymaster/manager-signer.jpg)

## Integration
Below diagram provides the flow of the integration:
Below the diagram provides the flow of the integration:

1. Dapp decides on custom logic for each user. Let's assume that Dapp decides to sponsor gas for every approve transaction.

Expand All @@ -71,10 +71,10 @@ deducts gas fees from the manager's balance, and pays for the user's transaction
For this tutorial, we will use paymaster deployed on ZKsync sepolia testnet : [0xc1B0E2edC4cCaB51A764D7Dd8121CBf58C4D9E40](https://sepolia.explorer.zksync.io/address/0xc1B0E2edC4cCaB51A764D7Dd8121CBf58C4D9E40#transactions)

## 1. Create a signer
Paymaster will verify signature based on this signer address.
Private key of this signer address should be stored securely by the Dapp.
The paymaster will verify signature based on this signer address.
The private key of this signer address should be stored securely by the Dapp.

- Easy way to create one:
- Here is an easy way to create one:

```javascript
import { Wallet } from "zksync-ethers";
Expand All @@ -87,13 +87,13 @@ Call `depositAndAddSigner()` function with 0.01 ether and the signer address.
![deposit and add a signer](/images/permissionless-paymaster/depositAndAddSigner.png)

::callout{icon="i-heroicons-exclamation-circle"}
The depositor address is considered "manager". A manager can deposit/withdraw gas funds & add/remove signers at any given time.
The depositor address is considered a "manager". A manager can deposit/withdraw gas funds and add/remove signers at any given time.

*A manager can be a signer address too. (not recommended)*
::

## 3. Create function to sign EIP-712 typed paymaster data
This paymaster verifies signature signed by the signer address on the below data.
This paymaster verifies the signature signed by the signer address on the below data.
On successful validation, it allows sponsorship for the user using manager's deposited gas funds.

```solidity
Expand All @@ -110,7 +110,7 @@ On successful validation, it allows sponsorship for the user using manager's dep
);
```

- Create `getSignature()` function in your backend(recommended)
- Create a `getSignature()` function in your backend(recommended)

```javascript
// Example code
Expand Down Expand Up @@ -229,20 +229,20 @@ const tx = await DappContract.<function>([args..],{

- The gas funds are deducted from the manager's balance related to the signer on successful verification.
- Hence, if signer's private key is leaked, respective manager will need to replace/remove the signer immediately.
- Hence, if a signer's private key is leaked, the respective manager will need to replace/remove the signer immediately.

::

- Adding correct customData(paymasterParams : paymaster address & innerInputs), user shall get signature request pop-up for transaction.
Here user can verify that gas is not being paid from their end and only signature is required.
- Adding correct the `customData(paymasterParams : paymaster address & innerInputs)`, the user shall get a signature request pop-up for transaction.
Here the user can verify that gas is not being paid from their end and only a signature is required.
![transaction](/images/permissionless-paymaster/signatureRequest.png)

::callout{icon="i-heroicons-check-circle"}
Paymaster is successfully integrated.
::

## Refunds
ZKsync refunds ETH to paymaster for the unused gas.
ZKsync refunds ETH to the paymaster for the unused gas.
All refunded ETH are added back to the respective manager's balance in the next paymaster transaction. Hence, solving the refund issue for every manager.
## Notes
Expand Down

0 comments on commit 35dc457

Please sign in to comment.