Loading...
Loading...
Compare original and translation side by side
pragma solidity ^0.8.20;remappings.txtrequireerror InsufficientBalance(uint256 available, uint256 required);if (balance < amount) revert InsufficientBalance(balance, amount);publicexternal@notice@param@returnindexedaddressimmutableconstantuncheckedassemblypragma solidity ^0.8.20;remappings.txtrequireerror InsufficientBalance(uint256 available, uint256 required);if (balance < amount) revert InsufficientBalance(balance, amount);publicexternal@notice@param@returnaddressindexedimmutableconstantuncheckedassembly| Element | Convention | Example |
|---|---|---|
| Contract / Library | PascalCase | |
| Interface | | |
| State variable / Function | lowerCamelCase | |
| Constant / Immutable | UPPER_SNAKE_CASE | |
| Event | PascalCase (past tense) | |
| Custom Error | PascalCase | |
| Function parameter | prefix | |
i/j/k| 元素 | 规范 | 示例 |
|---|---|---|
| 合约/库 | PascalCase | |
| 接口 | | |
| 状态变量/函数 | lowerCamelCase | |
| 常量/Immutable变量 | UPPER_SNAKE_CASE | |
| 事件 | PascalCase(过去式) | |
| 自定义错误 | PascalCase | |
| 函数参数 | setter方法参数前缀加 | |
i/j/k| Situation | Rule |
|---|---|
| Cross-contract constants | Place in |
| Interface definitions | Place in |
| Simple on-chain queries | Use |
| Complex multi-step operations | Use |
| Import style | Use named imports: |
| 场景 | 规则 |
|---|---|
| 跨合约常量 | 放置在 |
| 接口定义 | 放置在 |
| 简单链上查询 | 使用 |
| 复杂多步操作 | 使用 |
| 导入风格 | 使用命名导入: |
src/ — Contract source code
interfaces/ — Interface definitions (I*.sol)
common/ — Shared constants, types, errors (Const.sol, Types.sol)
test/ — Test files (*.t.sol)
script/ — Deployment & interaction scripts (*.s.sol)
config/ — Network config, parameters (*.json)
deployments/ — Deployment records (latest.env)
docs/ — Documentation, changelogs
lib/ — Dependencies (managed by forge install)src/ — 合约源代码
interfaces/ — 接口定义(I*.sol)
common/ — 共享常量、类型、错误(Const.sol, Types.sol)
test/ — 测试文件(*.t.sol)
script/ — 部署与交互脚本(*.s.sol)
config/ — 网络配置、参数(*.json)
deployments/ — 部署记录(latest.env)
docs/ — 文档、变更日志
lib/ — 依赖项(由forge install管理)config/*.jsondeployments/latest.envfoundry.tomlconfig/*.jsondeployments/latest.envfoundry.tomlundefinedundefinedundefinedundefined