> ## 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.

# Registering a resource

# Registering a Resource

A signed `.nota` file is self-contained, but it is not discoverable. To make a resource resolvable by anyone, register it on-chain with the `NotaRegistry` contract. This guide walks through the full flow: derive the resource ID, compute the proof hash, claim an alias, and send the transaction.

## What on-chain registration gives you

* **Ownership.** The transaction sender becomes the owner of the resource ID and is the only party able to revoke or elevate it.
* **Discoverability.** Aliases like `alice.eth` resolve directly to a resource ID without needing the original `.nota` file in hand.
* **Verifiability.** The proof hash anchors the canonical `.nota` file content on-chain; any tampering produces a different hash.
* **Revocation.** A single transaction flips `is_revoked = true`, a signal wallets and explorers can treat as terminal.

## Prerequisites

* A deployed Notareum instance with configured contract addresses (see [Contract Addresses](../reference/contract-addresses.md)).
* An Ethereum account with enough native gas (ETH on mainnet, testnet ETH on Sepolia) to send one transaction.
* Optional: enough NOTA to pay the alias fee if you want a human-readable alias.
* A signed `.nota` file (see [Your First .nota File](your-first-nota-file.md)).

## The flow

```mermaid theme={"system"}
flowchart LR
    A[Signed .nota file] --> B[keccak256<br/>of canonical JSON]
    B --> C[proofHash]
    A --> D[resourceType<br/>chainId<br/>identifier]
    D --> E[computeResourceId]
    C --> F[registerResource]
    E --> F
    F --> G[NotaRegistry on-chain]
```

## Step 1: Derive the resource ID locally

The SDK can preview the resource ID before you pay any gas:

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

const resourceId = ntm.registry.computeResourceId(
  ResourceType.ADDRESS,
  1n,
  await signer.getAddress()
);
console.log("Resource ID will be:", resourceId);
```

Resource ID is deterministic: `keccak256(abi.encode(resourceType, chainId, keccak256(identifier)))`. Same inputs always produce the same ID.

## Step 2: Compute the proof hash

Hash the canonical `.nota` serialization:

```typescript theme={"system"}
import { keccak256, toUtf8Bytes } from "ethers";

const wire = signed.serialize();
const proofHash = keccak256(toUtf8Bytes(wire));
```

Store `wire` somewhere durable, ideally IPFS, so anyone can retrieve and re-hash it to check.

## Step 3: Claim an alias (optional)

Aliases must be globally unique. The contract charges a small NOTA fee per alias (see [Fee Model](../protocol/fee-model.md)). Approve the fee first:

```typescript theme={"system"}
import { Contract } from "ethers";

const fee = await ntm.fee.getAliasFee();
const nota = new Contract(
  contracts.notaToken,
  ["function approve(address,uint256) returns (bool)"],
  signer
);
await (await nota.approve(contracts.notaRegistry, fee)).wait();
```

Skip this step entirely if you pass an empty alias string to `registerResource`.

## Step 4: Send the transaction

```typescript theme={"system"}
const txHash = await ntm.registry.registerResource(
  ResourceType.ADDRESS,
  1n,
  await signer.getAddress(),
  proofHash,
  "alice.eth"
);
console.log("Registered:", txHash);
```

Once the transaction is mined, the resource is live.

## Step 5: Verify from any wallet

Any party, including ones without the original `.nota` file, can resolve and inspect the record:

```typescript theme={"system"}
const id = await ntm.registry.resolveAlias("alice.eth");
const info = await ntm.registry.getResource(id);
console.log(info.owner, info.proofHash, info.verificationLevel);
```

If they also have the `.nota` file, they can `keccak256` its serialization and match it against `info.proofHash` to prove the file has not been tampered with.

## Common pitfalls

* **Reverts with `AliasAlreadyTaken`.** Someone else already owns that alias. Choose another or bid on a release in the future (governance-configurable).
* **Reverts with `InvalidResourceType`.** Governance has not added this type ID yet. Use one of the six initial types or sponsor a proposal.
* **Wrong proof hash.** Always hash the canonical serialization (`serialize()`), not the file as you pretty-printed it.

## Next step

To attach a trust level to the registration, continue to [Requesting Verification](requesting-verification.md).
