Created
July 28, 2021 20:06
-
-
Save Matarwy/933c6fbe6403e533326f5e7bb0b0e153 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.4.26+commit.4563c3fc.js&optimize=true&runs=200&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Storage | |
* @dev Store & retrieve value in a variable | |
*/ | |
contract Storage { | |
uint256 number; | |
/** | |
* @dev Store value in variable | |
* @param num value to store | |
*/ | |
function store(uint256 num) public { | |
number = num; | |
} | |
/** | |
* @dev Return value | |
* @return value of 'number' | |
*/ | |
function retrieve() public view returns (uint256){ | |
return number; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Owner | |
* @dev Set & change owner | |
*/ | |
contract Owner { | |
address private owner; | |
// event for EVM logging | |
event OwnerSet(address indexed oldOwner, address indexed newOwner); | |
// modifier to check if caller is owner | |
modifier isOwner() { | |
// If the first argument of 'require' evaluates to 'false', execution terminates and all | |
// changes to the state and to Ether balances are reverted. | |
// This used to consume all gas in old EVM versions, but not anymore. | |
// It is often a good idea to use 'require' to check if functions are called correctly. | |
// As a second argument, you can also provide an explanation about what went wrong. | |
require(msg.sender == owner, "Caller is not owner"); | |
_; | |
} | |
/** | |
* @dev Set contract deployer as owner | |
*/ | |
constructor() { | |
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor | |
emit OwnerSet(address(0), owner); | |
} | |
/** | |
* @dev Change owner | |
* @param newOwner address of new owner | |
*/ | |
function changeOwner(address newOwner) public isOwner { | |
emit OwnerSet(owner, newOwner); | |
owner = newOwner; | |
} | |
/** | |
* @dev Return owner address | |
* @return address of owner | |
*/ | |
function getOwner() external view returns (address) { | |
return owner; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Ballot | |
* @dev Implements voting process along with vote delegation | |
*/ | |
contract Ballot { | |
struct Voter { | |
uint weight; // weight is accumulated by delegation | |
bool voted; // if true, that person already voted | |
address delegate; // person delegated to | |
uint vote; // index of the voted proposal | |
} | |
struct Proposal { | |
// If you can limit the length to a certain number of bytes, | |
// always use one of bytes1 to bytes32 because they are much cheaper | |
bytes32 name; // short name (up to 32 bytes) | |
uint voteCount; // number of accumulated votes | |
} | |
address public chairperson; | |
mapping(address => Voter) public voters; | |
Proposal[] public proposals; | |
/** | |
* @dev Create a new ballot to choose one of 'proposalNames'. | |
* @param proposalNames names of proposals | |
*/ | |
constructor(bytes32[] memory proposalNames) { | |
chairperson = msg.sender; | |
voters[chairperson].weight = 1; | |
for (uint i = 0; i < proposalNames.length; i++) { | |
// 'Proposal({...})' creates a temporary | |
// Proposal object and 'proposals.push(...)' | |
// appends it to the end of 'proposals'. | |
proposals.push(Proposal({ | |
name: proposalNames[i], | |
voteCount: 0 | |
})); | |
} | |
} | |
/** | |
* @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. | |
* @param voter address of voter | |
*/ | |
function giveRightToVote(address voter) public { | |
require( | |
msg.sender == chairperson, | |
"Only chairperson can give right to vote." | |
); | |
require( | |
!voters[voter].voted, | |
"The voter already voted." | |
); | |
require(voters[voter].weight == 0); | |
voters[voter].weight = 1; | |
} | |
/** | |
* @dev Delegate your vote to the voter 'to'. | |
* @param to address to which vote is delegated | |
*/ | |
function delegate(address to) public { | |
Voter storage sender = voters[msg.sender]; | |
require(!sender.voted, "You already voted."); | |
require(to != msg.sender, "Self-delegation is disallowed."); | |
while (voters[to].delegate != address(0)) { | |
to = voters[to].delegate; | |
// We found a loop in the delegation, not allowed. | |
require(to != msg.sender, "Found loop in delegation."); | |
} | |
sender.voted = true; | |
sender.delegate = to; | |
Voter storage delegate_ = voters[to]; | |
if (delegate_.voted) { | |
// If the delegate already voted, | |
// directly add to the number of votes | |
proposals[delegate_.vote].voteCount += sender.weight; | |
} else { | |
// If the delegate did not vote yet, | |
// add to her weight. | |
delegate_.weight += sender.weight; | |
} | |
} | |
/** | |
* @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. | |
* @param proposal index of proposal in the proposals array | |
*/ | |
function vote(uint proposal) public { | |
Voter storage sender = voters[msg.sender]; | |
require(sender.weight != 0, "Has no right to vote"); | |
require(!sender.voted, "Already voted."); | |
sender.voted = true; | |
sender.vote = proposal; | |
// If 'proposal' is out of the range of the array, | |
// this will throw automatically and revert all | |
// changes. | |
proposals[proposal].voteCount += sender.weight; | |
} | |
/** | |
* @dev Computes the winning proposal taking all previous votes into account. | |
* @return winningProposal_ index of winning proposal in the proposals array | |
*/ | |
function winningProposal() public view | |
returns (uint winningProposal_) | |
{ | |
uint winningVoteCount = 0; | |
for (uint p = 0; p < proposals.length; p++) { | |
if (proposals[p].voteCount > winningVoteCount) { | |
winningVoteCount = proposals[p].voteCount; | |
winningProposal_ = p; | |
} | |
} | |
} | |
/** | |
* @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then | |
* @return winnerName_ the name of the winner | |
*/ | |
function winnerName() public view | |
returns (bytes32 winnerName_) | |
{ | |
winnerName_ = proposals[winningProposal()].name; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": { | |
"linkReferences": {}, | |
"object": "608060405234801561001057600080fd5b5060405160608061040f8339810160409081528151602083015191909201516000831161003c57600080fd5b600160a060020a038216151561005157600080fd5b600160a060020a038116151561006657600080fd5b60029290925560018054600160a060020a03928316600160a060020a03199182161790915560008054939092169216919091179055610365806100aa6000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632c4e722e81146100775780634042b66f1461009e578063521eb273146100b3578063ec8ac4d8146100e4578063fc0c546a146100f8575b6100753361010d565b005b34801561008357600080fd5b5061008c6101af565b60408051918252519081900360200190f35b3480156100aa57600080fd5b5061008c6101b5565b3480156100bf57600080fd5b506100c86101bb565b60408051600160a060020a039092168252519081900360200190f35b610075600160a060020a036004351661010d565b34801561010457600080fd5b506100c86101ca565b34600061011a83836101d9565b610123826101fe565b600354909150610139908363ffffffff61021b16565b6003556101468382610228565b60408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a361019883836101fa565b6101a0610232565b6101aa83836101fa565b505050565b60025481565b60035481565b600154600160a060020a031681565b600054600160a060020a031681565b600160a060020a03821615156101ee57600080fd5b8015156101fa57600080fd5b5050565b60006102156002548361026e90919063ffffffff16565b92915050565b8181018281101561021557fe5b6101fa8282610297565b600154604051600160a060020a03909116903480156108fc02916000818181858888f1935050505015801561026b573d6000803e3d6000fd5b50565b600082151561027f57506000610215565b5081810281838281151561028f57fe5b041461021557fe5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690529151919092169263a9059cbb92604480820193602093909283900390910190829087803b15801561030957600080fd5b505af115801561031d573d6000803e3d6000fd5b505050506040513d602081101561033357600080fd5b505050505600a165627a7a723058209275b881e15cfb6c8c6a8e2d9bc5ea476451562252b269d33a3b3b55283763ff0029", | |
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x40 MLOAD PUSH1 0x60 DUP1 PUSH2 0x40F DUP4 CODECOPY DUP2 ADD PUSH1 0x40 SWAP1 DUP2 MSTORE DUP2 MLOAD PUSH1 0x20 DUP4 ADD MLOAD SWAP2 SWAP1 SWAP3 ADD MLOAD PUSH1 0x0 DUP4 GT PUSH2 0x3C JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP3 AND ISZERO ISZERO PUSH2 0x51 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP2 AND ISZERO ISZERO PUSH2 0x66 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x2 SWAP3 SWAP1 SWAP3 SSTORE PUSH1 0x1 DUP1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP3 DUP4 AND PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT SWAP2 DUP3 AND OR SWAP1 SWAP2 SSTORE PUSH1 0x0 DUP1 SLOAD SWAP4 SWAP1 SWAP3 AND SWAP3 AND SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE PUSH2 0x365 DUP1 PUSH2 0xAA PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x6C JUMPI PUSH4 0xFFFFFFFF PUSH29 0x100000000000000000000000000000000000000000000000000000000 PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x2C4E722E DUP2 EQ PUSH2 0x77 JUMPI DUP1 PUSH4 0x4042B66F EQ PUSH2 0x9E JUMPI DUP1 PUSH4 0x521EB273 EQ PUSH2 0xB3 JUMPI DUP1 PUSH4 0xEC8AC4D8 EQ PUSH2 0xE4 JUMPI DUP1 PUSH4 0xFC0C546A EQ PUSH2 0xF8 JUMPI JUMPDEST PUSH2 0x75 CALLER PUSH2 0x10D JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x83 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x8C PUSH2 0x1AF JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xAA JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x8C PUSH2 0x1B5 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xBF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xC8 PUSH2 0x1BB JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP3 AND DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST PUSH2 0x75 PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB PUSH1 0x4 CALLDATALOAD AND PUSH2 0x10D JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x104 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xC8 PUSH2 0x1CA JUMP JUMPDEST CALLVALUE PUSH1 0x0 PUSH2 0x11A DUP4 DUP4 PUSH2 0x1D9 JUMP JUMPDEST PUSH2 0x123 DUP3 PUSH2 0x1FE JUMP JUMPDEST PUSH1 0x3 SLOAD SWAP1 SWAP2 POP PUSH2 0x139 SWAP1 DUP4 PUSH4 0xFFFFFFFF PUSH2 0x21B AND JUMP JUMPDEST PUSH1 0x3 SSTORE PUSH2 0x146 DUP4 DUP3 PUSH2 0x228 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD DUP4 DUP2 MSTORE PUSH1 0x20 DUP2 ADD DUP4 SWAP1 MSTORE DUP2 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP7 AND SWAP3 CALLER SWAP3 PUSH32 0x623B3804FA71D67900D064613DA8F94B9617215EE90799290593E1745087AD18 SWAP3 SWAP1 DUP2 SWAP1 SUB SWAP1 SWAP2 ADD SWAP1 LOG3 PUSH2 0x198 DUP4 DUP4 PUSH2 0x1FA JUMP JUMPDEST PUSH2 0x1A0 PUSH2 0x232 JUMP JUMPDEST PUSH2 0x1AA DUP4 DUP4 PUSH2 0x1FA JUMP JUMPDEST POP POP POP JUMP JUMPDEST PUSH1 0x2 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x3 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP3 AND ISZERO ISZERO PUSH2 0x1EE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP1 ISZERO ISZERO PUSH2 0x1FA JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x215 PUSH1 0x2 SLOAD DUP4 PUSH2 0x26E SWAP1 SWAP2 SWAP1 PUSH4 0xFFFFFFFF AND JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST DUP2 DUP2 ADD DUP3 DUP2 LT ISZERO PUSH2 0x215 JUMPI INVALID JUMPDEST PUSH2 0x1FA DUP3 DUP3 PUSH2 0x297 JUMP JUMPDEST PUSH1 0x1 SLOAD PUSH1 0x40 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP2 AND SWAP1 CALLVALUE DUP1 ISZERO PUSH2 0x8FC MUL SWAP2 PUSH1 0x0 DUP2 DUP2 DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH2 0x26B JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP JUMP JUMPDEST PUSH1 0x0 DUP3 ISZERO ISZERO PUSH2 0x27F JUMPI POP PUSH1 0x0 PUSH2 0x215 JUMP JUMPDEST POP DUP2 DUP2 MUL DUP2 DUP4 DUP3 DUP2 ISZERO ISZERO PUSH2 0x28F JUMPI INVALID JUMPDEST DIV EQ PUSH2 0x215 JUMPI INVALID JUMPDEST PUSH1 0x0 DUP1 SLOAD PUSH1 0x40 DUP1 MLOAD PUSH32 0xA9059CBB00000000000000000000000000000000000000000000000000000000 DUP2 MSTORE PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP7 DUP2 AND PUSH1 0x4 DUP4 ADD MSTORE PUSH1 0x24 DUP3 ADD DUP7 SWAP1 MSTORE SWAP2 MLOAD SWAP2 SWAP1 SWAP3 AND SWAP3 PUSH4 0xA9059CBB SWAP3 PUSH1 0x44 DUP1 DUP3 ADD SWAP4 PUSH1 0x20 SWAP4 SWAP1 SWAP3 DUP4 SWAP1 SUB SWAP1 SWAP2 ADD SWAP1 DUP3 SWAP1 DUP8 DUP1 EXTCODESIZE ISZERO DUP1 ISZERO PUSH2 0x309 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP GAS CALL ISZERO DUP1 ISZERO PUSH2 0x31D JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP POP POP PUSH1 0x40 MLOAD RETURNDATASIZE PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x333 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP POP POP POP JUMP STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 SWAP3 PUSH22 0xB881E15CFB6C8C6A8E2D9BC5EA476451562252B269D3 GASPRICE EXTCODESIZE EXTCODESIZE SSTORE 0x28 CALLDATACOPY PUSH4 0xFF002900 ", | |
"sourceMap": "2727:4751:0:-;;;3573:226;8:9:-1;5:2;;;30:1;27;20:12;5:2;3573:226:0;;;;;;;;;;;;;;;;;;;;;;;;;3660:1;3652:9;;3644:18;;;;;;-1:-1:-1;;;;;3676:21:0;;;;3668:30;;;;;;-1:-1:-1;;;;;3712:20:0;;;;3704:29;;;;;;3740:4;:12;;;;3758:6;:16;;-1:-1:-1;;;;;3758:16:0;;;-1:-1:-1;;;;;;3758:16:0;;;;;;;:6;3780:14;;;;;;;;;;;;;;2727:4751;;;;;;" | |
}, | |
"deployedBytecode": { | |
"linkReferences": {}, | |
"object": "60806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632c4e722e81146100775780634042b66f1461009e578063521eb273146100b3578063ec8ac4d8146100e4578063fc0c546a146100f8575b6100753361010d565b005b34801561008357600080fd5b5061008c6101af565b60408051918252519081900360200190f35b3480156100aa57600080fd5b5061008c6101b5565b3480156100bf57600080fd5b506100c86101bb565b60408051600160a060020a039092168252519081900360200190f35b610075600160a060020a036004351661010d565b34801561010457600080fd5b506100c86101ca565b34600061011a83836101d9565b610123826101fe565b600354909150610139908363ffffffff61021b16565b6003556101468382610228565b60408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a361019883836101fa565b6101a0610232565b6101aa83836101fa565b505050565b60025481565b60035481565b600154600160a060020a031681565b600054600160a060020a031681565b600160a060020a03821615156101ee57600080fd5b8015156101fa57600080fd5b5050565b60006102156002548361026e90919063ffffffff16565b92915050565b8181018281101561021557fe5b6101fa8282610297565b600154604051600160a060020a03909116903480156108fc02916000818181858888f1935050505015801561026b573d6000803e3d6000fd5b50565b600082151561027f57506000610215565b5081810281838281151561028f57fe5b041461021557fe5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690529151919092169263a9059cbb92604480820193602093909283900390910190829087803b15801561030957600080fd5b505af115801561031d573d6000803e3d6000fd5b505050506040513d602081101561033357600080fd5b505050505600a165627a7a723058209275b881e15cfb6c8c6a8e2d9bc5ea476451562252b269d33a3b3b55283763ff0029", | |
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x6C JUMPI PUSH4 0xFFFFFFFF PUSH29 0x100000000000000000000000000000000000000000000000000000000 PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x2C4E722E DUP2 EQ PUSH2 0x77 JUMPI DUP1 PUSH4 0x4042B66F EQ PUSH2 0x9E JUMPI DUP1 PUSH4 0x521EB273 EQ PUSH2 0xB3 JUMPI DUP1 PUSH4 0xEC8AC4D8 EQ PUSH2 0xE4 JUMPI DUP1 PUSH4 0xFC0C546A EQ PUSH2 0xF8 JUMPI JUMPDEST PUSH2 0x75 CALLER PUSH2 0x10D JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x83 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x8C PUSH2 0x1AF JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xAA JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x8C PUSH2 0x1B5 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xBF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xC8 PUSH2 0x1BB JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP3 AND DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST PUSH2 0x75 PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB PUSH1 0x4 CALLDATALOAD AND PUSH2 0x10D JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x104 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xC8 PUSH2 0x1CA JUMP JUMPDEST CALLVALUE PUSH1 0x0 PUSH2 0x11A DUP4 DUP4 PUSH2 0x1D9 JUMP JUMPDEST PUSH2 0x123 DUP3 PUSH2 0x1FE JUMP JUMPDEST PUSH1 0x3 SLOAD SWAP1 SWAP2 POP PUSH2 0x139 SWAP1 DUP4 PUSH4 0xFFFFFFFF PUSH2 0x21B AND JUMP JUMPDEST PUSH1 0x3 SSTORE PUSH2 0x146 DUP4 DUP3 PUSH2 0x228 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD DUP4 DUP2 MSTORE PUSH1 0x20 DUP2 ADD DUP4 SWAP1 MSTORE DUP2 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP7 AND SWAP3 CALLER SWAP3 PUSH32 0x623B3804FA71D67900D064613DA8F94B9617215EE90799290593E1745087AD18 SWAP3 SWAP1 DUP2 SWAP1 SUB SWAP1 SWAP2 ADD SWAP1 LOG3 PUSH2 0x198 DUP4 DUP4 PUSH2 0x1FA JUMP JUMPDEST PUSH2 0x1A0 PUSH2 0x232 JUMP JUMPDEST PUSH2 0x1AA DUP4 DUP4 PUSH2 0x1FA JUMP JUMPDEST POP POP POP JUMP JUMPDEST PUSH1 0x2 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x3 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP3 AND ISZERO ISZERO PUSH2 0x1EE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP1 ISZERO ISZERO PUSH2 0x1FA JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x215 PUSH1 0x2 SLOAD DUP4 PUSH2 0x26E SWAP1 SWAP2 SWAP1 PUSH4 0xFFFFFFFF AND JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST DUP2 DUP2 ADD DUP3 DUP2 LT ISZERO PUSH2 0x215 JUMPI INVALID JUMPDEST PUSH2 0x1FA DUP3 DUP3 PUSH2 0x297 JUMP JUMPDEST PUSH1 0x1 SLOAD PUSH1 0x40 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP2 AND SWAP1 CALLVALUE DUP1 ISZERO PUSH2 0x8FC MUL SWAP2 PUSH1 0x0 DUP2 DUP2 DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH2 0x26B JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP JUMP JUMPDEST PUSH1 0x0 DUP3 ISZERO ISZERO PUSH2 0x27F JUMPI POP PUSH1 0x0 PUSH2 0x215 JUMP JUMPDEST POP DUP2 DUP2 MUL DUP2 DUP4 DUP3 DUP2 ISZERO ISZERO PUSH2 0x28F JUMPI INVALID JUMPDEST DIV EQ PUSH2 0x215 JUMPI INVALID JUMPDEST PUSH1 0x0 DUP1 SLOAD PUSH1 0x40 DUP1 MLOAD PUSH32 0xA9059CBB00000000000000000000000000000000000000000000000000000000 DUP2 MSTORE PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP7 DUP2 AND PUSH1 0x4 DUP4 ADD MSTORE PUSH1 0x24 DUP3 ADD DUP7 SWAP1 MSTORE SWAP2 MLOAD SWAP2 SWAP1 SWAP3 AND SWAP3 PUSH4 0xA9059CBB SWAP3 PUSH1 0x44 DUP1 DUP3 ADD SWAP4 PUSH1 0x20 SWAP4 SWAP1 SWAP3 DUP4 SWAP1 SUB SWAP1 SWAP2 ADD SWAP1 DUP3 SWAP1 DUP8 DUP1 EXTCODESIZE ISZERO DUP1 ISZERO PUSH2 0x309 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP GAS CALL ISZERO DUP1 ISZERO PUSH2 0x31D JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP POP POP PUSH1 0x40 MLOAD RETURNDATASIZE PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x333 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP POP POP POP JUMP STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 SWAP3 PUSH22 0xB881E15CFB6C8C6A8E2D9BC5EA476451562252B269D3 GASPRICE EXTCODESIZE EXTCODESIZE SSTORE 0x28 CALLDATACOPY PUSH4 0xFF002900 ", | |
"sourceMap": "2727:4751:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4029:21;4039:10;4029:9;:21::i;:::-;2727:4751;2942:19;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2942:19:0;;;;;;;;;;;;;;;;;;;;2992:24;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2992:24:0;;;;2869:21;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2869:21:0;;;;;;;;-1:-1:-1;;;;;2869:21:0;;;;;;;;;;;;;;4191:577;;-1:-1:-1;;;;;4191:577:0;;;;;2807:18;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2807:18:0;;;;4191:577;4274:9;4254:17;4289:45;4310:12;4274:9;4289:20;:45::i;:::-;4402:26;4418:9;4402:15;:26::i;:::-;4467:9;;4385:43;;-1:-1:-1;4467:24:0;;4481:9;4467:24;:13;:24;:::i;:::-;4455:9;:36;4498:38;4515:12;4529:6;4498:16;:38::i;:::-;4547:88;;;;;;;;;;;;;;-1:-1:-1;;;;;4547:88:0;;;4568:10;;4547:88;;;;;;;;;;;4642:47;4665:12;4679:9;4642:22;:47::i;:::-;4696:15;:13;:15::i;:::-;4717:46;4739:12;4753:9;4717:21;:46::i;:::-;4191:577;;;:::o;2942:19::-;;;;:::o;2992:24::-;;;;:::o;2869:21::-;;;-1:-1:-1;;;;;2869:21:0;;:::o;2807:18::-;;;-1:-1:-1;;;;;2807:18:0;;:::o;5192:175::-;-1:-1:-1;;;;;5305:26:0;;;;5297:35;;;;;;5346:15;;;5338:24;;;;;;5192:175;;:::o;7205:121::-;7277:7;7301:20;7316:4;;7301:10;:14;;:20;;;;:::i;:::-;7294:27;7205:121;-1:-1:-1;;7205:121:0:o;1007:123::-;1086:5;;;1104:6;;;;1097:14;;;6433:150;6536:42;6551:12;6565;6536:14;:42::i;7405:71::-;7445:6;;:26;;-1:-1:-1;;;;;7445:6:0;;;;7461:9;7445:26;;;;;:6;:26;:6;:26;7461:9;7445:6;:26;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7445:26:0;7405:71::o;202:167::-;260:9;281:6;;277:35;;;-1:-1:-1;304:1:0;297:8;;277:35;-1:-1:-1;321:5:0;;;325:1;321;:5;339;;;;;;;;:10;332:18;;;6038:148;6139:5;;;:42;;;;;;-1:-1:-1;;;;;6139:42:0;;;;;;;;;;;;;;;:5;;;;;:14;;:42;;;;;;;;;;;;;;;;;;:5;:42;;;5:2:-1;;;;30:1;27;20:12;5:2;6139:42:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;6139:42:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;;;6038:148:0:o" | |
}, | |
"gasEstimates": { | |
"creation": { | |
"codeDepositCost": "173800", | |
"executionCost": "61151", | |
"totalCost": "234951" | |
}, | |
"external": { | |
"": "infinite", | |
"buyTokens(address)": "infinite", | |
"rate()": "384", | |
"token()": "625", | |
"wallet()": "581", | |
"weiRaised()": "406" | |
}, | |
"internal": { | |
"_deliverTokens(address,uint256)": "infinite", | |
"_forwardFunds()": "infinite", | |
"_getTokenAmount(uint256)": "infinite", | |
"_postValidatePurchase(address,uint256)": "infinite", | |
"_preValidatePurchase(address,uint256)": "134", | |
"_processPurchase(address,uint256)": "infinite", | |
"_updatePurchasingState(address,uint256)": "infinite" | |
} | |
}, | |
"methodIdentifiers": { | |
"buyTokens(address)": "ec8ac4d8", | |
"rate()": "2c4e722e", | |
"token()": "fc0c546a", | |
"wallet()": "521eb273", | |
"weiRaised()": "4042b66f" | |
} | |
}, | |
"abi": [ | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "rate", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "weiRaised", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "wallet", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "_beneficiary", | |
"type": "address" | |
} | |
], | |
"name": "buyTokens", | |
"outputs": [], | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "token", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"name": "_rate", | |
"type": "uint256" | |
}, | |
{ | |
"name": "_wallet", | |
"type": "address" | |
}, | |
{ | |
"name": "_token", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "fallback" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"name": "purchaser", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"name": "beneficiary", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
}, | |
{ | |
"indexed": false, | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "TokenPurchase", | |
"type": "event" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compiler": { | |
"version": "0.4.26+commit.4563c3fc" | |
}, | |
"language": "Solidity", | |
"output": { | |
"abi": [ | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "rate", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "weiRaised", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "wallet", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "_beneficiary", | |
"type": "address" | |
} | |
], | |
"name": "buyTokens", | |
"outputs": [], | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "token", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"name": "_rate", | |
"type": "uint256" | |
}, | |
{ | |
"name": "_wallet", | |
"type": "address" | |
}, | |
{ | |
"name": "_token", | |
"type": "address" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "fallback" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"name": "purchaser", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"name": "beneficiary", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
}, | |
{ | |
"indexed": false, | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "TokenPurchase", | |
"type": "event" | |
} | |
], | |
"devdoc": { | |
"methods": { | |
"buyTokens(address)": { | |
"details": "low level token purchase ***DO NOT OVERRIDE***", | |
"params": { | |
"_beneficiary": "Address performing the token purchase" | |
} | |
} | |
}, | |
"title": "Crowdsale" | |
}, | |
"userdoc": { | |
"methods": {} | |
} | |
}, | |
"settings": { | |
"compilationTarget": { | |
"contracts/ICO/ico.sol": "Crowdsale" | |
}, | |
"evmVersion": "byzantium", | |
"libraries": {}, | |
"optimizer": { | |
"enabled": true, | |
"runs": 200 | |
}, | |
"remappings": [] | |
}, | |
"sources": { | |
"contracts/ICO/ico.sol": { | |
"keccak256": "0xeb753831d768e27eecbc5ae9d715caeeaccca2475e6b4910ed975d0825ce26a2", | |
"urls": [ | |
"bzzr://1a0da438401c266282e5b8fddd9aa46ac5489a61f2c084255cfd7511a8c7f3d0" | |
] | |
} | |
}, | |
"version": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": { | |
"linkReferences": {}, | |
"object": "", | |
"opcodes": "", | |
"sourceMap": "" | |
}, | |
"deployedBytecode": { | |
"linkReferences": {}, | |
"object": "", | |
"opcodes": "", | |
"sourceMap": "" | |
}, | |
"gasEstimates": null, | |
"methodIdentifiers": { | |
"allowance(address,address)": "dd62ed3e", | |
"approve(address,uint256)": "095ea7b3", | |
"balanceOf(address)": "70a08231", | |
"totalSupply()": "18160ddd", | |
"transfer(address,uint256)": "a9059cbb", | |
"transferFrom(address,address,uint256)": "23b872dd" | |
} | |
}, | |
"abi": [ | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "approve", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transferFrom", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"name": "who", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transfer", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"name": "spender", | |
"type": "address" | |
} | |
], | |
"name": "allowance", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Approval", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compiler": { | |
"version": "0.5.17+commit.d19bba13" | |
}, | |
"language": "Solidity", | |
"output": { | |
"abi": [ | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Approval", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
} | |
], | |
"name": "allowance", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "approve", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "who", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transfer", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transferFrom", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
} | |
], | |
"devdoc": { | |
"details": "see https://github.com/ethereum/EIPs/issues/20", | |
"methods": {}, | |
"title": "ERC20 interface" | |
}, | |
"userdoc": { | |
"methods": {} | |
} | |
}, | |
"settings": { | |
"compilationTarget": { | |
"contracts/ICO/ico.sol": "ERC20" | |
}, | |
"evmVersion": "istanbul", | |
"libraries": {}, | |
"optimizer": { | |
"enabled": true, | |
"runs": 200 | |
}, | |
"remappings": [] | |
}, | |
"sources": { | |
"contracts/ICO/ico.sol": { | |
"keccak256": "0xb0a50384ed8b6049615a2e90fb9d8d52cb2aba3174b1a2efdc15c785fd98bfda", | |
"urls": [ | |
"bzz-raw://72d2b51e87fbc1419844de6aeec038c2a84996038d47739e4236ea115936a789", | |
"dweb:/ipfs/QmX8mMVfRoBihztchDLc4uiHsrvytU27izUgrkreihb9Bj" | |
] | |
} | |
}, | |
"version": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": { | |
"linkReferences": {}, | |
"object": "", | |
"opcodes": "", | |
"sourceMap": "" | |
}, | |
"deployedBytecode": { | |
"linkReferences": {}, | |
"object": "", | |
"opcodes": "", | |
"sourceMap": "" | |
}, | |
"gasEstimates": null, | |
"methodIdentifiers": { | |
"balanceOf(address)": "70a08231", | |
"totalSupply()": "18160ddd", | |
"transfer(address,uint256)": "a9059cbb" | |
} | |
}, | |
"abi": [ | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"name": "who", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transfer", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compiler": { | |
"version": "0.5.17+commit.d19bba13" | |
}, | |
"language": "Solidity", | |
"output": { | |
"abi": [ | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
}, | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "who", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "transfer", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
} | |
], | |
"devdoc": { | |
"details": "Simpler version of ERC20 interfacesee https://github.com/ethereum/EIPs/issues/179", | |
"methods": {}, | |
"title": "ERC20Basic" | |
}, | |
"userdoc": { | |
"methods": {} | |
} | |
}, | |
"settings": { | |
"compilationTarget": { | |
"contracts/ICO/ico.sol": "ERC20Basic" | |
}, | |
"evmVersion": "istanbul", | |
"libraries": {}, | |
"optimizer": { | |
"enabled": true, | |
"runs": 200 | |
}, | |
"remappings": [] | |
}, | |
"sources": { | |
"contracts/ICO/ico.sol": { | |
"keccak256": "0xb0a50384ed8b6049615a2e90fb9d8d52cb2aba3174b1a2efdc15c785fd98bfda", | |
"urls": [ | |
"bzz-raw://72d2b51e87fbc1419844de6aeec038c2a84996038d47739e4236ea115936a789", | |
"dweb:/ipfs/QmX8mMVfRoBihztchDLc4uiHsrvytU27izUgrkreihb9Bj" | |
] | |
} | |
}, | |
"version": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": { | |
"linkReferences": {}, | |
"object": "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820349a2a84093dc67b40c426cee638ae470e3006133ecf06f96f5bb1d657b58ed30029", | |
"opcodes": "PUSH1 0x4C PUSH1 0x2C PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH1 0x0 BYTE PUSH1 0x73 EQ PUSH1 0x0 DUP2 EQ PUSH1 0x1C JUMPI PUSH1 0x1E JUMP JUMPDEST INVALID JUMPDEST POP ADDRESS PUSH1 0x0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN STOP PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 CALLVALUE SWAP11 0x2a DUP5 MULMOD RETURNDATASIZE 0xc6 PUSH28 0x40C426CEE638AE470E3006133ECF06F96F5BB1D657B58ED300290000 ", | |
"sourceMap": "116:1016:0:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24" | |
}, | |
"deployedBytecode": { | |
"linkReferences": {}, | |
"object": "73000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820349a2a84093dc67b40c426cee638ae470e3006133ecf06f96f5bb1d657b58ed30029", | |
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 CALLVALUE SWAP11 0x2a DUP5 MULMOD RETURNDATASIZE 0xc6 PUSH28 0x40C426CEE638AE470E3006133ECF06F96F5BB1D657B58ED300290000 ", | |
"sourceMap": "116:1016:0:-;;;;;;;;" | |
}, | |
"gasEstimates": { | |
"creation": { | |
"codeDepositCost": "15200", | |
"executionCost": "116", | |
"totalCost": "15316" | |
}, | |
"internal": { | |
"add(uint256,uint256)": "infinite", | |
"div(uint256,uint256)": "infinite", | |
"mul(uint256,uint256)": "infinite", | |
"sub(uint256,uint256)": "infinite" | |
} | |
}, | |
"methodIdentifiers": {} | |
}, | |
"abi": [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compiler": { | |
"version": "0.4.26+commit.4563c3fc" | |
}, | |
"language": "Solidity", | |
"output": { | |
"abi": [], | |
"devdoc": { | |
"methods": {}, | |
"title": "SafeMath" | |
}, | |
"userdoc": { | |
"methods": {} | |
} | |
}, | |
"settings": { | |
"compilationTarget": { | |
"contracts/ICO/ico.sol": "SafeMath" | |
}, | |
"evmVersion": "byzantium", | |
"libraries": {}, | |
"optimizer": { | |
"enabled": true, | |
"runs": 200 | |
}, | |
"remappings": [] | |
}, | |
"sources": { | |
"contracts/ICO/ico.sol": { | |
"keccak256": "0xeb753831d768e27eecbc5ae9d715caeeaccca2475e6b4910ed975d0825ce26a2", | |
"urls": [ | |
"bzzr://1a0da438401c266282e5b8fddd9aa46ac5489a61f2c084255cfd7511a8c7f3d0" | |
] | |
} | |
}, | |
"version": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
/** | |
* @title SafeMath | |
* @dev Math operations with safety checks that throw on error | |
*/ | |
library SafeMath { | |
/** | |
* @dev Multiplies two numbers, throws on overflow. | |
*/ | |
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { | |
if (a == 0) { | |
return 0; | |
} | |
c = a * b; | |
assert(c / a == b); | |
return c; | |
} | |
/** | |
* @dev Integer division of two numbers, truncating the quotient. | |
*/ | |
function div(uint256 a, uint256 b) internal pure returns (uint256) { | |
// assert(b > 0); // Solidity automatically throws when dividing by 0 | |
// uint256 c = a / b; | |
// assert(a == b * c + a % b); // There is no case in which this doesn't hold | |
return a / b; | |
} | |
/** | |
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). | |
*/ | |
function sub(uint256 a, uint256 b) internal pure returns (uint256) { | |
assert(b <= a); | |
return a - b; | |
} | |
/** | |
* @dev Adds two numbers, throws on overflow. | |
*/ | |
function add(uint256 a, uint256 b) internal pure returns (uint256 c) { | |
c = a + b; | |
assert(c >= a); | |
return c; | |
} | |
} | |
/** | |
* @title ERC20Basic | |
* @dev Simpler version of ERC20 interface | |
* @dev see https://github.com/ethereum/EIPs/issues/179 | |
*/ | |
contract ERC20Basic { | |
function totalSupply() public view returns (uint256); | |
function balanceOf(address who) public view returns (uint256); | |
function transfer(address to, uint256 value) public returns (bool); | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
} | |
/** | |
* @title ERC20 interface | |
* @dev see https://github.com/ethereum/EIPs/issues/20 | |
*/ | |
contract ERC20 is ERC20Basic { | |
function allowance(address owner, address spender) | |
public view returns (uint256); | |
function transferFrom(address from, address to, uint256 value) | |
public returns (bool); | |
function approve(address spender, uint256 value) public returns (bool); | |
event Approval( | |
address indexed owner, | |
address indexed spender, | |
uint256 value | |
); | |
} | |
/** | |
* @title Crowdsale | |
* @dev Crowdsale is a base contract for managing a token crowdsale, | |
* allowing investors to purchase tokens with ether. This contract implements | |
* such functionality in its most fundamental form and can be extended to provide additional | |
* functionality and/or custom behavior. | |
* The external interface represents the basic interface for purchasing tokens, and conform | |
* the base architecture for crowdsales. They are *not* intended to be modified / overriden. | |
* The internal interface conforms the extensible and modifiable surface of crowdsales. Override | |
* the methods to add functionality. Consider using 'super' where appropiate to concatenate | |
* behavior. | |
*/ | |
contract Crowdsale { | |
using SafeMath for uint256; | |
// The token being sold | |
ERC20 public token; | |
// Address where funds are collected | |
address public wallet; | |
// How many token units a buyer gets per wei | |
uint256 public rate; | |
// Amount of wei raised | |
uint256 public weiRaised; | |
/** | |
* Event for token purchase logging | |
* @param purchaser who paid for the tokens | |
* @param beneficiary who got the tokens | |
* @param value weis paid for purchase | |
* @param amount amount of tokens purchased | |
*/ | |
event TokenPurchase( | |
address indexed purchaser, | |
address indexed beneficiary, | |
uint256 value, | |
uint256 amount | |
); | |
/** | |
* @param _rate Number of token units a buyer gets per wei | |
* @param _wallet Address where collected funds will be forwarded to | |
* @param _token Address of the token being sold | |
*/ | |
constructor(uint256 _rate, address _wallet, ERC20 _token) public { | |
require(_rate > 0); | |
require(_wallet != address(0)); | |
require(_token != address(0)); | |
rate = _rate; | |
wallet = _wallet; | |
token = _token; | |
} | |
// ----------------------------------------- | |
// Crowdsale external interface | |
// ----------------------------------------- | |
/** | |
* @dev fallback function ***DO NOT OVERRIDE*** | |
*/ | |
function () external payable { | |
buyTokens(msg.sender); | |
} | |
/** | |
* @dev low level token purchase ***DO NOT OVERRIDE*** | |
* @param _beneficiary Address performing the token purchase | |
*/ | |
function buyTokens(address _beneficiary) public payable { | |
uint256 weiAmount = msg.value; | |
_preValidatePurchase(_beneficiary, weiAmount); | |
// calculate token amount to be created | |
uint256 tokens = _getTokenAmount(weiAmount); | |
// update state | |
weiRaised = weiRaised.add(weiAmount); | |
_processPurchase(_beneficiary, tokens); | |
emit TokenPurchase( | |
msg.sender, | |
_beneficiary, | |
weiAmount, | |
tokens | |
); | |
_updatePurchasingState(_beneficiary, weiAmount); | |
_forwardFunds(); | |
_postValidatePurchase(_beneficiary, weiAmount); | |
} | |
// ----------------------------------------- | |
// Internal interface (extensible) | |
// ----------------------------------------- | |
/** | |
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. | |
* @param _beneficiary Address performing the token purchase | |
* @param _weiAmount Value in wei involved in the purchase | |
*/ | |
function _preValidatePurchase( | |
address _beneficiary, | |
uint256 _weiAmount | |
) | |
internal | |
{ | |
require(_beneficiary != address(0)); | |
require(_weiAmount != 0); | |
} | |
/** | |
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. | |
* @param _beneficiary Address performing the token purchase | |
* @param _weiAmount Value in wei involved in the purchase | |
*/ | |
function _postValidatePurchase( | |
address _beneficiary, | |
uint256 _weiAmount | |
) | |
internal | |
{ | |
// optional override | |
} | |
/** | |
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. | |
* @param _beneficiary Address performing the token purchase | |
* @param _tokenAmount Number of tokens to be emitted | |
*/ | |
function _deliverTokens( | |
address _beneficiary, | |
uint256 _tokenAmount | |
) | |
internal | |
{ | |
token.transfer(_beneficiary, _tokenAmount); | |
} | |
/** | |
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. | |
* @param _beneficiary Address receiving the tokens | |
* @param _tokenAmount Number of tokens to be purchased | |
*/ | |
function _processPurchase( | |
address _beneficiary, | |
uint256 _tokenAmount | |
) | |
internal | |
{ | |
_deliverTokens(_beneficiary, _tokenAmount); | |
} | |
/** | |
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) | |
* @param _beneficiary Address receiving the tokens | |
* @param _weiAmount Value in wei involved in the purchase | |
*/ | |
function _updatePurchasingState( | |
address _beneficiary, | |
uint256 _weiAmount | |
) | |
internal | |
{ | |
// optional override | |
} | |
/** | |
* @dev Override to extend the way in which ether is converted to tokens. | |
* @param _weiAmount Value in wei to be converted into tokens | |
* @return Number of tokens that can be purchased with the specified _weiAmount | |
*/ | |
function _getTokenAmount(uint256 _weiAmount) | |
internal view returns (uint256) | |
{ | |
return _weiAmount.mul(rate); | |
} | |
/** | |
* @dev Determines how ETH is stored/forwarded on purchases. | |
*/ | |
function _forwardFunds() internal { | |
wallet.transfer(msg.value); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "remix_tests.sol"; // this import is automatically injected by Remix. | |
import "../contracts/3_Ballot.sol"; | |
contract BallotTest { | |
bytes32[] proposalNames; | |
Ballot ballotToTest; | |
function beforeAll () public { | |
proposalNames.push(bytes32("candidate1")); | |
ballotToTest = new Ballot(proposalNames); | |
} | |
function checkWinningProposal () public { | |
ballotToTest.vote(0); | |
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); | |
Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name"); | |
} | |
function checkWinninProposalWithReturnValue () public view returns (bool) { | |
return ballotToTest.winningProposal() == 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment