Docs/API/readPolicyVersions

readPolicyVersions

functionPolicy versioning (HCS-2)

Read the full policy version history from the registry via the mirror node (consensus order).

signature
readPolicyVersions(registryTopicId, mirrorBaseUrl, trustedPayer?): Promise<PolicyVersion[]>

Pass `trustedPayer` (the owner’s account id) to only trust versions the owner published — defense-in-depth against policy injection even on a topic without a submit key.

Parameters

NameTypeDescription
registryTopicIdreqstringThe HCS-2 registry topic.
mirrorBaseUrlreqstringMirror node REST base, e.g. https://testnet.mirrornode.hedera.com/api/v1.
trustedPayeroptstringOnly include versions published by this account id.

Returns

Promise<PolicyVersion[]>

All versions, oldest → newest, each with caps + reason + consensus timestamp.

Example

example
const versions = await readPolicyVersions(policyTopicId, MIRROR, ownerAccountId);
VERIFIABLE SPEND-CONTROL   ·   ENFORCED ON-CHAIN   ·   AGENTS CAN PAY — NOW THEY CAN’T OVERSPEND   ·   CURB × HEDERA   ·   VERIFIABLE SPEND-CONTROL   ·   ENFORCED ON-CHAIN   ·   AGENTS CAN PAY — NOW THEY CAN’T OVERSPEND   ·   CURB × HEDERA   ·