我需要使用 wagmi 计算交换功能的预估 Gas 费用
import { useEstimateGas } from 'wagmi'
import { parseEther } from 'viem'
import { config } from './config'
function App() {
const result = useEstimateGas({
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
}
我尝试使用这个钩子,但使用它无法获取交换功能的估计汽油费。
在Wagmi2.0中,可以在writeContract之前估计Gas。 请注意以下网址。 https://wagmi.sh/core/api/actions/estimateGas