如何使用 wagmi 计算交换的预估 Gas 费用

问题描述 投票:0回答:1

我需要使用 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'),
  })
}

我尝试使用这个钩子,但使用它无法获取交换功能的估计汽油费。

blockchain smartcontracts swap evm wagmi
1个回答
0
投票

在Wagmi2.0中,可以在writeContract之前估计Gas。 请注意以下网址。 https://wagmi.sh/core/api/actions/estimateGas

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.