# Use Claude Code and Codex for Solidity Workflows

> Markdown mirror of https://router.one/use-cases/solidity-claude-code for AI assistants and crawlers. Router One is an OpenAI-compatible LLM API gateway.
> Last updated: 2026-07-25

Solidity teams use Claude Code and OpenAI Codex CLI for contract review, test generation, and deployment checks. Router One puts both behind one gateway: an OpenAI-compatible endpoint for Codex, an Anthropic-compatible endpoint for Claude Code, per-key budget caps, request traces, and USDT/USDC top-ups for teams funded from a stablecoin treasury.

## Solidity workflows Claude Code and Codex handle well

### Contract review

Walk through Solidity contracts to flag reentrancy, access control, and arithmetic concerns for a human auditor.

### Foundry test generation

Draft Foundry or Hardhat test cases that cover the edge conditions you describe.

### Audit checklist drafting

Generate a structured review checklist before a contract goes to a formal audit.

### Deployment script review

Read deployment and upgrade scripts to surface mismatched addresses or unsafe steps.

## Why route Solidity coding tools through Router One

### One account for both tools

Use Claude Code and Codex from the same wallet balance and API key set.

### Per-key budget caps

Cap spend per developer, repo, or CI environment before an agent loops on a large codebase.

### Request traces

See model, tokens, latency, and cost for each Claude Code or Codex call.

### Stablecoin-funded billing

Top up with USDT or USDC so a Web3 team funds coding tools from its existing treasury.

## Boundaries

### Review assist, not an audit

Model output supports human review. It does not replace a professional smart contract audit.

### No execution

Router One returns code and text. It does not compile, deploy, or send transactions.

### No prompt storage

Contract code in prompts is not retained; only request metadata is logged for billing and observability.

## Point Claude Code and Codex at Router One

Set the base URL and key for OpenAI-compatible clients and Claude Code. Codex CLI picks the same key up through the provider block in its ~/.codex/config.toml, then runs as usual on your Solidity repo.

`.env`

```ts
# OpenAI-compatible SDKs and clients
OPENAI_BASE_URL=https://api.router.one/v1
OPENAI_API_KEY=sk-rk-your-router-one-key

# Claude Code — ANTHROPIC_API_KEY is not required
ANTHROPIC_BASE_URL=https://api.router.one
ANTHROPIC_AUTH_TOKEN=sk-rk-your-router-one-key

# Codex CLI — env_key in ~/.codex/config.toml (wire_api = "responses")
ROUTER_ONE_API_KEY=sk-rk-your-router-one-key
```

## FAQ

### Can I use Claude Code for Solidity through Router One?

Yes. Set ANTHROPIC_BASE_URL to the Anthropic-compatible base URL https://api.router.one and ANTHROPIC_AUTH_TOKEN to your Router One key, then run it on your Solidity repo. ANTHROPIC_API_KEY is not required — unset it if you exported it earlier.

### Can I use OpenAI Codex CLI as well?

Yes. Codex registers Router One as a model provider in ~/.codex/config.toml with base_url = "https://api.router.one/v1", wire_api = "responses", and env_key = "ROUTER_ONE_API_KEY". Other OpenAI-compatible clients just use the /v1 endpoint directly.

### Can I pay for coding tools with stablecoins?

Yes. Top up with USDT or USDC; the balance funds Claude Code and Codex usage per token.

### Can I cap spend per developer or repo?

Yes. Issue a separate API key per developer, repo, or CI environment, each with a hard budget cap.

### Does this replace a smart contract audit?

No. Claude Code and Codex assist human review. A professional audit is still required before mainnet deployment.

### Is contract code in prompts stored?

No. Router One does not retain prompt or completion bodies; only request metadata is logged.

## See also

- LLM API for Web3 AI agents: https://router.one/web3-ai-agents
- Claude Code setup: https://router.one/claude-code-china
- Codex CLI setup: https://router.one/codex-china
- Onchain analyst agent: https://router.one/use-cases/onchain-analyst-agent
- LLM API for DAO bots: https://router.one/use-cases/dao-community-bot
- Stablecoin LLM billing: https://router.one/crypto-llm-api
- Canonical page: https://router.one/use-cases/solidity-claude-code
- Models and per-model token rates: https://router.one/models (markdown: https://router.one/models.md)
- Pricing: https://router.one/pricing
- API docs (markdown): https://router.one/docs.md
- Company facts: https://router.one/facts/company.md
