├── .gitignore ├── migrations ├── 1_initial_migration.js └── 2_deploy_contracts.js ├── truffle.js ├── contracts ├── GustavoCoin.sol ├── Migrations.sol └── GustavoCoinCrowdsale.sol ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules 3 | -------------------------------------------------------------------------------- /migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /truffle.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | networks: { 3 | development: { 4 | host: "localhost", 5 | port: 8545, 6 | network_id: "*" // Match any network id 7 | } 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /contracts/GustavoCoin.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.4.24; 2 | 3 | import 'openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol'; 4 | 5 | contract GustavoCoin is ERC20Mintable { 6 | string public name = "GUSTAVO COIN"; 7 | string public symbol = "GUS"; 8 | uint8 public decimals = 18; 9 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # my-ico 2 | 3 | Example of creating a crowdsale with Zeppelin Solidity v2.0 4 | 5 | Companion code to the Blogpost [https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6](https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6) 6 | -------------------------------------------------------------------------------- /contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.4; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | function Migrations() { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contracts/GustavoCoinCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.4.24; 2 | 3 | import './GustavoCoin.sol'; 4 | import 'openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol'; 5 | import 'openzeppelin-solidity/contracts/crowdsale/validation/TimedCrowdsale.sol'; 6 | 7 | 8 | contract GustavoCoinCrowdsale is TimedCrowdsale, MintedCrowdsale { 9 | constructor 10 | ( 11 | uint256 _openingTime, 12 | uint256 _closingTime, 13 | uint256 _rate, 14 | address _wallet, 15 | ERC20Mintable _token 16 | ) 17 | public 18 | Crowdsale(_rate, _wallet, _token) 19 | TimedCrowdsale(_openingTime, _closingTime) { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-ico", 3 | "version": "1.0.0", 4 | "description": "Example of creating a crowdsale with OpenZeppelin v2.0", 5 | "main": "truffle.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "dependencies": { 10 | "openzeppelin-solidity": "2.0.0" 11 | }, 12 | "devDependencies": {}, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/gustavoguimaraes/my-ico.git" 19 | }, 20 | "author": "", 21 | "license": "ISC", 22 | "bugs": { 23 | "url": "https://github.com/gustavoguimaraes/my-ico/issues" 24 | }, 25 | "homepage": "https://github.com/gustavoguimaraes/my-ico#readme" 26 | } 27 | -------------------------------------------------------------------------------- /migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | const GustavoCoinCrowdsale = artifacts.require('./GustavoCoinCrowdsale.sol'); 2 | const GustavoCoin = artifacts.require('./GustavoCoin.sol'); 3 | 4 | module.exports = function(deployer, network, accounts) { 5 | const openingTime = web3.eth.getBlock('latest').timestamp + 20; // twenty secs in the future 6 | const closingTime = openingTime + 86400 * 20; // 20 days 7 | const rate = new web3.BigNumber(1000); 8 | const wallet = accounts[1]; 9 | 10 | return deployer 11 | .then(() => { 12 | return deployer.deploy(GustavoCoin); 13 | }) 14 | .then(() => { 15 | return deployer.deploy( 16 | GustavoCoinCrowdsale, 17 | openingTime, 18 | closingTime, 19 | rate, 20 | wallet, 21 | GustavoCoin.address 22 | ); 23 | }); 24 | }; 25 | --------------------------------------------------------------------------------