Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
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 on the official repo ⚡️
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:
Nano.send()
and Nano.recieve()
, so you don't have to know about creating, signing, publishing, etc.Want to build with NANO, but not running a full node? Sign up for node access and get your API key at nanode.co
npm install nanode
This library is built with TypeScript, and I highly reccommend you take advantage of your code editor's Intellisense features. All fields on requests and responses for the RPC are strings - and for now, the same is true for this library.
The full code for these snippets can be found /examples directory
Initiate the client with your API key and a valid RPC url. Optionally pass your address and private key to the constructor.
Not sure what your private key is? Call nano.get_deterministic_key()
with your account's seed to get all relevant account information.
//examples/init.ts
import Nano from 'nanode'
const nano = new Nano({
api_key: process.env.API_KEY,
url: 'https://api.nanode.co',
origin_address: process.env.SENDER_WALLET, // wallet for the 'controlling' account
origin_key: process.env.SENDER_WALLET_PRIVATE_KEY // key for the 'controlling' account
})
Now that we're connected, we need to 'open' the account. Opening an account is a bit of a catch-22 - it requires any amount to be sent to the address from a funded account before account is actually open.
//examples/open.ts
import Nano from './init'
//create a new key
const target = await Nano.key.create()
console.log(`Initializing account ${target.account} with funds..`)
//send new account init funds from our walet
const hash = await Nano.send('0.01', target.account)
//open block with send's hash
const hash = await Nano.open(
hash,
process.env.DEFAULT_REP,
target.private,
target.public
)
console.log(`Open block published with hash: ${hash}`)
Sending and receiving are simple one liners. For receive, we have to pass in the hash of the block we're receiving
//examples/send.ts, examples/receive.ts
import Nano from './init'
const wallet_addr =
'xrb_3hk1e77fbkr67fwzswc31so7zi76g7poek9fwu1jhqxrn3r9wiohwt5hi4p1'
const hash = await Nano.send('0.01', wallet_addr)
return await Nano.receive(
hash,
process.env.RECIPIENT_WALLET_PRIVATE_KEY,
wallet_addr
)
If you aren't sure about some of the arguments, they're available as types in your editor, or in the official RPC guide. Full TypeDoc documentation is on the way!
if you only need to send and recieve NANO, these methods should technically be the only ones you need, per the examples above:
Nano.open()
Nano.send()
Nano.receive()
Nano.change()
Account methods take a single account string or in some cases, an array of accounts.
Nano.account.get()
Nano.account.balance()
Nano.account.balances()
Nano.account.block_count()
Nano.account.frontiers()
Nano.account.history()
Nano.account.info()
Nano.account.key()
Nano.account.ledger()
Nano.account.pending()
Nano.account.representative()
Nano.account.weight()
Block methods either require a block hash as a single argument, or a stringified block:
Nano.block.account(block_hash)
Nano.block.count(block_hash)
Nano.block.chain(block_hash)
Nano.block.history(block_hash)
Nano.block.pending(block_hash)
Nano.block.change(block_string)
Nano.block.open(block_string)
Nano.block.publish(block_string)
Nano.block.receive(block_string)
Nano.block.send(block_string)
This utility method allows a block hash or array of block hashes -
Nano.blocks.find()
The convert method allows you to convert krai, mrai, and rai to and from their raw values. Both take an amount and denomination.
Nano.convert.toRaw(22, 'mrai')
Nano.convert.fromRaw(22, 'mrai')
Exposes work methods to perform on hashes
Nano.work.generate(block_hash)
Nano.work.cancel(block_hash)
Nano.work.get(wallet, 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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
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.