# Agent framework recipes: ElizaOS, viem, wagmi, Coinbase AgentKit

> Original page: https://docs.blockvectra.com/en/guides/agent-frameworks/

Autonomous AI agents and Web3 application frameworks interact with blockchain networks via JSON-RPC and WebSocket transports. BlockVectra provides dedicated endpoints with an API key, keyless public endpoints for supported read methods, and a Model Context Protocol (MCP) server for tool discovery.

## ElizaOS

* Official documentation: [elizaOS Documentation](https://elizaos.github.io/eliza/)
* Official repository: [elizaos/eliza](https://github.com/elizaos/eliza)

In elizaOS, EVM interactions are handled by the `@elizaos/plugin-evm` plugin. The plugin reads RPC provider endpoints from environment variables named with the `ETHEREUM_PROVIDER_<NETWORK>` pattern, or the `EVM_PROVIDER_URL` fallback variable.

Configure your `.env` file with your wallet private key and RPC endpoints:

```bash
# EVM wallet private key for signing transactions
export EVM_PRIVATE_KEY=0x...

# Dedicated endpoints with API key
export ETHEREUM_PROVIDER_ETHEREUM=https://api.blockvectra.com/v1/eth_mainnet/${BLOCKVECTRA_API_KEY}
export ETHEREUM_PROVIDER_BASE=https://api.blockvectra.com/v1/base_mainnet/${BLOCKVECTRA_API_KEY}

# Keyless public RPC endpoint
# export ETHEREUM_PROVIDER_ETHEREUM=https://api.blockvectra.com/v1/eth_mainnet/public
```

Include `@elizaos/plugin-evm` in your agent character configuration:

```json
{
  "name": "DeFiAgent",
  "plugins": ["@elizaos/plugin-evm"]
}
```

## viem

* Official documentation: [viem Documentation](https://viem.sh/docs/clients/public.html)
* Transports reference: [viem HTTP Transport](https://viem.sh/docs/clients/transports/http.html) and [viem WebSocket Transport](https://viem.sh/docs/clients/transports/websocket.html)
* Official repository: [wevm/viem](https://github.com/wevm/viem)

In viem, configure client transports using `http()` or `webSocket()`.

### HTTP transport with API key

```typescript
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";

export const client = createPublicClient({
  chain: mainnet,
  transport: http(`https://api.blockvectra.com/v1/eth_mainnet/${process.env.BLOCKVECTRA_API_KEY}`),
});
```

### HTTP transport with keyless public endpoint

For read requests on permitted public methods without an API key:

```typescript
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http("https://api.blockvectra.com/v1/eth_mainnet/public"),
});
```

### WebSocket transport

WebSocket transport (`webSocket(...)`) is supported on chains with `ws: true` in `GET /v1/chains`, such as on Robinhood Chain (`robinhood_mainnet`):

```typescript
import { createPublicClient, webSocket } from "viem";

export const wsClient = createPublicClient({
  transport: webSocket(`wss://api.blockvectra.com/v1/robinhood_mainnet/${process.env.BLOCKVECTRA_API_KEY}`),
});
```

For connection parameters and subscription types, see the [WebSocket subscriptions guide](https://docs.blockvectra.com/en/guides/websocket-subscriptions/).

## wagmi

* Official documentation: [wagmi createConfig](https://wagmi.sh/core/api/createConfig) and [wagmi HTTP Transport](https://wagmi.sh/core/api/transports/http)
* Official repository: [wevm/wagmi](https://github.com/wevm/wagmi)

In wagmi, pass the BlockVectra RPC URL to the `transports` map inside `createConfig`.

### Configuration with API key

```typescript
import { createConfig, http } from "wagmi";
import { mainnet } from "wagmi/chains";

export const config = createConfig({
  chains: [mainnet],
  transports: {
    [mainnet.id]: http(`https://api.blockvectra.com/v1/eth_mainnet/${process.env.BLOCKVECTRA_API_KEY}`),
  },
});
```

### Configuration with keyless public endpoint

```typescript
import { createConfig, http } from "wagmi";
import { mainnet } from "wagmi/chains";

export const config = createConfig({
  chains: [mainnet],
  transports: {
    [mainnet.id]: http("https://api.blockvectra.com/v1/eth_mainnet/public"),
  },
});
```

## Coinbase AgentKit

* Official documentation: [Coinbase AgentKit Documentation](https://docs.cdp.coinbase.com/agentkit/docs/welcome)
* Official repository: [coinbase/agentkit](https://github.com/coinbase/agentkit)

Coinbase AgentKit uses wallet providers to execute onchain actions. In TypeScript, the `ViemWalletProvider` from `@coinbase/agentkit` wraps a standard viem `WalletClient`, allowing you to route transaction execution and RPC queries through BlockVectra endpoints.

### Configuration with ViemWalletProvider

```typescript
import { AgentKit, ViemWalletProvider } from "@coinbase/agentkit";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";

const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);

const client = createWalletClient({
  account,
  chain: mainnet,
  transport: http(`https://api.blockvectra.com/v1/eth_mainnet/${process.env.BLOCKVECTRA_API_KEY}`),
});

const walletProvider = new ViemWalletProvider(client);

export const agentKit = await AgentKit.from({
  walletProvider,
});
```

For read operations on permitted methods, configure `http("https://api.blockvectra.com/v1/eth_mainnet/public")`.

## Remote MCP

If your agent connects via the Model Context Protocol (Streamable HTTP MCP), connect to the BlockVectra MCP server endpoint:

`https://docs.blockvectra.com/mcp`

For client configuration instructions across Claude Code, Cursor, VS Code, Codex, Gemini CLI, OpenAI Responses API, and Windsurf, see [Connecting from MCP clients](https://docs.blockvectra.com/en/guides/ai-agents/#connecting-from-mcp-clients) in the AI agents guide.

## Next steps

* [Connect an AI agent](https://docs.blockvectra.com/en/guides/ai-agents/) to discover endpoints with MCP, llms.txt, and OpenAPI.
* [Follow the programmatic sign-up guide](https://docs.blockvectra.com/en/guides/programmatic-signup/) to sign up and create an API key with a wallet signature, or [log in to the console](https://console.blockvectra.com/en/login/?next=%2Fen%2Fkeys%2F) to create a key.
* [Billing rules](https://docs.blockvectra.com/en/guides/billing-rules/) to review Compute Unit (CU) metering, rate limits, and non-billed errors.
