Code Monkey home page Code Monkey logo

nicehash-calculator's Introduction

NOTE: This project is no longer maintained

#16

NiceHash Profit Calculator for Buyers

The program running.

A JavaScript (TypeScript) program for estimating the profitability of buying hashing power on NiceHash. Feel free to make an issue if you need help with usage or have find any bugs.

This project has been updated to use the new platform and the new API for NiceHash.

This project is not affiliated with NiceHash. I am not responsible for any losses that may come as a result of this project.

Website

The website has been shut down for years.

Usage

Requirements

Downloading

git clone https://github.com/GarboMuffin/nicehash-calculator/
cd nicehash-calculator

If you wish to use the old platform (api.nicehash.com) instead of the new platform (new.nicehash.com/docs.nicehash.com) while it is still around, do git checkout old-platform before continuing.

Setup

# You can try 'npm install --only=production' instead if you don't plan to make edits and normal 'npm install' is slow.
npm install

# Build the TypeScript files to JavaScript, must be done each time you make a change to the source.
npm run build

Running

# Any of these will work. Pick your favorite.
node index [arguments or coins]
node dist/index [arguments or coins]
node . [arguments or coins]
npm start -- [arguments or coins]

Arguments

Argument parsing is very strict. You must use -- before each argument name, - will not work (it is used for coin filtering). You must use an = to seperate argument names from their value if an arguments takes a value (do not use a space instead of =). You should see a warning if you did something wrong.

Argument Description
--experimental-fees Enables experimental fee support (only a 3% fee in calculations for now)
--no-color Disables color
--no-header Disables the large message printed at the start
--no-warnings Disables warnings
--output=thing Changes the format of the output. Valid values for thing are pretty (default), json, and delayed-json
--prices=thing Changes the how prices to buy hashing power are obtained. Valid values for thing are minimum (minimum with miners) and minimum-with-speed
--sleep-time=1000 Changes the time waited between each coin in milliseconds. Default is 1000. 1000 can be replaced with any other number (including 0 to effectively disable a delay, but be warned you might get hit by rate limits)
--list-coins List coins and exit
--watch Enables watch mode
--watch-delay Delay between runs with watch mode enabled
--debug Enables debug logging (very verbose)

You can also put arguments you would like to always be added in arguments.txt. See that file for more information.

Coins

By default it will do calculations for all known coins. This is slow and probably not what you want. Instead, you probably want to monitor a few specific coins or algorithms that you have wallets or pools setup for. Coin filtering rules allow you to do this:

# Everything is case insensitive. 'bitcoin', 'bItCoIn', 'Bitcoin', and 'bITCOIN' all have the same effect.
# Warnings will be printed if something you enter is not recognized.

# The easiest filtering rule is to simply list the names of the coins you want to monitor.
# To monitor only Bitcoin, Litecoin, and Ethereum you could do:
node index bitcoin litecoin ethereum
# A coin's ticker or abbreviation has the same effect as the name:
node index btc ltc eth

# You can also use the names of algorithms to monitor all coins of that algorithm.
# To monitor all Scrypt coins you could do:
node index scrypt

# Coin names/tickers and algorithm names can be mixed together.
# To monitor all Scrypt coins and Bitcoin you could do:
node index scrypt bitcoin

# You can prepend a single `-` to any filter (coin name, coin ticker, algorithm name, etc.) to disable that coin (or algorithm) instead of enabling it.
# To run on all coins **except** Bitcoin you could do:
node index -bitcoin
# To monitor all coins **except** Scrypt coins you could do:
node index -scypt
# You can mix exclusion rules with regular rules. To monitor all Scrypt coins **except** Litecoin you could do:
node index scrypt -litecoin
# To monitor all Scrypt coins except Litecoin and also monitor Bitcoin you could do:
node index scrypt -litecoin bitcoin

# You can easily determine what your filters include using `--list-coins`
$ node index bitcoin --list-coins
Enabled coins:
 * Bitcoin (BTC) (SHA-256)

