Metadata Reactor Capabilities
This browser-only demo showcases MetadataReactor capabilities using a local
IDL service definition, so it can run without a live canister.
Features Demonstrated
Section titled “Features Demonstrated”- Generate runtime input metadata with
getInputMeta()andgetAllInputMeta() - Generate runtime output metadata with
getOutputMeta()andgetAllOutputMeta() - Build dynamic variable references with
buildMethodVariableCandidates() - Hydrate form values from hex-encoded Candid args with
buildForMethod() - Resolve rich method outputs with metadata-driven resolvers
Open in StackBlitzEdit and run in your browser
View on GitHubBrowse the source code
Live Preview
Section titled “Live Preview”Key Code
Section titled “Key Code”import type { MetadataReactor } from "@ic-reactor/candid"import { IDL } from "@icp-sdk/core/candid"
const toHex = (bytes: Uint8Array): string => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")
async function inspectMethod( reactor: MetadataReactor, methodName: string, argTypes: IDL.Type[], args: unknown[], sampleOutputs: Record<string, unknown>) { const inputMeta = reactor.getInputMeta(methodName) const outputMeta = reactor.getOutputMeta(methodName) const variableCandidates = reactor.buildMethodVariableCandidates(methodName)
const candidArgsHex = toHex(IDL.encode(argTypes, args)) const hydrated = await reactor.buildForMethod(methodName, { candidArgsHex })
const resolved = outputMeta?.resolve(sampleOutputs[methodName])}