starknet_estimateFee

Estimates the resources required by transactions when applied on a given state.

Parameters

  • Invoke transaction V0 : invokes a specific function in the desired contract (not necessarily an account) OR
  • Invoke transaction V1 : initiates a transaction from a given account

📘

Invoke transaction version 0 is deprecated and will be removed in a future release of Starknet.

V0

KeyRequiredDetailType
contract_addressAddress the transaction is sent from.String
entry_point_selectorSmart contract entry pointsArray of string
call_dataHash of method signature and encoded parameters.String

V1

KeyRequiredDetailType
sender_addressA field element. represented by at most 63 hex digitsString
calldataThe data expected by the account's execute function (in most use cases, this includes the called contract address and a function selector)Array
  • Type:INVOKE
  • Broadcasted transaction common properties
KeyRequiredDetailType
max_feeThe maximal fee that can be charged for including the transactionString
versionVersion of the transaction schemeString
signatureArray of stringsArray
nonceA field element. represented by at most 63 hex digitsString
"params": {
  "request": [{
    "type": "INVOKE",
    "max_fee": "0x28ed6103d0000",
    "version": "0x1",
    "signature": [
      "0x42527ffe9912b338983cbed67e139cfcc26a4d8cf1d1c2a85e4125fdf5f59ed", "0x636147d06fefd02ed37984b752556d4b9aefdac1a50b3df0528ec7c201ad84b"
    ],
    "sender_address": "0x13e3ca9a377084c37dc7eacbd1d9f8c3e3733935bcbad887c32a0e213cd6fe0",
    "calldata": [
      "0x2",
      "0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
      "0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
      "0x0",
      "0x1",
      "0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
      "0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
      "0x1",
      "0x1",
      "0x2",
      "0x0",
      "0x1"
    ],
    "nonce": "0x1"
  }],
    "block_id": {
      "block_number": 59999
    }
}

Result

The fee estimations

Example

Request

curl <your-endpoint> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '
{
    "jsonrpc": "2.0",
    "id": "0",
    "method": "starknet_estimateFee",
    "params": {
        "request": [{
            "type": "INVOKE",
            "max_fee": "0x28ed6103d0000",
            "version": "0x1",
            "signature": [
                "0x42527ffe9912b338983cbed67e139cfcc26a4d8cf1d1c2a85e4125fdf5f59ed", "0x636147d06fefd02ed37984b752556d4b9aefdac1a50b3df0528ec7c201ad84b"
            ],
            "sender_address": "0x13e3ca9a377084c37dc7eacbd1d9f8c3e3733935bcbad887c32a0e213cd6fe0",
            "calldata": [
                "0x2",
                "0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
                "0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
                "0x0",
                "0x1",
                "0x57c4b510d66eb1188a7173f31cccee47b9736d40185da8144377b896d5ff3",
                "0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
                "0x1",
                "0x1",
                "0x2",
                "0x0",
                "0x1"
            ],
            "nonce": "0x1"
        }],
        "block_id": {
            "block_number": 59999
        }
    }
}'

Return

{
    "jsonrpc": "2.0",
    "result": [
        {
            "gas_consumed": "0x4d3b",
            "gas_price": "0x67edb4f57",
            "overall_fee": "0x1f5a73368740d"
        }
    ],
    "id": "0"
}
Language
Click Try It! to start a request and see the response here!