Skip to content

Commit

Permalink
Merge branch 'main' into db/update-verify-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter authored Oct 24, 2024
2 parents 94183a1 + a39ffe7 commit 27fc2d5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
- [zkVmSkip](./zksync-specifics/cheatcodes/zk-vm-skip.md)
- [zkUsePaymaster](./zksync-specifics/cheatcodes/zk-use-paymaster.md)
- [Gas Overview](./zksync-specifics/gas.md)
- [Paymaster Overview](./zksync-specifics/paymaster-overview.md)
- [Examples](./zksync-specifics/examples/README.md)
- [Paymaster Approval Based](./zksync-specifics/examples/paymaster-approval-based.md)

# Supported Commands
- [Command List](./supported-commands/README.md)

Expand Down
2 changes: 1 addition & 1 deletion src/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ For Windows users, you'll also need a recent version of [Visual Studio](https://
You can either use the different [Foundryup-ZKsync](#using-foundryup) flags:

```sh
foundryup-zksync --branch master
foundryup-zksync --branch main
foundryup-zksync --path path/to/foundry-zksync
```

Expand Down
1 change: 1 addition & 0 deletions src/zksync-specifics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
- [Additional Cheatcodes](cheatcodes/README.md)
- [zkVm](cheatcodes/zkvm.md)
- [Gas Overview](gas.md)
- [Paymaster Overview](paymaster-overview.md)
53 changes: 53 additions & 0 deletions src/zksync-specifics/paymaster-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Paymaster Overview

Paymasters in the ZKsync ecosystem represent a groundbreaking approach to handling transaction fees. They are special accounts designed to subsidize transaction costs for other accounts, potentially making certain transactions free for end-users. This feature is particularly useful for dApp developers looking to improve their platform's accessibility and user experience by covering transaction fees on behalf of their users.

### How Paymasters Work

Paymasters are smart contracts that implement the `IPaymaster` interface. They are designed to be used in conjunction with the ZKsync network's transaction processing mechanism. When a transaction is sent from an account, the paymaster is specified in the transaction's metadata. The paymaster is then responsible for paying the transaction fee and any other costs associated with the transaction.

## How to interact with a Paymaster using Foundry

As of right now, the ways to interact with a paymaster contract using Foundry are using `cast send`, `forge create` or with the use of the `zkUsePaymaster` cheatcode.

### Using `cast send`

`cast send` signs and publishes a transaction. The documentation can be found [here](../reference/cast/cast-send.md).

To pair this with a paymaster contract, you need to specify the paymaster address and the encoded paymaster input in the command.

The flags for this are:

`--zk-paymaster-address`
    The address where the paymaster contract is deployed.

`--zk-paymaster-input`
    The encoded input for the paymaster contract. This depends on the paymaster contract implementation.

To encode the paymaster input, you can use the `cast calldata` command which can be found [here](../reference/cast/cast-calldata.md).

```bash
cast send 0xdb8bA5F5DfB1636361d2fE851d7D3ed93acfc487 "increment()" --rpc-url https://sepolia.era.zksync.dev --private-key <your-private-key> --zk-paymaster-address 0x3cB2b87D10Ac01736A65688F3e0Fb1b070B3eeA3 --zk-paymaster-input $(cast calldata "approvalBased(address,uint256,bytes)" 0x31c43ac5e6A0fe62954B9056441b0A214722516e 1000000000000000000 "0x")
```

### Using `forge create`

`forge create` is a command-line tool for deploying smart contracts using the Foundry framework. The documentation can be found [here](../reference/forge/forge-create.md).

To deploy a paymaster contract using `forge create`, you need to specify the paymaster contract address in the command.

The flags for this are:

`--zk-paymaster-address`
&nbsp;&nbsp;&nbsp;&nbsp;The address where the paymaster contract is deployed.

`--zk-paymaster-input`
&nbsp;&nbsp;&nbsp;&nbsp;The encoded input for the paymaster contract. This depends on the paymaster contract implementation.

To encode the paymaster input, you can use the `cast calldata` command also which can be found [here](../reference/cast/cast-calldata.md).

```bash
forge create Greeter.sol:Greeter --rpc-url "https://sepolia.era.zksync.dev" --private-key <your-private-key> --zksync --zk-paymaster-address 0x3cB2b87D10Ac01736A65688F3e0Fb1b070B3eeA3 --zk-paymaster-input $(cast calldata "approvalBased(address,uint256,bytes)" 0x31c43ac5e6A0fe62954B9056441b0A214722516e 1 "0x")
```

Also, see the [ZKsync Paymaster Documentation](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters) for more information.

0 comments on commit 27fc2d5

Please sign in to comment.