Skip to content

Instantly share code, notes, and snippets.

@haziqAhmed7
Created March 27, 2021 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haziqAhmed7/a961b98f7ffb02c3252f1df13a7a111b to your computer and use it in GitHub Desktop.
Save haziqAhmed7/a961b98f7ffb02c3252f1df13a7a111b to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
The 'scripts' folder contains example async/await scripts for deploying the 'Storage' contract.
For the deployment of any other contract, 'contractName' and 'constructorArgs' should be updated (along with other code if required).
Scripts have full access to the web3.js and ethers.js libraries.
To run a script, right click on file name in the file explorer and click 'Run'. Remember, Solidity file must already be compiled.
Output from script will appear in remix terminal.
{
"deploy": {
"VM:-": {
"linkReferences": {},
"autoDeployLib": true
},
"main:1": {
"linkReferences": {},
"autoDeployLib": true
},
"ropsten:3": {
"linkReferences": {},
"autoDeployLib": true
},
"rinkeby:4": {
"linkReferences": {},
"autoDeployLib": true
},
"kovan:42": {
"linkReferences": {},
"autoDeployLib": true
},
"görli:5": {
"linkReferences": {},
"autoDeployLib": true
},
"Custom": {
"linkReferences": {},
"autoDeployLib": true
}
},
"data": {
"bytecode": {
"generatedSources": [],
"linkReferences": {},
"object": "6080604052629896806000556103e8600155600060025534801561002257600080fd5b506102ab806100326000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806310c51c1b1461005c578063cf6e328a1461008c578063df6386e8146100aa578063df7fedf7146100c8578063f64d49f4146100e6575b600080fd5b610076600480360381019061007191906101cf565b610116565b6040516100839190610207565b60405180910390f35b61009461015f565b6040516100a19190610207565b60405180910390f35b6100b2610165565b6040516100bf9190610207565b60405180910390f35b6100d061016b565b6040516100dd9190610207565b60405180910390f35b61010060048036038101906100fb91906101cf565b610171565b60405161010d9190610207565b60405180910390f35b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60025481565b60015481565b60005481565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000813590506101c98161025e565b92915050565b6000602082840312156101e157600080fd5b60006101ef848285016101ba565b91505092915050565b61020181610254565b82525050565b600060208201905061021c60008301846101f8565b92915050565b600061022d82610234565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61026781610222565b811461027257600080fd5b5056fea264697066735822122022a94207b533ecdd0850407f1208dac2acfc8b420f9b9fb59df1c9115876e39a64736f6c63430008010033",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE PUSH3 0x989680 PUSH1 0x0 SSTORE PUSH2 0x3E8 PUSH1 0x1 SSTORE PUSH1 0x0 PUSH1 0x2 SSTORE CALLVALUE DUP1 ISZERO PUSH2 0x22 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x2AB DUP1 PUSH2 0x32 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x57 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x10C51C1B EQ PUSH2 0x5C JUMPI DUP1 PUSH4 0xCF6E328A EQ PUSH2 0x8C JUMPI DUP1 PUSH4 0xDF6386E8 EQ PUSH2 0xAA JUMPI DUP1 PUSH4 0xDF7FEDF7 EQ PUSH2 0xC8 JUMPI DUP1 PUSH4 0xF64D49F4 EQ PUSH2 0xE6 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x76 PUSH1 0x4 DUP1 CALLDATASIZE SUB DUP2 ADD SWAP1 PUSH2 0x71 SWAP2 SWAP1 PUSH2 0x1CF JUMP JUMPDEST PUSH2 0x116 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x83 SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x94 PUSH2 0x15F JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xA1 SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0xB2 PUSH2 0x165 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xBF SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0xD0 PUSH2 0x16B JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xDD SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x100 PUSH1 0x4 DUP1 CALLDATASIZE SUB DUP2 ADD SWAP1 PUSH2 0xFB SWAP2 SWAP1 PUSH2 0x1CF JUMP JUMPDEST PUSH2 0x171 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x10D SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 PUSH1 0x4 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x2 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x1 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 PUSH1 0x3 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP2 CALLDATALOAD SWAP1 POP PUSH2 0x1C9 DUP2 PUSH2 0x25E JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x1E1 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x1EF DUP5 DUP3 DUP6 ADD PUSH2 0x1BA JUMP JUMPDEST SWAP2 POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH2 0x201 DUP2 PUSH2 0x254 JUMP JUMPDEST DUP3 MSTORE POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 ADD SWAP1 POP PUSH2 0x21C PUSH1 0x0 DUP4 ADD DUP5 PUSH2 0x1F8 JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x22D DUP3 PUSH2 0x234 JUMP JUMPDEST SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP3 AND SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP2 SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH2 0x267 DUP2 PUSH2 0x222 JUMP JUMPDEST DUP2 EQ PUSH2 0x272 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP JUMP INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x22 0xA9 TIMESTAMP SMOD 0xB5 CALLER 0xEC 0xDD ADDMOD POP BLOCKHASH PUSH32 0x1208DAC2ACFC8B420F9B9FB59DF1C9115876E39A64736F6C6343000801003300 ",
"sourceMap": "26:937:0:-:0;;;104:8;77:35;;147:4;118:33;;192:1;157:36;;26:937;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"generatedSources": [
{
"ast": {
"nodeType": "YulBlock",
"src": "0:1214:1",
"statements": [
{
"body": {
"nodeType": "YulBlock",
"src": "59:87:1",
"statements": [
{
"nodeType": "YulAssignment",
"src": "69:29:1",
"value": {
"arguments": [
{
"name": "offset",
"nodeType": "YulIdentifier",
"src": "91:6:1"
}
],
"functionName": {
"name": "calldataload",
"nodeType": "YulIdentifier",
"src": "78:12:1"
},
"nodeType": "YulFunctionCall",
"src": "78:20:1"
},
"variableNames": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "69:5:1"
}
]
},
{
"expression": {
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "134:5:1"
}
],
"functionName": {
"name": "validator_revert_t_address",
"nodeType": "YulIdentifier",
"src": "107:26:1"
},
"nodeType": "YulFunctionCall",
"src": "107:33:1"
},
"nodeType": "YulExpressionStatement",
"src": "107:33:1"
}
]
},
"name": "abi_decode_t_address",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "offset",
"nodeType": "YulTypedName",
"src": "37:6:1",
"type": ""
},
{
"name": "end",
"nodeType": "YulTypedName",
"src": "45:3:1",
"type": ""
}
],
"returnVariables": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "53:5:1",
"type": ""
}
],
"src": "7:139:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "218:196:1",
"statements": [
{
"body": {
"nodeType": "YulBlock",
"src": "264:16:1",
"statements": [
{
"expression": {
"arguments": [
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "273:1:1",
"type": "",
"value": "0"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "276:1:1",
"type": "",
"value": "0"
}
],
"functionName": {
"name": "revert",
"nodeType": "YulIdentifier",
"src": "266:6:1"
},
"nodeType": "YulFunctionCall",
"src": "266:12:1"
},
"nodeType": "YulExpressionStatement",
"src": "266:12:1"
}
]
},
"condition": {
"arguments": [
{
"arguments": [
{
"name": "dataEnd",
"nodeType": "YulIdentifier",
"src": "239:7:1"
},
{
"name": "headStart",
"nodeType": "YulIdentifier",
"src": "248:9:1"
}
],
"functionName": {
"name": "sub",
"nodeType": "YulIdentifier",
"src": "235:3:1"
},
"nodeType": "YulFunctionCall",
"src": "235:23:1"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "260:2:1",
"type": "",
"value": "32"
}
],
"functionName": {
"name": "slt",
"nodeType": "YulIdentifier",
"src": "231:3:1"
},
"nodeType": "YulFunctionCall",
"src": "231:32:1"
},
"nodeType": "YulIf",
"src": "228:2:1"
},
{
"nodeType": "YulBlock",
"src": "290:117:1",
"statements": [
{
"nodeType": "YulVariableDeclaration",
"src": "305:15:1",
"value": {
"kind": "number",
"nodeType": "YulLiteral",
"src": "319:1:1",
"type": "",
"value": "0"
},
"variables": [
{
"name": "offset",
"nodeType": "YulTypedName",
"src": "309:6:1",
"type": ""
}
]
},
{
"nodeType": "YulAssignment",
"src": "334:63:1",
"value": {
"arguments": [
{
"arguments": [
{
"name": "headStart",
"nodeType": "YulIdentifier",
"src": "369:9:1"
},
{
"name": "offset",
"nodeType": "YulIdentifier",
"src": "380:6:1"
}
],
"functionName": {
"name": "add",
"nodeType": "YulIdentifier",
"src": "365:3:1"
},
"nodeType": "YulFunctionCall",
"src": "365:22:1"
},
{
"name": "dataEnd",
"nodeType": "YulIdentifier",
"src": "389:7:1"
}
],
"functionName": {
"name": "abi_decode_t_address",
"nodeType": "YulIdentifier",
"src": "344:20:1"
},
"nodeType": "YulFunctionCall",
"src": "344:53:1"
},
"variableNames": [
{
"name": "value0",
"nodeType": "YulIdentifier",
"src": "334:6:1"
}
]
}
]
}
]
},
"name": "abi_decode_tuple_t_address",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "headStart",
"nodeType": "YulTypedName",
"src": "188:9:1",
"type": ""
},
{
"name": "dataEnd",
"nodeType": "YulTypedName",
"src": "199:7:1",
"type": ""
}
],
"returnVariables": [
{
"name": "value0",
"nodeType": "YulTypedName",
"src": "211:6:1",
"type": ""
}
],
"src": "152:262:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "485:53:1",
"statements": [
{
"expression": {
"arguments": [
{
"name": "pos",
"nodeType": "YulIdentifier",
"src": "502:3:1"
},
{
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "525:5:1"
}
],
"functionName": {
"name": "cleanup_t_uint256",
"nodeType": "YulIdentifier",
"src": "507:17:1"
},
"nodeType": "YulFunctionCall",
"src": "507:24:1"
}
],
"functionName": {
"name": "mstore",
"nodeType": "YulIdentifier",
"src": "495:6:1"
},
"nodeType": "YulFunctionCall",
"src": "495:37:1"
},
"nodeType": "YulExpressionStatement",
"src": "495:37:1"
}
]
},
"name": "abi_encode_t_uint256_to_t_uint256_fromStack",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "473:5:1",
"type": ""
},
{
"name": "pos",
"nodeType": "YulTypedName",
"src": "480:3:1",
"type": ""
}
],
"src": "420:118:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "642:124:1",
"statements": [
{
"nodeType": "YulAssignment",
"src": "652:26:1",
"value": {
"arguments": [
{
"name": "headStart",
"nodeType": "YulIdentifier",
"src": "664:9:1"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "675:2:1",
"type": "",
"value": "32"
}
],
"functionName": {
"name": "add",
"nodeType": "YulIdentifier",
"src": "660:3:1"
},
"nodeType": "YulFunctionCall",
"src": "660:18:1"
},
"variableNames": [
{
"name": "tail",
"nodeType": "YulIdentifier",
"src": "652:4:1"
}
]
},
{
"expression": {
"arguments": [
{
"name": "value0",
"nodeType": "YulIdentifier",
"src": "732:6:1"
},
{
"arguments": [
{
"name": "headStart",
"nodeType": "YulIdentifier",
"src": "745:9:1"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "756:1:1",
"type": "",
"value": "0"
}
],
"functionName": {
"name": "add",
"nodeType": "YulIdentifier",
"src": "741:3:1"
},
"nodeType": "YulFunctionCall",
"src": "741:17:1"
}
],
"functionName": {
"name": "abi_encode_t_uint256_to_t_uint256_fromStack",
"nodeType": "YulIdentifier",
"src": "688:43:1"
},
"nodeType": "YulFunctionCall",
"src": "688:71:1"
},
"nodeType": "YulExpressionStatement",
"src": "688:71:1"
}
]
},
"name": "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "headStart",
"nodeType": "YulTypedName",
"src": "614:9:1",
"type": ""
},
{
"name": "value0",
"nodeType": "YulTypedName",
"src": "626:6:1",
"type": ""
}
],
"returnVariables": [
{
"name": "tail",
"nodeType": "YulTypedName",
"src": "637:4:1",
"type": ""
}
],
"src": "544:222:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "817:51:1",
"statements": [
{
"nodeType": "YulAssignment",
"src": "827:35:1",
"value": {
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "856:5:1"
}
],
"functionName": {
"name": "cleanup_t_uint160",
"nodeType": "YulIdentifier",
"src": "838:17:1"
},
"nodeType": "YulFunctionCall",
"src": "838:24:1"
},
"variableNames": [
{
"name": "cleaned",
"nodeType": "YulIdentifier",
"src": "827:7:1"
}
]
}
]
},
"name": "cleanup_t_address",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "799:5:1",
"type": ""
}
],
"returnVariables": [
{
"name": "cleaned",
"nodeType": "YulTypedName",
"src": "809:7:1",
"type": ""
}
],
"src": "772:96:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "919:81:1",
"statements": [
{
"nodeType": "YulAssignment",
"src": "929:65:1",
"value": {
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "944:5:1"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "951:42:1",
"type": "",
"value": "0xffffffffffffffffffffffffffffffffffffffff"
}
],
"functionName": {
"name": "and",
"nodeType": "YulIdentifier",
"src": "940:3:1"
},
"nodeType": "YulFunctionCall",
"src": "940:54:1"
},
"variableNames": [
{
"name": "cleaned",
"nodeType": "YulIdentifier",
"src": "929:7:1"
}
]
}
]
},
"name": "cleanup_t_uint160",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "901:5:1",
"type": ""
}
],
"returnVariables": [
{
"name": "cleaned",
"nodeType": "YulTypedName",
"src": "911:7:1",
"type": ""
}
],
"src": "874:126:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "1051:32:1",
"statements": [
{
"nodeType": "YulAssignment",
"src": "1061:16:1",
"value": {
"name": "value",
"nodeType": "YulIdentifier",
"src": "1072:5:1"
},
"variableNames": [
{
"name": "cleaned",
"nodeType": "YulIdentifier",
"src": "1061:7:1"
}
]
}
]
},
"name": "cleanup_t_uint256",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "1033:5:1",
"type": ""
}
],
"returnVariables": [
{
"name": "cleaned",
"nodeType": "YulTypedName",
"src": "1043:7:1",
"type": ""
}
],
"src": "1006:77:1"
},
{
"body": {
"nodeType": "YulBlock",
"src": "1132:79:1",
"statements": [
{
"body": {
"nodeType": "YulBlock",
"src": "1189:16:1",
"statements": [
{
"expression": {
"arguments": [
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "1198:1:1",
"type": "",
"value": "0"
},
{
"kind": "number",
"nodeType": "YulLiteral",
"src": "1201:1:1",
"type": "",
"value": "0"
}
],
"functionName": {
"name": "revert",
"nodeType": "YulIdentifier",
"src": "1191:6:1"
},
"nodeType": "YulFunctionCall",
"src": "1191:12:1"
},
"nodeType": "YulExpressionStatement",
"src": "1191:12:1"
}
]
},
"condition": {
"arguments": [
{
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "1155:5:1"
},
{
"arguments": [
{
"name": "value",
"nodeType": "YulIdentifier",
"src": "1180:5:1"
}
],
"functionName": {
"name": "cleanup_t_address",
"nodeType": "YulIdentifier",
"src": "1162:17:1"
},
"nodeType": "YulFunctionCall",
"src": "1162:24:1"
}
],
"functionName": {
"name": "eq",
"nodeType": "YulIdentifier",
"src": "1152:2:1"
},
"nodeType": "YulFunctionCall",
"src": "1152:35:1"
}
],
"functionName": {
"name": "iszero",
"nodeType": "YulIdentifier",
"src": "1145:6:1"
},
"nodeType": "YulFunctionCall",
"src": "1145:43:1"
},
"nodeType": "YulIf",
"src": "1142:2:1"
}
]
},
"name": "validator_revert_t_address",
"nodeType": "YulFunctionDefinition",
"parameters": [
{
"name": "value",
"nodeType": "YulTypedName",
"src": "1125:5:1",
"type": ""
}
],
"src": "1089:122:1"
}
]
},
"contents": "{\n\n function abi_decode_t_address(offset, end) -> value {\n value := calldataload(offset)\n validator_revert_t_address(value)\n }\n\n function abi_decode_tuple_t_address(headStart, dataEnd) -> value0 {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n\n {\n\n let offset := 0\n\n value0 := abi_decode_t_address(add(headStart, offset), dataEnd)\n }\n\n }\n\n function abi_encode_t_uint256_to_t_uint256_fromStack(value, pos) {\n mstore(pos, cleanup_t_uint256(value))\n }\n\n function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart , value0) -> tail {\n tail := add(headStart, 32)\n\n abi_encode_t_uint256_to_t_uint256_fromStack(value0, add(headStart, 0))\n\n }\n\n function cleanup_t_address(value) -> cleaned {\n cleaned := cleanup_t_uint160(value)\n }\n\n function cleanup_t_uint160(value) -> cleaned {\n cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff)\n }\n\n function cleanup_t_uint256(value) -> cleaned {\n cleaned := value\n }\n\n function validator_revert_t_address(value) {\n if iszero(eq(value, cleanup_t_address(value))) { revert(0, 0) }\n }\n\n}\n",
"id": 1,
"language": "Yul",
"name": "#utility.yul"
}
],
"immutableReferences": {},
"linkReferences": {},
"object": "608060405234801561001057600080fd5b50600436106100575760003560e01c806310c51c1b1461005c578063cf6e328a1461008c578063df6386e8146100aa578063df7fedf7146100c8578063f64d49f4146100e6575b600080fd5b610076600480360381019061007191906101cf565b610116565b6040516100839190610207565b60405180910390f35b61009461015f565b6040516100a19190610207565b60405180910390f35b6100b2610165565b6040516100bf9190610207565b60405180910390f35b6100d061016b565b6040516100dd9190610207565b60405180910390f35b61010060048036038101906100fb91906101cf565b610171565b60405161010d9190610207565b60405180910390f35b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60025481565b60015481565b60005481565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000813590506101c98161025e565b92915050565b6000602082840312156101e157600080fd5b60006101ef848285016101ba565b91505092915050565b61020181610254565b82525050565b600060208201905061021c60008301846101f8565b92915050565b600061022d82610234565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61026781610222565b811461027257600080fd5b5056fea264697066735822122022a94207b533ecdd0850407f1208dac2acfc8b420f9b9fb59df1c9115876e39a64736f6c63430008010033",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x57 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x10C51C1B EQ PUSH2 0x5C JUMPI DUP1 PUSH4 0xCF6E328A EQ PUSH2 0x8C JUMPI DUP1 PUSH4 0xDF6386E8 EQ PUSH2 0xAA JUMPI DUP1 PUSH4 0xDF7FEDF7 EQ PUSH2 0xC8 JUMPI DUP1 PUSH4 0xF64D49F4 EQ PUSH2 0xE6 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x76 PUSH1 0x4 DUP1 CALLDATASIZE SUB DUP2 ADD SWAP1 PUSH2 0x71 SWAP2 SWAP1 PUSH2 0x1CF JUMP JUMPDEST PUSH2 0x116 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x83 SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x94 PUSH2 0x15F JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xA1 SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0xB2 PUSH2 0x165 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xBF SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0xD0 PUSH2 0x16B JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xDD SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x100 PUSH1 0x4 DUP1 CALLDATASIZE SUB DUP2 ADD SWAP1 PUSH2 0xFB SWAP2 SWAP1 PUSH2 0x1CF JUMP JUMPDEST PUSH2 0x171 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x10D SWAP2 SWAP1 PUSH2 0x207 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 PUSH1 0x4 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x2 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x1 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 PUSH1 0x3 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP2 CALLDATALOAD SWAP1 POP PUSH2 0x1C9 DUP2 PUSH2 0x25E JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x1E1 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x1EF DUP5 DUP3 DUP6 ADD PUSH2 0x1BA JUMP JUMPDEST SWAP2 POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH2 0x201 DUP2 PUSH2 0x254 JUMP JUMPDEST DUP3 MSTORE POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 ADD SWAP1 POP PUSH2 0x21C PUSH1 0x0 DUP4 ADD DUP5 PUSH2 0x1F8 JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x22D DUP3 PUSH2 0x234 JUMP JUMPDEST SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP3 AND SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP2 SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH2 0x267 DUP2 PUSH2 0x222 JUMP JUMPDEST DUP2 EQ PUSH2 0x272 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP JUMP INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x22 0xA9 TIMESTAMP SMOD 0xB5 CALLER 0xEC 0xDD ADDMOD POP BLOCKHASH PUSH32 0x1208DAC2ACFC8B420F9B9FB59DF1C9115876E39A64736F6C6343000801003300 ",
"sourceMap": "26:937:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;843:118;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;157:36;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;118:33;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;77:35;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;667:118;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;843;902:4;925:19;:29;945:8;925:29;;;;;;;;;;;;;;;;918:36;;843:118;;;:::o;157:36::-;;;;:::o;118:33::-;;;;:::o;77:35::-;;;;:::o;667:118::-;730:4;753:15;:25;769:8;753:25;;;;;;;;;;;;;;;;746:32;;667:118;;;:::o;7:139:1:-;;91:6;78:20;69:29;;107:33;134:5;107:33;:::i;:::-;59:87;;;;:::o;152:262::-;;260:2;248:9;239:7;235:23;231:32;228:2;;;276:1;273;266:12;228:2;319:1;344:53;389:7;380:6;369:9;365:22;344:53;:::i;:::-;334:63;;290:117;218:196;;;;:::o;420:118::-;507:24;525:5;507:24;:::i;:::-;502:3;495:37;485:53;;:::o;544:222::-;;675:2;664:9;660:18;652:26;;688:71;756:1;745:9;741:17;732:6;688:71;:::i;:::-;642:124;;;;:::o;772:96::-;;838:24;856:5;838:24;:::i;:::-;827:35;;817:51;;;:::o;874:126::-;;951:42;944:5;940:54;929:65;;919:81;;;:::o;1006:77::-;;1072:5;1061:16;;1051:32;;;:::o;1089:122::-;1162:24;1180:5;1162:24;:::i;:::-;1155:5;1152:35;1142:2;;1201:1;1198;1191:12;1142:2;1132:79;:::o"
},
"gasEstimates": {
"creation": {
"codeDepositCost": "136600",
"executionCost": "45201",
"totalCost": "181801"
},
"external": {
"equity_in_hadcoin(address)": "1607",
"equity_in_usd(address)": "1519",
"max_hadcoins()": "1173",
"total_hadcoin_bought()": "1129",
"usd_to_hadcoin()": "1151"
}
},
"methodIdentifiers": {
"equity_in_hadcoin(address)": "f64d49f4",
"equity_in_usd(address)": "10c51c1b",
"max_hadcoins()": "df7fedf7",
"total_hadcoin_bought()": "cf6e328a",
"usd_to_hadcoin()": "df6386e8"
}
},
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "investor",
"type": "address"
}
],
"name": "equity_in_hadcoin",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "investor",
"type": "address"
}
],
"name": "equity_in_usd",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "max_hadcoins",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "total_hadcoin_bought",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "usd_to_hadcoin",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
}
{
"compiler": {
"version": "0.8.1+commit.df193b15"
},
"language": "Solidity",
"output": {
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "investor",
"type": "address"
}
],
"name": "equity_in_hadcoin",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "investor",
"type": "address"
}
],
"name": "equity_in_usd",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "max_hadcoins",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "total_hadcoin_bought",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "usd_to_hadcoin",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
},
"settings": {
"compilationTarget": {
"contracts/headcoin-ico.sol": "hadcoin_ico"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
},
"sources": {
"contracts/headcoin-ico.sol": {
"keccak256": "0xdde0f6e18d970c50a402c595aae6236930107b25c2ccdb192ac5392c88357d8f",
"urls": [
"bzz-raw://f38d24af4aef033c6ef5e4ab7b71c688ed44559bb01bba34b64f6bf0b60592ff",
"dweb:/ipfs/Qmdj7NNpBikz9X2WXcwCHXaSTxPUFPULNxmdXhNhDCA9q3"
]
}
},
"version": 1
}
pragma solidity ^0.8.1;
contract hadcoin_ico {
// public variables
uint public max_hadcoins = 10000000;
uint public usd_to_hadcoin = 1000;
uint public total_hadcoin_bought = 0;
// private variables
// mapping from the investor address to the USD conversion of hadcoin
mapping(address => uint) investor_equity;
mapping(address => uint) investor_equity_usd;
// checking if an investor can buy more hadcoin
modifier can_buy_hadcoin(uint usd_invested) {
require(usd_invested * usd_to_hadcoin + total_hadcoin_bought <= max_hadcoins);
_;
}
// getting the equity in hadcoin of an investor
function equity_in_hadcoin(address investor) external returns (uint) {
return investor_equity[investor];
}
// getting the equity in USD of an investor
function equity_in_usd(address investor) external returns (uint) {
return investor_equity_usd[investor];
}
}
// Right click on the script name and hit "Run" to execute
(async () => {
try {
console.log('Running deployWithEthers script...')
const contractName = 'Storage' // Change this for other contract
const constructorArgs = [] // Put constructor args (if any) here for your contract
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer);
let contract = await factory.deploy(...constructorArgs);
console.log('Contract Address: ', contract.address);
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
console.log('Deployment successful.')
} catch (e) {
console.log(e.message)
}
})()
// Right click on the script name and hit "Run" to execute
(async () => {
try {
console.log('Running deployWithWeb3 script...')
const contractName = 'Storage' // Change this for other contract
const constructorArgs = [] // Put constructor args (if any) here for your contract
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
const accounts = await web3.eth.getAccounts()
let contract = new web3.eth.Contract(metadata.abi)
contract = contract.deploy({
data: metadata.data.bytecode.object,
arguments: constructorArgs
})
const newContractInstance = await contract.send({
from: accounts[0],
gas: 1500000,
gasPrice: '30000000000'
})
console.log('Contract deployed at address: ', newContractInstance.options.address)
} catch (e) {
console.log(e.message)
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment