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: use getGeneralPaymasterInput instead of zksync-ethers for viem paymasters #31

Merged
merged 1 commit into from
Jul 8, 2024
Merged
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
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
Loading