# Foundry / cast 工具链

## 必须用 foundry-zksync

不是标准 foundry！需要 `--zksync` flag 才能编译 zkSync system contract。

```bash
# 安装
curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash
```

## 关键 cast 命令

```bash
# Chain id (验证 chain 391 LIVE)
cast chain-id --rpc-url https://rpc-testnet.axblade.io

# 调 view 函数
cast call $POB "getBatchCount()(uint256)" --rpc-url $RPC

# 调 state-mutating 函数
cast send $POB "submitBatch(...)" --private-key $KEY --rpc-url $RPC

# Estimate gas
cast estimate $POB "submitBatch(...)" --rpc-url $RPC
```

## 已知坑

* `cast call` 返回科学记数 `[5e17]` — 用 `awk '{print $1}'` 截
* foundry-zksync 还在 v0.1.x，部分 forge feature 未支持


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yellowpaper.axblade.io/integration-jie-ru-fang-shi/tooling-foundry-cast.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
