# PieceCID

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:27](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L27)

## Extends

- `CID`\<`unknown`, *typeof* [`CODEC_CODE`](/reference/filoz/synapse-core/piece/variables/codec_code/), *typeof* [`MULTIHASH_CODE`](/reference/filoz/synapse-core/piece/variables/multihash_code/), `1`\>

## Properties

### \[toStringTag\]

> `readonly` **\[toStringTag\]**: `"CID"` = `"CID"`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:34

#### Inherited from

`CID.[toStringTag]`

***

### /

> `readonly` **/**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<[`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:11

#### Inherited from

`CID./`

***

### bytes

> `readonly` **bytes**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<[`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:10

#### Inherited from

`CID.bytes`

***

### code

> `readonly` **code**: `85`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:7

#### Inherited from

`CID.code`

***

### multihash

> `readonly` **multihash**: `MultihashDigest`\<`4113`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:9

#### Inherited from

`CID.multihash`

***

### version

> `readonly` **version**: `1`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:8

#### Inherited from

`CID.version`

## Accessors

### asCID

#### Get Signature

> **get** **asCID**(): `this`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:24

Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
please either use `CID.asCID(cid)` or switch to new signalling mechanism

:::caution[Deprecated]
  This API is no longer supported and may be removed in a future release.
  :::

##### Returns

`this`

#### Inherited from

`CID.asCID`

***

### byteLength

#### Get Signature

> **get** **byteLength**(): `number`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:26

##### Returns

`number`

#### Inherited from

`CID.byteLength`

***

### byteOffset

#### Get Signature

> **get** **byteOffset**(): `number`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:25

##### Returns

`number`

#### Inherited from

`CID.byteOffset`

***

### height

#### Get Signature

> **get** **height**(): `number`

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:72](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L72)

Tree height.

##### Returns

`number`

***

### paddedSize

#### Get Signature

> **get** **paddedSize**(): `bigint`

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:100](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L100)

Padded piece size in bytes (`2^height × 32`).

This is the canonical Filecoin "padded piece size" that contracts and the
Filecoin protocol use, also called the "expanded" size: the total tree
leaf count multiplied by node size. Always a power of 2 × 32.

##### Returns

`bigint`

***

### padding

#### Get Signature

> **get** **padding**(): `bigint`

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:77](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L77)

Zero-padding bytes added to the raw payload before FR32 expansion.

##### Returns

`bigint`

***

### root

#### Get Signature

> **get** **root**(): [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:67](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L67)

The 32-byte merkle root (what FOC contracts encode).

##### Returns

[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)

***

### size

#### Get Signature

> **get** **size**(): `number`

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:85](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L85)

Raw (unpadded) payload size in bytes.

##### Throws

when the size exceeds Number.MAX_SAFE_INTEGER.

##### Returns

`number`

## Methods

### equals()

> **equals**(`other`): `other is CID<unknown, 85, 4113, 1>`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:29

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `other` | `unknown` |

#### Returns

`other is CID<unknown, 85, 4113, 1>`

#### Inherited from

`CID.equals`

***

### link()

> **link**(): `this`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:33

#### Returns

`this`

#### Inherited from

`CID.link`

***

### toHex()

> **toHex**(): `` `0x${string}` ``

Defined in: [packages/synapse-core/src/piece/piece-cid.ts:105](https://github.com/FilOzone/synapse-sdk/blob/64c5042d4a5c01045e0d46e7d07508a03dc0149a/packages/synapse-core/src/piece/piece-cid.ts#L105)

The full multihash digest as a `0x...` hex string (e.g. for contract calls).

#### Returns

`` `0x${string}` ``

***

### toJSON()

> **toJSON**(): `LinkJSON`\<`PieceCID`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:32

#### Returns

`LinkJSON`\<`PieceCID`\>

#### Inherited from

`CID.toJSON`

***

### toString()

> **toString**(`base?`): `string`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:31

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `base?` | `MultibaseEncoder`\<`string`\> |

#### Returns

`string`

#### Inherited from

`CID.toString`

***

### toV0()

> **toV0**(): `CID`\<`unknown`, `112`, `18`, `0`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:27

#### Returns

`CID`\<`unknown`, `112`, `18`, `0`\>

#### Inherited from

`CID.toV0`

***

### toV1()

> **toV1**(): `CID`\<`unknown`, `85`, `4113`, `1`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:28

#### Returns

`CID`\<`unknown`, `85`, `4113`, `1`\>

#### Inherited from

`CID.toV1`

***

### asCID()

> `static` **asCID**\<`Data`, `Format`, `Alg`, `Version`, `U`\>(`input`): `CID`\<`Data`, `Format`, `Alg`, `Version`\> \| `null`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:45

Takes any input `value` and returns a `CID` instance if it was
a `CID` otherwise returns `null`. If `value` is instanceof `CID`
it will return value back. If `value` is not instance of this CID
class, but is compatible CID it will return new instance of this
`CID` class. Otherwise returns null.

This allows two different incompatible versions of CID library to
co-exist and interop as long as binary interface is compatible.

#### Type Parameters

| Type Parameter |
| ------ |
| `Data` |
| `Format` *extends* `number` |
| `Alg` *extends* `number` |
| `Version` *extends* `Version` |
| `U` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | `U` \| `Link`\<`Data`, `Format`, `Alg`, `Version`\> |

#### Returns

`CID`\<`Data`, `Format`, `Alg`, `Version`\> \| `null`

#### Inherited from

`CID.asCID`

***

### create()

> `static` **create**\<`Data`, `Format`, `Alg`, `Version`\>(`version`, `code`, `digest`): `CID`\<`Data`, `Format`, `Alg`, `Version`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:51

#### Type Parameters

| Type Parameter |
| ------ |
| `Data` |
| `Format` *extends* `number` |
| `Alg` *extends* `number` |
| `Version` *extends* `Version` |

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `version` | `Version` | Version of the CID |
| `code` | `Format` | Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv |
| `digest` | `MultihashDigest`\<`Alg`\> | (Multi)hash of the of the content. |

#### Returns

`CID`\<`Data`, `Format`, `Alg`, `Version`\>

#### Inherited from

`CID.create`

***

### createV0()

> `static` **createV0**\<`T`\>(`digest`): `CID`\<`T`, `112`, `18`, `0`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:55

Simplified version of `create` for CIDv0.

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
| `T` | `unknown` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `digest` | `MultihashDigest`\<`18`\> |

#### Returns

`CID`\<`T`, `112`, `18`, `0`\>

#### Inherited from

`CID.createV0`

***

### createV1()

> `static` **createV1**\<`Data`, `Code`, `Alg`\>(`code`, `digest`): `CID`\<`Data`, `Code`, `Alg`, `1`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:62

Simplified version of `create` for CIDv1.

#### Type Parameters

| Type Parameter |
| ------ |
| `Data` |
| `Code` *extends* `number` |
| `Alg` *extends* `number` |

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `code` | `Code` | Content encoding format code. |
| `digest` | `MultihashDigest`\<`Alg`\> | Multihash of the content. |

#### Returns

`CID`\<`Data`, `Code`, `Alg`, `1`\>

#### Inherited from

`CID.createV1`

***

### decode()

> `static` **decode**\<`Data`, `Code`, `Alg`, `Version`\>(`bytes`): `CID`\<`Data`, `Code`, `Alg`, `Version`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:70

Decoded a CID from its binary representation. The byte array must contain
only the CID with no additional bytes.

An error will be thrown if the bytes provided do not contain a valid
binary representation of a CID.

#### Type Parameters

| Type Parameter |
| ------ |
| `Data` |
| `Code` *extends* `number` |
| `Alg` *extends* `number` |
| `Version` *extends* `Version` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `bytes` | `ByteView`\<`Link`\<`Data`, `Code`, `Alg`, `Version`\>\> |

#### Returns

`CID`\<`Data`, `Code`, `Alg`, `Version`\>

#### Inherited from

`CID.decode`

***

### decodeFirst()

> `static` **decodeFirst**\<`T`, `C`, `A`, `V`\>(`bytes`): \[`CID`\<`T`, `C`, `A`, `V`\>, [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<`ArrayBufferLike`\>\]

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:80

Decoded a CID from its binary representation at the beginning of a byte
array.

Returns an array with the first element containing the CID and the second
element containing the remainder of the original byte array. The remainder
will be a zero-length byte array if the provided bytes only contained a
binary CID representation.

#### Type Parameters

| Type Parameter |
| ------ |
| `T` |
| `C` *extends* `number` |
| `A` *extends* `number` |
| `V` *extends* `Version` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `bytes` | `ByteView`\<`Link`\<`T`, `C`, `A`, `V`\>\> |

#### Returns

\[`CID`\<`T`, `C`, `A`, `V`\>, [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<`ArrayBufferLike`\>\]

#### Inherited from

`CID.decodeFirst`

***

### equals()

> `static` **equals**\<`Data`, `Format`, `Alg`, `Version`\>(`self`, `other`): `other is CID<unknown, number, number, Version>`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:30

#### Type Parameters

| Type Parameter |
| ------ |
| `Data` |
| `Format` *extends* `number` |
| `Alg` *extends* `number` |
| `Version` *extends* `Version` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `self` | `Link`\<`Data`, `Format`, `Alg`, `Version`\> |
| `other` | `unknown` |

#### Returns

`other is CID<unknown, number, number, Version>`

#### Inherited from

`CID.equals`

***

### inspectBytes()

> `static` **inspectBytes**\<`T`, `C`, `A`, `V`\>(`initialBytes`): `object`

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:90

Inspect the initial bytes of a CID to determine its properties.

Involves decoding up to 4 varints. Typically this will require only 4 to 6
bytes but for larger multicodec code values and larger multihash digest
lengths these varints can be quite large. It is recommended that at least
10 bytes be made available in the `initialBytes` argument for a complete
inspection.

#### Type Parameters

| Type Parameter |
| ------ |
| `T` |
| `C` *extends* `number` |
| `A` *extends* `number` |
| `V` *extends* `Version` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `initialBytes` | `ByteView`\<`Link`\<`T`, `C`, `A`, `V`\>\> |

#### Returns

`object`

##### codec

> **codec**: `C`

##### digestSize

> **digestSize**: `number`

##### multihashCode

> **multihashCode**: `A`

##### multihashSize

> **multihashSize**: `number`

##### size

> **size**: `number`

##### version

> **version**: `V`

#### Inherited from

`CID.inspectBytes`

***

### parse()

> `static` **parse**\<`Prefix`, `Data`, `Code`, `Alg`, `Version`\>(`source`, `base?`): `CID`\<`Data`, `Code`, `Alg`, `Version`\>

Defined in: node\_modules/.pnpm/multiformats@14.0.0/node\_modules/multiformats/dist/src/cid.d.ts:104

Takes cid in a string representation and creates an instance. If `base`
decoder is not provided will use a default from the configuration. It will
throw an error if encoding of the CID is not compatible with supplied (or
a default decoder).

#### Type Parameters

| Type Parameter |
| ------ |
| `Prefix` *extends* `string` |
| `Data` |
| `Code` *extends* `number` |
| `Alg` *extends* `number` |
| `Version` *extends* `Version` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `source` | `ToString`\<`Link`\<`Data`, `Code`, `Alg`, `Version`\>, `Prefix`\> |
| `base?` | `MultibaseDecoder`\<`Prefix`\> |

#### Returns

`CID`\<`Data`, `Code`, `Alg`, `Version`\>

#### Inherited from

`CID.parse`