Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add complex crowdsale example #331
  • Loading branch information
jakub-wojciechowski committed Jul 28, 2017
commit 2403508e1b60a7b2a75b8df9aaae00f0c6eddd4e
27 changes: 27 additions & 0 deletions contracts/examples/crowdsale/SampleCrowdsale.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pragma solidity ^0.4.11;

import "../../crowdsale/CappedCrowdsale.sol";
import "../../crowdsale/RefundableCrowdsale.sol";
import "./SampleCrowdsaleToken.sol";

/**
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale that incorporates
* ability to finalize sale and checks for both cap and goal.
*/
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {

function SampleCrowdsale(uint256 _startBlock, uint256 _endBlock, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet)
CappedCrowdsale(_cap)
FinalizableCrowdsale()
RefundableCrowdsale(_goal)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
{
require(_goal <= _cap);
}

function createTokenContract() internal returns (MintableToken) {
return new SampleCrowdsaleToken();
}

}
18 changes: 18 additions & 0 deletions contracts/examples/crowdsale/SampleCrowdsaleToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pragma solidity ^0.4.11;


import "../../token/MintableToken.sol";


/**
* @title SampleCrowdsaleToken
* @dev Very simple ERC20 Token that can be minted.
* It is meant to be used in a crowdsale contract.
*/
contract SampleCrowdsaleToken is MintableToken {

string public constant name = "Sample Crowdsale Token";
string public constant symbol = "SCT";
uint256 public constant decimals = 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decimals should be uint8 according to ERC20. (I've just realized this is wrong in the SimpleToken example too.)


}