Utilities
The@kynesyslabs/demosdk/utils subpath exposes small pure-function helpers used across the SDK. They are all framework-free and safe to import in browser or Node code.
Sleep
sleep(ms) returns a Promise<void> that resolves after the given number of milliseconds.
Address validation
validateEd25519Address(address) returns true when address matches /^0x[0-9a-f]{64}$/i — a 0x prefix followed by exactly 64 hex characters (case-insensitive). Use it to fail fast on malformed input before constructing transactions.
Uint8Array ↔ Base64
serializeUint8Array(u8) returns a Base64 string. deserializeUint8Array(base64) returns the original Uint8Array. Useful when carrying binary payloads through JSON (e.g. wire formats that require string fields).
Data manipulation
ThedataManipulation namespace bundles object-to-hex and forge-buffer helpers used by the wire serializers:
| Helper | Purpose |
|---|---|
ObjectToHex(obj) | JSON-stringify and hex-encode an object. Async (returns Promise<string>). |
HexToObject(hex) | Inverse of ObjectToHex. Async. |
ForgeToHex(buf) | Convert a node-forge buffer to 0x-prefixed hex. |
HexToForge(hex) | Convert a 64-byte hex string to a Uint8Array(64) accepted by node-forge. |
copyCreate(obj) | Deep-clone via JSON.parse(JSON.stringify(...)). Loses functions / dates / undefined; intended for plain payloads. |
Prefer the WebSDK-level helpers (
Demos.signMessage, denomination.demToOs, etc.) for everyday use. Reach for utils only when you need raw byte/hex manipulation that the higher-level surface doesn’t cover.