github.com/klaytn/klaytn@v1.12.1/node/cn/tracers/testdata/contracts/CornerCase.sol (about) 1 // SPDX-License-Identifier: MIT 2 3 pragma solidity >=0.7.0 <0.9.0; 4 5 // References 6 // - https://www.evm.codes 7 // - https://ethervm.io/decompile 8 // - https://docs.soliditylang.org/en/v0.4.26/assembly.html 9 10 contract CornerCaseCall { 11 event Done(); // to make functions non-view. 12 function doit() public { 13 assembly { 14 let g := gas() 15 let c := caller() 16 let s := call(g, c, 0, 0xfffffffffffffff0, 0, 0xffffffffffffffe0, 0) 17 } 18 emit Done(); 19 } 20 } 21 22 contract CornerCaseCreate { 23 event Done(); 24 function doit() public { 25 assembly { 26 let a := create(0, 0xffffffffffffffd0, 0) 27 } 28 emit Done(); 29 } 30 } 31 32 contract CornerCaseRevertSmall { 33 event Done(); 34 function doit() public { 35 assembly { 36 mstore(0x100, 0x0000000000000000000000000000000000000000000000000000000008c379a0) // sha3("Error(string)") 37 mstore(0x120, 0x000000000000000000000000000000000000000000000000000000000000cafe) // string offset 38 mstore(0x140, 0x0000000000000000000000000000000000000000000000000000000000c0ffee) // string length 39 mstore(0x160, 0x4141414141414141000000000000000000000000000000000000000000000000) // string bytes 40 revert(0x11c, 0x64) 41 } 42 emit Done(); 43 } 44 } 45 46 contract CornerCaseRevertBig { 47 event Done(); 48 function doit() public { 49 assembly { 50 mstore(0x100, 0x0000000000000000000000000000000000000000000000000000000008c379a0) // sha3("Error(string)") 51 mstore(0x120, 0x1100000000000000000000000000000000000000000000000000000000000020) // string offset 52 mstore(0x140, 0x1100000000000000000000000000000000000000000000000000000000000008) // string length 53 mstore(0x160, 0x4141414141414141000000000000000000000000000000000000000000000000) // string bytes 54 revert(0x11c, 0x64) 55 } 56 emit Done(); 57 } 58 }