# @iota/transaction-converter

> Converts transaction trytes to transaction objects and back.

Latest version **1.0.0-beta.30** (published 2020-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @iota/transaction-converter
pnpm add @iota/transaction-converter
yarn add @iota/transaction-converter
bun add @iota/transaction-converter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.30 |
| Published | 2020-06-18 |
| First published | 2018-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 119.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 949 |
| Maintainers | domschiener, laumair, lexerr, lucasfernog, martyniota, nothingismagick |
| Keywords | iota, tangle, library, browser, javascript, nodejs, API |

## Links

- npm: https://www.npmjs.com/package/@iota/transaction-converter
- Repository: https://github.com/iotaledger/iota.js.git/tree/develop/packages/crypto
- Issues: https://github.com/iotaledger/iota.js/issues
- npm.io page: https://npm.io/package/@iota/transaction-converter

## Dependencies (3)

- [@iota/pad](https://npm.io/package/@iota/pad.md) ^1.0.0-beta.30
- [@iota/converter](https://npm.io/package/@iota/converter.md) ^1.0.0-beta.30
- [@iota/transaction](https://npm.io/package/@iota/transaction.md) ^1.0.0-beta.30

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0-beta.30 (latest) — 2020-06-18
- 1.0.0-alpha.a09e7908 (canary) — 2019-02-20
- 1.0.0-beta.23 — 2019-11-27
- 1.0.0-beta.21 — 2019-08-05
- 1.0.0-beta.19 — 2019-07-19
- 1.0.0-beta.16 — 2019-06-20
- 1.0.0-beta.15 — 2019-06-14
- 1.0.0-beta.12 — 2019-04-09
- 1.0.0-beta.11 — 2019-02-22
- 1.0.0-beta.10 — 2019-02-21
- 1.0.0-beta.9 — 2019-02-21
- 1.0.0-alpha.66ccc99f — 2019-02-19
- 1.0.0-alpha.e5bd9497 — 2019-02-19
- 1.0.0-alpha.912642aa — 2019-02-18
- 1.0.0-alpha.899a376d — 2019-02-17
- … 25 more at https://npm.io/package/@iota/transaction-converter/versions

## README

# @iota/transaction-converter

Methods for calculating transaction hashes and converting transaction objects to transaction trytes and back.

## Installation

Install using [npm](https://www.npmjs.org/):
```
npm install @iota/transaction-converter
```

or using [yarn](https://yarnpkg.com/):

```
yarn add @iota/transaction-converter
```

## API Reference

    
* [transaction-converter](#module_transaction-converter)

    * _static_
        * [.asTransactionTrytes(transactions)](#module_transaction-converter.asTransactionTrytes)

        * [.asTransactionObject(transaction)](#module_transaction-converter.asTransactionObject)

        * [.asTransactionObjects([hashes])](#module_transaction-converter.asTransactionObjects)

    * _inner_
        * [~transactionObjectsMapper(trytes)](#module_transaction-converter..transactionObjectsMapper)


<a name="module_transaction-converter.asTransactionTrytes"></a>

### *transaction-converter*.asTransactionTrytes(transactions)
**Summary**: Converts one or more transaction objects into transaction trytes.  
**Throws**:

- <code>errors.INVALID\_TRYTES</code> : Make sure that the object fields in the `transactions` argument contains valid trytes (A-Z or 9).


| Param | Type | Description |
| --- | --- | --- |
| transactions | <code>Transaction</code> \| <code>Array.&lt;Transaction&gt;</code> | Transaction objects |

This method takes one or more transaction objects and converts them into trytes.

## Related methods

To get JSON data from the `signatureMessageFragment` field of the transaction trytes, use the [`extractJSON()`](#module_extract-json.extractJSON) method.

**Returns**: <code>Trytes</code> \| <code>Array.&lt;Trytes&gt;</code> - Transaction trytes  
**Example**  
```js
let trytes = TransactionConverter.asTransactionTrytes(transactionObject);
```
<a name="module_transaction-converter.asTransactionObject"></a>

### *transaction-converter*.asTransactionObject(transaction)
**Summary**: Converts transaction trytes into a transaction object.  
**Throws**:

- <code>errors.INVALID\_TRYTES</code> : Make sure that the object fields in the `transaction` argument contains valid trytes (A-Z or 9).


| Param | Type | Description |
| --- | --- | --- |
| transaction | <code>Trytes</code> | Transaction trytes |

This method takes 2,673 transaction trytes and converts them into a transaction object.

## Related methods

To convert more than one transaction into an object at once, use the [`asTransactionObjects()`](#module_transaction-converter.asTransactionObjects) method.

To get a transaction's trytes from the Tangle, use the [`getTrytes()`](#module_core.getTrytes) method.

**Returns**: <code>Transaction</code> - transactionObject - A transaction object  
**Example**  
```js
let transactionObject = TransactionConverter.asTransactionObject(transactionTrytes);
```
<a name="module_transaction-converter.asTransactionObjects"></a>

### *transaction-converter*.asTransactionObjects([hashes])
**Summary**: Converts one or more transaction trytes into transaction objects.  
**Throws**:

- <code>errors.INVALID\_TRYTES</code> : Make sure that transcactions contains valid trytes (A-Z or 9).


| Param | Type | Description |
| --- | --- | --- |
| [hashes] | <code>Array.&lt;Hash&gt;</code> | Transaction hashes |

This method takes an array of transaction hashes and returns a mapper.

If any hashes are given, the mapper function maps them to their converted objects. Otherwise, all hashes are recalculated.

## Related methods

To get a transaction's trytes from the Tangle, use the [`getTrytes()`](#module_core.getTrytes) method.

**Returns**: <code>function</code> - [`transactionObjectsMapper()`](#module_transaction.transactionObjectsMapper)  
**Example**  
```js
let transactionObjectsMapper = TransactionConverter.asTransactionObjects([hashes]);
```
<a name="module_transaction-converter..transactionObjectsMapper"></a>

### *transaction-converter*~transactionObjectsMapper(trytes)

| Param | Type | Description |
| --- | --- | --- |
| trytes | <code>Array.&lt;Trytes&gt;</code> | List of transaction trytes to convert |

Maps the list of given hashes to a list of converted transaction objects.

**Returns**: <code>Array.&lt;Transaction&gt;</code> - List of transaction objects with hashes

---
_Source: https://npm.io/package/@iota/transaction-converter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
