Skip to content

registryCreateProperties

registryCreateProperties(tx_hash, blob): Promise<IRegistryCreate>

Creates properties for a new registry, including the transaction hash, document ID, document author ID, document node ID, and optionally a serialized and CBOR-encoded blob.

This function requires either a transaction hash or a blob to generate the registry properties. If a blob is provided without a transaction hash, the hash will be computed from the serialized blob. The blob will be CBOR-encoded before dispatching to the blockchain.

If only a transaction hash is provided, it will be dispatched as-is into the CORD Registry.

If both tx_hash and blob are provided, the function will:

  • Validate the blob for serialization.
  • Encode the blob in CBOR before dispatching it.
  • Use the existing tx_hash as-is for the registry creation process, without computing a new hash from the blob.

Parameters

tx_hash: any= null

A hex string representing the transaction hash.

blob: null | string= null

An optional string representing the data to be stored in the registry.

Returns

Promise<IRegistryCreate>

A promise that resolves to an object containing the properties of the registry, including the transaction hash, blob, document ID, author ID, and node ID.

Throws

If neither transaction hash nor blob is provided, or if the transaction hash is empty after processing.

Example

const registryProperties = await registryCreateProperties(
'0x123...', // tx_hash
'{"key":"value"}', // blob
);
console.log(registryProperties);

Source

registry/src/Registry.ts:208