Giter VIP home page Giter VIP logo

monerod-js's Introduction

NodeJS RPC Client for Monero Daemon

Monerod-js is a NodeJS RPC Client for Monero Daemon.

It is written in Typescript and transpiled to Javascript. Using Typescript for development comes with the benefit that all the return values are typed and errors may be spotted earlier.

The official Monero Daemon RPC documentation can be found here.

Developed for / Last tested with Monerod v0.10.3.1.

Checkout the CHANGELOG to keep track of the latest changes.

Install

npm install cryptoshrimpi/monerod-js

Test

You need to install the dev dependencies to run the test suite:

cd node_modules/monerod-js
npm install
npm test

The test's default daemon is monero.whattheserver.me:8081. In order to use your local node please edit test.spec.ts or test.spec.js. Some tests may fail if your daemon is configured to restrict access to certain RPC calls.

Usage

Example (Typescript)

import { MoneroDaemon } from "node_modules/monerod-js/lib/ts/monerod-js";

var monerod = new MoneroDaemon("monero.whattheserver.me", 8081);

monerod.getBlockCount().then((result) => {
    console.log("Block count: " + result.count);
}).catch((f) => {
    console.log("Something went wrong: " + f);
});

Example (Javascript)

const m = require("./node_modules/monerod-js/lib/js/monerod-js");

var monerod = new m.MoneroDaemon("monero.whattheserver.me", 8081);

monerod.getBlockCount().then((result) => {
    console.log("Block count: " + result.count);
}).catch((f) => {
    console.log("Something went wrong: " + f);
});

Run the example code:

cd node_modules/monerod-js
node example.js

Available methods

Please see monerod-js.ts for a list of the specific return values of each method.

getBlockCount()

onGetBlockHash(blockHeight: number)

getBlockTemplate(walletAddress: string, reserveSize: number)

getLastBlockHeader()

getBlockHeaderByHash(hash: string)

getBlockHeaderByHeight(height: number)

getBlock(height: number, hash: string)

getConnections()

getInfo()

getHardFork()

setBans(bans: BansList)

getBans()

getHeight()

getTransactions(txsHashes: string[], decodeAsJson: boolean)

sendRawTransaction(txAsHex: string)

getTransactionPool()

submitBlock(blockBlobData: string)

getVersion()

getFeeEstimate()

Beer

It is highly appreciated if you want to tip me with a beer.

Monero: 4ATwquCmjnUTuDcF2Yce4YMLexuyFMKF96W7gEA6QU8S5pffgFDi9i29R8yyvHq1MzBVNVXZXUuEtdqpgVRC2hTc7Vtuahu

License

MIT. See LICENSE.md.

monerod-js's People

Contributors

cryptoshrimpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

monerod-js's Issues

promise rejection

Hi, I am trying to use getTransactions function to get transaction data. Somehow I am not able to decode it. If I set decode boolean to false, I am able to get the raw data. But when I set it to true, I return an error as follow. Any thought why?

monerod.getTransactions('f062d04308f89fd3b18a86f1cb28ab62b1e5aa79364c83ad7ce11a0c7d08fbcb', true).then(txInfo =>{
console.log(txInfo);
});

(node:4754) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 42): SyntaxError: Unexpected token u in JSON at position 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.