Adding support for zkSync Paymasters and AA #1229
Replies: 5 comments 3 replies
-
Disclaimer: I am not a maintainer of Viem.
So, the final API would look something like this: import { zkSync } from 'viem/chains'
const signature = await walletClient.signTransaction({
chain: zkSync,
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n,
customData: {
gasPerPubdata?: BigNumberish;
factoryDeps?: BytesLike[];
customSignature?: BytesLike;
paymasterParams?: {
paymaster: Address;
paymasterInput: BytesLike;
}
}}) |
Beta Was this translation helpful? Give feedback.
-
Hey @jxom @tmm any thoughts here? Reading the CONTRIBUTING.md asks to post larger endeavours to discussions page first for maintainer feedback. Hoping to kickstart this work 💪 |
Beta Was this translation helpful? Give feedback.
-
I wanted to add another discussion subject about this, please let me know if this needs to be separate thread. I'm currently adding the formatters/serializers to support ZkSync and with this PR it should be able to interact with the ZkSync chain, but not in an easy way. The field const transactionToSign = {
txType: 113n,
from: BigInt(account),
to: BigInt(prepareTransactionRequest.to),
gasLimit: BigInt(prepareTransactionRequest.gas),
gasPerPubdataByteLimit: 50000n,
maxFeePerGas: prepareTransactionRequest.maxFeePerGas,
maxPriorityFeePerGas: 0n,
paymaster: BigInt(params.paymaster),
nonce: BigInt(prepareTransactionRequest.nonce),
value: 0n,
data: prepareTransactionRequest.data,
factoryDeps: [],
paymasterInput: params.paymasterInput
}
const customSignature = await walletClient.signTypedData({
account,
domain: {
name: 'zkSync',
version: '2',
chainId: 270
},
types: {
Transaction: [
{ name: 'txType', type: 'uint256' },
{ name: 'from', type: 'uint256' },
{ name: 'to', type: 'uint256' },
{ name: 'gasLimit', type: 'uint256' },
{ name: 'gasPerPubdataByteLimit', type: 'uint256' },
{ name: 'maxFeePerGas', type: 'uint256' },
{ name: 'maxPriorityFeePerGas', type: 'uint256' },
{ name: 'paymaster', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'value', type: 'uint256' },
{ name: 'data', type: 'bytes' },
{ name: 'factoryDeps', type: 'bytes32[]' },
{ name: 'paymasterInput', type: 'bytes' }
],
},
primaryType: 'Transaction',
message: transactionToSign,
}) This then will ask MetaMask to sign and then we have value for the This is currently being done with I'm not sure how EIP712 can be generically implemented and if I'm also not sure if this is a feature that should be added to Viem or if there is another possibility for this use case. |
Beta Was this translation helpful? Give feedback.
-
@jxom I dont know how the team handles closing discussions but I would consider this closed. Thanks again for supporting this 🚀 |
Beta Was this translation helpful? Give feedback.
-
@jxom does viem support AA tx with paymaster? |
Beta Was this translation helpful? Give feedback.
-
Objective
First, big fan of
viem
❤️ thank you for the great work!Second, it is great that zkSync has been added but it does not seem like you can leverage its native account abstraction and paymasters using
viem
currently. I am looking to understand what the best approach or preferred approach to have this supported inviem
.Context
zkSync Era is Web3-compatible, although it has some differences compared to Ethereum. One of the main differences is native AA support which required extending standard Ethereum transactions with new custom fields. Such extended transactions are called EIP-712 transactions since EIP-712 is used to sign them. The additional fields consist of:
In order to take advantage of paymasters the transaction must be a 712-transaction and must have
paymasterParams
set.Problem
The issue is that
viem
does not support transaction overrides and will complain or ignore if you attempt to do the following:Minimum reproducible repo:
The provided repo is a minimum example of the problem.
Implementation questions
viem
maintainers to what the preferred approach would be.Resources
Beta Was this translation helpful? Give feedback.
All reactions