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

# Python: Registry

`RegistryClient` is the on-chain half of `.nota` files. It wraps the `NotaRegistry` contract and lets you register, resolve, and revoke resources. Access it as `ntm.registry`. All write methods require the `Notareum` instance to be constructed with an `account`.

## Write methods

### `register_resource`

Registers a new resource and returns the transaction hash:

```python theme={"system"}
def register_resource(
    self,
    *,
    resource_type: int,            # 0..5 plus any governance-added types
    chain_id: int,                  # EIP-155 chain id (0 for non-EVM)
    identifier: str,
    proof_hash: str | bytes,        # keccak256 of canonical .nota serialization
    alias: str = "",
) -> str
```

The resource ID is derived on-chain as `keccak256(abi.encode(resource_type, chain_id, keccak256(identifier)))`. You can preview it with `compute_resource_id` below.

### `revoke_resource`

Only the owner can revoke. Revocation does not delete; it flips `is_revoked = True`:

```python theme={"system"}
def revoke_resource(self, resource_id: bytes | str) -> str
```

### `add_resource_type` / `remove_resource_type`

Governance-only operations for managing custom resource types beyond the initial six:

```python theme={"system"}
def add_resource_type(self, type_id: int, name: str) -> str
def remove_resource_type(self, type_id: int) -> str
```

## Read methods

### `get_resource`

Fetches the full `ResourceInfo` record:

```python theme={"system"}
def get_resource(self, resource_id: bytes | str) -> ResourceInfo
```

`ResourceInfo` (a dataclass) includes `owner`, `resource_type`, `chain_id`, `proof_hash`, `alias`, `verification_level`, `registered_at`, `last_updated_at`, and `is_revoked`.

### `resolve_alias`

Resolves a registered alias to its bytes32 resource ID (returned as a `0x`-prefixed hex string):

```python theme={"system"}
def resolve_alias(self, alias: str) -> str
```

### `is_valid_resource_type` / `get_resource_type_name`

Introspection helpers over the governance-managed type registry:

```python theme={"system"}
def is_valid_resource_type(self, type_id: int) -> bool
def get_resource_type_name(self, type_id: int) -> str
```

## Utility: `compute_resource_id`

Deterministically derives the resource ID locally, without any RPC round-trip. Use this to predict the ID before paying gas:

```python theme={"system"}
def compute_resource_id(
    self,
    *,
    resource_type: int,
    chain_id: int,
    identifier: str,
) -> str
```

## Full example

```python theme={"system"}
from notareum import Notareum
from eth_utils import keccak

ntm = Notareum(provider=w3, contracts=addresses, account=acct)

# 1. Create and sign a .nota file
nota = (
    ntm.nota
    .create(
        type="address",
        chain_name="ethereum",
        chain_id=1,
        identifier=acct.address,
        alias="alice.eth",
    )
    .validate()
    .sign(acct.key.hex())
)

# 2. Compute proof hash
proof_hash = "0x" + keccak(nota.serialize().encode()).hex()

# 3. Register on-chain
tx_hash = ntm.registry.register_resource(
    resource_type=0,
    chain_id=1,
    identifier=acct.address,
    proof_hash=proof_hash,
    alias="alice.eth",
)
print("Registered:", tx_hash)

# 4. Later, anyone resolves the alias
resource_id = ntm.registry.resolve_alias("alice.eth")
info = ntm.registry.get_resource(resource_id)
print(info.owner, info.verification_level)
```

## See also

* [Resource Registry protocol page](../../protocol/resource-registry.md)
* [Registering a Resource guide](../../guides/registering-a-resource.md)
* [Python API Reference](api-reference.md)
