{"_id":"@albermonte/nimiq-rpc-client-ts","_rev":"2-cd105a90bc895f572e5333d553daf440","name":"@albermonte/nimiq-rpc-client-ts","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@albermonte/nimiq-rpc-client-ts","version":"0.1.0","author":{"name":"albermonte"},"license":"MIT","_id":"@albermonte/nimiq-rpc-client-ts@0.1.0","maintainers":[{"name":"albermonte","email":"alberto.monterroso@hotmail.com"}],"dist":{"shasum":"8a74e2fdcab442e9c6bc5574e17052b2d9b04a29","tarball":"https://registry.npmjs.org/@albermonte/nimiq-rpc-client-ts/-/nimiq-rpc-client-ts-0.1.0.tgz","fileCount":8,"integrity":"sha512-wA2TUYO53sH8NBb1LxztkT50P+a4OFiSQRhP1dqWUPXtfnGhahEdStGJTvU3BRxEs1vrgqRuYYqlcyHn5KB4mA==","signatures":[{"sig":"MEUCIQCDiR3vlTaZxodR5BzuFdhUKVXBt7drY7YDBRmeDiYAQQIgP2rxA+yaBn/Vc5VzINNLQDVd445/drkXWw/gNy++xR8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":396967},"main":"dist/index.mjs","type":"module","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"gitHead":"b06bdcc576a698d8e65b74377a2b45a284e1e3dd","private":false,"scripts":{"ci":"pnpm lint && pnpm build","dev":"unbuild --stub","lint":"eslint .","test":"vitest run","build":"unbuild","release":"pnpm lint && pnpm build && bumpp --commit --push --tag && pnpm publish","lint:fix":"eslint --fix ."},"_npmUser":{"name":"albermonte","email":"alberto.monterroso@hotmail.com"},"_npmVersion":"10.9.0","description":"A Nimiq RPC client for TypeScript","directories":{},"lint-staged":{"*":"eslint --fix"},"_nodeVersion":"22.11.0","dependencies":{"@open-rpc/client-js":"^1.8.1"},"_hasShrinkwrap":false,"packageManager":"pnpm@9.14.2","devDependencies":{"vite":"^5.4.11","bumpp":"^9.8.1","dotenv":"^16.4.5","eslint":"^9.15.0","vitest":"^2.1.5","unbuild":"^2.0.0","@types/ws":"^8.5.13","pkg-pr-new":"^0.0.31","simple-git":"^3.27.0","typescript":"^5.7.2","lint-staged":"^15.2.10","@changesets/cli":"^2.27.10","simple-git-hooks":"^2.11.1","@antfu/eslint-config":"^3.9.2"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"_npmOperationalInternal":{"tmp":"tmp/nimiq-rpc-client-ts_0.1.0_1747076712701_0.03718230942224321","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@albermonte/nimiq-rpc-client-ts","type":"module","version":"0.1.1","private":false,"packageManager":"pnpm@9.14.2","description":"A Nimiq RPC client for TypeScript","author":{"name":"albermonte"},"license":"MIT","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"main":"dist/index.mjs","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"dev":"unbuild --stub","test":"vitest run","build":"unbuild","lint":"eslint .","lint:fix":"eslint --fix .","ci":"pnpm lint && pnpm build","release":"pnpm lint && pnpm build && bumpp --commit --push --tag && pnpm publish"},"dependencies":{"@open-rpc/client-js":"^1.8.1"},"devDependencies":{"@antfu/eslint-config":"^3.9.2","@changesets/cli":"^2.27.10","@types/ws":"^8.5.13","bumpp":"^9.8.1","dotenv":"^16.4.5","eslint":"^9.15.0","lint-staged":"^15.2.10","pkg-pr-new":"^0.0.31","simple-git":"^3.27.0","simple-git-hooks":"^2.11.1","typescript":"^5.7.2","unbuild":"^2.0.0","vite":"^5.4.11","vitest":"^2.1.5"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"lint-staged":{"*":"eslint --fix"},"_id":"@albermonte/nimiq-rpc-client-ts@0.1.1","gitHead":"c06ff113aaddaa3e9a49130bf7fd76012798e1fb","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-chT0e7BXr/IlWIV/kUPp6LPDoZtv+3PbmuiKV4uwalJtfS9o8OThMWhv/FQK8HFmXf/4uboOI1kdmy7fxk7ZzA==","shasum":"03d3386af24d1e8eb10d0d10f37ec3732c116474","tarball":"https://registry.npmjs.org/@albermonte/nimiq-rpc-client-ts/-/nimiq-rpc-client-ts-0.1.1.tgz","fileCount":8,"unpackedSize":396979,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDBg6+KQw9/ZKFTelZiCc7waoIYKdmWOOSgXI94UKbywAiA7YVghvlKFo8gYX2ME2gsixOtSv+KL0irNYrgu8y50MA=="}]},"_npmUser":{"name":"albermonte","email":"alberto.monterroso@hotmail.com"},"directories":{},"maintainers":[{"name":"albermonte","email":"alberto.monterroso@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nimiq-rpc-client-ts_0.1.1_1747077214664_0.35012307125855524"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-12T19:05:12.610Z","modified":"2025-05-12T19:13:35.037Z","0.1.0":"2025-05-12T19:05:12.906Z","0.1.1":"2025-05-12T19:13:34.862Z"},"author":{"name":"albermonte"},"license":"MIT","description":"A Nimiq RPC client for TypeScript","maintainers":[{"name":"albermonte","email":"alberto.monterroso@hotmail.com"}],"readme":"# Nimiq RPC Client for TypeScript\n\nA fully typed Nimiq RPC client for TypeScript.\n\n## How to use\n\n### Installation\n\n```bash\nnpm install @albermonte/nimiq-rpc-client-ts\n```\n\n#### NIMIQ_SECRET\n\n<!--\nThe development network is currently in a phase where we are giving RPC access to interested developers. Its main purpose is to invite all developers to exercise and test the Nimiq 2.0 RPC functionality (to see how it fits for their app use cases), and we invite them to file and report any issues through our GitHub repository. Using the TOKEN that will be given after requesting developer access from a team member through our social media channels.\n-->\n\nThe development network is currently in a phase where we request developers to set up their own nodes.\n\n### Usage\n\nIt is structured the same way as the [`Rust RPC Client`](https://github.com/nimiq/core-rs-albatross/tree/albatross/rpc-server/src/dispatchers)\n\n```typescript\nimport { NimiqRPCClient } from 'nimiq-rpc-client-ts'\n\nconst url = 'NODE_URL'\nconst client = new NimiqRPCClient(new URL(url))\nconst { data: currentEpoch, error: errorCurrentEpoch } = await client.blockchain.getEpochNumber()\nif (errorCurrentEpoch || !currentEpoch)\n  throw new Error(errorCurrentEpoch?.message || 'No current epoch')\n\nclient.blockchain.getBlockNumber()\nclient.network.getPeerCount()\n// use auto-complete to see all available methods, or checkout the class https://github.com/onmax/albatross-rpc-client-ts/blob/main/src/index.ts#L26\n```\n\n## Call custom method\n\nIf you have a custom method in your RPC server, or the library is out of date, you can always make a `raw` request:\n\n```ts\ninterface ResponseType {\n  myResult: string\n}\nconst { data, error } = await client.call<ResponseType>({ method: 'myAwesomeCustomMethod', params: ['FirstParameter', 'secondParameter'] }, { /* some http options */ })\n//     ?^ ResponseType | undefined  ?^ Use call for custom HTTP methods or `subscribe` for custom WS\n```\n\n## Type Augmentation\n\nYou can extend or update the types in the `albatross-rpc-client-ts` library, you can define your own type extensions. This approach is particularly useful if the Rust implementation evolves and includes new types or features that are not yet included in the TypeScript definitions.\n\n```typescript\n/// albatross-rpc-client-ts.d.ts\n\ndeclare module 'albatross-rpc-client-ts' {\n  interface Block {\n    newFeature: string\n  }\n}\n```\n\nThen, whenever you import the library, the new types will be available.\n\n```ts\nimport { NimiqRPCClient } from 'albatross-rpc-client-ts'\n\nconst client = new NimiqRPCClient(new URL('NODE_URL'))\nconst block = await client.blockchain.getBlockByHash('HASH')\n// The `block` object now has the new `newFeature` property as well as the other properties defined by the library\n```\n\n> This solution is great for you so it doesn't block your workflow, but all developers will benefit if you can create a PR or open the issue so I can add it to the library asap! 🙌\n\n## Need help?\n\nCheck the tests for examples on how to use the client [here](./src/index.test.ts).\n","readmeFilename":"README.md"}