# algodClient

> Create an Algodv2 client for a named network or custom endpoint.

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

```ts
export function algodClient(network: string, url?: string, token?: string): algosdk.Algodv2;
```

Create an Algodv2 client for a named network or custom endpoint.

Connects to public AlgoNode endpoints for "mainnet" and "testnet", or default
credentials (port 4001, token of 64 'a's) for "localnet". For private networks,
pass the node's URL explicitly.

## Parameters

- `network` (`string`, required):
Network name ('mainnet', 'testnet', 'localnet', or CAIP-2 string).

- `url` (`string`):
Optional custom algod base URL.

- `token` (`string`):
Optional authentication token or header.

## Returns

- `returns` (`algosdk.Algodv2`):
Configured Algodv2 client.

## Throws

- `UnknownNetworkError`: If network has no default endpoint and url is omitted.

## Example

```ts
const client = algodClient('testnet'); // https://testnet-api.algonode.cloud
const localClient = algodClient('localnet'); // http://localhost:4001
const status = await localClient.status().do();
const privateNode = algodClient('my-private-net', 'http://10.0.0.5:4001', 'my-token');
```

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

Source: https://x402-avm.github.io/reference/js/algod-client
