{"_id":"@0xbigboss/pocketjs-provider","_rev":"3-315e8b83510ef476744bdc75a7a5fd33","name":"@0xbigboss/pocketjs-provider","dist-tags":{"latest":"2.1.1"},"versions":{"2.1.0":{"name":"@0xbigboss/pocketjs-provider","version":"2.1.0","keywords":[],"license":"MIT","_id":"@0xbigboss/pocketjs-provider@2.1.0","maintainers":[{"name":"0xbigboss","email":"0xbigboss@proton.me"}],"dist":{"shasum":"816e180fcd738a81f55183ac8993a89b0695cf58","tarball":"https://registry.npmjs.org/@0xbigboss/pocketjs-provider/-/pocketjs-provider-2.1.0.tgz","fileCount":28,"integrity":"sha512-ECifuVbISxgw5PKE9ols0cKB+DGIwSCkkmhUOrvi5f53fziRC/8FMAYpLx3qGhzQ/HsiUMKquUXcY7XsC00aRw==","signatures":[{"sig":"MEUCIF1fXyIge7tpryHI92aBMI8uwnC8hNolmft2aDMoB7+WAiEApcxvogLX5xh7oEpXYLk3gLIKsJE1yXxtJxT9XU8S9L8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4479097,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjORLqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpptw/9EWTlJGt+YMhCz5hzKDW5eTnyB+76ZKPnbsI1UOprgun/U4ag\r\nyM6qA2B3p5+WIc4QdlRgQRZlLlGEub8ZadP2TtTSl/RCaF8Z/DCm6knx8v+w\r\nXS7Kk0clRjg1BcGnxq2LFTHRdPwIHtbHeMIsHROfTutfyncD4CecqfdwgPuQ\r\nYdo8Egrtx948Xh4R7qLmpDcKLuWnUTuKnPSK6uwxwNKBZjPITozcd+aSXUWK\r\ncXE0EMpfR6nXCArADxasW97BuLQVZxZIZ8439MAe2T5AupymKSIF2oX+k090\r\nztGLE7FkGwTUf0z3lE2kT6okceMj2DleF/GScHzS9rBBFdAbkl+OrJDQggoi\r\nazEKvpXSOznAEurTwgeDTn1YH0ia1Iz2Wo42AkyaW4pOtjhRcq0ZhHO4T3n0\r\nnn3SJPQOnPNSEMQ+Y8BwcPiM2FySq5cMMgpVWoW9kcR1xJ4haTdUJqXDTs0N\r\nMqe2x1IKRCHXF7kkWlNKf4EZTjdf2syHE8t6VBa0mwXlZ947yY+QSkwOmHc4\r\nV4kRXVOyMAy83MCaLSDdRXfu3mU8k8YFCiIWqyTaKnGWTTw3rIoDXyPAAZG3\r\nKjukNpwiVXmoGQLvkaQb1b5Wk5I+NYpXOabKM0pQVu73f7ocjwZ7bTVAQois\r\n3Kf93gUO6INCUwawbsyDoycq5ZA3pRXhdk8=\r\n=l7+J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.cjs","type":"module","_from":"file:0xbigboss-pocketjs-provider-2.1.0.tgz","types":"dist/src/index.d.ts","unpkg":"./dist/index.umd.js","module":"./dist/index.js","source":"src/index.ts","authors":["BigBoss <0xbigboss@proton.me>"],"exports":{"default":"./dist/index.js","require":"./dist/index.cjs"},"scripts":{"dev":"microbundle watch","build":"microbundle"},"_npmUser":{"name":"0xbigboss","email":"0xbigboss@proton.me"},"_resolved":"/private/var/folders/9b/khhz0hwd07z_p9n1wh5mqg_80000gn/T/6300e131884ec24e0ddbd06d3a365fe3/0xbigboss-pocketjs-provider-2.1.0.tgz","_integrity":"sha512-ECifuVbISxgw5PKE9ols0cKB+DGIwSCkkmhUOrvi5f53fziRC/8FMAYpLx3qGhzQ/HsiUMKquUXcY7XsC00aRw==","_npmVersion":"8.15.0","description":"The JSONRPCProvider is the NodeJS-only provider for making queries to the Pocket network chain, sending relays or dispatching sessions.","directories":{},"_nodeVersion":"16.17.0","dependencies":{"debug":"^4.3.3","undici":"^5.0.0","abort-controller":"^3.0.0","@0xbigboss/pocketjs-abstract-provider":"2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.4.7","nock":"^13.2.4","eslint":"7.32.0","ts-jest":"^27.1.3","prettier":"^2.5.1","typescript":"^4.5.5","@types/jest":"^27.4.0","microbundle":"^0.14.2","@0xbigboss/pocketjs-types":"2.1.0","@typescript-eslint/parser":"^5.10.2","@typescript-eslint/eslint-plugin":"^5.10.2"},"_npmOperationalInternal":{"tmp":"tmp/pocketjs-provider_2.1.0_1664684777708_0.43516381119982395","host":"s3://npm-registry-packages"}},"2.1.1":{"name":"@0xbigboss/pocketjs-provider","version":"2.1.1","keywords":[],"author":"","license":"MIT","_id":"@0xbigboss/pocketjs-provider@2.1.1","maintainers":[{"name":"0xbigboss","email":"0xbigboss@proton.me"}],"dist":{"shasum":"75c974c912c83ac346506cc325a0ac66e18f9b96","tarball":"https://registry.npmjs.org/@0xbigboss/pocketjs-provider/-/pocketjs-provider-2.1.1.tgz","fileCount":28,"integrity":"sha512-tEr4nKbXtMuQahKax6ghX4gMNaz2pph6naI73zgF/MEMalOnFebJfwEtjnQA+j+SYzC4EL6Tp2BfyvqrUCGBVA==","signatures":[{"sig":"MEUCIQCalBCbQ/2czK/OCSO4LANbTsu3xgckriJxJloud276swIgH8nWG8RHWqEwLEfkMJF4SJBhPXJtNRcyFkgcQ1HNsoU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4504819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjXwX+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpNSQ//Z5q0DpdXZFMvhhmRdRhiotG05sAzDFuEwJC8uH7+8UAFZ7wU\r\nvpdIMS3vtVZPlqtjrRop9H7J1kzfx6HCezdhTxqnBZDXtmm22BI0vRFNFg7l\r\nA/ljA0mSA5iQyxCaALLrcFKoetdsldEgjMhczrzHghNxe9Upah2AowW4NTH4\r\n5Azn4UkVftqzGFbrV9Js4zErXNJT/skx2jRfbIW7beWx4gADTcTbFU8g7wm1\r\nNUcspUB2ZRKGE71CH8C/QwfPENrivptNPmrYUmk9Sgd2+jYxm+Emd9Dtl5WU\r\nlA+PDp4ea9PlT5cBVz7YLAPgyTWMrP6udrHNit5yJ/eEs9Kwc86MVp6duSuy\r\nMkkSWTW2m7tsCbeUl8kTOmhxRug2UZ2SR9CcOGyKfhFDghqK0cIKMWL0SmTF\r\n6Ns8E7NMyl02hu/8/GNVImfFaMuWykZvQ+SXJkl9aEUgFPEA7cM3UTIaCmZu\r\nHFfBXsdp4Sk6FRPOwCkgbQGP7AKNXqYE9WJ49Xcl9TcMCN9OxwlVj+bPedK1\r\nHiH3HTUrZr0qopgYoLwTJX12hiJioNCFL8UtfEsav9WOHHdO/qKKBYJd4UpX\r\nKKy2sTxy00d2sYYKy7b7B5rCUb/ubeGCtdb5lQ0slbCvK/czQfwCef1oT9oG\r\nEYzt35Gl14Y7sF5tky5v1J7p0p6smqFskiU=\r\n=gAUA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.cjs","type":"module","_from":"file:0xbigboss-pocketjs-provider-2.1.1.tgz","types":"dist/src/index.d.ts","unpkg":"./dist/index.umd.js","module":"./dist/index.js","source":"src/index.ts","exports":{"default":"./dist/index.js","require":"./dist/index.cjs"},"scripts":{"dev":"microbundle watch","build":"microbundle"},"_npmUser":{"name":"0xbigboss","email":"0xbigboss@proton.me"},"_resolved":"/private/var/folders/9b/khhz0hwd07z_p9n1wh5mqg_80000gn/T/67e21b964713bb83a2905dbae98690bd/0xbigboss-pocketjs-provider-2.1.1.tgz","_integrity":"sha512-tEr4nKbXtMuQahKax6ghX4gMNaz2pph6naI73zgF/MEMalOnFebJfwEtjnQA+j+SYzC4EL6Tp2BfyvqrUCGBVA==","_npmVersion":"8.19.2","description":"The JSONRPCProvider is the NodeJS-only provider for making queries to the Pocket network chain, sending relays or dispatching sessions.","directories":{},"_nodeVersion":"18.12.0","dependencies":{"debug":"^4.3.3","undici":"^5.0.0","abort-controller":"^3.0.0","@0xbigboss/pocketjs-abstract-provider":"2.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.4.7","nock":"^13.2.4","eslint":"7.32.0","ts-jest":"^27.1.3","prettier":"^2.5.1","typescript":"^4.5.5","@types/jest":"^27.4.0","@types/node":"^18.11.8","microbundle":"^0.14.2","@0xbigboss/pocketjs-types":"2.1.1","@typescript-eslint/parser":"^5.10.2","@typescript-eslint/eslint-plugin":"^5.10.2"},"_npmOperationalInternal":{"tmp":"tmp/pocketjs-provider_2.1.1_1667171838235_0.9023202974951816","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-10-02T04:26:17.642Z","modified":"2026-06-24T17:39:13.936Z","2.1.0":"2022-10-02T04:26:18.038Z","2.1.1":"2022-10-30T23:17:18.421Z"},"license":"MIT","keywords":[],"description":"The JSONRPCProvider is the NodeJS-only provider for making queries to the Pocket network chain, sending relays or dispatching sessions.","maintainers":[{"email":"0xbigboss@proton.me","name":"alleneubank"}],"readme":"# JSONRPCProvider\n\nThe JSONRPCProvider is the NodeJS-only provider for making queries to the Pocket network chain, sending relays or dispatching sessions.\n\n## Installation\nInstall from NPM, using your favorite package manager:\n\n```js\npnpm i @pokt-foundation/pocketjs-provider\n```\n\n## Usage\n### Initialization\n```js\nimport { JsonRpcProvider } from '@pokt-foundation/pocketjs-provider'\n\n// If you wanna just send queries to the chain, this is the simplest way to Initialize it:\nconst simpleProvider = new JsonRpcProvider({ \n  // RPC_URL = any URL that connects to a Pocket node, or a Pocket mainnet portal endpoint\n  rpcUrl: process.env.RPC_URL \n})\n\n// If you wanna also send relays, you'll need to initialize dispatchers as well.\n// Dispatchers are Pocket nodes that only perform dispatch calls (to the route /client/dispatch) to generate sessions.\nconst providerWithDispatchers = new JsonRpcProvider({\n    // RPC_URL = needs to be a pocket node to send relays.\n    rpcUrl: process.env.RPC_URL\n    // DISPATCHER_1, DISPATCHER_2 = pocket node URLs for dispatching. You can include as many as you can for redundancy.\n    dispatchers: [process.env.DISPATCHER_1, process.env.DISPATCHER_2]\n})\n\n```\n### Usage examples\n```js\nimport { JsonRpcProvider } from '@pokt-foundation/pocketjs-provider'\n\nconst simpleProvider = new JsonRpcProvider({ \n  rpcUrl: process.env.RPC_URL \n})\n\n// Getting an account's balance\nconst balance = await simpleProvider.getBalance('0992d9acddf86ad7dcae1c96cb37a88d0b716243')\n\n// Getting the type of an account (node, app, or normal account);\nconst accountType = await simpleProvider.getType('4a6dd4559ff723ea1937ec379be0998e15c61c04');\n\n// Getting existing apps, involving pagination\nconst apps = await simpleProvider.getApps({\n  page: 1,\n  perPage: 500,\n  // customizable timeout\n  timeout: 5000\n})\n```\n\n## API\n\n### Constructor\n#### rpcUrl\n- type: `String`\nThe URL of the RPC to connect to. Can be a Pocket Portal endpoint, or a Pocket node.\n\n#### Dispatchers (optional)\n- type: `String[]`\nAn array of URLs of Pocket nodes that will perform dispatch calls to generate new sessions.\n\n### Methods\n#### getBalance(address): Promise<bigint>\nFetches the provided address's balance.\n\nReturns a `Promise<bigint>`: the address's balance.\n\n| Param   | Type                          | Description                          |\n|---------|-------------------------------|--------------------------------------|\n| address | `string` or `Promise<string>` | The address to fetch the balance of. |\n\n#### getTransactionCount(address): Promise<number>\nFetches the provided address's transaction count.\n\nReturns a `Promise<number>`: the address's transaction count.\n\n| Param   | Type                          | Description                                       |\n|---------|-------------------------------|---------------------------------------------------|\n| address | `string` or `Promise<string>` | The address to fetch the transaction count of of. |\n\n#### getType(address): Promise<'node' | 'app' | 'account'>\nFetches the address's account type (node, app, or account).\n\nReturns a `Promise<'node' | 'app' | 'account'>`: If the account is a node, an app, or a normal account.\n\n| Param   | Type                          | Description                               |\n|---------|-------------------------------|-------------------------------------------|\n| address | `string` or `Promise<string>` | The address to fetch the account type of. |\n\n#### sendTransaction(transaction): Promise<TransactionResponse>\nSends a signed transaction from this provider.\n\nReturns a `Promise<TransactionResponse>`: The network's response to the transaction.\n\n| Param       | Type           | Description                                                   |\n|-------------|----------------|---------------------------------------------------------------|\n| transaction | `RawTxRequest` | The transaction to send, formatted as a `TransactionRequest`. |\n\n#### getBlock(blockNumber): Promise<Block>\nGet an specific block by its block number.\n\nReturns a `Promise<Block>`: The block requested.\n\n| Param       | Type     | Description                                |\n|-------------|----------|--------------------------------------------|\n| blockNumber | `number` | The number (height) of the block to query. |\n\n#### getTransaction(transactionHash): Promise<Transaction>\nGets an specific transaction specified by its hash.\n\nReturns a `Promise<Transaction>`: The transaction requested;\n\n| Param           | Type     | Description                         |\n|-----------------|----------|-------------------------------------|\n| transactionHash | `string` | The hash of the transaction to get. |\n\n#### getBlockNumber(): Promise<number>\nFetches the latest block number.\n\nReturns `Promise<number>`: The latest height as observed by the node the provider is connected to.\n\n#### getBlockTransactions(GetBlockTransactionsOptions): Promise<PaginableBlockTransactions>\nFetches the requested block's transactions.\n\nReturns a `Promise<PaginableBlockTransactions>`: The block's transactions.\n\n- `GetBlockTransactionOptions` object params:\n\n| Param         | Type      | Description                                     |\n|---------------|-----------|-------------------------------------------------|\n| blockHeight   | `number`  | The block's height.                             |\n| page          | `number`  | The page to query for, pagination-wise.         |\n| perPage       | `number`  | The number of transactions to include per page. |\n| includeProofs | `boolean` | Include the transactions's proofs.              |\n| timeout       | `number`  | Time to wait before cancelling the request.     |\n\n#### getNodes(GetNodesOptions): Promise<Paginable<Node>>\nFetches nodes acrtibve from the network with the options provided.\n\nReturns `Promise<Paginable<Node>>`: An array with the nodes requested and their information.\n\n- `GetNodesOptions` params:\n\n| Param       | Type     | Description                                     |\n|-------------|----------|-------------------------------------------------|\n| blockHeight | `number` | The block's height.                             |\n| page        | `number` | The page to query for, pagination-wise.         |\n| perPage     | `number` | The number of transactions to include per page. |\n| timeout     | `number` | Time to wait before cancelling the request.     |\n\n#### getNode({ address, blockHeight }): Promise<Node>\nFetches a node from the network with the options provided.\n\nReturns `Promise<Node>`: The node requested and its information.\n\n| Param          | Type     | Description                                                  |\n|----------------|----------|--------------------------------------------------------------|\n| address        | `string` | The address of the node to get the claims from.              |\n| blockHeight    | `number` | The block height to use to determine the result of the call. |\n\n####  getApps(GetAppsOptions): Promise<Paginable<App>>\nFetches apps from the network with the options provided.\n\nReturns `Promise<Paginable<App>>`: An array with the apps requested and their information.\n\n- `GetAppsOptions` params:\n\n| Param       | Type     | Description                                     |\n|-------------|----------|-------------------------------------------------|\n| blockHeight | `number` | The block's height.                             |\n| page        | `number` | The page to query for, pagination-wise.         |\n| perPage     | `number` | The number of transactions to include per page. |\n| timeout     | `number` | Time to wait before cancelling the request.     |\n\n#### getApp({ address, blockHeight }): Promise<App>\nFetches an app from the network with the options provided.\n\nReturns `Promise<App>`: The app requested and its information.\n\n| Param          | Type     | Description                                                  |\n|----------------|----------|--------------------------------------------------------------|\n| address        | `string` | The address of the node to get the claims from.              |\n| blockHeight    | `number` | The block height to use to determine the result of the call. |\n\n#### getAccount(address): Promise<Account>\nFetches an account from the network.\n\nReturns `Promise<Account>`: The account requested and its information.\n\n| Param   | Type                          | Description                          |\n|---------|-------------------------------|--------------------------------------|\n| address | `string` or `Promise<string>` | The address to fetch the balance of. |\n\n#### getAccountWithTransactions(address, options): Promise<AccountWithTransactions>\nFetches an account from the network, along with its transactions.\n\nReturns `Promise<AccountWithTransactions>`: The account requested and its information, along with its transactions.\n\n| Param           | Type                                | Description                                         |\n|-----------------|-------------------------------------|-----------------------------------------------------|\n| address         | `string` or `Promise<string>`       | The address of the account to query.                |\n| options         | `GetAccountWithTransactionsOptions` | The options object for the method.                  |\n| options.page    | `number`                            | The page to get (pagination-wise) for transactions. |\n| options.perPage | `number`                            | The number of transactions to include per page.     |\n| timeout         | `number`                            | Time to wait before cancelling the request.         |\n\n#### dispatch(request, options): Promise<DispatchResponse>\nPerforms a dispatch request to a random dispatcher from the ones provided. Fails if no dispatcher is found. Best used through a Relayer, as this is a very low level method.\n\nReturns `Promise<DispatchResponse>`: The dispatch response from the dispatcher node.\n\n| Param                                | Type              | Description                                       |\n|--------------------------------------|-------------------|---------------------------------------------------|\n| request                              | `DispatchRequest` | The dispatch request.                             |\n| options                              | `object`          | The options object for the method.                |\n| options.retryAttempts                | `number`          | Number of retries if the first request fails.     |\n| options.rejectSelfSignedCertificates | `boolean`         | Option to reject self signed certificates or not. |\n| options.timeout                      | `number`          | Time to wait before cancelling the request.       |\n\n#### relay(request, rpcUrl, options): Promise<unknown>\nSends a relay to the network through the main RPC URL provided. Best used through a Relayer, as this is a very low level method.\n\nReturns `Promise<unknown>`: The relay response (in unknown format, depends on the chain used).\n\n| Param                                | Type              | Description                                       |\n|--------------------------------------|-------------------|---------------------------------------------------|\n| request                              | `DispatchRequest` | The dispatch request.                             |\n| rpcUrl                               | `string`          | The rpcUrl to use                                 |\n| options                              | `object`          | The options object for the method.                |\n| options.retryAttempts                | `number`          | Number of retries if the first request fails.     |\n| options.rejectSelfSignedCertificates | `boolean`         | Option to reject self signed certificates or not. |\n| options.timeout                      | `number`          | Time to wait before cancelling the request.       |\n\n#### getAllParams(height, options): Promise<unknown>\nGets all the parameters used to configure the Pocket Network.\n\nReturns `Promise<any>`: The raw data structure with the parameters.\n\n| Param           | Type     | Description                                 |\n|-----------------|----------|---------------------------------------------|\n| height          | `number` | The height to use for querying the params.  |\n| options         | `object` | The options object for the method.          |\n| options.timeout | `number` | Time to wait before cancelling the request. |\n\n#### getNodeClaims(address, options): Promise<Paginable<any>>\nGets the corresponding node's claims.\n\nReturns `Promise<Paginable<any>>`: The raw data structure containing the node claims.\n\n| Param           | Type     | Description                                                  |\n|-----------------|----------|--------------------------------------------------------------|\n| address         | `string` | The address of the node to get the claims from.              |\n| options         | `object` | The options object for the method.                           |\n| options.height  | `number` | The block height to use to determine the result of the call. |\n| options.page    | `number` | The page to get the node claims from.                        |\n| options.perPage | `number` | How many claims per page to retrieve.                        |\n| options.timeout | `number` | Time to wait before cancelling the request.                  |\n\n#### getSupply(height, options): Promise<any>\nGets the requested supply information.\n\nReturns `Promise<any>`: The raw data structure with the supply info.\n\n| Param           | Type     | Description                                 |\n|-----------------|----------|---------------------------------------------|\n| height          | `number` | The height to use for querying the info.    |\n| options         | `object` | The options object for the method.          |\n| options.timeout | `number` | Time to wait before cancelling the request. |\n\n#### getSupportedCHains(height, options): Promise<any>\nGets the supported chains in the protocol.\n\nReturns `Promise<any`: The currently supported chains in a raw manner.\n\n| Param           | Type     | Description                                 |\n|-----------------|----------|---------------------------------------------|\n| height          | `number` | The height to use for querying the info.    |\n| options         | `object` | The options object for the method.          |\n| options.timeout | `number` | Time to wait before cancelling the request. |\n\n#### getPocketParams(height, options): Promise<any>\nGets the current Pocket Network Params.\n\nReturns `Promise<any>`: The current raw pocket params.\n\n| Param           | Type     | Description                                 |\n|-----------------|----------|---------------------------------------------|\n| height          | `number` | The height to use for querying the info.    |\n| options         | `object` | The options object for the method.          |\n| options.timeout | `number` | Time to wait before cancelling the request. |\n\n#### getAppParams(height, options): Promise<any>\nGets the current Application Params.\n\nReturns `Promise<any>`: The raw application params.\n\n| Param           | Type     | Description                                 |\n|-----------------|----------|---------------------------------------------|\n| height          | `number` | The height to use for querying the info.    |\n| options         | `object` | The options object for the method.          |\n| options.timeout | `number` | Time to wait before cancelling the request. |\n","readmeFilename":"README.md"}