A battle-tested toolkit for the Nano cryptocurrency.
If you are looking for legacy blocks, you will want the ^1.0.0
versions.
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 examples/
directory.
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 lint
: lint the code against JavaScript Standard Style
yarn generate-docs
: generate the docs/
website from the JSDoc annotations
If you like the project, feel free to donate some nano:
xrb_3mrogerjhkdyj6mzf4e7aatf3xs3gp4stwc9yt9ymgasw7kr7g17t4jwwwy8
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
Valid
Check if the given amount is valid.
Note: a valid amount means that it can be embedded into a block balance
.
The amount to check
Valid
Check if the given hash is valid.
Note: it only checks the format of the hash.
The hash to check
Valid
Check if the given index is valid.
Note: it only checks the format of the index.
Valid
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
Valid
Check if the given seed is valid.
Note: it only checks the format of the seed.
The seed to check
Valid
Check if the given signature is valid.
Note: it only checks the format of the signature.
The signature to check
Valid
Check if the given threshold is valid.
Note: it only checks the format of the threshold.
The threshold to check
Valid
Check if the given work is valid.
Note: it only checks the format of the work, not its difficulty.
The work to check
Valid
Find a work value that meets the difficulty for the given hash. Require WebAssembly support.
The block hash to find a work for
Parameters
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
Params
Converted number
Derive address from a public key.
The public key to generate the address from, in hexadecimal format
Parameters
Address
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.
Parameters
Hash, in hexadecimal format
Sign a block.
Parameters
Signature, in hexadecimal format
Validate whether or not the work value meets the difficulty for the given hash.
Parameters
Valid
Verify a block against a public key.
Parameters
Valid
Generated using TypeDoc
State block data.