Skip to main content

starknet_estimateMessageFee

Returns an estimate of the L2 fee required for the network to process the specified L1 message, at the specified block.

Parameters

  • message: [Required] The message to estimate, which includes the following fields:
    • from_address: (string) [Required] The address of the L1 contract sending the message.
    • to_address: (string) [Required] The L2 address the message is sent to.
    • entry_point_selector: (string) [Required] The entry point selector.
    • payload: (array) [Required] The payload of the message.
  • block_id: [Required] The block parameter object containing one of the following:
    • block_hash: (string) Block hash.
    • block_number: (integer) Decimal block number.
    • One of the string tags latest or pending.

Returns

A fee estimate object containing:

  • gas_consumed: The Ethereum gas consumption of the transaction.
  • gas_price: The gas price (in gwei) that was used in the cost estimation.
  • overall_fee: The estimated fee for the transaction (in gwei), product of gas_consumed and gas_price.

Example

Replace YOUR-API-KEY with an API key from your Infura dashboard.

Request

curl https://starknet-mainnet.infura.io/v3/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_estimateMessageFee",
"params": {
"message": {
"from_address": "0xAbCdEf0123456789aBcDeF0123456789AbCdEf01",
"to_address": "0x044e5b3f0471a26bc749ffa1d8dd8e43640e05f1b33cf05cef6adee6f5b1b4cf",
"entry_point_selector": "0x00000",
"payload": []
},
"block_id": "latest"
},
"id": 0
}'

Response

{
"jsonrpc": "2.0",
"result": {
"gas_consumed": "0x41de",
"gas_price": "0x67edb4f57",
"overall_fee": "0x1abd7b153e472"
},
"id": 0
}