{"id":15023809,"url":"https://github.com/jklepatch/monero-nodejs-rpc-client","last_synced_at":"2025-04-12T06:17:42.438Z","repository":{"id":57301431,"uuid":"106817437","full_name":"jklepatch/monero-nodejs-rpc-client","owner":"jklepatch","description":"A NodeJS client for the JSON RPC API of Monero","archived":false,"fork":false,"pushed_at":"2018-03-15T20:40:34.000Z","size":33,"stargazers_count":13,"open_issues_count":3,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T01:41:22.585Z","etag":null,"topics":["cryptocurrency","monero","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jklepatch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-13T11:43:50.000Z","updated_at":"2024-05-31T07:27:29.000Z","dependencies_parsed_at":"2022-09-13T06:21:10.769Z","dependency_job_id":null,"html_url":"https://github.com/jklepatch/monero-nodejs-rpc-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jklepatch%2Fmonero-nodejs-rpc-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jklepatch%2Fmonero-nodejs-rpc-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jklepatch%2Fmonero-nodejs-rpc-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jklepatch%2Fmonero-nodejs-rpc-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jklepatch","download_url":"https://codeload.github.com/jklepatch/monero-nodejs-rpc-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248130409,"owners_count":21052741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptocurrency","monero","nodejs"],"created_at":"2024-09-24T19:59:28.004Z","updated_at":"2025-04-12T06:17:42.404Z","avatar_url":"https://github.com/jklepatch.png","language":"JavaScript","readme":"# Monero NodeJS RPC Client\n\nMonero RPC client written with Nodejs.\nIt produces JSON objects or strings as output, wrapped in\nnative promises.\n\nAll RPC calls are defined here:\nhttps://getmonero.org/resources/developer-guides/daemon-rpc.html\n\n## Getting Started\n\n1. Install the npm package:Create a `node_modules` directory inside your project, if none:\n\n```\ncd yourproject\nnpm install -S monero-rpc-client\n```\n\n2. Require the RPC client into your project:\n\n```\nconst rpcClientClass = require('monero-rpc-client');\nconst NODE_ADDRESS = 'http://[urltonode|iptonode]:port';\n//decodeJSON is an optional boolean argument. \n//When set to true (default), the JSON string response is\n//parsed into a JSON object. Otherwise the string is returned.\nconst rpcClient = new rpcClientClass(NODE_ADDRESS [, decodeJSON]);\n```\n\n3. Use methods attached to `rpcClient` to send RPC calls:\n\n### Example\n```\n//Some method dont require arguments:\nrpcClient.getBlockCount();\n  .then((result) =\u003e {\n    console.log(result);\n    /**\n     * print:\n     * {  \n     *   \"id\": \"0\",  \n     *   \"jsonrpc\": \"2.0\",  \n     *   \"result\": {  \n     *     \"count\": 9933,  \n     *     \"status\": \"OK\"  \n     *   }  \n     * }  \n     */\n  })\n  .catch((err) =\u003e {\n    //Deal with your error here\n  });\n\n//Some method require arguments.\nrpcClient.getBlockHeaderByHeight({height: 1000});\n  .then((result) =\u003e {\n    console.log\n    /**\n     * print:\n     * {\n     *  \"id\": \"0\",\n     * \"jsonrpc\": \"2.0\",\n     *  \"result\": {\n     *    \"block_header\": {\n     *      \"depth\": 78376,\n     *      \"difficulty\": 815625\n     *      ...\n     *      ...\n     *     }\n     *   }\n     * }\n     */\n```\n### Promise-wrapped responses\nAll method calls return native Nodejs promises. You need to use the\n`then()` / `catch()` pattern shown above. If the call was succesful,\nthe data will be passed to `then()`, otherwise the error will be passed\nto `catch()`. \n\n### Method Names\nThe method calls are the camel-case version of the original RPC methods defined\non the Monero website.\n(See https://getmonero.org/resources/developer-guides/daemon-rpc.html)\n\nExample1: on the Monero website `getblockheaderbyhash` is called with `height`\nFor the Nodejs client, the method is `getBlockHeaderByHash` and the argument to\nquery height 12345 will be this object: {height: 12345}\n\nExample2: on the Monero website there a RPC call `get_transaction_pool`\nFor the Nodejs client, the method is `getTransactionPool` \n\n### Arguments\nThe arguments to use for those methods are detailed in the inline documentation of \nthe `index.js`. There are the same as those mentioned in the Monero documentation:\nhttps://getmonero.org/resources/developer-guides/daemon-rpc.html#getblockheaderbyheight\n\n### Returned value\nIf you havent specified any `decodeJSON` argument when you\ninstantiated `rpcClient`, by default the returned data will already be parsed\ninto a JSON object for you. Otherwise you will receive the original JSON string\nreturned by the Monero network.\n\n## Testing\n\nTesting is done with `mocha`, `chai` and `chai-as-promised` to test promises.\n\nTo run the tests:\n\n```\nnpm run test\n```\n\nThe tests are located in the `tests.js` file. They perform actual API calls to the monero network through moneroworld. In order to prevent the tests from failing because of a timeout, tests are run with a `timeout` option of 10s. Tests can still fail if moneroworld servers are too slow.\n\nIf you want to just run one set of test (i.e a `describe` block), for let's say the `getBlockTemplate() function, you can do so with this command:\n\n```\n./node_modules/mocha/bin/mocha --grep [functionNameHere] --timeout 10000\n```\nFor example, if you want to test `getBlockTemplate`:\n```\n./node_modules/mocha/bin/mocha --grep getBlockTemplate --timeout 10000\n```\n\nYou can be even more specific by adding `only` to the individual tests. Example for `getInfo()`:\n\n```\ndescribe('getInfo()', () =\u003e {\n  it.only('should successfully retrieve information about the network', () =\u003e {\n    return expect(rpc.getInfo())\n            .to\n            .eventually\n            .contain('\"status\": \"OK\"')\n            .and\n            .contain('top_block_hash');\n  });\n});\n```\n## Possible future features\n* Caching of some responses\n    * First with javascript objects\n    * Then with some external db, like Redis or SQLLite\n* Make the library Isomorphic, i.e work in web-browsers as well\n* Make the method calls also support callbacks\n* Setup automated testing with travis. Will need first to build a mock object for Monero to have deterministic tests\n\n## License\n\nThis project is licensed under the MIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjklepatch%2Fmonero-nodejs-rpc-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjklepatch%2Fmonero-nodejs-rpc-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjklepatch%2Fmonero-nodejs-rpc-client/lists"}