npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iota-js-chrysalis-tmp

v1.0.0

Published

IOTA JavaScript Library for Chrysalis

Downloads

2

Readme

About

Experimental client library for IOTA Chrysalis network. Implemeted in TypeScript to strongly type the objects sent and received from the API.

Also includes High Level operations and MQTT support.

Runs in both NodeJS and Browser environments.

Prerequisites

npm install iotaledger/iota.js#chrysalis

Example

const { SingleNodeClient } = require("@iota/iota.js");

async function run() {
    const client = new SingleNodeClient("http://localhost:14265");

    const info = await client.info();
    console.log("Node Info");
    console.log("\tName:", info.name);
    console.log("\tVersion:", info.version);
    console.log("\tIs Healthy:", info.isHealthy);
    console.log("\tNetwork Id:", info.networkId);
    console.log("\tLatest Milestone Index:", info.latestMilestoneIndex);
    console.log("\tConfirmed Milestone Index:", info.confirmedMilestoneIndex);
    console.log("\tPruning Index:", info.pruningIndex);
    console.log("\tFeatures:", info.features);
    console.log("\tMin PoW Score:", info.minPowScore);
}

run()
    .then(() => console.log("Done"))
    .catch((err) => console.error(err));

API Endpoints

These methods are implemented on the API client.

  • health() - Is the node healthy.
  • info() - Get the information about a node.
  • tips() - The tips for the tangle.
  • message(messageId) - Get a message.
  • messageMetadata(messageId) - Get the metadata for a message.
  • messageRaw(messageId) - Get the raw message bytes.
  • messageSubmit(message) - Submit a new message to the tangle.
  • messageSubmitRaw(message) - Submit a new message to the tangle as bytes.
  • messageChildren(messageId) - Find the children of a message.
  • messagesFind(index) - Find messages by indexation key.
  • output(outputId) - Get an output by id.
  • address(address) - Get an address details using bech32 address.
  • addressOutputs(address) - Get address outputs using bech32 address.
  • addressEd25519(address) - Get address details using ed25519 address.
  • addressEd25519Outputs(address) - Get address outputs using ed25519 address.
  • milestone(index) - Get the milestone details.
  • peers() - Get a list of peers.
  • peerAdd() - Add a peer.
  • peerDelete() - Delete a peer.
  • peer() - Get the details of a peer.

High level operations

There are also high level operations which make use of the API level methods:

  • getBalance - Given a seed and account index calculate the total balance available on it's addresses.
  • getUnspentAddress - Given a seed, account index, and start index find the next unspent address.
  • getUnspentAddresses - Given a seed, account index, and start index find all the unspent addresses.
  • promote - Promote a message by attaching an empty message to it.
  • reattach - Reattach a message using the message id.
  • retry - Looks at the metadata for a message and promotes or retries depending on it's state.
  • retrieveData - Given a message id return the index and data from it.
  • send - Given a seed, path, destination address in bech32 format and amount, make a single transfer.
  • sendEd25519 - Given a seed, path, destination address in ed25519 format and amount, make a single transfer.
  • sendMultiple - Given a seed, path, destination addresses in bech32 format and amounts, make multiple transfers.
  • sendMultipleEd25519 - Given a seed, path, destination addresses in ed25519 format and amounts, make multiple transfers.
  • sendAdvanced - Given a set of inputs with keypairs seed, path, list of destinations make multiple transfers, can also include index data.
  • sendData - Given index and data create a new data message.

MQTT Operations

You can create a MQTT client which once connected can stream the following feeds.

  • milestonesLatest
  • milestonesConfirmed
  • messageMetadata - Metadata updates for a specified messageId
  • output - Output updates for a specified outputId
  • addressOutputs - Address output updates for a specified address
  • address25519Outputs - Address output updates for a specified ed25519 address
  • messagesRaw - All messages in binary form
  • messages - All messaged decoded to objects
  • indexRaw - All messages for a specified indexation key in binary form
  • index - All messages for a specified indexation key in object form
  • messagesMetadata - All metadata updates

Models

You can see the model definitions for all the objects in the typings folder.

Proof of Work

A very simple local proof of work provider ./localPowProvider is implemented but not used by default. The example is included for reference purposes, but should not be used as it is very slow. You can experiment using it or any other PoW implementation by passing it in the options parameter of the SingleNodeClient constructor.

const client = new SingleNodeClient("http://localhost:14265", { powProvider: new LocalPowProvider() });

Additional Examples

Please find other examples in the ./examples folder.

  • Simple - Performs basic API operations.
  • Address - Demonstrates address generation from a Bip39 mnemonic seed using raw and Bip32 path methods.
  • Transaction - Demonstrates how to send a transaction and call some of the other higher level functions.
  • Data - Storing and retrieving data on the tangle.
  • Browser - Demonstrates direct inclusion and use of the library in an html page.
  • Peers - Demonstrates peer management.
  • Mqtt - Using mqtt to read streaming messages.
  • Browser Mqtt - Using mqtt to read streaming messages in the browser.

Supporting the project

If the iota.js has been useful to you and you feel like contributing, consider submitting a bug report, feature request or a pull request.

See our contributing guidelines for more information.

Joining the discussion

If you want to get involved in the community, need help with getting set up, have any issues or just want to discuss IOTA, Distributed Registry Technology (DRT), and IoT with other people, feel free to join our Discord.