Skip to content
Starknet Start

usePaymasterEstimateFees

Hook to estimate fees for smart contract calls.

Usage

import {  } from "@starknetfoundation/starknet-start-react";
import { ,  } from "starknet";
 
const : [] = [
  {
    : "STRK_SEPOLIA_ADDRESS",
    : "transfer",
    : ["recipient_address", "0x1", "0x0"],
  },
];
 
const :  = {
  : "default", // default or sponsored(need api-key)
  : "USDC_SEPOLIA_ADDRESS", // mandatory if 'default'
};
 
const { ,  } = ({
  ,
  : {
    ,
  },
});

Data

  • Type: PaymasterFeeEstimate

The PaymasterFeeEstimate response type from starknet.

Arguments

calls

  • Type: Call[] | undefined

List of smart contract calls to estimate, type from starknet

options

  • Type: PaymasterDetails

Paymaster details, type from starknet

watch

  • Type: boolean | undefined

If true, refetch the data at every block.

enabled

  • Type: boolean | undefined

If false, don't perform the query.

refetchInterval

  • Type: number | false | ((query: Query) => number | false | undefined)

If set to a number, the query is refetched at the provided interval (in milliseconds).

If set to a function, the callback will be used to determine the refetch interval.

Returns

data

  • Type: Data | undefined

The resolved data.

error

  • Type: Error | null

Any error thrown by the query.

status

  • Type: "error" | "pending" | "success"

The query status.

  • pending: the query is being executed.
  • success: the query executed without an error.
  • error: the query threw an error.

isError

  • Type: boolean

Derived from status.

isPending

  • Type: boolean

Derived from status.

isSuccess

  • Type: boolean

Derived from status.

fetchStatus

  • Type: "fetching" | "paused" | "idle"

  • fetching: the query is fetching.

  • paused: the query is paused.

  • idle: the query is not fetching.

isFetching

  • Type: boolean

Derived from fetchStatus.

isLoading

  • Type: boolean

True while the query is loading for the first time.

refetch

  • Type: (options?: RefetchOptions) => Promise<QueryObserverResult<Data, Error>>

Refetch the query.