Supported coins

As coins are added to What To Mine they should automatically be supported if they use an algorithm on NiceHash. As coins become inactive they will become unsupported.

All supported coins (as of 2020-1-20)
$ node index --list-coins
...

Enabled coins:
 * Bitcoin (BTC) (SHA-256)
 * Litecoin (LTC) (Scrypt)
 * Vertcoin (VTC) (Lyra2REv3)
 * Dogecoin (DOGE) (Scrypt)
 * Feathercoin (FTC) (NeoScrypt)
 * Einsteinium (EMC2) (Scrypt)
 * DGB-Scrypt (DGB) (Scrypt)
 * Worldcoin (WDC) (Scrypt)
 * Myriad-Scrypt (XMY) (Scrypt)
 * Dash (DASH) (X11)
 * AUR-Scrypt (AUR) (Scrypt)
 * Peercoin (PPC) (SHA-256)
 * Zetacoin (ZET) (SHA-256)
 * Unobtanium (UNO) (SHA-256)
 * Myriad-SHA (XMY) (SHA-256)
 * Phoenixcoin (PXC) (NeoScrypt)
 * Orbitcoin (ORB) (NeoScrypt)
 * Maxcoin (MAX) (Keccak)
 * Monero (XMR) (RandomXmonero)
 * Viacoin (VIA) (Scrypt)
 * DGB-SHA (DGB) (SHA-256)
 * DGB-Qubit (DGB) (Qubit)
 * Mooncoin (MOON) (Scrypt)
 * Halcyon (HAL) (NeoScrypt)
 * Startcoin (START) (X11)
 * Quark (QRK) (Quark)
 * GameCredits (GAME) (Scrypt)
 * Monacoin (MONA) (Lyra2REv2)
 * Influxcoin (INFX) (X11)
 * Verge-Scrypt (XVG) (Scrypt)
 * Ethereum (ETH) (DaggerHashimoto)
 * Decred (DCR) (Decred)
 * Expanse (EXP) (DaggerHashimoto)
 * Adzcoin (ADZ) (X11)
 * Ethereum Classic (ETC) (DaggerHashimoto)
 * LBRY (LBC) (LBRY)
 * Zcash (ZEC) (Equihash)
 * Hush (HUSH) (Equihash)
 * Komodo (KMD) (Equihash)
 * Musicoin (MUSIC) (DaggerHashimoto)
 * Deutsche eMark (DEM) (SHA-256)
 * Horizen (ZEN) (Equihash)
 * Cannabiscoin (CANN) (X11)
 * BitcoinCashABC (BCH) (SHA-256)
 * Linx (LINX) (Scrypt)
 * Sumokoin (SUMO) (CryptoNightR)
 * SmartCash (SMART) (Keccak)
 * Vivo (VIVO) (NeoScrypt)
 * BitcoinZ (BTCZ) (Zhash)
 * Metaverse (ETP) (DaggerHashimoto)
 * Pirl (PIRL) (DaggerHashimoto)
 * Bitcoin Gold (BTG) (Zhash)
 * Trezarcoin (TZC) (NeoScrypt)
 * DeepOnion (ONION) (X13)
 * Verge-Lyra2REv2 (XVG) (Lyra2REv2)
 * Verge-Blake (2s) (XVG) (Blake (2s))
 * Ellaism (ELLA) (DaggerHashimoto)
 * Florin (FLO) (Scrypt)
 * GoByte (GBX) (NeoScrypt)
 * CRowdCLassic (CRCL) (NeoScrypt)
 * Dinastycoin (DCY) (RandomXmonero)
 * AUR-SHA (AUR) (SHA-256)
 * Innova (INN) (NeoScrypt)
 * LitecoinCash (LCC) (SHA-256)
 * Ravencoin (RVN) (X16Rv2)
 * Straks (STAK) (Lyra2REv2)
 * Motion (XMN) (X16R)
 * Commercium (CMM) (Equihash)
 * Gravium (GRV) (X16R)
 * Hanacoin (HANA) (Lyra2REv3)
 * Dubaicoin (DBIX) (DaggerHashimoto)
 * Traid (TRAID) (NeoScrypt)
 * LitecoinPlus (LCP) (Scrypt)
 * Callisto (CLO) (DaggerHashimoto)
 * SnowGem (XSG) (Zhash)
 * BitcoinSV (BSV) (SHA-256)
 * Actinium (ACM) (Lyra2Z)
 * Grin-CR29 (GRIN) (Cuckaroom)
 * Beam (BEAM) (BeamV2)
 * Hilux (HLX) (X16R)
 * Lethean (LTHN) (CryptoNightR)
 * Aeternity (AE) (CuckooCycle)
 * Pirate (ARRR) (Equihash)
 * Grin-CT31 (GRIN) (GrinCuckatoo31)
 * Swap (XWP) (GrinCuckarood29)
 * BitCash (BITC) (X16Rv2)
 * Ether-1 (ETHO) (DaggerHashimoto)
 * EtherGem (EGEM) (DaggerHashimoto)
 * Euno (EUNO) (X11)
 * Imagecoin (IMG) (X11)
 * Axe (AXE) (X11)
 * Exosis (EXO) (X16R)
 * BitcoinRhodium (XRC) (X13)
 * QuarkChain (QKC) (DaggerHashimoto)
 * EtherSocial (ESN) (DaggerHashimoto)
 * Nervos (CKB) (Eaglesong)

