HCS-12 Validation & Schemas
The Standards SDK exposes runtime validation for HashLinks components and messages, plus a WASM validator to enforce the module interface contract.
Zod Schemas & HelpersDirect link to Zod Schemas & Helpers
- TypeScript
- Go
import {
validateActionRegistration,
validateBlockRegistration,
validateAssemblyMessage,
validateAssemblyRegistration,
validateHashLinksRegistration,
actionRegistrationSchema,
safeValidate,
validateWithSchema,
} from '@hashgraphonline/standards-sdk';
// Validate a block definition before registering
try {
validateBlockRegistration(blockDefinition);
} catch (error) {
console.error(error);
}
// Safer variant that never throws
const ok = safeValidate(actionRegistrationSchema, actionReg);
// Go SDK implementation available
validateActionRegistration– ensures action registration (WASM mapping + metadata) is well-formedvalidateBlockRegistration– validates block definition (attributes, actions, template link)validateAssemblyMessage– validates assembly ops/messagesvalidateAssemblyRegistration– validates assembly composition payloadsvalidateHashLinksRegistration– high-level registry entry validationsafeValidate– wraps a validation call and returns a consistent result shapevalidateWithSchema– pass a custom Zod schema to validate arbitrary data
WASM Module ContractDirect link to WASM Module Contract
HashLinks requires WASM modules to expose a minimal interface so SDKs can interact with them consistently:
INFO()→ string (JSON) describing module metadata: name, version, declared actions and typesPOST(...)→ state-changing entrypoint for operationsGET(...)→ read-only entrypoint for queries
- TypeScript
- Go
import { Logger, WasmValidator } from '@hashgraphonline/standards-sdk';
const logger = new Logger({ module: 'WasmValidation' });
const validator = new WasmValidator(logger);
const result = await validator.validate(wasmBuffer);
if (!result.isValid) {
console.error(result.errors);
}
console.log(result.exports); // e.g., ['INFO', 'POST', 'GET']
console.log(result.exportSignatures); // parsed function signatures if available
// Go SDK implementation available
The validator inspects exports/imports, basic signatures, and can report missing functions (INFO, POST, GET). It does not execute untrusted code: it parses the module structure to verify the contract.
Recommended FlowDirect link to Recommended Flow
- Build your WASM module and run
WasmValidator.validate()locally. - Validate registrations (
validate*) before broadcasting to HCS. - In CI: fail fast on invalid blocks/actions/assemblies.
- At runtime: use
safeValidatefor graceful error handling.
Common ErrorsDirect link to Common Errors
- Missing
INFO/POST/GETexport → add required functions to the module. - Invalid attribute types in a block → ensure types align with UI/renderer expectations.
- Assembly references unresolved → register actions/blocks first, then bind in assemblies.