@thru/helpers is the root entrypoint for the package. It exports the small set of encoding and runtime helpers that most app integrations need.
Install
Import
When to use it
Use@thru/helpers when you need low-level encoding and runtime helpers without pulling in wallet, RPC, or React abstractions.
Use @thru/crypto when you need mnemonic generation or HD wallet derivation on top of these helpers.
Export groups
| Group | Exports | Use it for |
|---|---|---|
| Address encoding | encodeAddress, decodeAddress | Converting between raw 32-byte account data and ta... addresses. |
| Signature encoding | encodeSignature, decodeSignature | Converting between raw 64-byte signatures and ts... strings. |
| Byte handling | decodeBase64, hexToBytes, isHexString, ensureBytes | Normalizing binary inputs from app code or API payloads. |
| Runtime support | getWebCrypto | Accessing Web Crypto in browser-facing code. |
Address helpers
UseencodeAddress and decodeAddress when you need to move between raw 32-byte account data and the Thru address format.
encodeAddress(bytes) expects a 32-byte Uint8Array and returns a ta... address string. decodeAddress(value) accepts a ta... address string and returns the original 32-byte value after validating the checksum.
Signature helpers
UseencodeSignature and decodeSignature when you need to convert between raw 64-byte signatures and the Thru signature format.
encodeSignature(bytes) expects a 64-byte Uint8Array and returns a ts... signature string. decodeSignature(value) accepts a ts... signature string and returns the original 64-byte signature after validating the checksum.
Byte helpers
decodeBase64(value) converts a base64 string to bytes and requires globalThis.atob to be available.
hexToBytes(value) accepts hex strings with or without a 0x prefix. isHexString(value) checks whether a string is a non-empty even-length hex string.
ensureBytes(value, field) is the strict input normalizer: it accepts either a non-empty Uint8Array or a non-empty base64 string and throws a field-specific error if the value is missing or empty.
Web Crypto
getWebCrypto() returns globalThis.crypto when the Web Crypto API is available and throws if the runtime does not provide it. Use it in browser-facing code that needs getRandomValues without pulling in a separate polyfill path.