solidity-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Deployment Workflow

部署工作流

Language Rule

语言规则

  • Always respond in the same language the user is using. If the user asks in Chinese, respond in Chinese. If in English, respond in English.
  • 始终使用与用户相同的语言回复。如果用户用中文提问,就用中文回复;如果用英文,就用英文回复。

Pre-deployment Checklist (all must pass)

预部署检查清单(必须全部通过)

StepCommand / Action
Format code
forge fmt
Run all tests
forge test
— zero failures required
Check gas report
forge test --gas-report
— review critical functions
Verify configManually check
config/*.json
parameters
Dry-run
forge script <Script> --fork-url <RPC_URL> -vvvv
(no
--broadcast
)
Check balance
cast balance <DEPLOYER> --rpc-url <RPC_URL>
— sufficient gas?
Gas limit setDeployment command must include
--gas-limit
步骤命令 / 操作
格式化代码
forge fmt
运行所有测试
forge test
— 必须零失败
查看gas报告
forge test --gas-report
— 检查核心函数
验证配置手动检查
config/*.json
参数
模拟运行
forge script <Script> --fork-url <RPC_URL> -vvvv
(不添加
--broadcast
检查余额
cast balance <DEPLOYER> --rpc-url <RPC_URL>
— gas是否充足?
设置gas上限部署命令必须包含
--gas-limit

Deployment Decision Rules

部署决策规则

SituationRule
Default deploymentNo
--verify
— contracts are not verified on block explorers by default
User requests verificationAdd
--verify
and
--etherscan-api-key
to the command
Post-deploy verificationUse
forge verify-contract
as a separate step
Multi-chain deploySeparate scripts per chain, never batch multiple chains in one script
Proxy deploymentDeploy implementation first, then proxy — verify both separately
场景规则
默认部署不添加
--verify
— 默认不在区块浏览器上验证合约
用户要求验证在命令中添加
--verify
--etherscan-api-key
部署后验证单独使用
forge verify-contract
步骤
多链部署每条链使用单独的脚本,切勿在一个脚本中批量处理多条链
代理部署先部署实现合约,再部署代理合约 — 分别验证两者

Post-deployment Operations (all required)

部署后操作(必须全部执行)

  1. Update addresses in
    config/*.json
    and
    deployments/latest.env
  2. Test critical functions:
    cast call
    to verify on-chain state is correct
  3. Record changes in
    docs/CHANGELOG.md
  4. Submit PR with deployment transaction hash link
  5. If verification needed, run
    forge verify-contract
    separately
  1. 更新
    config/*.json
    deployments/latest.env
    中的地址
  2. 测试核心函数:使用
    cast call
    验证链上状态是否正确
  3. docs/CHANGELOG.md
    中记录变更
  4. 提交包含部署交易哈希链接的PR
  5. 如果需要验证,单独运行
    forge verify-contract

Key Security Rule

核心安全规则

  • Never pass private keys directly in commands. Use Foundry Keystore (
    cast wallet import
    ) to manage keys securely.
  • Never include
    --broadcast
    in templates.
    The user must explicitly add it when ready to deploy.
  • 切勿在命令中直接传入私钥。使用Foundry Keystore(
    cast wallet import
    )安全管理密钥。
  • 切勿在模板中包含
    --broadcast
    。用户准备好部署时必须手动添加该参数。

Command Templates

命令模板

bash
undefined
bash
undefined

Dry-run (simulation only, no on-chain execution)

模拟运行(仅模拟,不执行链上操作)

forge script script/Deploy.s.sol:DeployScript
--rpc-url <RPC_URL>
--gas-limit 5000000
-vvvv
forge script script/Deploy.s.sol:DeployScript
--rpc-url <RPC_URL>
--gas-limit 5000000
-vvvv

When user is ready to deploy, instruct them to add:

当用户准备好部署时,指导他们添加:

--account <KEYSTORE_NAME> --broadcast

--account <KEYSTORE_NAME> --broadcast

Verify existing contract separately

单独验证已部署的合约

forge verify-contract <ADDRESS> <CONTRACT>
--chain-id <CHAIN_ID>
--etherscan-api-key <API_KEY>
--constructor-args $(cast abi-encode "constructor(address)" <ARG>)
forge verify-contract <ADDRESS> <CONTRACT>
--chain-id <CHAIN_ID>
--etherscan-api-key <API_KEY>
--constructor-args $(cast abi-encode "constructor(address)" <ARG>)

Quick on-chain read test after deployment

部署后快速链上读取测试

cast call <CONTRACT_ADDRESS> "functionName()" --rpc-url <RPC_URL>
undefined
cast call <CONTRACT_ADDRESS> "functionName()" --rpc-url <RPC_URL>
undefined