Monero JavaScript Library
A JavaScript library for creating Monero applications using RPC and WebAssembly bindings to monero v0.18.2.2 'Flourine Fermie'.
- Supports client-side wallets in Node.js and the browser using WebAssembly.
- Supports wallet and daemon RPC clients.
- Supports multisig, view-only, and offline wallets.
- Wallet types are interchangeable by conforming to a common interface.
- Uses a clearly defined data model and API specification intended to be intuitive and robust.
- Query wallet transactions, transfers, and outputs by their properties.
- Fetch and process binary data from the daemon (e.g. raw blocks).
- Receive notifications when blocks are added to the chain or when wallets sync, send, or receive.
- Over 300 passing Mocha tests.
Table of contents
Architecture

Build browser or Node.js applications using RPC or WebAssembly bindings to monero-project/monero. Wallet implementations are interchangeable by conforming to a common interface, MoneroWallet.js.
Sample code
const monerojs = require("monero-javascript");
let daemon = await monerojs.connectToDaemonRpc("http://localhost:38081", "superuser", "abctesting123");
let height = await daemon.getHeight();
let txsInPool = await daemon.getTxPool();
let walletRpc = await monerojs.connectToWalletRpc("http://localhost:38084", "rpc_user", "abc123");
await walletRpc.openWallet("sample_wallet_rpc", "supersecretpassword123");
let primaryAddress = await walletRpc.getPrimaryAddress();
let balance = await walletRpc.getBalance();
let txs = await walletRpc.getTxs();
let walletFull = await monerojs.createWalletFull({
path: "sample_wallet_full",
password: "supersecretpassword123",
networkType: "stagenet",
serverUri: "http://localhost:38081",
serverUsername: "superuser",
serverPassword: "abctesting123",
seed: "hefty value scenic...",
restoreHeight: 573936,
});
await walletFull.sync(new class extends monerojs.MoneroWalletListener {
onSyncProgress(height, startHeight, endHeight, percentDone, message) {
}
});
await walletFull.startSyncing(5000);
let fundsReceived = false;
await walletFull.addListener(new class extends monerojs.MoneroWalletListener {
onOutputReceived(output) {
let amount = output.getAmount();
let txHash = output.getTx().getHash();
let isConfirmed = output.getTx().isConfirmed();
let isLocked = output.getTx().isLocked();
fundsReceived = true;
}
});
let createdTx = await walletRpc.createTx({
accountIndex: 0,
address: await walletFull.getAddress(1, 0),
amount: "250000000000",
relay: false
});
let fee = createdTx.getFee();
await walletRpc.relayTx(createdTx);
await new Promise(function(resolve) { setTimeout(resolve, 5000); });
assert(fundsReceived);
await walletFull.close(true);
Documentation
Using monero-javascript in your project
cd your_project or mkdir your_project && cd your_project && npm init
npm install monero-javascript@0.8.4
- Add
require("monero-javascript") to your application code.
Running in Node.js
Node.js 18 LTS is recommended and requires using the --no-experimental-fetch flag. Alternatively, Node.js 16 LTS works.
Building a browser application
- Bundle your application code for a browser. See xmr-sample-app for an example project using webpack.
- Copy assets from ./dist to your web app's build directory.
Using RPC servers:
- Download and install Monero CLI.
- Start monerod, e.g.:
./monerod --stagenet (or use a remote daemon).
- 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 ./
Building WebAssembly binaries from source
This project uses WebAssembly to package and execute Monero's source code for use in a browser or other WebAssembly-supported environment.
Compiled WebAssembly binaries are committed to ./dist for convenience, but these files can be built independently from source code:
- Install and activate emscripten.
- Clone emscripten repository:
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull && ./emsdk install 3.1.10 && ./emsdk activate 3.1.10 && source ./emsdk_env.sh
export EMSCRIPTEN=path/to/emsdk/upstream/emscripten (change for your system)
- Clone monero-javascript repository:
git clone --recursive https://github.com/monero-ecosystem/monero-javascript.git
cd monero-javascript
./bin/update_submodules.sh
- 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" ....
- Download and install unbound 1.17.0 to your home directory (
~).
./bin/build_all.sh (install monero-project dependencies as needed for your system)
Running tests
- Clone the project repository:
git clone https://github.com/monero-ecosystem/monero-javascript.git
cd monero-javascript
- Start RPC servers:
- Download and install Monero CLI.
- Start monerod, e.g.:
./monerod --testnet (or use a remote daemon).
- 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 ./
- Configure the appropriate RPC endpoints, authentication, and other settings in TestUtils.js (e.g.
WALLET_RPC_CONFIG and DAEMON_RPC_CONFIG).
Running tests in Node.js
- Run all tests:
npm test
- Run tests by their description, e.g.:
npm run test -- --grep "Can get transactions"
Running tests in a browser
- Start monero-wallet-rpc servers used by tests:
./bin/start_wallet_rpc_test_servers.sh
- In another terminal, build browser tests:
./bin/build_browser_tests.sh
- Access http://localhost:8080/tests.html in a browser to run all tests
Related projects
License
This project is licensed under MIT.
Donations
If this library brings you value, please consider donating.

46FR1GKVqFNQnDiFkH7AuzbUBrGQwz2VdaXTDD4jcjRE8YkkoTYTmZ2Vohsz9gLSqkj5EM6ai9Q7sBoX4FPPYJdGKQQXPVz