Monero JavaScript API


This project provides a modern JavaScript API for a Monero wallet and daemon.

The API currently relies on running instances of Monero Wallet RPC and Monero Daemon RPC. Primary goals of this project are to support a local wallet with client-side crypto and a MyMonero wallet which shares the view key with a 3rd party to scan the blockchain.

Main Features

A quick reference of the wallet and daemon data models can be found here.

Wallet Sample Code

See the tests for the most complete examples of using this library.

// create a wallet that uses a monero-wallet-rpc endpoint
let wallet = new MoneroWalletRpc({
  uri: "http://localhost:38083",
  user: "rpc_user",
  pass: "abc123"

// get wallet balance as BigInteger
let balance = await wallet.getBalance();  // e.g. 533648366742
// get wallet primary address
let primaryAddress = await wallet.getPrimaryAddress();  // e.g. 59aZULsUF3YNSKGiHz4J...
// get address and balance of subaddress [1, 0]
let subaddress = await wallet.getSubaddress(1, 0);
let subaddressBalance = subaddress.getBalance();
let subaddressAddress = subaddress.getAddress();

// send to an address
let sentTx = await wallet.send("74oAtjgE2dfD1bJBo4DW...", new BigInteger(50000));

// send to multiple destinations from subaddress 1, 0 which can be split into multiple transactions
// see MoneroSendConfig.js for all config options or to build a config object
let sentTxs = await wallet.sendSplit({
  destinations: [
    { address: "7BV7iyk9T6kfs7cPfmn7...", amount: new BigInteger(50000) },
    { address: "78NWrWGgyZeYgckJhuxm...", amount: new BigInteger(50000) }
  accountIndex: 1,
  subaddressIndices: [0]

// get confirmed transactions
for (let tx of await wallet.getTxs({isConfirmed: true})) {
  let txId = tx.getId();                 // e.g. f8b2f0baa80bf6b...
  let txFee = tx.getFee();               // e.g. 750000
  let isConfirmed = tx.getIsConfirmed(); // e.g. true

// get incoming transfers to account 0
for (let transfer of await wallet.getTransfers({isIncoming: true, accountIndex: 0})) {
  let amount = transfer.getAmount();     // e.g. 752343011023

Daemon Sample Code

// create a daemon that uses a monero-daemon-rpc endpoint
let daemon = new MoneroDaemonRpc({uri: "http://localhost:38081"});

// get daemon info
let height = await daemon.getHeight();           // e.g. 1523651
let feeEstimate = await daemon.getFeeEstimate(); // e.g. 750000

// get first 100 blocks as a binary request
let blocks = await daemon.getBlocksByRange(0, 100);

// get block info
for (let block of blocks) {
  let blockHeight = block.getHeader().getHeight();
  let blockId = block.getHeader().getId();
  let blockSize = block.getHeader().getSize();
  let txCount = block.getTxs().length;

Running Tests

  1. Set up running instances of Monero Wallet RPC and Monero Daemon RPC. See Monero RPC Setup.
  2. git clone --recurse-submodules
  3. npm install
  4. Configure the appropriate RPC endpoints and authentication by modifying WALLET_RPC_CONFIG and DAEMON_RPC_CONFIG in TestUtils.js.
  5. npm test

Note: some tests are failing as not all functionality is implemented.

Monero RPC Setup

  1. Download and extract the latest Monero CLI for your platform.
  2. Start Monero daemon locally: ./monerod --stagenet (or use a remote daemon).
  3. Create a wallet file if one does not exist. This is only necessary one time.
    • Create new / open existing: ./monero-wallet-cli --daemon-address http://localhost:38081 --stagenet
    • Restore from mnemonic seed: ./monero-wallet-cli --daemon-address http://localhost:38081 --stagenet --restore-deterministic-wallet
  4. Start monero-wallet-rpc (requires –wallet-dir to run tests):

    e.g. For wallet name test_wallet_1, user rpc_user, password abc123, stagenet: ./monero-wallet-rpc --daemon-address http://localhost:38081 --stagenet --rpc-bind-port 38083 --rpc-login rpc_user:abc123 --wallet-dir /Applications/monero-v0.13.0.2

Interfaces and Types

Project Goals


This project is licensed under MIT.


Thank you supporting this project.

For more info, please check the original repository page