{"_id":"@dojo-tools/next-block-estimator","_rev":"2-6cecb600a00772ab6b4456f5d172ee26","name":"@dojo-tools/next-block-estimator","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@dojo-tools/next-block-estimator","version":"1.0.0","keywords":["bitcoin","fees","calculator","estimator"],"author":{"name":"Katana Cryptographic Ltd."},"license":"LGPL-3.0","_id":"@dojo-tools/next-block-estimator@1.0.0","maintainers":[{"name":"pajasevi","email":"pavel.sevcik@protonmail.com"}],"homepage":"https://github.com/Dojo-Open-Source-Project/dojo-tools","bugs":{"url":"https://github.com/Dojo-Open-Source-Project/dojo-tools/issues"},"dist":{"shasum":"093eb3a4a6e1cd63558923dc946c2e9a0f560927","tarball":"https://registry.npmjs.org/@dojo-tools/next-block-estimator/-/next-block-estimator-1.0.0.tgz","fileCount":20,"integrity":"sha512-+aW4rIeXSiXyj2abH/jo3AYegzxvhGsnjMoxrPwg/4ABuMZPyq1eUZICywfXpWaZ+WBzSE/kXhMR0VFluMFbwg==","signatures":[{"sig":"MEYCIQD5Uv01qtKC0O2RJBJ3JrHUTlg96QTUhxwKaU0K8tkFCAIhANGbCL7I75UKzcgJOw6waJbKj7q7AoWzBmSrkyzr+BMl","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29228},"type":"module","_from":"file:dojo-tools-next-block-estimator-1.0.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"pnpm exec biome lint src test","test":"vitest run","build":"pnpm run build:clean && pnpm run build:esm && pnpm run build:types","check":"pnpm exec biome check --write src test","format":"pnpm exec biome format --write src test","lint:fix":"pnpm exec biome lint --write src test","build:esm":"pnpm exec esbuild \"src/**/*.ts\" --format=esm --platform=node --target=es2020 --sourcemap --outdir=dist","test:watch":"vitest watch","typescript":"tsc --noEmit","build:clean":"rm -rf dist","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --rootDir src --outDir dist --paths null"},"_npmUser":{"name":"pajasevi","email":"pavel.sevcik@protonmail.com"},"_resolved":"/private/var/folders/ry/rx5jctws6tj1npd85yrttkqm0000gn/T/6ea33178e80c84ad766b4a9ceba0e719/dojo-tools-next-block-estimator-1.0.0.tgz","_integrity":"sha512-+aW4rIeXSiXyj2abH/jo3AYegzxvhGsnjMoxrPwg/4ABuMZPyq1eUZICywfXpWaZ+WBzSE/kXhMR0VFluMFbwg==","repository":{"url":"git+https://github.com/Dojo-Open-Source-Project/dojo-tools.git","type":"git"},"_npmVersion":"11.12.1","description":"A script estimating the minimum feerate required for the inclusion of a bitcoin transaction into the next block.","directories":{},"_nodeVersion":"24.15.0","dependencies":{"@dojo-tools/bitcoin-rpc":"1.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/next-block-estimator_1.0.0_1776722264171_0.5211704264585626","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@dojo-tools/next-block-estimator","version":"1.0.1","engines":{"node":">=24"},"description":"A script estimating the minimum feerate required for the inclusion of a bitcoin transaction into the next block.","keywords":["bitcoin","fees","calculator","estimator"],"type":"module","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Dojo-Open-Source-Project/dojo-tools.git"},"bugs":{"url":"https://github.com/Dojo-Open-Source-Project/dojo-tools/issues"},"author":"Katana Cryptographic Ltd.","license":"LGPL-3.0","homepage":"https://github.com/Dojo-Open-Source-Project/dojo-tools","dependencies":{"@dojo-tools/bitcoin-rpc":"1.0.1"},"scripts":{"test":"vitest run","test:watch":"vitest watch","typescript":"tsc --noEmit","build:clean":"rm -rf dist","build:esm":"pnpm exec esbuild \"src/**/*.ts\" --format=esm --platform=node --target=es2020 --sourcemap --outdir=dist","build":"pnpm run build:clean && pnpm run build:esm && pnpm run build:types","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --rootDir src --outDir dist --paths null","lint":"pnpm exec biome lint src test","lint:fix":"pnpm exec biome lint --write src test","format":"pnpm exec biome format --write src test","check":"pnpm exec biome check --write src test"},"_nodeVersion":"26.0.0","_id":"@dojo-tools/next-block-estimator@1.0.1","dist":{"integrity":"sha512-ht+kOoVHNbpPO6pvJKQJh/EO/bBdPQHUYeuRoB9UOgHcZ5HZM0L1JjNo6No+1MqCezrM5OVL+eOWfBrc0pKT7A==","shasum":"62b0316feb2fa11cb44626450e0cf40625c4be57","tarball":"https://registry.npmjs.org/@dojo-tools/next-block-estimator/-/next-block-estimator-1.0.1.tgz","fileCount":20,"unpackedSize":30087,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDsYzzIQy0RH4USOY+O1JOUL/wKqHHk/jjMa8r/LLQfzwIhAPhN1ziLqTp+ZA454b8TyeA7k6vraBHYDxb4WxscBg00"}]},"_npmUser":{"name":"pajasevi","email":"pavel.sevcik@protonmail.com"},"directories":{},"maintainers":[{"name":"pajasevi","email":"pavel.sevcik@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/next-block-estimator_1.0.1_1787674157262_0.44673785391587884"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-20T21:57:44.055Z","modified":"2026-08-25T16:09:17.724Z","1.0.0":"2026-04-20T21:57:44.315Z","1.0.1":"2026-08-25T16:09:17.419Z"},"bugs":{"url":"https://github.com/Dojo-Open-Source-Project/dojo-tools/issues"},"author":"Katana Cryptographic Ltd.","license":"LGPL-3.0","homepage":"https://github.com/Dojo-Open-Source-Project/dojo-tools","keywords":["bitcoin","fees","calculator","estimator"],"repository":{"type":"git","url":"git+https://github.com/Dojo-Open-Source-Project/dojo-tools.git"},"description":"A script estimating the minimum feerate required for the inclusion of a bitcoin transaction into the next block.","maintainers":[{"name":"pajasevi","email":"pavel.sevcik@protonmail.com"}],"readme":"# The $1 Fee Estimator\n## @dojo-tools/next-block-estimator\n\nThis library is a Typescript port of the original Python library - [The $1 Fee Estimator](https://github.com/Archive-Samourai-Wallet/one_dollar_fee_estimator).\n\n> The $1 Fee Estimator is an algorithm designed to return a feerate:\n>\n> - allowing the confirmation of a Bitcoin transaction by the next block,\n> - lower than the median feerate paid by the transactions included in the next block.\n>\n> Despite its simplicity, the $1 Fee Estimator requires very few data to perform well and is less than 200 lines of code, making it easy to deploy or to implement in all programming languages.\n\nSee [original README](https://github.com/Archive-Samourai-Wallet/one_dollar_fee_estimator) to understand how this algorithm works.\n\n## Requirements\n- Node.js v18 or newer\n- NPM (or yarn or pnpm)\n- Synchnonized Bitcoin Core with accessible RPC\n\n## Installation\n```shell\nnpm i @dojo-tools/next-block-estimator\n```\nor\n```shell\npnpm i @dojo-tools/next-block-estimator\n```\nor\n```shell\nyarn add @dojo-tools/next-block-estimator\n```\n\n## Usage\n\n### CLI\nSee [@dojo-tools/next-block-estimator-cli](../next-block-estimator-cli)\n\n### Node.js\n\n```javascript\nimport {FeeEstimator} from '@dojo-tools/next-block-estimator';\n\nlet receivedFees; // variable you want to store received fee rates in\n\nconst estimator = new FeeEstimator({\n    mode: 'txs', // 'txs' | 'bundles' - optional, default 'txs'\n    refresh: 30, // optional, default 30 - interval in seconds, setting too low can cause unexpected errors\n    rpcOptions: {\n        host: 'localhost',\n        port: 8332,\n        username: 'rpcUsername',\n        password: 'rpcPassword',\n        cookie: 'path/to/cookiefile' // optionally use cookie instead of username & password\n    },\n    useWorker: true, // optional, default false, set to true if your want to run estimator in a worker thread to prevent blocking of main thread\n    debug: true // optional, default false, set to true if you want to see debug logs\n})\n\n// handle errors emitted by FeeEstimator\nestimator.on('error', (err) => {\n    console.error(err)\n})\n\n// receive live fee rate updates from the FeeEstimator\nestimator.on('data', (result) => {\n    // fee rates and ready status received from FeeEstimator\n    // object of targets and their feerates: \n    // {\n    //  ready: true,\n    //  lastBlock: {\n    //    height: 829364,\n    //    hash: \"00000000000000000001f3eb6464cd19b0a8a1f3a98b1b0af83ba9b4a4c0b259\",\n    //    time: 1707310080,\n    //  }\n    //  fees: {\n    //    \"0.1\": number,\n    //    \"0.2\": number,\n    //    \"0.5\": number,\n    //    \"0.9\": number,\n    //    \"0.99\": number,\n    //    \"0.999\": number,\n    //   }\n    // }\n    // `ready` field signals that the mempool of the bitcoind is synchronized\n    // calculated fee rates are unreliable if ready=false\n    if (result.ready) {\n      // these targets are probabilities for fee rates for next block (10%, 20%, 50%, ...)\n      receivedFees = result.fees;\n    }\n})\n\n// or just read last fee rates directly from the estimator\nif (estimator.data.ready) {\n    receivedFees = estimator.data.fees;\n}\n\n// FeeEstimator will continue working until you stop it, or the process is terminated\nestimator.stop()\n\n```\n","readmeFilename":""}