-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPetroCrowdSale.sol
57 lines (46 loc) · 2.27 KB
/
PetroCrowdSale.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pragma solidity ^0.5.5;
import "./PetrolCoin.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/Crowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol";
// @TODO: Inherit the crowdsale contracts
contract PetrolCoinSale is Crowdsale, MintedCrowdsale, CappedCrowdsale, TimedCrowdsale, RefundablePostDeliveryCrowdsale{
constructor(
uint rate,
address payable wallet,
PetrolCoin token,
uint goal,
uint openingTime,
uint closingTime
)
TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal)
CappedCrowdsale(goal)
Crowdsale(rate, wallet, token)
public
{
// constructor can stay empty
}
}
contract PetrolCoinSaleDeployer {
address public petrol_sale_address;
address public token_address;
constructor(
string memory name,
string memory symbol,
address payable wallet, // this address will receive all Ether raised by the sale
uint goal
)
public
{
// @TODO: create the PetrolCoin and keep its address handy
PetrolCoin token = new PetrolCoin(name, symbol, 0);
token_address = address(token);
// @TODO: create the PetrolCoinSale and tell it about the token, set the goal, and set the open and close times to now and now + 24 weeks.
PetrolCoinSale petrol_sale = new PetrolCoinSale(1, wallet, token, goal, now, now + 24 weeks);
petrol_sale_address = address(petrol_sale);
// make the PetrolCoinSale contract a minter, then have the PetrolCoinSaleDeployer renounce its minter role
token.addMinter(petrol_sale_address);
token.renounceMinter();