-
Allow passing a gas limit multiplier on usePrepareContractWrite, to support use cases where there's considerable gas usage variability. Why?One example: on auction contracts with extension for last-minute bids: if the bid is placed when the extension is triggered, the gas usage is considerably higher. If usePrepareContractWrite estimated the gas before that threshold, the gas limit might be too low and lead to a failed tx. The existing alternatives lead to bad dev experience:
Suggested API:
example: const { config, error } = usePrepareContractWrite({
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
abi: wagmigotchiABI,
functionName: 'feed',
gasLimitMultiplier: 1.2,
}) The importance of this issueThere's a bunch of discussions suggesting the need for something like this: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
My current workaround is multiplying manually, btw: const { config } = usePrepareContractWrite({
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
abi: wagmigotchiABI,
functionName: 'feed',
})
const { data, isLoading, isSuccess, write } = useContractWrite({
...config,
request: {
...config.request,
gasLimit: config.request.gasLimit.mul(115).div(100), // equivalent to a gasLimitMultiplier of 1.15
},
}) |
Beta Was this translation helpful? Give feedback.
-
@volkyeth did you find an elegant solution in the end? @AndonMitev |
Beta Was this translation helpful? Give feedback.
https://wagmi.sh/react/guides/migrate-from-v1-to-v2#removed-prepare-hooks