Skip to main content

starknet_estimateFee RPC Method

Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transactions reverts or fails due to any reason (e.g. validation failure or an internal error), a TRANSACTION_EXECUTION_ERROR is returned. For v0-2 transactions the estimate is given in wei, and for v3 transactions it is given in fri.

Updated on
Mar 18, 2024

starknet_estimateFee RPC Method

Parameters

request
array
REQUIRED
The request object which contains one of the following objects:
BROADCASTED_INVOKE_TXN
object
The broadcasted invoke transaction object which contains the following fields:
type
string
REQUIRED
The type of declare. It can take only one value - 'INVOKE'
max_fee
string
REQUIRED
The maximal fee that can be charged for including the transaction
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
sender_address
string
REQUIRED
The address of the account contract sending the declaration transaction
entry_point_selector
string
REQUIRED
The entry point selector
calldata
array
REQUIRED
The parameters passed to the constructor
BROADCASTED_DECLARE_TXN
object
The broadcasted declare transaction which contains one of the following objects:
BROADCASTED_DECLARE_TXN_V1
object
The Broadcasted declare contract transaction V1
type
string
REQUIRED
The type of declare. It can take only one value - 'DECLARE'
sender_address
string
REQUIRED
The address of the account contract sending the declaration transaction
max_fee
string
REQUIRED
The maximal fee that can be charged for including the transaction
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
nonce
string
REQUIRED
The nonce value
contract_class
object
REQUIRED
The class to be declared
sierra_program
array
REQUIRED
The list of Sierra instructions of which the program consists
contract_class_version
string
REQUIRED
The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
entry_points_by_type
object
REQUIRED
The entry points by type object which contains the following fields:
CONSTRUCTOR
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
EXTERNAL
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
L1_HANDLER
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
abi
string
The class ABI, as supplied by the user declaring the class
BROADCASTED_DECLARE_TXN_V2
object
The Broadcasted declare Contract Transaction V2
type
string
REQUIRED
The type of declare. It can take only one value - 'DECLARE'
sender_address
string
REQUIRED
The address of the account contract sending the declaration transaction
compiled_class_hash
string
REQUIRED
The hash of the Cairo assembly resulting from the Sierra compilation
max_fee
string
REQUIRED
The maximal fee that can be charged for including the transaction
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
nonce
string
REQUIRED
The nonce value
contract_class
object
REQUIRED
The class to be declared
sierra_program
array
REQUIRED
The list of Sierra instructions of which the program consists
contract_class_version
string
REQUIRED
The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
entry_points_by_type
object
REQUIRED
The entry points by type object which contains the following fields:
CONSTRUCTOR
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
EXTERNAL
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
L1_HANDLER
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
abi
string
The class ABI, as supplied by the user declaring the class
BROADCASTED_DECLARE_TXN_V3
object
The Broadcasted declare Contract Transaction V3
type
string
REQUIRED
The type of declare. It can take only one value - 'DECLARE'
sender_address
string
REQUIRED
The address of the account contract sending the declaration transaction
compiled_class_hash
string
REQUIRED
The hash of the Cairo assembly resulting from the Sierra compilation
max_fee
string
REQUIRED
The maximal fee that can be charged for including the transaction
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
nonce
string
REQUIRED
The nonce value
contract_class
object
REQUIRED
The class to be declared
sierra_program
array
REQUIRED
The list of Sierra instructions of which the program consists
contract_class_version
string
REQUIRED
The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
entry_points_by_type
object
REQUIRED
The entry points by type object which contains the following fields:
CONSTRUCTOR
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
EXTERNAL
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
L1_HANDLER
array
REQUIRED
The list of Sierra instructions of which the program consists
selector
string
REQUIRED
A unique identifier of the entry point (function) in the program
function_idx
integer
REQUIRED
The index of the function in the program
abi
string
The class ABI, as supplied by the user declaring the class
resource_bounds
object
REQUIRED
The resource bounds for the transaction execution
l1_gas
string
REQUIRED
The max amount and max price per unit of L1 gas used in this tx
max_amount
string
REQUIRED
The max amount of the resource that can be used in the tx
max_price_per_unit
string
REQUIRED
The max price per unit of this resource for this tx
l2_gas
string
REQUIRED
The max amount and max price per unit of L2 gas used in this tx
max_amount
string
REQUIRED
The max amount of the resource that can be used in the tx
max_price_per_unit
string
REQUIRED
The max price per unit of this resource for this tx
tip
string
REQUIRED
The tip for the transaction
paymaster_data
array
REQUIRED
The data needed to allow the paymaster to pay for the transaction in native tokens
account_deployment_data
array
REQUIRED
The data needed to deploy the account contract from which this tx will be initiated
nonce_data_availability_mode
string
REQUIRED
The storage domain of the account's nonce (an account has a nonce per DA mode). It can be one of 'L1' or 'L2'
fee_data_availability_mode
string
REQUIRED
The storage domain of the account's balance from which fee will be charged. It can be one of 'L1' or 'L2'
BROADCASTED_DEPLOY_ACCOUNT_TXN
object
The broadcasted deploy account transaction which contains one of the following objects:
DEPLOY_ACCOUNT_TXN_V1
object
The deploy account transaction object which contains the following field:
type
string
REQUIRED
The type of declare. It can take only one value - 'DEPLOY_ACCOUNT'
max_fee
string
REQUIRED
The maximal fee that can be charged for including the transaction
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
nonce
string
REQUIRED
The nonce value
contract_address_salt
string
REQUIRED
The salt for the address of the deployed contract
constructor_calldata
array
REQUIRED
The parameters passed to the constructor
class_hash
string
REQUIRED
The hash of the deployed contract's class
DEPLOY_ACCOUNT_TXN_V3
object
The deploy account transaction object which contains the following field:
type
string
REQUIRED
The type of declare. It can take only one value - 'DEPLOY_ACCOUNT'
version
string
REQUIRED
The version of the transaction scheme
signature
string
REQUIRED
The signature associated with the transaction
nonce
string
REQUIRED
The nonce value
contract_address_salt
string
REQUIRED
The salt for the address of the deployed contract
constructor_calldata
array
REQUIRED
The parameters passed to the constructor
class_hash
string
REQUIRED
The hash of the deployed contract's class
resource_bounds
object
REQUIRED
The resource bounds for the transaction execution
l1_gas
string
REQUIRED
The max amount and max price per unit of L1 gas used in this tx
max_amount
string
REQUIRED
The max amount of the resource that can be used in the tx
max_price_per_unit
string
REQUIRED
The max price per unit of this resource for this tx
l2_gas
string
REQUIRED
The max amount and max price per unit of L2 gas used in this tx
max_amount
string
REQUIRED
The max amount of the resource that can be used in the tx
max_price_per_unit
string
REQUIRED
The max price per unit of this resource for this tx
tip
string
REQUIRED
The tip for the transaction
paymaster_data
array
REQUIRED
The data needed to allow the paymaster to pay for the transaction in native tokens
nonce_data_availability_mode
string
REQUIRED
The storage domain of the account's nonce (an account has a nonce per DA mode). It can be one of 'L1' or 'L2'
fee_data_availability_mode
string
REQUIRED
The storage domain of the account's balance from which fee will be charged. It can be one of 'L1' or 'L2'
payload
array
REQUIRED
The payload of the message
block_id
string
REQUIRED
The hash of the requested block, the block number (height) of the requested block, or a block tag (latest or pending)
simulation_flags
array
REQUIRED
It describes what parts of the transaction should be executed. It can take a value as 'SKIP_VALIDATE'

