# caip2_from_genesis_hash

> Derive CAIP-2 network identifier from an Algorand genesis hash.

```python
from x402_algorand import caip2_from_genesis_hash
```

```python
def caip2_from_genesis_hash(genesis_hash: str | bytes) -> str
```

Derive CAIP-2 network identifier from an Algorand genesis hash.

Following the Algorand CAIP-2 profile, the reference is the first 32
characters of the URL-safe base64 encoding of the raw 32-byte genesis hash.

## Parameters

- `genesis_hash` (`str | bytes`, required):
32-byte genesis hash (raw bytes or base64-encoded string).

## Returns

- `returns` (`str`):
CAIP-2 network identifier (e.g. "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k").

## Raises

- `TypeError`: If `genesis_hash` is neither `str` nor `bytes`.
- `NetworkError`: If `genesis_hash` is not valid base64.

## Examples

```python
from x402_algorand import caip2_from_genesis_hash

print(caip2_from_genesis_hash("wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8="))
# algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k
```

Source: [x402_algorand/utils.py](https://github.com/x402-avm/x402-algorand/blob/main/x402_algorand/utils.py#L78)

Source: https://x402-avm.github.io/reference/python/x402-algorand/caip2-from-genesis-hash
