Gas Statistics

Subscribe to real-time gas price and PPU (Price Per Unit) statistics per shard. This data helps optimize transaction timing and gas price selection for faster confirmation.

Subscribe

ws.send(JSON.stringify({
  action: 'subscribe',
  topic: 'gasStats'
}));

Response

Upon subscription, you immediately receive current statistics, followed by updates every 50ms:

{
  "type": "gasStats",
  "data": {
    "shards": [
      {
        "shardId": 0,
        "gasPrice": {
          "min": 1000000000,
          "max": 1500000000,
          "avg": 1200000000
        },
        "ppu": {
          "min": 1000000000,
          "max": 2000000000,
          "avg": 1400000000
        },
        "txCount": 145,
        "lastUpdated": 1704067200000
      },
      {
        "shardId": 1,
        "gasPrice": {
          "min": 1000000000,
          "max": 1800000000,
          "avg": 1350000000
        },
        "ppu": {
          "min": 1000000000,
          "max": 2500000000,
          "avg": 1600000000
        },
        "txCount": 178,
        "lastUpdated": 1704067200000
      },
      {
        "shardId": 2,
        "gasPrice": {
          "min": 1000000000,
          "max": 1200000000,
          "avg": 1100000000
        },
        "ppu": {
          "min": 1000000000,
          "max": 1500000000,
          "avg": 1200000000
        },
        "txCount": 92,
        "lastUpdated": 1704067200000
      }
    ],
    "timestamp": 1704067200000
  }
}

Response Fields

Root Object

Field
Type
Description

type

string

Always "gasStats"

data

object

Gas statistics container

data.shards

array

Per-shard statistics

data.timestamp

number

Unix timestamp in milliseconds

Shard Statistics

Field
Type
Description

shardId

number

Shard identifier (0, 1, 2)

gasPrice

object

Gas price statistics in atomic units

ppu

object

Price Per Unit statistics

txCount

number

Transactions in the time window

lastUpdated

number

Last update timestamp

Metric Statistics

Each metric (gasPrice, ppu) contains:

Field
Type
Description

min

number

Minimum value in window

max

number

Maximum value in window

avg

number

Average value in window

Understanding Gas Statistics

Gas Price

The gas price is the amount of EGLD (in atomic units) paid per unit of gas. The minimum network gas price is 1,000,000,000 (1 Gwei).

PPU (Price Per Unit)

PPU represents the effective cost of transaction processing, calculated as:

For transactions with data, PPU accounts for the additional cost per byte.

Shard Selection

MultiversX has 3 execution shards (0, 1, 2) plus a metachain. Use gas statistics to:

  1. Identify congested shards - Higher avg gas prices indicate congestion

  2. Optimize timing - Wait for lower gas prices during off-peak times

  3. Set competitive gas prices - Use avg or slightly above for faster confirmation

Example: Dynamic Gas Pricing

Example: Gas Price Monitor UI

Default Values

When a shard has no recent transactions, default values are returned:

Metric
Default Value
Meaning

gasPrice.min/max/avg

1,000,000,000

Minimum network gas price

ppu.min/max/avg

1,000,000,000

Minimum PPU

txCount

0

No transactions in window

These defaults indicate an empty shard with full capacity available.

Unsubscribe

Gas statistics are computed over a 1-minute sliding window. The data reflects recent mempool activity, not historical blockchain data.

Last updated

Was this helpful?