> For the complete documentation index, see [llms.txt](https://docs.twine.world/twine-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.twine.world/twine-js/twine-protocol/twine-core/classes/twine.md).

# Twine

[**@twine-protocol/twine-core v0.1.0**](/twine-js/twine-protocol/twine-core/index.md) • **Docs**

***

[twine-js](/twine-js/index.md) / [@twine-protocol/twine-core](/twine-js/twine-protocol/twine-core/index.md) / Twine

## Class: Twine\<T>

Generic class for twine data

### Extends

* `Block`<`T`, `number`, `number`, `Version`>

### Extended by

* [`ChainResolver`](/twine-js/twine-protocol/twine-core/classes/chainresolver.md)

### Type Parameters

| Type Parameter                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `T` *extends* [`ChainValue`](/twine-js/twine-protocol/twine-core/type-aliases/chainvalue.md) \| [`PulseValue`](/twine-js/twine-protocol/twine-core/type-aliases/pulsevalue.md) |

### Constructors

#### new Twine()

> **new Twine**<`T`>(`__namedParameters`): [`Twine`](/twine-js/twine-protocol/twine-core/classes/twine.md)<`T`>

Create a new twine instance

This class extends the Block class from multiformats/block. So anything that reads or writes blocks can be used with this class. A twine can be created from a multi-format block too.

But generally you'll want to use the [fromBytes](/twine-js/twine-protocol/twine-core/functions/frombytes.md) or [fromJSON](/twine-js/twine-protocol/twine-core/functions/fromjson.md) functions to decode a twine instance. Or use the [twine-builder](https://github.com/twine-protocol/twine-js/tree/master/packages/twine-builder) package to create a twine instance.

**Parameters**

| Parameter                 | Type                                                                                                  |
| ------------------------- | ----------------------------------------------------------------------------------------------------- |
| `__namedParameters`       | `object`                                                                                              |
| `__namedParameters.cid`   | [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`> |
| `__namedParameters.bytes` | `Uint8Array`                                                                                          |
| `__namedParameters.value` | `T`                                                                                                   |

**Returns**

[`Twine`](/twine-js/twine-protocol/twine-core/classes/twine.md)<`T`>

**Overrides**

`Block.Block<T, number, number, Version>.constructor`

**Defined in**

[packages/twine-core/src/twine.ts:47](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L47)

### Properties

| Property          | Modifier   | Type                                                                                                  | Default value | Description                                          | Inherited from        | Defined in                                                                                                                                                           |
| ----------------- | ---------- | ----------------------------------------------------------------------------------------------------- | ------------- | ---------------------------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `isTwineInstance` | `public`   | `boolean`                                                                                             | `true`        | is a twine instance (true)                           | -                     | [packages/twine-core/src/twine.ts:24](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L24) |
| `isChain`         | `public`   | `boolean`                                                                                             | `undefined`   | is this a chain                                      | -                     | [packages/twine-core/src/twine.ts:26](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L26) |
| `chainCid`        | `public`   | [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`> | `undefined`   | chain CID (either this CID or the pulse's chain CID) | -                     | [packages/twine-core/src/twine.ts:28](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L28) |
| `cid`             | `readonly` | [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`T`, `number`, `number`, `Version`>       | `undefined`   | -                                                    | `Block.Block.cid`     | node\_modules/multiformats/dist/src/block.d.ts:10                                                                                                                    |
| `bytes`           | `readonly` | `ByteView`<`T`>                                                                                       | `undefined`   | -                                                    | `Block.Block.bytes`   | node\_modules/multiformats/dist/src/block.d.ts:11                                                                                                                    |
| `value`           | `readonly` | `T`                                                                                                   | `undefined`   | -                                                    | `Block.Block.value`   | node\_modules/multiformats/dist/src/block.d.ts:12                                                                                                                    |
| `asBlock`         | `readonly` | [`Twine`](/twine-js/twine-protocol/twine-core/classes/twine.md)<`T`>                                  | `undefined`   | -                                                    | `Block.Block.asBlock` | node\_modules/multiformats/dist/src/block.d.ts:13                                                                                                                    |

### Accessors

#### isPulse

**Get Signature**

> **get** **isPulse**(): `boolean`

Is this a pulse

**Returns**

`boolean`

**Defined in**

[packages/twine-core/src/twine.ts:82](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L82)

### Methods

#### isTwine()

> `static` **isTwine**(`thing`): thing is Chain | Pulse

Check if a value is a twine

**Parameters**

| Parameter | Type  |
| --------- | ----- |
| `thing`   | `any` |

**Returns**

thing is Chain | Pulse

**Defined in**

[packages/twine-core/src/twine.ts:31](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L31)

***

#### toJSON()

> **toJSON**(): `any`

Get the twine data as a DAG-JSON object

**Returns**

`any`

**Defined in**

[packages/twine-core/src/twine.ts:89](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L89)

***

#### getContentDigest()

> **getContentDigest**(): `Promise`<`MultihashDigest`<`number`>>

Get the twine content field hash digest

**Returns**

`Promise`<`MultihashDigest`<`number`>>

**Defined in**

[packages/twine-core/src/twine.ts:101](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L101)

***

#### verifySignature()

> **verifySignature**(`chain`?): `Promise`<`boolean`>

Verify the signature of this twine instance

If this is a chain, no chain instance is required. If this is a pulse, a chain instance must be provided.

**Parameters**

| Parameter | Type                                                                                                                                         | Description                            |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| `chain`?  | [`Chain`](/twine-js/twine-protocol/twine-core/type-aliases/chain.md)<[`AnyMap`](/twine-js/twine-protocol/twine-core/type-aliases/anymap.md)> | Chain instance to use for verification |

**Returns**

`Promise`<`boolean`>

**Defined in**

[packages/twine-core/src/twine.ts:113](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/twine.ts#L113)

***

#### links()

> **links**(): `Iterable`<\[`string`, [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`>], `any`, `any`>

**Returns**

`Iterable`<\[`string`, [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`>], `any`, `any`>

**Inherited from**

`Block.Block.links`

**Defined in**

node\_modules/multiformats/dist/src/block.d.ts:19

***

#### tree()

> **tree**(): `Iterable`<`string`, `any`, `any`>

**Returns**

`Iterable`<`string`, `any`, `any`>

**Inherited from**

`Block.Block.tree`

**Defined in**

node\_modules/multiformats/dist/src/block.d.ts:20

***

#### get()

> **get**(`path`?): `BlockCursorView`<`unknown`>

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `path`?   | `string` |

**Returns**

`BlockCursorView`<`unknown`>

**Inherited from**

`Block.Block.get`

**Defined in**

node\_modules/multiformats/dist/src/block.d.ts:21
