Polkadot JS APIGlobals"primitive/Bytes"Bytes

# Class: Bytes

name Bytes

description A Bytes wrapper for Vec. The significant difference between this and a normal Uint8Array is that this version allows for length-encoding. (i.e. it is a variable-item codec, the same as what is found in Text and Vec)

# Hierarchy

Raw

Bytes

StorageKey

# Implements

# Indexable

  • [ index: number]: number

name Bytes

description A Bytes wrapper for Vec. The significant difference between this and a normal Uint8Array is that this version allows for length-encoding. (i.e. it is a variable-item codec, the same as what is found in Text and Vec)

# Index

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

+ new Bytes(registry: Registry, value?: AnyU8a): Bytes

Overrides Raw.constructor

Defined in packages/types/src/primitive/Bytes.ts:47

Parameters:

Name Type
registry Registry
value? AnyU8a

Returns: Bytes

# Properties

# Readonly registry

registry: Registry

Implementation of IU8a.registry

Inherited from Raw.registry

Defined in packages/types/src/codec/Raw.ts:30

# Accessors

# encodedLength

get encodedLength(): number

Overrides Raw.encodedLength

Defined in packages/types/src/primitive/Bytes.ts:55

description The length of the value when encoded as a Uint8Array

Returns: number


# hash

get hash(): H256

Inherited from Raw.hash

Defined in packages/types/src/codec/Raw.ts:48

description returns a hash of the contents

Returns: H256


# isEmpty

get isEmpty(): boolean

Inherited from Raw.isEmpty

Defined in packages/types/src/codec/Raw.ts:55

description Returns true if the type wraps an empty/default all-0 value

Returns: boolean


# length

get length(): number

Inherited from Raw.length

Overrides IU8a.length

Defined in packages/types/src/codec/Raw.ts:62

description The length of the value

Returns: number

# Methods

# bitLength

bitLength(): number

Implementation of IU8a

Inherited from Raw.bitLength

Defined in packages/types/src/codec/Raw.ts:70

description Returns the number of bits in the value

Returns: number


# eq

eq(other?: unknown): boolean

Implementation of IU8a

Inherited from Raw.eq

Defined in packages/types/src/codec/Raw.ts:77

description Compares the value of the input to see if there is a match

Parameters:

Name Type
other? unknown

Returns: boolean


# subarray

subarray(begin: number, end?: undefined | number): Uint8Array

Inherited from Raw.subarray

Overrides IU8a.subarray

Defined in packages/types/src/codec/Raw.ts:91

description Create a new subarray from the actual buffer. This is needed for compat reasons since a new Uint8Array gets returned here

Parameters:

Name Type Description
begin number The position to start at
end? undefined | number The position to end at

Returns: Uint8Array


# toHex

toHex(): string

Inherited from Raw.toHex

Defined in packages/types/src/codec/Raw.ts:98

description Returns a hex string representation of the value

Returns: string


# toHuman

toHuman(): AnyJson

Inherited from Raw.toHuman

Defined in packages/types/src/codec/Raw.ts:105

description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information

Returns: AnyJson


# toJSON

toJSON(): string

Implementation of IU8a

Inherited from Raw.toJSON

Defined in packages/types/src/codec/Raw.ts:112

description Converts the Object to JSON, typically used for RPC transfers

Returns: string


# toRawType

toRawType(): string

Implementation of IU8a

Overrides Raw.toRawType

Defined in packages/types/src/primitive/Bytes.ts:62

description Returns the base runtime type name for this instance

Returns: string


# toString

toString(): string

Implementation of IU8a

Inherited from Raw.toString

Overrides IU8a.toString

Defined in packages/types/src/codec/Raw.ts:126

description Returns the string representation of the value

Returns: string


# toU8a

toU8a(isBare?: undefined | false | true): Uint8Array

Overrides Raw.toU8a

Defined in packages/types/src/primitive/Bytes.ts:70

description Encodes the value as a Uint8Array as per the SCALE specifications

Parameters:

Name Type Description
isBare? undefined | false | true true when the value has none of the type-specific prefixes (internal)

Returns: Uint8Array