Returns

result
object
The result object with the following fields:
gas_consumed
string
The Ethereum gas consumption of the transaction
gas_price
string
The gas price (in wei or fri, depending on the tx version) that was used in the cost estimation
data_gas_consumed
string
The Ethereum data gas consumption of the transaction
data_gas_price
string
The data gas price (in wei or fri, depending on the tx version) that was used in the cost estimation
overall_fee
string
The estimated fee for the transaction (in wei or fri, depending on the tx version), equals to gas_consumed*gas_price + data_gas_consumed*data_gas_price
unit
string
The units in which the fee is given
Request
1
curl --location 'https://docs-demo.strk-mainnet.quiknode.pro/' \
2
--header 'accept: application/json' \
3
--header 'content-type: application/json' \
4
--data '{
5
"id": 1,
6
"jsonrpc": "2.0",
7
"method": "starknet_estimateFee",
8
"params": {
9
"request": [{
10
"type": "INVOKE",
11
"max_fee": "0x28ed6103d0000",
12
"version": "0x1",
13
"signature": [
14
"0x42527ffe9912b338983cbed67e139cfcc26a4d8cf1d1c2a85e4125fdf5f59ed", "0x636147d06fefd02ed37984b752556d4b9aefdac1a50b3df0528ec7c201ad84b"
15
],
16
"sender_address": "0x13e3ca9a377084c37dc7eacbd1d9f8c3e3733935bcbad887c32a0e213cd6fe0",
17
"calldata": [
18
"0x2",
19
"0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
20
"0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
21
"0x0",
22
"0x1",
23
"0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
24
"0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
25
"0x1",
26
"0x1",
27
"0x2",
28
"0x0",
29
"0x1"
30
],
31
"nonce": "0x1"
32
}],
33
"simulation_flags" : ["SKIP_VALIDATE"],
34
"block_id": {
35
"block_number": 59999
36
}
37
}
38
}'
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free