Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Dead simple, promise-based client for interacting and building services on top of the NANO network.
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:
send()
and recieve()
that do everything automatically so you don't have to know about Proof of Work, creating, signing, publishing, etcThis library works natively with the Nanode Node API as well as the official Nano node software, so there's no vendor lock-in.
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.
const {Nano} = require('nanode')
const nano = new Nano({apiKey: process.env.NANODE_API_KEY})
const {Nano} = require('nanode')
const nano = new Nano({url: 'http://localhost:7076'})
To enable some helpful logs, pass debug: true
as a paramater in the constructor object.
It's easy to generate a new random account. You'll get the account's private and public keys along with its address.
const {privateKey, publicKey, address} = await nano.key.create()
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 open()
.
await nano.account(PRIVATE_KEY).open()
await nano.account(PRIVATE_KEY).send(0.01, RECIPIENT_ADDRESS)
The receive()
method will automatically receive the latest pending block for the given account.
await nano.account(PRIVATE_KEY).receive()
All methods return native or Bluebird promises and are fully compatible with async/await
.
If you're just looking to transact with Nano, these methods will cover 90% of your use case.
const account = nano.account(PRIVATE_KEY)
account.open(representative?: string, hash?: string)
account.send(nanoAmount: string | number, address: string)
account.receive(hash?: string)
account.change(representative: string)
account.rawBalance()
account.nanoBalance()
account.blockCount()
account.history(count?: number)
account.info()
account.publicKey()
account.ledger(count?: number, details?: boolean)
account.pending(count?: number, minNanoThreshold?: string | number)
account.representative()
account.weight()
Used for generating accounts and extrapolating public keys/addresses from private keys.
nano.key.create()
nano.key.expand(privateKey: string)
Account methods take a single account string or in some cases, an array of accounts.
nano.accounts.get(publicKey: string)
nano.accounts.rawBalance(account: string)
nano.accounts.nanoBalance(account: string)
nano.accounts.balances(accounts: string[])
nano.accounts.blockCount(account: string)
nano.accounts.frontiers(accounts: string[])
nano.accounts.history(account: string, count?: number)
nano.accounts.info(account: string)
nano.accounts.key(account: string)
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)
nano.accounts.representative(account: string)
nano.accounts.weight(account: string)
Has methods to get information about blocks:
nano.blocks.account(hash: string)
nano.blocks.count(byType?: boolean)
nano.blocks.chain(hash: string, count?: number)
nano.blocks.history(hash: string, count?: number)
nano.blocks.info(hashOrHahes: string | string[], details?: boolean)
nano.blocks.pending(hash: string)
nano.blocks.successors(block: string, count?: number)
Methods to construct blocks:
nano.blocks.createOpen(block: OpenBlock)
nano.blocks.createSend(block: SendBlock)
nano.blocks.createReceive(block: ReceiveBlock)
nano.blocks.createChange(block: ChangeBlock)
And a method to publish a constructed block to the network:
nano.blocks.publish(block: string)
Allows you to convert rai
, krai
, and 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.generate(hash: string)
nano.work.validate(work: string, hash: string)
nano.available()
nano.representatives()
nano.deterministicKey(seed: string, index?: string | number)
nano.minimumReceive.get()
nano.minimumReceive.set(nanoAmount: string | number)
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.
await nano.rpc('account_info', {account})
FAQs
Dead simple, promise-based client for interacting and building services on top of the NANO network.
The npm package nanode receives a total of 18 weekly downloads. As such, nanode popularity was classified as not popular.
We found that nanode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.