This is an intermediate series for learning Solidity and smart contract development. You will explore technicalities from syntax edgecases, to assembly in the EVM, to smart contract coding conventions, all through test driven development.
“If your mind is empty, it is always ready for anything, it is open to everything. In the beginner’s mind there are many possibilities, but in the expert’s mind there are few.”
- variable modifers: public private
- Visbility modifiers: public, private, external, etc.
- Getter modifiers: view, pure, constant
- address & how its computed
- data types: sender, value, gas, this
- async return values
- events
- error handling: require, asserts
- free getter functions
- constructing send / call fns
- interfaces
- libraries, ERC libs
- factory patterns
- ownership
- overflow, underflow
- re-entry
- tx.origin
- delegatecall: scope
- storage hacks
- bytecode & opcodes
- Clone the repo:
git clone https://github.com/nczhu/solidity-koans.git
- Install dependencies:
npm install -g truffle ganache-cli
- Start Ganache:
ganache-cli
- In a new tab, check out the
/test
directory, where each test represents a koan. To get started with the easiest (and first) Koan, run:truffle test ./test/Test_assert_1.sol
- Each test is initially incomplete, e.g.:
function test_should_return_true() public {
Assert.isTrue(__, "should return true");
}
- Run each level with:
truffle test ./test/Test_FILENAME
Tests will fail with error messages, e.g.:
2) Test_Assert_1
test_should_return_true::
Error: should return true
- In your editor, replace
__
with the correct values or code, e.g.:
function test_should_return_true() public {
Assert.isTrue(true, "should return true");
}
- To pass each level, make sure:
-
All tests are passing
-
All compiler warnings and errors are fixed
-
Hint: Use Remix IDE to test potential solutions
Member "..." not unique after argument-dependent lookup in type(library Assert)
. Solution: try typecasting your answer to solve compiler issues.
- Fork it the project
- Create your feature branch using issue #:
git checkout -b issue#-feature
- Commit your changes:
git commit -am 'Fix/Add/Change: commit msg'
- Push to the branch:
git push origin issue#-feature
- Create a new Pull Request
See full list of outstanding issues here.
- Rewrote Assert.sol to accommodate for additional data types. Modifications are signed inline with @nczhu
MIT License