> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notareum.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Registry

# TypeScript: Registry

`RegistryClient` is the on-chain half of `.nota` files. It wraps the `NotaRegistry` contract: you register a resource once, the contract stores ownership and proof hash, and later anyone can resolve aliases or fetch records without needing the original file. Access it via `ntm.registry`.

## Write methods

All writes require the Notareum instance to be configured with a `signer`.

### `registerResource`

Registers a new resource, returning the transaction hash:

```typescript theme={"system"}
async registerResource(
  resourceType: number,       // ResourceType enum value (0..5 + governance-added)
  chainId: bigint | number,   // EIP-155 chain id (0 for non-EVM resources)
  identifier: string,         // the resource identifier as a string
  proofHash: string,          // 0x-prefixed keccak256 of the canonical .nota serialization
  alias?: string              // optional unique alias, "" to skip
): Promise<string>
```

Resource ID is derived on-chain from `(resourceType, chainId, keccak256(identifier))`. Aliases must be globally unique; re-using an existing alias reverts with `AliasAlreadyTaken`.

### `revokeResource`

Only the current owner can revoke. Revocation does not delete the record; it flags `isRevoked = true`, which wallets and explorers should treat as a terminal state:

```typescript theme={"system"}
async revokeResource(resourceId: string): Promise<string>
```

### `addResourceType` / `removeResourceType`

Governance-only. Add custom resource types beyond the initial six (`ADDRESS`, `TRANSACTION`, `CONTRACT`, `IPFS`, `NFT`, `METADATA`):

```typescript theme={"system"}
async addResourceType(typeId: number, name: string): Promise<string>
async removeResourceType(typeId: number): Promise<string>
```

## Read methods

### `getResource`

Fetches the full `ResourceInfo` record:

```typescript theme={"system"}
async getResource(resourceId: string): Promise<ResourceInfo>
```

`ResourceInfo` includes `owner`, `resourceType`, `chainId`, `proofHash`, `alias`, `verificationLevel`, `registeredAt`, `lastUpdatedAt`, and `isRevoked`.

### `resolveAlias`

Resolves a human-readable alias to the bytes32 resource ID it points to:

```typescript theme={"system"}
async resolveAlias(alias: string): Promise<string>
```

### `isValidResourceType` / `getResourceTypeName`

Introspection helpers over the governance-managed resource type registry:

```typescript theme={"system"}
async isValidResourceType(typeId: number): Promise<boolean>
async getResourceTypeName(typeId: number): Promise<string>
```

## Utility: `computeResourceId`

Computes a resource ID locally, off-chain, without any RPC call. Identical to the on-chain derivation, so you can predict the ID before sending a transaction:

```typescript theme={"system"}
computeResourceId(
  resourceType: number,
  chainId: bigint | number,
  identifier: string
): string
```

## Full example

```typescript theme={"system"}
import { Notareum, ResourceType } from "@notareum/sdk";

const ntm = Notareum({ provider, signer, contracts });

// 1. Create and sign a .nota file
const file = await ntm.nota
  .create({
    type: "address",
    chainName: "ethereum",
    chainId: 1,
    identifier: await signer.getAddress(),
    alias: "alice.eth",
  })
  .validate()
  .sign(signer);

// 2. Derive the on-chain proof hash
const { keccak256, toUtf8Bytes } = await import("ethers");
const proofHash = keccak256(toUtf8Bytes(file.serialize()));

// 3. Register
const txHash = await ntm.registry.registerResource(
  ResourceType.ADDRESS,
  1n,
  await signer.getAddress(),
  proofHash,
  "alice.eth"
);

// 4. Later, anyone resolves the alias
const resourceId = await ntm.registry.resolveAlias("alice.eth");
const info = await ntm.registry.getResource(resourceId);
console.log(info.owner, info.verificationLevel);
```

## See also

* [Resource Registry](../../protocol/resource-registry.md) protocol page
* [Verification client](verification.md) for elevating registered resources
* [Registering a Resource](../../guides/registering-a-resource.md) guide
