diff --git a/website/content/hooks/query/useEstimateFees.mdx b/website/content/hooks/query/useEstimateFees.mdx new file mode 100644 index 00000000..55ef6486 --- /dev/null +++ b/website/content/hooks/query/useEstimateFees.mdx @@ -0,0 +1,53 @@ +--- +title: useEstimateFees +priority: 194 +hookType: query +--- + +Perform fee estimation for smart contract calls. Estimation then later can be used to specify the `maxFee` for the actual contract call. + +## Usage + +```ts +import { useAccount, useContract, useEstimateFees } from "@starknet-react/core"; + +export default function Component() { + const { address } = useAccount(); + + const { contract } = useContract({ + abi: erc20ABI, + address: chain.nativeCurrency.address, + }); + + const calls = useMemo(() => { + if (!address || !contract) return []; + return contract.populateTransaction["transfer"]!(address, { low: 1, high: 0 }); + }, [contract, address]); + + const { data, isError, isLoading, error } = useEstimateFees({ + calls, + watch: true, + }); + + if (isLoading) return