QubicTypeScript

findContractByName

Looks up a contract's numeric index from its name in the registry.

Signature

findContractByName(registry: ContractRegistry, name: string): number

Purpose

Looks up a contract's numeric index from its name. Use this when you have a contract name and need the index for ABI or RPC calls.

import { findContractByName } from "@qubic.org/registry"
import registry from "@qubic.org/registry/registry.json"
import type { ContractRegistry } from "@qubic.org/registry"

const reg = registry as ContractRegistry

const index = findContractByName(reg, "Qearn") // 9

Parameters

NameTypeDescription
registryContractRegistryThe imported registry JSON
namestringThe contract name to look up

Returns

number — the numeric contract index corresponding to the given name.

Throws

EntryNotFoundError — if the name is not present in the registry.

On this page