Skip to content

Instantly share code, notes, and snippets.

View sekrystal's full-sized avatar

Sam Krystal sekrystal

View GitHub Profile
@sekrystal
sekrystal / `init code` Contract Example
Last active November 10, 2022 19:13
`init code` contract example
label_0000:
0000 60 PUSH1 0x80
0002 60 PUSH1 0x40
0004 52 MSTORE
0005 34 CALLVALUE
0006 80 DUP1
0007 15 ISZERO
0008 61 PUSH2 0x0010
000B 57 JUMPI
label_000C:
@sekrystal
sekrystal / Dissasembled `init code` after removing `runtime code`
Created November 10, 2022 20:37
Dissasembled `init code` after removing `runtime code`
label_0000:
0000 60 PUSH1 0x80
0002 60 PUSH1 0x40
0004 52 MSTORE
0005 34 CALLVALUE
0006 80 DUP1
0007 15 ISZERO
0008 60 PUSH1 0x0f
000A 57 JUMPI
label_000B:
@sekrystal
sekrystal / SimpleConstructor.sol
Created November 11, 2022 14:58
EVM Contract Construction Example 1
pragma solidity ^0.8.13;
contract MyCoin {
uint public constant totalSupply = 1000000000000000000000000000;
mapping(address => uint256) balances;
constructor() {
balances[msg.sender] = totalSupply;
}
}
@sekrystal
sekrystal / Output.json
Created November 11, 2022 15:04
EVM Contract Construction Example
[
{
"inputs":
[],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs":
[],
@sekrystal
sekrystal / Code.md
Created November 11, 2022 15:09
EVM Contract Construction Example 3

solc --bin ~/Desktop/MyCoin.sol

======= Desktop/MyCoin.sol:MyCoin =======

Binary: 608060405234801561001057600080fd5b506b033b2e3c9fd0803ce80000006000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060bd8061006e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806318160ddd14602d575b600080fd5b60336047565b604051603e9190606e565b60405180910390f35b6b033b2e3c9fd0803ce800000081565b6000819050919050565b6068816057565b82525050565b6000602082019050608160008301846061565b9291505056fea2646970667358221220edc6183cb296d3c2809859d4531deef0fb83c0ad90b772697ffaa375befe9c7664736f6c634300080d0033

@sekrystal
sekrystal / Code2.md
Created November 11, 2022 15:18
EVM Contract Construction Example 4

solc --bin-runtime ~/Desktop/MyCoin.sol

======= Desktop/MyCoin.sol:MyCoin =======

Binary of the runtime part: 6080604052348015600f57600080fd5b506004361060285760003560e01c806318160ddd14602d575b600080fd5b60336047565b604051603e9190606e565b60405180910390f35b6b033b2e3c9fd0803ce800000081565b6000819050919050565b6068816057565b82525050565b6000602082019050608160008301846061565b9291505056fea2646970667358221220edc6183cb296d3c2809859d4531deef0fb83c0ad90b772697ffaa375befe9c7664736f6c634300080d0033

@sekrystal
sekrystal / disassembly.txt
Created November 11, 2022 15:19
EVM Contract Construction Example 5
label_0000:
0000 60 PUSH1 0x80
0002 60 PUSH1 0x40
0004 52 MSTORE
0005 34 CALLVALUE
0006 80 DUP1
0007 15 ISZERO
0008 61 PUSH2 0x0010
000B 57 JUMPI
label_000C:
@sekrystal
sekrystal / Constructor.sol
Last active November 11, 2022 17:22
EVM Contract Construction Example 6
pragma solidity ^0.8.13;
...
balances[msg.sender] = totalSupply;
@sekrystal
sekrystal / AsciiArt.sol
Created November 11, 2022 15:23
EVM Contract Construction Example 7
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ +
| setup_code |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | |
@sekrystal
sekrystal / ConstructorArgument.sol
Created November 11, 2022 15:24
EVM Contract Construction Example 8
pragma solidity ^0.8.13;
contract MyCoin2 {
mapping(address => uint256) balances;
constructor(uint256 _totalSupply) {
balances[msg.sender] = _totalSupply;
}
}