A battle-tested toolkit for the Nano cryptocurrency.
If you are looking for legacy blocks, you will want the
The documentation is available locally in
docs/ or online at https://marvinroger.github.io/nanocurrency-js/packages/nanocurrency/docs/.
To install the library:
npm install nanocurrency # or yarn add nanocurrency
import * as nanocurrency from 'nanocurrency'
You might be wondering how fast is the work generation. There's a
pow-benchmark example in the
On an Intel Core i7-8550U CPU, with 100 iterations, the average computation time is 18.5s per work.
Considering you can pre-compute and cache the work prior to an actual transaction, this should be satisfying for a smooth user experience.
Contributions are very welcome. To develop, make use of the following commands (using Yarn):
yarn build:dev: build the C++ code to WebAssembly and bundle the files into the
dist/ directory, without optimization so that it is fast while developing. Note that you'll need to have Docker installed
yarn test: test the code
yarn generate-docs: generate the
docs/ website from the JSDoc annotations
If you like the project, feel free to donate some nano:
State block data.
Check if the given address is valid.
Note: it checks the format and the checksum of the address. It does not check whether or not the address does exist on the network.
The address to check
Check if the given amount is valid.
Note: a valid amount means that it can be embedded into a block
The amount to check
Check if the given hash is valid.
Note: it only checks the format of the hash.
The hash to check
Check if the given index is valid.
Note: it only checks the format of the index.
Check if the given public or secret key is valid.
Note: it only checks the format of the key. It does not check whether or not the key does exist on the network.
The key to check
Check if the given seed is valid.
Note: it only checks the format of the seed.
The seed to check
Check if the given signature is valid.
Note: it only checks the format of the signature.
The signature to check
Check if the given threshold is valid.
Note: it only checks the format of the threshold.
The threshold to check
Check if the given work is valid.
Note: it only checks the format of the work, not its difficulty.
The work to check
Find a work value that meets the difficulty for the given hash. Require WebAssembly support.
The block hash to find a work for
Work, in hexadecimal format, or null if no work has been found (very unlikely)
Convert a value from one Nano unit to another.
The value to convert
Derive address from a public key.
The public key to generate the address from, in hexadecimal format
Derive a public key from a secret key.
The secret key or address to generate the public key from, in hexadecimal or address format
Public key, in hexadecimal format
Derive a secret key from a seed, given an index.
The seed to generate the secret key from, in hexadecimal format
The index to generate the secret key from
Secret key, in hexadecimal format
Generate a cryptographically secure seed.
Promise fulfilled with seed, in hexadecimal format
Hash a state block.
Hash, in hexadecimal format
Sign a block.
Signature, in hexadecimal format
Validate whether or not the work value meets the difficulty for the given hash.
Verify a block against a public key.
Generated using TypeDoc