项目
在 GitHub 查看
RareSkills/gas-puzzles
关于
一组用于练习 Gas 优化的智能合约。这些合约用作 RareSkills.io 和 Udemy Gas Optimization Course 的练习作业。
学习与教育实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文RareSkills Gas Puzzles
If you want to learn about gas optimization, take the Udemy gas optimization course!
Puzzles that are ready for you
- Distribute (hard)
- Array Sum (easy)
- Mint150 (hard)
- ERC165 (low level programming required)
- Array Sort (medium)
- Security101 (easy/medium)
- Escrow
- EscrowV2
- Mint
- Presale
- Vote (easy)
- Require (easy)
- Staking
Contributors
DO NOT COMMIT SOLUTIONS, BE SURE TO PUT ANSWERS IN contracts/contracts_optimized to ensure they fall into the .gitignore
Players
Your goal is to optimize the contracts such that they reach the target efficiency.
Rules
- you may not change the optimizer level
- you may not change the solidity version
- you may refactor functionality as long as you don't break the business logic
- you may make reasonable assumptions about what variable sizes are necessary to get things done
- you may remove unnecessary or redundant logic (some have been intentionally added)
- because making functions
payableis a controversial optimization, you do not need to make functionspayableto reach the gas target unless the function needs to be payable to fulfill its business logic
Testing
As mentioned above, optimized contracts should be created in their own sub-folder to prevent committing them publicly.
The file structure should look similar to this:
- GasPuzzles
|_
contracts
|_
contracts_optimized
| |_
| ArraySum.sol
| Distribute.sol
| ..
| ...
|
ArraySum.sol
Distribute.sol
..
...
Within the contracts that are optimized be sure to follow the following naming convention to ensure tests run smoothly:
contract OptimizedArraySum {
...
contract OptimizedDistribute {
...
npx hardhat test
npx hardhat test test/ArraySum
npx prettier --write *
探索相关项目
加载中…