// SPDX-License-Identifier: MITpragma solidity ^0.8.0;interface Buyer { function price() external view returns (uint256);}contract Shop { uint256 public price = 100; bool public isSold; function buy() public { Buyer _buyer = Buyer(msg.sender); if (_buyer.price() >= price && !isSold) { isSold = true; price = _buyer.price(); } }} 얘도 문제를 애매하..
Predic's Study BLOG
If you can deny the owner from withdrawing funds when they call withdraw() (whilst the contract still has funds, and the transaction is of 1M gas or less) you will win this level.// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Denial { address public partner; // withdrawal partner - pay the gas, split the withdraw address public constant owner = address(0xA9E); uint256 ti..
Fallback과 Receive함수는 둘 다 이더를 전송 받을 때 사용되는 함수이다.그러나 두 함수에 몇가지 차이점도 있고 헷갈리는 부분이 있어 정리할려 한다. 공통점- 상대방이 이더를 전송해서 내 컨트랙트에서 이더를 받을 때 실행된다. 차이점순수하게 이더만 전송할때는 Receive()이더와 데이터를 포함하여 전송 또는 잘못된 함수를 호출할때 Fallback()함수가 호출된다.예를 들어,contractAddress.call{value: 1 ether}();는 Receive함수를contractAddress.call{value: 1 ether}("someData");는 Fallback 함수를 호출한다. 다만, 순수하게 이더만 전송할 때, Receive함수가 없고 Fallback 함수만 있으면 Fallback..
![](https://blog.kakaocdn.net/dn/baExVR/btsL50ZzSPD/MQCDPCHlCUcPnhMXgatYaK/img.png)
// SPDX-License-Identifier: MITpragma solidity ^0.5.0;import "../helpers/Ownable-05.sol";contract AlienCodex is Ownable { bool public contact; bytes32[] public codex; modifier contacted() { assert(contact); _; } function makeContact() public { contact = true; } function record(bytes32 _content) public contacted { codex.push(_content); } func..
![](https://blog.kakaocdn.net/dn/mstWR/btsL4cNTeqV/Kc6CXgebiwigxWd9593tY1/img.png)
To solve this level, you only need to provide the Ethernaut with a Solver, a contract that responds to whatIsTheMeaningOfLife() with the right 32 byte number.Easy right? Well... there's a catch.The solver's code needs to be really tiny. Really reaaaaaallly tiny. Like freakin' really really itty-bitty tiny: 10 bytes at most.Hint: Perhaps its time to leave the comfort of the Solidity compiler mome..
![](https://blog.kakaocdn.net/dn/bkOIgV/btsL5OERPZ4/5pTb8KLkxqpl6V8SWbfW5K/img.png)
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Recovery { //generate tokens function generateToken(string memory _name, uint256 _initialSupply) public { new SimpleToken(_name, msg.sender, _initialSupply); }}contract SimpleToken { string public name; mapping(address => uint256) public balances; // constructor constructor(string memory _name, address _cr..
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Preservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public owner; uint256 storedTime; // Sets the function signature for delegatecall bytes4 constant setTimeSignature = bytes4(keccak256("setTime(uint256)")); constructor(address _timeZone1LibraryA..
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;import "openzeppelin-contracts-08/token/ERC20/ERC20.sol";contract NaughtCoin is ERC20 { // string public constant name = 'NaughtCoin'; // string public constant symbol = '0x0'; // uint public constant decimals = 18; uint256 public timeLock = block.timestamp + 10 * 365 days; uint256 public INITIAL_SUPPLY; address public playe..
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract GatekeeperTwo { address public entrant; modifier gateOne() { require(msg.sender != tx.origin); _; } modifier gateTwo() { uint256 x; assembly { x := extcodesize(caller()) } require(x == 0); _; } modifier gateThree(bytes8 _gateKey) { require(uint64(byt..