Skip to content

Commit

Permalink
fix: use getGeneralPaymasterInput instead of zksync-ethers for viem p…
Browse files Browse the repository at this point in the history
…aymasters
  • Loading branch information
Romsters committed Jul 7, 2024
1 parent 9e02531 commit 2211d41
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions content/tutorials/guide-viem/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ To utilize ZKsync Era's native account abstraction and Paymasters, extend the Wa
import 'viem/window';
import { createWalletClient, custom } from 'viem';
import { zkSync } from 'viem/chains';
import { eip712WalletActions } from 'viem/zksync';
import { eip712WalletActions, getGeneralPaymasterInput } from 'viem/zksync';

// Initialize and extend the wallet client
const walletClient = createWalletClient({
Expand All @@ -111,21 +111,15 @@ const walletClient = createWalletClient({
#### Sending a Transaction with a Paymaster

```javascript
import { utils } from "zksync-ethers";

const paymasterAddress = "<DEPLOYED_PAYMASTER_ADDRESS>"; // Replace with your paymaster address
const params = utils.getPaymasterParams(paymasterAddress, {
type: "General",
innerInput: new Uint8Array(),
});

// Send the transaction example
const hash = await walletClient.sendTransaction({
account: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
to: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
value: 1000000000000000000n,
paymaster: paymasterAddress,
paymasterInput: params.paymasterInput,
paymasterInput: getGeneralPaymasterInput({ innerInput: new Uint8Array() }),
});
```

Expand All @@ -141,24 +135,16 @@ Remember to replace `PAYMASTER_CONTRACT_ADDRESS` with your own!
#### Contract Function Call

```javascript
import { utils } from "zksync-ethers";

const paymasterAddress = "<DEPLOYED_PAYMASTER_ADDRESS>"; // Replace with actual address

// Set up paymaster parameters
const params = utils.getPaymasterParams(paymasterAddress, {
type: "General",
innerInput: new Uint8Array(),
});

// Call the contract function
const hash = await walletClient.writeContract({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: parseAbi(["function setGreeting(string _greeting) nonpayable"]),
functionName: "setGreeting",
args: ["ZKsync!"],
paymaster: paymasterAddress,
paymasterInput: params.paymasterInput,
paymasterInput: getGeneralPaymasterInput({ innerInput: new Uint8Array() }),
});
```

Expand Down

0 comments on commit 2211d41

Please sign in to comment.