// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Delegate { address public owner; constructor(address _owner) { owner = _owner; } function pwn() public { owner = msg.sender; }}contract Delegation { address public owner; Delegate delegate; constructor(address _delegateAddress) { delegate = Delegate(_delegateAddress); owner = msg.se..
Web3/The Ethernaut
// SPDX-License-Identifier: MITpragma solidity ^0.6.0;contract Token { mapping(address => uint256) balances; uint256 public totalSupply; constructor(uint256 _initialSupply) public { balances[msg.sender] = totalSupply = _initialSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(balances[msg.sender] - _value >= 0); balances[..
코드 자체는 심플하다.// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Telephone { address public owner; constructor() { owner = msg.sender; } function changeOwner(address _owner) public { if (tx.origin != msg.sender) { owner = _owner; } }}tx.origin 과 msg.sender의 값이 다르면 된다.msg.sender는 그렇다 치고 tx.origin이 뭔지 몰라서 찾아본 결과처음 트랜잭션을 최초로 생성한 계정이 반환된다고 한다...
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract CoinFlip { uint256 public consecutiveWins; uint256 lastHash; uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968; constructor() { consecutiveWins = 0; } function flip(bool _guess) public returns (bool) { uint256 blockValue = uint256(blockhash(block.number - 1)..
드디어 Web3를 시작하게 됐다.과연 흥미를 붙여 계속 할 수 있을진 모르겠지만.... The Ethernaut을 천천히 풀어보며 공부해보려 한다....일단 우여곡절끝에 지갑 생성 후 Level 1 Fallback을 풀었다. // SPDX-License-Identifier: MITpragma solidity ^0.8.0;contract Fallback { mapping(address => uint256) public contributions; address public owner; constructor() { owner = msg.sender; contributions[msg.sender] = 1000 * (1 ether); } modifier only..