Cursor-rules
PromptBeginner5 minmarkdown
.cursorrules
.llmrules
0
- 本项目 **只使用 Foundry**(forge/cast/anvil),**不用 Hardhat、Truffle**。
Sign in to like and favorite skills
.llmrules
Code Style and Structure
Here are some pieces of information you need to know about this project:
script/ 部署与运维脚本(forge script)。test/ 测试(forge-std + fuzz + invariant)。src/ 合约代码lib/ 外部依赖(通过 forge install)。broadcast/ 部署产物(forge script 自动生成)。.env / .env.example 管理私钥与 RPC(脚本中用 vm.env* 读取)。pragma solidity ^0.8.24;// SPDX-License-Identifier: MITpragma solidity ^0.8.24;MyToken, StakingPool。I,如 IMyToken。transferToken, maxSupply。MAX_SUPPLY。TokensStaked。MyToken.sol。forge fmt 自动格式化(提交前必须通过)。@title @notice @dev @param @return(actor, subject, value, data...)。require(...,"string"),减少 gas。immutable、constant 合理使用,节省存储。external/public/internal/private。Ownable 或 AccessControl,禁止随意混用。nonReentrant 或检查-效应-交互模式。call{value: ...}(""),检查返回值。tx.origin 鉴权。immutable 或构造函数赋值。block.timestamp 作为随机源(除非非安全用途且明确说明)。false 或无返回),优先用 SafeERC20。indexed(<=3 个)。unchecked 包裹确定无溢出的加减法。forge-std(vm, stdError, StdCheats)。forge test --fuzz-runs)invariant 套件,若涉及资产安全/AMM/金库)assertEq/approxEqAbs/expectRevert/expectEmit。ContractName.t.sol,测试合约 ContractNameTest。forge script + --broadcast,禁用自写私钥处理逻辑。.env,示例放在 .env.example。script/Deploy.s.sol 输出关键地址与校验信息(事件/日志)。solhint +(可选)prettier-plugin-solidity(以 forge fmt 为准)。forge fmt --check、forge build、forge test -vvv、slither .。feat: ... fix: ... refactor: ... test: ... chore: ... docs: ...main 受保护,功能分支 feat/*、修复分支 fix/*。forge install owner/repo 管理,固定 commit 哈希或 tag。@title @notice,关键函数给出使用示例。interface/)与错误(errors/)集中管理,便于复用。forge install 命令与 foundry.toml 片段。require(..., "long string") 取代自定义错误。tx.origin 鉴权。