⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

starknet_estimateMessageFee

estimate the L2 fee of a message sent on L1

estimates the resources required by the l1_handler transaction induced by the message

Parameters

ParameterTypeDescription
messageobjectL1 message object with from_address, to_address, entry_point_selector, and payload
block_idstringBlock reference ("latest", "l1_accepted", block hash, or block number)

Request

{
"jsonrpc": "2.0",
"method": "starknet_estimateMessageFee",
"params": [
{
"from_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"to_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"payload": [
"0x1"
],
"entry_point_selector": "0x0102030405"
},
{
"block_hash": "0x05abbad1e5"
}
],
"id": 1
}

Returns

The fee estimation

Fee estimation with L1/L2 gas consumption and prices

Errors

CodeMessage
40Contract error
24Block not found

Examples

curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_estimateMessageFee",
"params": [
{
"from_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"to_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"payload": [
"0x1"
],
"entry_point_selector": "0x0102030405"
},
{
"block_hash": "0x05abbad1e5"
}
],
"id": 1
}'