Set of methods that allows data encoding/decoding as standalone BCS value or a part of a composed structure/vector.

Constructors

Methods

  • Adds support for iterations over the object.

    Returns Iterator<number, Iterable<number, any, any>, any>

  • Shift current cursor position by bytes.

    Parameters

    • bytes: number

      Number of bytes to

    Returns this

    Self for possible chaining.

  • Get underlying buffer taking only value bytes (in case initial buffer size was bigger).

    Returns Uint8Array

    Resulting bcs.

  • Represent data as 'hex' or 'base64'

    Parameters

    • encoding: Encoding

      Encoding to use: 'base64' or 'hex'

    Returns string

  • Write a U128 value into a buffer and shift cursor position by 16.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a U16 value into a buffer and shift cursor position by 2.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a U256 value into a buffer and shift cursor position by 16.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a U32 value into a buffer and shift cursor position by 4.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a U64 value into a buffer and shift cursor position by 8.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a U8 value into a buffer and shift cursor position by 1.

    Parameters

    • value: number | bigint

      Value to write.

    Returns this

  • Write a ULEB value into a buffer and shift cursor position by number of bytes written.

    Parameters

    • value: number

      Value to write.

    Returns this

  • Write a vector into a buffer by first writing the vector length and then calling a callback on each passed value.

    Parameters

    • vector: any[]

      Array of elements to write.

    • cb: ((writer: BcsWriter, el: any, i: number, len: number) => void)

      Callback to call on each element of the vector.

        • (writer, el, i, len): void
        • Parameters

          Returns void

    Returns this