Dead simple, promise-based client for interacting and building services on top of the NANO network, a next-generation cryptocurrency created by Colin LeMahieu with nearly instant transactions and no fees. Learn more in the Nanode docs. ⚡️
If you've worked with NANO before, you probably have experienced it's learning curve. The community is amazingly helpful and growing fast, but the documentation and guides to working with it currently leave a lot to be desired.
This library is designed to get anyone, even a total beginner, up and running building services on NANO in just a few minutes. At it's core, this package is a wrapper around the official RPC protocol that does a few things:
- abstracts away some of the idiosyncracies and quirks with the RPC API,
- exposes some easy top-level account methods like
recieve()that do everything automatically so you don't have to know about Proof of Work, creating, signing, publishing, etc
- allows you to specify amounts in Nano without dealing with "raw" 128-bit integers
Sign up for Node API to get 1,000 free API calls per month! It's the easiest way to build with Nano.
npm install nanode
This library is built with TypeScript, and I highly reccommend you take advantage of your code editor's Intellisense features.
Nanode Node API
Your own Nano RPC server
To enable some helpful logs, pass
debug: true as a paramater in the constructor object.
Working with accounts
Generate an account
It's easy to generate a new random account. You'll get the account's private and public keys along with its address.
In order to open an account and let the network know it exists, we'll need publish an
open block. An account can't be opened with zero balance, so we'll first need to send some Nano to our account's address from our own wallet or NanoFaucet, then call
await nano.accountPRIVATE_KEY.send001, RECIPIENT_ADDRESS
receive() method will automatically receive the latest pending block for the given account.
Full list of methods
All methods return native or Bluebird promises and are fully compatible with
Working with a specific account
If you're just looking to transact with Nano, these methods will cover 90% of your use case.
account.open(representative?: string, hash?: string)
account.send(nanoAmount: string | number, address: string)
account.ledger(count?: number, details?: boolean)
account.pending(count?: number, minNanoThreshold?: string | number)
Used for generating accounts and extrapolating public keys/addresses from private keys.
Account methods take a single account string or in some cases, an array of accounts.
nano.accounts.history(account: string, count?: number)
nano.accounts.ledger(account: string, count?: number, details?: boolean)
nano.accounts.pending(account: string, count?: number, minNanoThreshold?: string | number)
nano.accounts.pendingMulti(accounts: string, count?: number, minNanoThreshold?: string | number)
Has methods to get information about blocks:
nano.blocks.chain(hash: string, count?: number)
nano.blocks.history(hash: string, count?: number)
nano.blocks.info(hashOrHahes: string | string, details?: boolean)
nano.blocks.successors(block: string, count?: number)
Methods to construct blocks:
And a method to publish a constructed block to the network:
Allows you to convert
mrai amounts to and from their raw values.
nano.convert.toRaw(amount: string | number, denomination: 'rai' | 'krai' | 'mrai')
nano.convert.fromRaw(amount: string, denomination: 'rai' | 'krai' | 'mrai')
Allows you to generate and validate Proof of Work for a given block hash.
nano.work.validate(work: string, hash: string)
nano.deterministicKey(seed: string, index?: string | number)
nano.minimumReceive.set(nanoAmount: string | number)
Calling RPC directly
If there's a method missing, or if you prefer to call RPC directly, you can use
nano.rpc. You'll still get the full benefit of type checking and return types for applicable RPC calls.
- TypeDoc site + add remaining method types