Utilities

Overview

Utility components for Zafeguard workflows — random values, EVM constants, and hash functions.

Overview

Lightweight, zero-dependency utility components for generating random values, computing hashes, and providing common constants.


RANDOM_UUID

RANDOM_UUID Utility Workflow Component

Generate a cryptographically random UUID v4.

Config

None.

Inputs

None.

Outputs

FieldTypeDescription
uuidstringUUID v4 string (e.g. "a4c2e8f1-39b0-4d7a-83c6-1b5f2e9d0c77")

SDK example

import { WorkspaceClient, ComponentModule } from '@zafeguard/caller-sdk';
const workspace = new WorkspaceClient({ apiKey: process.env.ZAFEGUARD_API_KEY! });

const result = await workspace.call(ComponentModule.RANDOM_UUID, {}).promise();
console.log(result.uuid); // "a4c2e8f1-39b0-4d7a-83c6-1b5f2e9d0c77"

REST (with waitForMs for inline result):

curl -X POST https://api.zafeguard.com/v1/sdk/components \
  -H "X-Api-Key: ws_..." \
  -H "X-Sdk-Timestamp: <timestamp>" \
  -H "X-Sdk-Signature: <signature>" \
  -H "Content-Type: application/json" \
  -d '{ "module": "RANDOM_UUID", "input": {}, "config": {}, "waitForMs": 5000 }'

Without waitForMs, the response returns status: "CREATED" immediately — the component runs asynchronously. See Authentication → for the required signing headers.


RANDOM_HEX

RANDOM_HEX Utility Workflow Component

Generate a cryptographically random hex string. Useful as a nonce, salt, or random seed.

Config

FieldTypeDefaultDescription
lengthnumber6Number of hex characters to generate (output length, excluding 0x prefix)

Inputs

None.

Outputs

FieldTypeDescription
hexstringRandom hex string (e.g. "a3f9c2" — without 0x prefix)

SDK example

const result = await workspace.call(ComponentModule.RANDOM_HEX, {}).promise();
console.log(result.hex); // "7f3a9c"

RANDOM_NUMBER

RANDOM_NUMBER Utility Workflow Component

Generate a cryptographically random integer.

Config

FieldTypeDefaultDescription
lengthnumber6Number of digits in the generated number (e.g. 6 → a 6-digit number between 100000 and 999999)

Inputs

None.

Outputs

FieldTypeDescription
numbernumberRandom integer of the configured digit length

SDK example

const result = await workspace.call(ComponentModule.RANDOM_NUMBER, {}).promise();
console.log(result.number); // 1847392615

ERC20_ABI_CONSTANT

ERC20_ABI_CONSTANT Utility Workflow Component

Returns the standard ERC-20 ABI as a constant. Eliminates the need to hardcode it in every workflow that interacts with ERC-20 tokens.

Config

None.

Inputs

None.

Outputs

FieldTypeDescription
abiAbiItem[]Standard ERC-20 ABI (transfer, approve, balanceOf, allowance, transferFrom, totalSupply, events)

Common pattern

ERC20_ABI_CONSTANT
        │ abi

BUILD_EVM_CALLDATA (function: "transfer", args: [to, amount])
        │ calldata

BUILD_EVM_TRANSACTION

EVM_ZERO_ADDRESS_CONSTANT

EVM_ZERO_ADDRESS_CONSTANT Utility Workflow Component

Returns the EVM zero address (0x0000000000000000000000000000000000000000). Used as the tokenAddress for native ETH balance checks, or as the null address in ABI encoding.

Config

None.

Inputs

None.

Outputs

FieldTypeDescription
addressstring"0x0000000000000000000000000000000000000000"

Common pattern

EVM_ZERO_ADDRESS_CONSTANT
        │ address
        ▼ tokenAddress
GET_EVM_ACCOUNT_BALANCE  (checks native ETH balance)

OBJECT_BUILDER

OBJECT_BUILDER Utility Workflow

Composes an object from dynamic input ports. Every connected input becomes a property of the output object, named after the input port. Useful for shaping data to pass into the next component or to return from a workflow.

Inputs

Dynamic — connect any number of upstream outputs to named input ports.

Outputs

FieldTypeDescription
valueobjectComposed object — { <inputPortName>: <upstreamValue>, ... }

JSON_FORMATTER

JSON_FORMATTER Utility Workflow

Returns a configured JSON template, with {{variable}} placeholders substituted from the dynamic inputs. Use it as a constant emitter for structured payloads (API request bodies, on-chain calldata templates) where some fields come from upstream components.

Config

FieldTypeDescription
valueJSONThe template — any valid JSON value. Strings inside the template may contain {{key}} placeholders

Inputs

Dynamic — each connected input port supplies a value for one {{key}} placeholder in the template.

Outputs

FieldTypeDescription
valueJSONThe template with all placeholders substituted

Example

config.value: { "to": "{{recipient}}", "amount": "{{amount}}" }
inputs: { recipient: "0xabc...", amount: "1000000" }
output.value: { "to": "0xabc...", "amount": "1000000" }

On this page