✅ Opcode!!!

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

contract MagicNum {

  address public solver;

  constructor() public {}

  function setSolver(address _solver) public {
    solver = _solver;
  }

  /*
    ____________/\\\\\\_______/\\\\\\\\\\\\\\\\\\_____        
     __________/\\\\\\\\\\_____/\\\\\\///////\\\\\\___       
      ________/\\\\\\/\\\\\\____\\///______\\//\\\\\\__      
       ______/\\\\\\/\\/\\\\\\______________/\\\\\\/___     
        ____/\\\\\\/__\\/\\\\\\___________/\\\\\\//_____    
         __/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_____/\\\\\\//________   
          _\\///////////\\\\\\//____/\\\\\\/___________  
           ___________\\/\\\\\\_____/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_ 
            ___________\\///_____\\///////////////__
  */
}

このレベルを解くためには、Ethernaut にSolverwhatIsTheMeaningOfLife()に正しい数字で応答するコントラクト)を提供するだけでよいのです。

We need to write two sections of opcodes:

The code needs to return the 32 byte magic number - 42 or 0x2a (in hex).

16*2 = 32 + a = 0,1,…9,a = 10 ⇒ 42

Solution

■Runtime Opcode

👇 Do it!!!

https://www.evm.codes/playground?unit=Wei&codeType=Bytecode&code='602a60505260206050f3'_

1.You need to return value 42 2. RETURN opcode need to 2 arguments ⇒ (offset,size) 3. You need to store value the 42 in memory 4. You need to use MSTORE(offset, value) offset: offset in the memory in bytes. value: 32-byte value to write in the memory.⇒(32 = 0x20)

Screen Shot 2022-07-17 at 11.25.05.png

OPCODE   DETAIL
------------------------------------------------
**60**2a     Push 0x2a in the stack.
**(PUSH)**   Value (v) param to MSTORE(0x60

6050     Push 0x50 in the stack.
         Position (p) param to MSTORE

52       Store value,v=0x2a at position, p=0x50 in memory

6020     Push 0x20 (32 bytes, size of v) in the stack.
         Size (s) param to RETURN(0xf3)

6050     Push 0x50 (slot at which v=0x42 was stored).
         Position (p) param to RETURN

f3      RETURN value, v=0x42 of size, s=0x20 (32 bytes)

602a60505260206050f3(20hex = 10bytes)