Skip to content

PieceCID

Defined in: packages/synapse-core/src/piece/piece-cid.ts:27

readonly [toStringTag]: "CID" = "CID"

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:34

CID.[toStringTag]


/

readonly /: Uint8Array<ArrayBuffer>

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:11

CID./


readonly bytes: Uint8Array<ArrayBuffer>

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:10

CID.bytes


readonly code: 85

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:7

CID.code


readonly multihash: MultihashDigest<4113>

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:9

CID.multihash


readonly version: 1

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:8

CID.version

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

this

CID.asCID


get byteLength(): number

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:26

number

CID.byteLength


get byteOffset(): number

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:25

number

CID.byteOffset


get height(): number

Defined in: packages/synapse-core/src/piece/piece-cid.ts:72

Tree height.

number


get paddedSize(): bigint

Defined in: packages/synapse-core/src/piece/piece-cid.ts:100

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.

bigint


get padding(): bigint

Defined in: packages/synapse-core/src/piece/piece-cid.ts:77

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

bigint


get root(): Uint8Array

Defined in: packages/synapse-core/src/piece/piece-cid.ts:67

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

Uint8Array


get size(): number

Defined in: packages/synapse-core/src/piece/piece-cid.ts:85

Raw (unpadded) payload size in bytes.

when the size exceeds Number.MAX_SAFE_INTEGER.

number

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

ParameterType
otherunknown

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

CID.equals


link(): this

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:33

this

CID.link


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

Defined in: packages/synapse-core/src/piece/piece-cid.ts:105

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

`0x${string}`


toJSON(): LinkJSON<PieceCID>

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:32

LinkJSON<PieceCID>

CID.toJSON


toString(base?): string

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:31

ParameterType
base?MultibaseEncoder<string>

string

CID.toString


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

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:27

CID<unknown, 112, 18, 0>

CID.toV0


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

Defined in: node_modules/.pnpm/multiformats@14.0.0/node_modules/multiformats/dist/src/cid.d.ts:28

CID<unknown, 85, 4113, 1>

CID.toV1


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 Parameter
Data
Format extends number
Alg extends number
Version extends Version
U
ParameterType
inputU | Link<Data, Format, Alg, Version>

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

CID.asCID


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 Parameter
Data
Format extends number
Alg extends number
Version extends Version
ParameterTypeDescription
versionVersionVersion of the CID
codeFormatCode of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
digestMultihashDigest<Alg>(Multi)hash of the of the content.

CID<Data, Format, Alg, Version>

CID.create


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 ParameterDefault type
Tunknown
ParameterType
digestMultihashDigest<18>

CID<T, 112, 18, 0>

CID.createV0


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 Parameter
Data
Code extends number
Alg extends number
ParameterTypeDescription
codeCodeContent encoding format code.
digestMultihashDigest<Alg>Multihash of the content.

CID<Data, Code, Alg, 1>

CID.createV1


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 Parameter
Data
Code extends number
Alg extends number
Version extends Version
ParameterType
bytesByteView<Link<Data, Code, Alg, Version>>

CID<Data, Code, Alg, Version>

CID.decode


static decodeFirst<T, C, A, V>(bytes): [CID<T, C, A, V>, 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 Parameter
T
C extends number
A extends number
V extends Version
ParameterType
bytesByteView<Link<T, C, A, V>>

[CID<T, C, A, V>, Uint8Array<ArrayBufferLike>]

CID.decodeFirst


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 Parameter
Data
Format extends number
Alg extends number
Version extends Version
ParameterType
selfLink<Data, Format, Alg, Version>
otherunknown

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

CID.equals


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 Parameter
T
C extends number
A extends number
V extends Version
ParameterType
initialBytesByteView<Link<T, C, A, V>>

object

codec: C

digestSize: number

multihashCode: A

multihashSize: number

size: number

version: V

CID.inspectBytes


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 Parameter
Prefix extends string
Data
Code extends number
Alg extends number
Version extends Version
ParameterType
sourceToString<Link<Data, Code, Alg, Version>, Prefix>
base?MultibaseDecoder<Prefix>

CID<Data, Code, Alg, Version>

CID.parse