Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web3js-plugin): update-custom-data #102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions content/10.js/01.web3js/05.custom-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ ZKsync-specific parameters:

## Add custom data to a transaction

Any transaction made to the ZKsync Era network with the Web3.js plugin for ZKsync can include the above ZKsync-specific
Transactions made to the ZKsync Era network with the Web3.js plugin for ZKsync can include the above ZKsync-specific
parameters by specifying a `customData` property of the [type `Eip712Meta`](https://chainsafe.github.io/web3-plugin-zksync/types/types.Eip712Meta.html).
The following code snippet demonstrates specifying the `gasPerpPubdata` parameter for a [deposit transaction](/js/web3js/wallet#deposit):
The following code snippet demonstrates specifying the `gasPerPubdata` parameter:

```ts
const tx: types.PriorityOpResponse = await wallet.deposit({
token: "<TOKEN_ADDRESS>",
const transactionRequest: types.TransactionRequest = {
to: "<RECEIVER_ADDRESS>",
amount: 2_000_000_000n,
refundRecipient: wallet.getAddress(),
value: 1,
customData: {
gasPerPubdata: 50_000,
},
});
};
const response: types.PriorityOpResponse =
await wallet.signAndSend(transactionRequest);
```
12 changes: 6 additions & 6 deletions content/10.js/01.web3js/06.paymasters.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ which expects two parameters: the address of the paymaster account and an object
or the [`GeneralPaymasterInput` interface](https://chainsafe.github.io/web3-plugin-zksync/interfaces/types.GeneralPaymasterInput.html)
(for [general paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters#general-paymaster-flow)).

The following code snippet demonstrates using an approval-based paymaster to cover the fees of a [deposit transaction](/js/web3js/wallet#deposit):
The following code snippet demonstrates using an approval-based paymaster to cover the fees of a transaction:

```ts
const tx: types.PriorityOpResponse = await wallet.deposit({
token: "<TOKEN_ADDRESS>",
const transactionRequest: types.TransactionRequest = {
to: "<RECEIVER_ADDRESS>",
amount: 2_000_000_000n,
refundRecipient: wallet.getAddress(),
value: 1,
customData: {
paymasterParams: getPaymasterParams("<PAYMASTER_ADDRESS>", {
innerInput: new Uint8Array(),
Expand All @@ -35,5 +33,7 @@ const tx: types.PriorityOpResponse = await wallet.deposit({
type: "ApprovalBased",
}),
},
});
};
const response: types.PriorityOpResponse =
await wallet.signAndSend(transactionRequest);
```