Replies: 3 comments 8 replies
-
Hi!
Let me know your thoughts on 1! |
Beta Was this translation helpful? Give feedback.
-
Also wanted to know what if I want to override/write a wrapper around method to send transaction so that I can extend it's behavior Say I want to write a nonce handling for the privateKeyToAccount so that wen tx fails due to incorrect nonce it can be sent again (retry |
Beta Was this translation helpful? Give feedback.
-
Finally figured how to avoid
viem's writing custom import type { Account, Address, Chain, Transport, WalletClientConfig } from 'viem'
import { createClient, walletActions } from 'viem'
export function createWalletCustomClient<accountOrAddress extends Account | Address>(
parameters: WalletClientConfig<Transport, Chain, accountOrAddress>,
) {
const { key = 'wallet', name = 'Wallet Client', transport } = parameters
let client = createClient({
...parameters,
key,
name,
transport,
type: 'walletClient',
})
if (parameters.chain) {
const chainId = parameters.chain.id
client = client.extend(() => ({
async getChainId() {
return chainId
},
}))
}
return client.extend(walletActions)
} |
Beta Was this translation helpful? Give feedback.
-
Wen sending a raw transaction with account(privateKeyToAccount) and
walletClient
withchain
andhttp
and passingnonce
,maxFeePerGas
,gasLimit
andmaxPriorityFeePerGas
contract.write({args: [], ...aboveOptions}
sends three rpc calls before sending a transaction or raw transaction
eth_chainId
- already passed in chain object and it's static why waste of resourceseth_getBlockByNumber
eth_estimateGas
Already feeding all the required information why do double work and increase the latency of sending tx by 4x
I can send gasLimit to avoid
eth_estimateGas
, butis there a way to avoid
eth_chainId
ð_getBlockByNumber
Beta Was this translation helpful? Give feedback.
All reactions