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
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_feeHistoryreturns 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
| path | lines | bytes |
|---|---|---|
.editorconfig# | 12 | 188 |
.github/dependabot.yml# | 10 | 195 |
.github/workflows/ci.yml# | 25 | 417 |
.github/workflows/npm.yml# | 29 | 895 |
.gitignore# | 3 | 26 |
CHANGELOG.md# | 15 | 623 |
LICENSE# | 21 | 1,069 |
README.md# | 60 | 2,304 |
examples/browser.html# | 15 | 582 |
package-lock.json# | 412 | 13,284 |
package.json# | 38 | 1,255 |
src/fees.ts# | 112 | 4,493 |
src/index.ts# | 28 | 1,433 |
src/rpc.ts# | 68 | 2,537 |
src/stats.ts# | 151 | 5,766 |
test/fees.test.ts# | 91 | 3,965 |
test/stats.test.ts# | 81 | 3,180 |
tsconfig.json# | 17 | 374 |
history
the latest 8 commits. all 8, with the signature of each: the commit list.