alina schanz

codetypescriptmit

gasweek-js

gasweek for the browser and node: the same pages of eth_feeHistory, the same interpolation and percentiles, in typescript with zero dependencies. import { gasweek, table } from "gasweek".

head bf63ee72026-09-1018 files325 lines of typescript

contents
  1. record
  2. readme
  3. files
  4. history

record

commits
8 on main, 2026-09-08 to 2026-09-10
signed
4 good signature from 17BA…F3AB
4 from dependabot signed by github's key B5690EEEBB952194 for dependabot, not checked here
tests
not run by this build
typescript; i run only the python tests when i build the site.
clone
git clone https://alinaschanz.life/code/gasweek-js.git, or gasweek-js.bundle.
source
gasweek-js.tar.gz, 13.4 KB · sha256 c5bcc2e868f1…: the files at bf63ee7.
license
mit (LICENSE)

readme

rendered from README.md at bf63ee7. i left out the badges, which load from github and shields.io. the install lines point at github, which answers 404 for this account at the moment.

gasweek-js

when is ethereum cheapest? the base fee by hour of day over the last week, from a public json-rpc endpoint, in the browser or in node. zero dependencies, no keys. the typescript twin of gasweek, same pages, same interpolation, same percentiles.

install

npm install gasweek

or straight from the repository: npm install github:alinaschanz/gasweek-js.

use

import { gasweek, table } from "gasweek";

const { rows, summary } = await gasweek({ hours: 168, tz: 2 }); // a week, hour bins in berlin summer time
console.log(summary.median, summary.cheapestHour, summary.priciestHour);
console.log(table(rows, 2));

in a browser it is the same import from a module script (the public endpoints answer cross-origin requests); pass your own node first with rpc: ["https://your.node", ...RPCS].

the pieces are exported on their own: Rpc (a list of endpoints tried in order, the one that answered goes first next time), fetchFees(rpc, blocks) (rows with interpolated timestamps), summarize(rows, tz) (min, p25, median, p75, p90, max, blob median, medians by hour and by weekday, cheapest and priciest hour), percentile, bucket, table.

how it works

  • eth_feeHistory returns the base fee per block, the gas used ratio and, since cancun, the blob base fee. it does not return timestamps.
  • so one block header per 1024-block page is fetched and the blocks in between are interpolated; post-merge blocks are 12 s apart except for missed slots, which keeps the error inside a page under a minute.
  • percentiles are order statistics with linear interpolation; hour and weekday bins follow tz (an offset in hours, no dst logic on purpose).
  • a full week is 50,400 blocks, 50 pages, four in flight at once; a minute or two on a public node.
  • endpoints: publicnode, drpc, mevblocker, tenderly, blastapi, in that order.

development

npm ci
npm test        # tsc, then node --test on the compiled output

see also

  • gasweek, the python original, with the daily dataset and the svg chart
  • onchain-notes, the daily card

license

mit.

files

history

  1. bf63ee7dependabot[bot]signed by github's key B5690EEEBB952194 for dependabot, not checked here

  2. 0dc6423dependabot[bot]signed by github's key B5690EEEBB952194 for dependabot, not checked here

  3. 9359f42megood signature from 17BA…F3AB

  4. 8d46e18megood signature from 17BA…F3AB

  5. 429b4b4dependabot[bot]signed by github's key B5690EEEBB952194 for dependabot, not checked here

  6. b6556eddependabot[bot]signed by github's key B5690EEEBB952194 for dependabot, not checked here

  7. c57a5cdmegood signature from 17BA…F3AB

  8. a5c768emegood signature from 17BA…F3AB

the latest 8 commits. all 8, with the signature of each: the commit list.