Solidity
Ethernaut 挑戰 Magicnumber
這是我的操作碼:
INIT: PUSH 0x0a(10 OPCODES=10 bytes) = 600a PUSH 0x0c = 600c PUSH 0x00 = 6000 CODECOPY - Where, current location of runtime code, size of runtime code = 39 PUSH 0x0a = 600a PUSH 0x00 = 6000 RETURN (position=0x00, value size=0x0a) = f3 Result = 600a600c600039600a6000f3 RUNTIME: PUSH 0xfa = 60fa PUSH 0x80 = 6080 MSTORE 0x80,0xfa = 53 PUSH 0x20 = 6020 PUSH 0x80 = 6080 RETURN (0x80, 0x20) = f3 Result = 60fa60805360206080f3
契約部署成功通過,但是當我送出挑戰時,它說我還沒有解決它。有人能告訴我我的 OPCODE 中的錯誤在哪裡嗎?
由於您的契約返回,您的字節碼似乎是錯誤的
113078212145816597093331040047546785012958969400039613319782796882727665664000
呼叫時。
為了檢查,我部署了一個契約
contract DeployBytecode { // Create contract from bytecode function deployBytecode(bytes memory bytecode) public returns (address) { address retval; assembly{ mstore(0x0, bytecode) retval := create(0,0xa0, calldatasize) } return retval; } }
並用它部署你的字節碼,然後取回地址並使用它
contract Answer { function whatIsTheMeaningOfLife() external view returns(uint){ } }
呼叫 whatIsTheMeaningOfLife() 並獲得那個巨大的數字。
希望這可以幫助