Skip to content

Commit

Permalink
fix(web3js-plugin): update-custom-data
Browse files Browse the repository at this point in the history
  • Loading branch information
danforbes committed Sep 12, 2024
1 parent 5792bd9 commit b1bbaa7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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);
```

0 comments on commit b1bbaa7

Please sign in to comment.