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/bundle

v1.0.0-beta.30

Published

Utilities for generating and signing bundles

Downloads

1,468

Readme

@iota/bundle

Utilities for generating and signing bundles. A bundle in IOTA is an atomic set of transactions.

Installation

Install using npm:

npm install @iota/bundle

or using yarn:

yarn add @iota/bundle

API Reference

bundle.addEntry(entry, bundle)

Summary: Adds the given transaction entry to a bundle array.
Throws:

  • errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH : Make sure that the bundle argument contains valid transaction trits
  • errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH : Make sure that the entry.signatureOrMessage argument contains 6,561 trits
  • errors.ILLEGAL_ADDRESS_LENGTH : Make sure that the entry.address argument contains 243 trits
  • errors.ILLEGAL_VALUE_LENGTH : Make sure that the entry.value argument contains 6,561 trits
  • errors.ILLEGAL_ISSUANCE_TIMESTAMP_LENGTH : Make sure that the entry.timestamp argument contains 81 trits

| Param | Type | Description | | --- | --- | --- | | entry | object | Transaction entry object | | entry.address | Int8Array | An address in trits | | entry.value | Int8Array | An amount of IOTA tokens in trits | | [entry.signatureOrMessage] | Int8Array | Signature fragments or a message in trits | | [entry.issuanceTimestamp] | Int8Array | Unix epoch in trits | | [entry.tag] | Int8Array | (deprecated) | | bundle | Int8Array | Bundle array to which to add the entry object |

Adds transaction trits in the given entry object to a given bundle array.

Related methods

See the converter package for methods that convert values to trits.

Returns: Int8Array - A copy of the original bundle that also includes the added entries.
Example

let bundle = new Int8Array();

bundle = Bundle.addEntry(bundle, {
 address: Converter.trytesToTrits(outputAddress),
 value: Converter.valueToTrits(value),
 issuanceTimestamp: Converter.valueToTrits(Math.floor(Date.now() / 1000));
});

bundle.finalizeBundle(bundle)

Summary: Generates a bundle hash.
Throws:

  • errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH : Make sure that the bundle argument contains valid transaction trits

| Param | Type | Description | | --- | --- | --- | | bundle | Int8Array | Transaction trits |

This method takes an array of transaction trits, generates the bundle hash, and adds it to each transaction.

Related methods

See the addEntry() method for creating new bundles.

Returns: Int8Array - Transaction trits that include a bundle hash
Example

const result = Bundle.finalizeBundle(bundle);

bundle.addSignatureOrMessage(bundle, signatureOrMessage, index)

Summary: Adds signature message fragments to transactions in a bundle.
Throws:

  • errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH : Make sure that the bundle argument contains valid transaction trits
  • errors.ILLEGAL_TRANSACTION_INDEX : Make sure that the index argument is a number and that the bundle contains enough transactions
  • errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH : Make sure that the signatureOrMessage argument contains at least 6,561 trits

| Param | Type | Description | | --- | --- | --- | | bundle | Int8Array | Transaction trits | | signatureOrMessage | Int8Array | Signature or message to add to the bundle | | index | number | Transaction index at which to start adding the signature or message |

This method takes an array of transaction trits, and add the given message or signature to the transactions, starting from the given index.

If the signature or message is too long to fit in a single transaction, it is split across the next transaction in the bundle, starting from the given index.

Related methods

See the addEntry() method for creating new bundles.

Returns: Int8Array - Transaction trits that include a bundle hash.
Example

const signature = Converter.trytesToTrits('SIGNATURE...')
bundle.set(Bundle.addSignatureOrMessage(bundle, signature, 1));

bundle~createBundle([entries])

Summary: Creates a bundle array from the given transaction entries.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [entries] | Array.<BundleEntry> | [] | Entries of single or multiple transactions with the same address |

Returns: Array.<Int8Array> - List of transactions in the bundle