Updating

Instructions for upgrading from an older version of nicehash-calculator to a newer one.

# If these commands do not work, delete the repository and clone it again. (see `Usage`)

# Reset any changes you made and pull new changes from GitHub
git checkout .
git pull

# Update dependencies & build the new code
npm install
npm run build

# Ready to be used. See `Running`

Using nicehash-calculator in other programs

If you only care about a few specific coins, then just use the What to Mine API directly. (hint: use --debug to find out what URLs are being requested - look for request(): requested https://whattomine.com/coins/...)

Reading stdout

You could spawn a new node process and read stdout. (Hint: use node --no-header --no-warnings --output=json to only print machine readable JSON) nicehash-calculator-web used to do this in the past.

Interfacing with the source

If you are already using nodejs, you could interface directly with the source code. nicehash-calculator-web does this now. Take the compiled JavaScript (the dist folder) and just drop it into your project somewhere (in this example a folder named "nicehash-calculator").

// import a couple of source files from the program
const parseOptions = require("./nicehash-calculator/options/index").parseOptions;
const NiceHashCalculator = require("./nicehash-calculator/calculator/NiceHashCalculator").NiceHashCalculator;

// You can also do this in getData() below, but you should only have to do it once.
const options = parseOptions([]); // Parse empty arguments to get the default options.
options.showHeader = false; // Disable header
options.showWarnings = false; // Disable warnings
options.sleepTime = 1500; // Choose a sensible time delay between each request to avoid API rate limits
// Define the coins you want to include. Supports all filtering rules you can use from the CLI (see section above)
options.coins = [
  "bitcoin"
];

// Returns a promise that resolves with all the data
function getData() {
  return new Promise((resolve, reject) => {
    const result = [];

    // We need to define a custom output handler
    // This happens inside of getData() so that the class can easily access `resolve()`, `reject()`, and `result`.
    options.outputHandler.class = class {
      constructor() {
        this.pretty = false; // disable additional console output meant for users
      }

      // handle(data) is called once for each coin with the coin's raw data.
      handle(data) {
        // `data` is the raw coin data that you can do anything with
        // here we just push it to an array so we can return it later
        result.push(data);
      }

      // finished() is called once after all coins have been processed.
      finished() {
        // resole the promise with the result
        resolve(result);
      }
    };

    // construct a `NiceHashCalculator` object with the options we determined earlier
    const calculator = new NiceHashCalculator(options);

    // start the calculator; start() returns a promise
    calculator.start()
      .catch((err) => {
        // handle errors here
        reject(err);
      });
  });
}

// example usage
getData()
  .then((result) => console.log(result))
  .catch((err) => console.error(err))

Donations

BTC (bech32): bc1qkuz9a4trzgvdq9sru800jtxfz0ld0vtwrqu0nq
BTC: 1GarboYPsadWuEi8B2Pv1SvwAsBHVn1ABZ
BCH: qzjtsdg8uskpa8q5lgt7rxvxm7gv27vk0qrwgyy0nz
LTC: LNTXpx86L2ADQPMC3t78jNvramJ1xMS2F4
ETH: 0xE9eDFAB6565695C01c1978B9782ad1FE22b3E5AC
DOGE: DS7aiQgXqFrmwG3bRK3kzC78Hb114y7Y1R

nicehash-calculator's People

Contributors

garbomuffin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nicehash-calculator's Issues

Support alternative sources of revenue

NanoPool, Cryptocompare, Coinwarz (paid/requires email), Mycryptobuddy (no api?), and many more other sources of getting revenue data for coins are out there. Currently everything comes from What To Mine which seems to often overestimate and whatnot.

I would probably implement a --revenue-source or similar argument that can be set to whattomine, cryptocompare, etc. It would only ever use a single source of revenue for consistency and ease of implementation. This would mean that some sources might have very limited selections of coins.

This is hopefully the last somewhat major feature to add to the rewrite before replacing the old pile of spaghetti.

Add --help

Even if it just tells you to read the README, it would probably help.

Improved error handling

If What to mine decides to return invalid JSON the entire thing crashes with an obscure error message. That's bad.

There's probably other things like that that need to be fixed.

Very related to #10

Include fees

NiceHash order fee, pools fees, etc. Should be possible to account for some of these at least. Perhaps a --pool-fee=X

nicehash-calculator is no longer maintained.

I am no longer going to be maintaining nicehash-calculator.

I have not used the NiceHash service in over two years. I don't use cryptocurrency anymore. I don't have access to my NiceHash account and I'm not sure whether I still have the private keys for the donation addresses.

This program literally just does a simple subtraction using public APIs. The code is a spaghetti mess of incomplete features and rewrites. I don't have the time I once had and I certainly don't want to spend what little time I do have maintaining this project.

Thanks for understanding.

Redoing options

[this is old and outdated, look at the readme for documentation]

  • Rewrite option parsing with a custom parser. Existing modules aren't very good (IMO) and try to do a lot more that they really shouldn't be trying to do. The one in the old one may have been ugly and dirty but it worked very well for what it was.
    • Custom parser should force consistency, eg. --thing=42 and --another-thing 16 should not work together. If you asked me only the the first should work.
    • No automatic converting of types unless told to
    • --no-thing does not set thing to false, it sets no-thing to true (debating)
  • Proposed Arguments:
    • Debating new format for specifying coins: --coins=bitcoin,ltc,eth
    • Debating new format for specifying algorithms (separate from coins): --algorithms=sha-256,scrypt
    • --debug
    • --no-header
    • --output=json
      • plan to have more output types in the future so this is gonna be for that
    • --prices=minimum
    • --use-coin-cache (debating name)
    • --sleep-time=x
    • --pool-fee=X (#8)

Fixed Orders

the calculations are not always accurate and does not account for the requested hashrate when making calculations.

Instead of hardcoding/listing which currencies are of interest, dynamically loop through all listed on whattomine

I see all coins added so far are hardcoded into this:
https://github.com/GarboMuffin/nicehash-calculator/blob/master/src/coins.ts

Rather than having one file per coin and importing it like this, how about fetching a list of coins from whatToMine:
https://whattomine.com/coins.json

Then using that to build a "top coins" to mine right now? Would be a ton more options, so would love to have it this dynamic!

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.