[SDK] EIP-712 gas price and viem: gasPrice or EIP-1559? #808
-
Team or ProjectLens Network Select the SDKJavaScript EnvironmentTestnet Issue DescriptionFrom past conversations, we have been using pre-EIP1559
Given the error message suggests a response from the node, we are not sure if this is an issue w/ the request or the client. We do send EIP712 transactions in the same way through ethers.js and allow-rs without any issue. Expected BehaviorThis ticket is more to clarify what is the recommended way to handle gas prices. Should we use legacy Code Exampleimport { chains } from '@lens-network/sdk/viem';
import { parseAbi, Hex, createWalletClient, http, encodeFunctionData } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { getGasPrice } from 'viem/actions';
import { eip712WalletActions, getGeneralPaymasterInput, sendEip712Transaction } from 'viem/zksync';
const chain = chains.testnet;
const account = privateKeyToAccount(process.env.PRIVATE_KEY as Hex);
const walletClient = createWalletClient({
account,
chain,
transport: http(),
}).extend(eip712WalletActions());
const abi = parseAbi([
"function ping()"
]);
const hash = await sendEip712Transaction(walletClient, {
account,
to: '0x06a71429d153026a0F3bAdf481c216FDfe2d0629',
data: encodeFunctionData({
abi: abi,
functionName: 'ping'
}),
paymaster: '0xE6b37F099439ED1Eb38a97b909E9AD0ad74270Af',
paymasterInput: getGeneralPaymasterInput({
innerInput: '0x',
}),
gasPrice: await getGasPrice(walletClient)
}) Repo Link (Optional)No response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
In the ZKsync Era, while the EIP-1559 transaction format is supported, the Given the error you encountered ("max fee per gas less than block base fee"), it suggests that the node (viem in this case) is expecting EIP-1559 style gas parameters but is not handling them as expected in the context of ZKsync Era. This could be due to a discrepancy in how the viem node interprets or expects these parameters compared to the standard ZKsync Era node behavior. For transactions on ZKsync Era, it's recommended to use the legacy For more detailed information on how gas is handled in ZKsync Era, you can refer to the ZKsync documentation on transaction lifecycle. For further discussions and developer support, you might find it helpful to visit the ZKsync developers discussions on Github. Your feedback helps us serve you better. If this fully addresses your question, please give it a thumbs up. If it doesn't, please give it a thumbs down. This will inform the community and team so we can improve our support. |
Beta Was this translation helpful? Give feedback.
-
From what I've found so far you'll want to use EIP-1559 |
Beta Was this translation helpful? Give feedback.
-
In sendEip712Transaction(wallet, {
account,
to: '0xa61464658AfeAf65CccaaFD3a512b69A83B77618',
value: 1_000_000_000n,
paymaster: '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174',
paymasterInput: getApprovalBasedPaymasterInput({
minAllowance: 1n,
token: '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4',
innerInput: new Uint8Array(),
}),
gasPrice: await getGasPrice(wallet) // <-- not supported
}) Error:
In |
Beta Was this translation helpful? Give feedback.
The best approach for gas and price estimation is to use zks_estimateFee endpoint. Both zksync-ethers and viem provide
estimateFee
method.