> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# createViemPublicClient

> Creates a viem public client for EVM blockchain interactions

## Function Signature

```typescript theme={"system"}
createViemPublicClient(params: {
  chain: Chain;
  rpcUrl: string;
}): PublicClient
```

## Description

Creates a viem public client for interacting with EVM blockchains. This client is used for read-only operations like getting balances, account information, and preparing transactions.

## Parameters

### Required Parameters

* **`chain`** (`Chain`) - The viem chain configuration
* **`rpcUrl`** (`string`) - The RPC URL for the blockchain network

## Returns

* **`PublicClient`** - A viem public client instance

## Example

```typescript theme={"system"}
import { authenticatedEvmClient } from './client';
import { base } from 'viem/chains';

const evmClient = await authenticatedEvmClient();

const publicClient = evmClient.createViemPublicClient({
  chain: base,
  rpcUrl: 'https://mainnet.base.org',
});

// Use the public client for read operations
const balance = await publicClient.getBalance({
  address: '0xYourWalletAddress' as `0x${string}`,
});

console.log('Balance:', balance.toString());
```

## Common Use Cases

### Get Account Balance

```typescript theme={"system"}
const balance = await publicClient.getBalance({
  address: '0xYourWalletAddress' as `0x${string}`,
});
```

### Prepare Transaction

```typescript theme={"system"}
const preparedTx = await publicClient.prepareTransactionRequest({
  to: '0xRecipientAddress' as `0x${string}`,
  value: parseEther('0.1'),
  chain: base,
  account: '0xYourWalletAddress' as `0x${string}`,
});
```

### Get Account Information

```typescript theme={"system"}
const accountInfo = await publicClient.getAccount({
  address: '0xYourWalletAddress' as `0x${string}`,
});
```

## Error Handling

```typescript theme={"system"}
try {
  const publicClient = evmClient.createViemPublicClient({
    chain: base,
    rpcUrl: 'https://mainnet.base.org',
  });
  console.log('Public client created successfully');
} catch (error) {
  console.error('Failed to create public client:', error);
}
```

## Related Functions

* [`signTransaction()`](/node/reference/evm/sign-transaction) - Sign a transaction
* [`getEvmWallets()`](/node/reference/evm/get-evm-wallets) - Get all EVM wallets
