starknet_estimateFee
Estimates the resources and fees required for executing a sequence of transactions on Starknet.
Parameters
Parameter | Type | Description |
---|---|---|
request | array | Array of transactions to estimate |
simulation_flags | array | Optional simulation parameters (SKIP_VALIDATE to skip validation phase) |
block_id | string | Block reference: "latest" (most recent block), block hash, or block number |
{
"jsonrpc": "2.0",
"method": "starknet_estimateFee",
"params": [
[
{
"type": "INVOKE",
"sender_address": "0x1234567890abcdef1234567890abcdef12345678",
"calldata": [
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0x83afdfe4cdc632f4b21f8bdebabc13e47c1f1b4b97fc8b5b4b1c4e6746a3a7e0",
"0x3",
"0x2386f26fc10000",
"0x0",
"0x456789abcdef456789abcdef456789ab"
],
"version": "0x3",
"signature": ["0x0"],
"nonce": "0x1"
}
],
["SKIP_VALIDATE"],
"latest"
],
"id": 1
}
Returns
ARRAY
- Array of fee estimation objects containing:
overall_fee
- Total fee in wei (felt252)gas_consumed
- Total gas consumed (felt252)gas_price
- Gas price in wei per unit (felt252)
Examples
- cURL
- JavaScript
- Python
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_estimateFee",
"params": [
[
{
"type": "INVOKE",
"sender_address": "0x1234567890abcdef1234567890abcdef12345678",
"calldata": [
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0x83afdfe4cdc632f4b21f8bdebabc13e47c1f1b4b97fc8b5b4b1c4e6746a3a7e0",
"0x3",
"0xde0b6b3a7640000",
"0x0",
"0x456789abcdef456789abcdef456789ab"
],
"version": "0x3",
"signature": ["0x0"],
"nonce": "0x1"
}
],
["SKIP_VALIDATE"],
"latest"
],
"id": 1
}'
import { RpcProvider } from 'starknet';
const provider = new RpcProvider({
nodeUrl: 'https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY'
});
const transaction = {
type: "INVOKE",
sender_address: "0x1234567890abcdef1234567890abcdef12345678",
calldata: [
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0x83afdfe4cdc632f4b21f8bdebabc13e47c1f1b4b97fc8b5b4b1c4e6746a3a7e0",
"0x3",
"0xde0b6b3a7640000",
"0x0",
"0x456789abcdef456789abcdef456789ab"
],
version: "0x3",
signature: ["0x0"],
nonce: "0x1"
};
const estimate = await provider.estimateFee([transaction], ["SKIP_VALIDATE"], "latest");
console.log(estimate);
from starknet_py.net.full_node_client import FullNodeClient
client = FullNodeClient(
node_url="https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY"
)
transaction = {
"type": "INVOKE",
"sender_address": "0x1234567890abcdef1234567890abcdef12345678",
"calldata": [
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0x83afdfe4cdc632f4b21f8bdebabc13e47c1f1b4b97fc8b5b4b1c4e6746a3a7e0",
"0x3",
"0xde0b6b3a7640000",
"0x0",
"0x456789abcdef456789abcdef456789ab"
],
"version": "0x3",
"signature": ["0x0"],
"nonce": "0x1"
}
estimate = await client.estimate_fee(
tx=transaction,
simulation_flags=["SKIP_VALIDATE"],
block_id="latest"
)
print(estimate)