
Ethernaut 是个由 Zeppelin 团队开发的闯关游戏, 玩家可透过闯关学习很多写Solidity 和web3.js 的知识。
游戏网址是 : https://ethernaut.zeppelin.solutions
要玩这个游戏,首先要用 metamask 这个 chrome extension, 然后使用 ropsten 这个testnet。
玩家首先要去 ropsten 的 faucet 去领一点免费的 testnet ethereum 才能做transaction。
然后在到 browser 的console 里 输入指令。
不是所有题目都能在console 里解决, 大多数的题目要你用游戏的create instance 来生产一个即时生成的 contract instance, 然后你破解后在submit 那个instance 。 成功后就会有一个勾在题目标题傍边。
有些题目会要求你写smart contract, 你可以用 remix.ethereum.org 或者 solc + truffle , 我是用 remix 的。 用remix 的话 ,直接在 browser + metamask 就可以了。
里头有很题目会考验玩家对Solidity 知多少,例如:
考验的概念:
- 玩家是否明白如何用web3.js 做call() 或 sendTransaction()
- 玩家是否明白 fallback 的概念。
- 玩家是否知道如何call contract function 来夺取contract 的owner 权。
- 玩家是否知道用 block hash 来做random seed 是可以被人用contract front run 的
- 玩家是否知道 msg.sender 和 tx.origin 的差别。
- 玩家是否知道 uint 过龙是会wraparound的 。
- 玩家是否明白 delegatecall 跟 context 的概念。
- 玩家是否知道如何用selfdestruct
- 玩家是否知道 private property 是可以被人看光光的。
- 玩家是否知道 如何send ether 到 contract。
- 玩家是否会写造成 recursion(递归)的smart contract
- 玩家是否知道 contract callee 可以call回 contract caller ,而且因为你是caller 你可以操控你的contract 来达到目的。
- 玩家是否知道 private property 是可以被人看光光的。
- 玩家是否知道如何知道 contract 在某个执行点会剩下多少gas , 和一些基本的 大container 去小container 的转化。
- 玩家是否明白 一个contract 在什么时候它的size是0
- 玩家是否明白锁住一个function 还是有其它没被implement 的function 可以达到一样的目的。
- 玩家是否明白 delegatecall 跟 context 的概念。
- 玩家是否明白 struct 在function 里instantiate 会有盖过storage 的危险
- 玩家是否明白 selfdestruct
- 玩家是否会用 evm bytecode。
- 玩家是否知道 dynamic array 是如何在storage 里收藏的, 玩家是否知道如何在sendtransaction 里制作 array 的argument, 还有结合其它题目的概念。
- 玩家是否知道 如何在别的contract call 你的contract 时,让整个程序终止
- 玩家是否知道 Contract 不但会被别的contact call , 还会回call 给call 它的contract
有兴趣的朋友可以试试看玩 。。
谢谢阅读。