# networkFromGenesisHash

> Derive the canonical CAIP-2 identifier from a network's genesis hash per the Algorand profile.

```ts
import { networkFromGenesisHash } from 'x402-avm-js';
```

```ts
export function networkFromGenesisHash(genesisHash: Uint8Array | string): string;
```

Derive the canonical CAIP-2 identifier from a network's genesis hash per the Algorand profile.

Computes URL-safe base64 of the genesis hash (with + -> -, / -> _, stripped padding)
and truncates to the first 32 characters as the CAIP-2 reference.

## Parameters

- `genesisHash` (`Uint8Array | string`, required):
32-byte genesis hash as a Uint8Array or base64-encoded string.

## Returns

- `returns` (`string`):
Canonical CAIP-2 identifier formatted as "algorand:<32-char-urlsafe-base64>".

## Example

```ts
const caip2 = networkFromGenesisHash('wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=');
// 'algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k'
```

Source: [src/index.ts](https://github.com/x402-avm/x402-avm-js/blob/main/src/index.ts#L258)

Source: https://x402-avm.github.io/reference/js/network-from-genesis-hash
