1.8.6 • Published 1 year ago

@iota/iota.js v1.8.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@iota/iota.js

This library is functionally complete, but it is recommended to use iota.rs. The rust library will be more heavily maintained and is much more performant.

Client library for IOTA stardust network, implemeted in TypeScript to strongly type the objects sent and received from the API.

Runs in both NodeJS and Browser environments.

Prerequisites

npm install @iota/iota.js@1.9.0-stardust.1

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.status.isHealthy);
    console.log("\tLatest Milestone Index:", info.status.latestMilestoneIndex);
    console.log("\tConfirmed Milestone Index:", info.status.confirmedMilestoneIndex);
    console.log("\tPruning Index:", info.status.pruningIndex);
    console.log("\tNetwork Name:", info.protocol.networkName);
    console.log("\tBech32 HRP:", info.protocol.bech32HRP);
    console.log("\tMin PoW Score:", info.protocol.minPoWScore);
    console.log("\tMessages Per Second:", info.metrics.messagesPerSecond);
    console.log("\tReferenced Messages Per Second:", info.metrics.referencedMessagesPerSecond);
    console.log("\tReferenced Rate:", info.metrics.referencedRate);
    console.log("\tFeatures:", info.features);
    console.log("\tPlugins:", info.plugins);
}

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.

Models

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

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.
  • Pow - Demonstrates using one of the other PoW packages.

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, feel free to join our Discord.

2.0.0-rc.3

1 year ago

2.0.0-rc.4

1 year ago

2.0.0-rc.2

1 year ago

2.0.0-rc.1

2 years ago

1.9.0-stardust.7

2 years ago

1.9.0-stardust.8

2 years ago

1.9.0-stardust.9

2 years ago

1.9.0-stardust.5

2 years ago

1.9.0-stardust.6

2 years ago

1.9.0-stardust.2

2 years ago

1.9.0-stardust.3

2 years ago

1.9.0-stardust.4

2 years ago

1.9.0-stardust.1

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago

1.8.2

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago