-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
218 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
lib/** linguist-vendored | ||
foundry/lib/** linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,45 @@ | ||
# Foundry Template | ||
# Awesome Web3 Contracts | ||
|
||
## Install Dependency | ||
|
||
```yarn | ||
yarn | ||
``` | ||
|
||
```bash | ||
|
||
git submodule update --rebase --remote | ||
# OR | ||
forge install OpenZeppelin/openzeppelin-contracts@v5.0.0 --no-commit | ||
forge install foundry-rs/forge-std@v1.7.1 --no-commit | ||
forge install PaulRBerg/prb-test@v0.6.5 --no-commit | ||
``` | ||
|
||
```bash | ||
# run test case | ||
forge test | ||
|
||
anvil | ||
# run local node | ||
anvil -f sepolia | ||
|
||
# run script | ||
forge script foundry/script/Deploy.s.sol --fork-url http://localhost:8545 --broadcast | ||
``` | ||
|
||
## Ethernaut | ||
|
||
Ethernaut is a Web3 / Solidity based adversarial game inspired by overthewire.org, running on the Ethernaut virtual | ||
machine. Each level is a smart contract that needs to be hacked. | ||
|
||
| Status | Level | Docs | Video | Note | | ||
| :----: | :-------------------- | :----------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: | :--: | | ||
| ✅ | [0.Hello Ethernaut]() | ... | [YouTube](https://www.youtube.com/watch?v=BE0J7I13CPo) 、[BILIBILI](https://www.bilibili.com/video/BV1GV411w7bk) | ... | | ||
| ✅ | [1.Fallback]() | [Mirror](https://mirror.xyz/leekdev.eth/fQn4QQF3iIwhOdolLmQpTTB5M7R9RWcvFaRFLdTodPM) | [YouTube](https://www.youtube.com/watch?v=6SZcd4bbTjQ) 、[BILIBILI](https://www.bilibili.com/video/BV1qu411u7Rn) | ... | | ||
| ✅ | [2.Fallout]() | [Mirror](https://mirror.xyz/leekdev.eth/GuFMbyyOnKqJOp49vRugrk_EWr2-JUIc9y-kJVWONeg) | [YouTube](https://www.youtube.com/watch?v=Q2EYC1a4VVM) 、 [BILIBILI](https://www.bilibili.com/video/BV1TC4y1o7Up/) | ... | | ||
| | [3.CoinFlip]() | ... | ... | ... | | ||
| | [4.Telephone]() | ... | ... | ... | | ||
| | [5.Token]() | ... | ... | ... | | ||
| | [6.Delegate]() | ... | ... | ... | | ||
| | [7.Force]() | ... | ... | ... | | ||
| | [8.Vault]() | ... | ... | ... | | ||
| | [9.King]() | ... | ... | ... | | ||
| | [10.Reentrance]() | ... | ... | ... | |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; | ||
import { Level } from "./00_Ethernaut.sol"; | ||
|
||
contract Fallout { | ||
using Math for uint256; | ||
|
||
mapping(address account => uint256 balance) private allocations; | ||
address payable public owner; | ||
|
||
function Fal1out() public payable { | ||
owner = payable(msg.sender); // Type issues must be payable address | ||
allocations[owner] = msg.value; | ||
} | ||
|
||
modifier onlyOwner() { | ||
require(msg.sender == owner, "caller is not the owner"); | ||
_; | ||
} | ||
|
||
function allocate() public payable { | ||
(, allocations[msg.sender]) = allocations[msg.sender].tryAdd(msg.value); | ||
} | ||
|
||
function sendAllocation(address payable allocator) public { | ||
require(allocations[allocator] > 0, "not have enough balance"); | ||
allocator.transfer(allocations[allocator]); | ||
} | ||
|
||
function collectAllocations() public onlyOwner { | ||
payable(msg.sender).transfer(address(this).balance); // Type issues must be payable address | ||
} | ||
|
||
function allocatorBalance(address allocator) public view returns (uint256) { | ||
return allocations[allocator]; | ||
} | ||
} | ||
|
||
contract FalloutFactory is Level { | ||
function createInstance(address _player) public payable override returns (address) { | ||
_player; | ||
Fallout instance = new Fallout(); | ||
return address(instance); | ||
} | ||
|
||
function validateInstance(address payable _instance, address _player) public view override returns (bool) { | ||
Fallout instance = Fallout(_instance); | ||
return instance.owner() == _player; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.