{"id":13496176,"url":"https://github.com/woodser/monero-ts","last_synced_at":"2025-04-09T05:10:09.537Z","repository":{"id":35100896,"uuid":"154672052","full_name":"woodser/monero-ts","owner":"woodser","description":"TypeScript library for using Monero","archived":false,"fork":false,"pushed_at":"2024-09-18T12:08:51.000Z","size":140734,"stargazers_count":212,"open_issues_count":26,"forks_count":71,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-29T17:37:42.608Z","etag":null,"topics":["javascript","monero","nodejs","rpc","typescript","typescript-library","webassembly","webpack"],"latest_commit_sha":null,"homepage":"http://woodser.github.io/monero-ts/typedocs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/woodser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-25T13:03:03.000Z","updated_at":"2024-10-14T12:57:24.000Z","dependencies_parsed_at":"2024-11-13T11:12:43.578Z","dependency_job_id":"674cc428-aee5-43a3-a48e-a13dd80806b5","html_url":"https://github.com/woodser/monero-ts","commit_stats":{"total_commits":3161,"total_committers":16,"mean_commits":197.5625,"dds":"0.025308446694084163","last_synced_commit":"059e29fa241a9e3339cecff4dd9b300dada93179"},"previous_names":["monero-ecosystem/monero-javascript","woodser/monero-ts"],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/woodser","download_url":"https://codeload.github.com/woodser/monero-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980837,"owners_count":21027808,"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":["javascript","monero","nodejs","rpc","typescript","typescript-library","webassembly","webpack"],"created_at":"2024-07-31T19:01:43.417Z","updated_at":"2025-04-09T05:10:09.497Z","avatar_url":"https://github.com/woodser.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Libraries"],"sub_categories":["Other Wallets"],"readme":"# Monero TypeScript Library\n\nA TypeScript library for creating Monero applications using RPC and WebAssembly bindings to [monero v0.18.3.4 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.3.4).\n\n* Supports client-side wallets in Node.js and the browser using WebAssembly.\n* Supports wallet and daemon RPC clients.\n* Supports multisig, view-only, and offline wallets.\n* Wallet types are interchangeable by conforming to a [common interface](https://woodser.github.io/monero-ts/typedocs/classes/MoneroWallet.html).\n* Uses a clearly defined [data model and API specification](https://woodser.github.io/monero-java/monero-spec.pdf) intended to be intuitive and robust.\n* [Query wallet transactions, transfers, and outputs](docs/developer_guide/query_data_model.md) by their properties.\n* Fetch and process binary data from the daemon (e.g. raw blocks).\n* Receive notifications when blocks are added to the chain or when wallets sync, send, or receive.\n* Over 300 passing Mocha tests.\n\n## Architecture\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg width=\"85%\" height=\"auto\" src=\"https://raw.githubusercontent.com/woodser/monero-ts/master/docs/img/architecture.png\"/\u003e\u003cbr\u003e\n\t\u003ci\u003eBuild browser or Node.js applications using RPC or WebAssembly bindings to \u003ca href=\"https://github.com/monero-project/monero\"\u003emonero-project/monero\u003c/a\u003e.  Wallet implementations are interchangeable by conforming to a common interface, \u003ca href=\"https://woodser.github.io/monero-ts/typedocs/classes/MoneroWallet.html\"\u003eMoneroWallet.ts\u003c/a\u003e.\u003c/i\u003e\n\u003c/p\u003e\n\n## Sample code\n\n```typescript\n// import monero-ts (or import types individually)\nimport moneroTs from \"monero-ts\";\n\n// connect to daemon\nlet daemon = await moneroTs.connectToDaemonRpc(\"http://localhost:28081\");\nlet height = await daemon.getHeight();        // 1523651\nlet txsInPool = await daemon.getTxPool();     // get transactions in the pool\n\n// create wallet from mnemonic phrase using WebAssembly bindings to monero-project\nlet walletFull = await moneroTs.createWalletFull({\n  path: \"sample_wallet_full\",\n  password: \"supersecretpassword123\",\n  networkType: moneroTs.MoneroNetworkType.TESTNET,\n  seed: \"hefty value scenic...\",\n  restoreHeight: 573936,\n  server: { // provide url or MoneroRpcConnection\n    uri: \"http://localhost:28081\",\n    username: \"superuser\",\n    password: \"abctesting123\"\n  }\n});\n\n// synchronize with progress notifications\nawait walletFull.sync(new class extends moneroTs.MoneroWalletListener {\n  async onSyncProgress(height: number, startHeight: number, endHeight: number, percentDone: number, message: string) {\n    // feed a progress bar?\n  }\n} as moneroTs.MoneroWalletListener);\n\n// synchronize in the background every 5 seconds\nawait walletFull.startSyncing(5000);\n\n// receive notifications when funds are received, confirmed, and unlocked\nlet fundsReceived = false;\nawait walletFull.addListener(new class extends moneroTs.MoneroWalletListener {\n  async onOutputReceived(output: moneroTs.MoneroOutputWallet) {\n    let amount = output.getAmount();\n    let txHash = output.getTx().getHash();\n    let isConfirmed = output.getTx().getIsConfirmed();\n    let isLocked = output.getTx().getIsLocked();\n    fundsReceived = true;\n  }\n});\n\n// connect to wallet RPC and open wallet\nlet walletRpc = await moneroTs.connectToWalletRpc(\"http://localhost:28084\", \"rpc_user\", \"abc123\");\nawait walletRpc.openWallet(\"sample_wallet_rpc\", \"supersecretpassword123\");\nlet primaryAddress = await walletRpc.getPrimaryAddress(); // 555zgduFhmKd2o8rPUz...\nlet balance = await walletRpc.getBalance();   // 533648366742\nlet txs = await walletRpc.getTxs();           // get transactions containing transfers to/from the wallet\n\n// send funds from RPC wallet to WebAssembly wallet\nlet createdTx = await walletRpc.createTx({\n  accountIndex: 0,\n  address: await walletFull.getAddress(1, 0),\n  amount: 250000000000n, // send 0.25 XMR (denominated in atomic units)\n  relay: false // create transaction and relay to the network if true\n});\nlet fee = createdTx.getFee(); // \"Are you sure you want to send... ?\"\nawait walletRpc.relayTx(createdTx); // relay the transaction\n\n// recipient receives unconfirmed funds within 5 seconds\nawait new Promise(function(resolve) { setTimeout(resolve, 5000); });\nassert(fundsReceived);\n\n// save and close WebAssembly wallet\nawait walletFull.close(true);\n```\n\n## Documentation\n\n* [TypeDocs](https://woodser.github.io/monero-ts/typedocs/)\n* [API and model overview with visual diagrams](https://woodser.github.io/monero-java/monero-spec.pdf)\n* [Creating wallets](docs/developer_guide/creating_wallets.md)\n* [The data model: blocks, transactions, transfers, and outputs](docs/developer_guide/data_model.md)\n* [Getting transactions, transfers, and outputs](docs/developer_guide/query_data_model.md)\n* [Sending funds](docs/developer_guide/sending_funds.md)\n* [Multisig wallets](docs/developer_guide/multisig_wallets.md)\n* [View-only and offline wallets](docs/developer_guide/view_only_offline.md)\n* [Connection manager](docs/developer_guide/connection_manager.md)\n* [HTTPS and self-signed certificates](./docs/developer_guide/https_and_self_signed_certificates.md)\n* [Mocha tests](src/test)\n* [Installing prerequisites](docs/developer_guide/installing_prerequisites.md)\n* [Getting started part 1: creating a Node.js application](docs/developer_guide/getting_started_p1.md)\n* [Getting started part 2: creating a web application](docs/developer_guide/getting_started_p2.md)\n\n## Sample projects\n\n* [Sample Node.js app](https://github.com/woodser/xmr-sample-node) - sample Node.js application\n* [Sample React app](https://github.com/woodser/xmr-sample-react) - sample browser application using React (create-react-app)\n* [Sample Next.js app](https://github.com/woodser/xmr-sample-next) - sample browser application using Next.js\n* [Sample Vite app](https://github.com/woodser/xmr-sample-vite) - sample browser application using Vite\n* [Sample Webpack app](https://github.com/woodser/xmr-sample-webpack) - sample browser application using Webpack\n\n## Related projects\n\n* [monero-cpp](https://github.com/woodser/monero-cpp) - C++ library counterpart\n* [monero-java](https://github.com/woodser/monero-java) - Java library counterpart\n* [haveno-ts](https://github.com/haveno-dex/haveno-ts) - used for testing Haveno and its TypeScript library\n\n## Using monero-ts in your project\n\n1. `cd your_project` or `mkdir your_project \u0026\u0026 cd your_project \u0026\u0026 npm init`\n2. `npm install monero-ts`\n3. Add `import moneroTs from \"monero-ts\"` in your application code (or import types individually).\n\n#### Running in Node.js\n\nNode 20 LTS is recommended. Alternatively, Node 16 and 18 LTS work using the `--experimental-wasm-threads` flag.\n\n#### Building a browser application\n1. Bundle your application code for a browser. See [xmr-sample-webpack](https://github.com/woodser/xmr-sample-webpack) for an example project using Webpack.\n2. Copy assets from ./dist to your web app's build directory.\n\n#### Using RPC servers:\n1. Download and install [Monero CLI](https://web.getmonero.org/downloads/).\n2. Start monerod, e.g.: `./monerod --stagenet` (or use a remote daemon).\n3. Start monero-wallet-rpc, e.g.: `./monero-wallet-rpc --daemon-address http://localhost:38081 --stagenet --rpc-bind-port 38084 --rpc-login rpc_user:abc123 --wallet-dir ./`\n\n## Building WebAssembly binaries from source\n\nThis project uses WebAssembly to package and execute Monero's source code for a browser or other WebAssembly-supported environment.\n\nCompiled WebAssembly binaries are committed to ./dist for convenience, but these files can be built independently from source code:\n\n1. Install and activate emscripten.\n\t1. Clone emscripten repository: `git clone https://github.com/emscripten-core/emsdk.git`\n\t2. `cd emsdk`\n\t3. `git pull \u0026\u0026 ./emsdk install 3.1.66 \u0026\u0026 ./emsdk activate 3.1.66 \u0026\u0026 source ./emsdk_env.sh`\n\t4. `export EMSCRIPTEN=path/to/emsdk/upstream/emscripten` (change for your system)\n2. Clone monero-ts repository: `git clone --recursive https://github.com/woodser/monero-ts.git`\n3. `cd monero-ts`\n4. `./bin/update_submodules.sh`\n5. Modify ./external/monero-cpp/external/monero-project/src/crypto/wallet/CMakeLists.txt from `set(MONERO_WALLET_CRYPTO_LIBRARY \"auto\" ...` to `set(MONERO_WALLET_CRYPTO_LIBRARY \"cn\" ...`.\n6. Build the monero-cpp submodule (located at ./external/monero-cpp) by following [instructions](https://github.com/woodser/monero-cpp#using-monero-cpp-in-your-project) for your system. This will ensure all dependencies are installed. Be sure to install unbound 1.19.0 to your home directory (`~/unbound-1.19.0`).\n7. `./bin/build_all.sh` (install [monero-project dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system)\n\n## Running tests\n\n1. Clone the project repository: `git clone https://github.com/woodser/monero-ts.git`\n2. `cd monero-ts`\n3. Start RPC servers:\n\t1. Download and install [Monero CLI](https://web.getmonero.org/downloads/).\n\t2. Start monerod, e.g.: `./monerod --testnet` (or use a remote daemon).\n\t3. Start monero-wallet-rpc, e.g.: `./monero-wallet-rpc --daemon-address http://localhost:38081 --testnet --rpc-bind-port 28084 --rpc-login rpc_user:abc123 --wallet-dir ./`\n4. Configure the appropriate RPC endpoints, authentication, and other settings in [TestUtils.ts](src/test/utils/TestUtils.ts) (e.g. `WALLET_RPC_CONFIG` and `DAEMON_RPC_CONFIG`).\n\n#### Running tests in Node.js\n\n* Run all tests: `npm test`\n* Run tests by their description, e.g.: `npm run test -- --grep \"Can get transactions\"`\n\n#### Running tests in a browser\n\n1. Start monero-wallet-rpc servers used by tests: `./bin/start_wallet_rpc_test_servers.sh`\n2. In another terminal, build browser tests: `./bin/build_browser_tests.sh`\n3. Access http://localhost:8080/tests.html in a browser to run all tests\n\n## License\n\nThis project is licensed under MIT.\n\n## Donations\n\nPlease consider donating to support the development of this project. 🙏\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"donate.png\" width=\"115\" height=\"115\"/\u003e\u003cbr\u003e\n\t\u003ccode\u003e46FR1GKVqFNQnDiFkH7AuzbUBrGQwz2VdaXTDD4jcjRE8YkkoTYTmZ2Vohsz9gLSqkj5EM6ai9Q7sBoX4FPPYJdGKQQXPVz\u003c/code\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodser%2Fmonero-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwoodser%2Fmonero-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodser%2Fmonero-ts/lists"}