For the complete documentation index, see llms.txt. This page is also available as Markdown.

Utils

Helper functions exported by the @4thtech-sdk/utils package.

Status: Maintenance mode. The 4thTech SDK and the BlockMail & BlockChat white-label apps are supported for existing users; no new features are planned. Last release: SDK 0.5.13 (25 Nov 2025).

Reference for SDK 0.5.x (maintenance mode). See Status.

Utility functions and helpers used by the other SDK packages. Version 0.0.2.

Installation

npm install @4thtech-sdk/utils

Usage

import { stringToArrayBuffer, arrayBufferToString } from '@4thtech-sdk/utils';

const buffer = stringToArrayBuffer('hello');
const text = arrayBufferToString(buffer);

Exports

The package index exports the buffer helpers, the Node crypto helpers and the error class.

Buffer helpers

Function
What it does

stringToArrayBuffer(str)

Converts a string to an ArrayBuffer

arrayBufferToString(buffer)

Converts an ArrayBuffer to a string

hexStringToArrayBuffer(hex)

Converts a hex string to an ArrayBuffer

arrayBufferToHexString(buffer)

Converts an ArrayBuffer to a hex string

concatenateArrayBuffers(...buffers)

Joins several ArrayBuffers into one

Crypto helpers

Function
What it does

calculateChecksum(data)

Returns the SHA-256 checksum of an ArrayBuffer as a hex string

calculateChecksumFromStream(filePath)

Returns the SHA-256 checksum of a file, read as a stream (Node)

createSha256Hash(data)

Returns the SHA-256 hash of a string

getRandomValues(typedArray)

Fills a Uint8Array with random values

subtle

The Web Crypto SubtleCrypto object

Errors

ContractRevertedError is thrown by the clients in @4thtech-sdk/ethereum when a contract call reverts.

See also

Last updated