Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
a9e1fcd6
Commit
a9e1fcd6
authored
Jul 29, 2017
by
Jakub Wojciechowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add complex crowdsale example #331 requested changes
parent
04e0b2e5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
24 deletions
+27
-24
SampleCrowdsale.sol
contracts/examples/SampleCrowdsale.sol
+26
-5
SampleCrowdsaleToken.sol
contracts/examples/crowdsale/SampleCrowdsaleToken.sol
+0
-18
SampleCrowdsale.js
test/SampleCrowdsale.js
+1
-1
No files found.
contracts/examples/
crowdsale/
SampleCrowdsale.sol
→
contracts/examples/SampleCrowdsale.sol
View file @
a9e1fcd6
pragma solidity ^0.4.11;
pragma solidity ^0.4.11;
import "../../crowdsale/CappedCrowdsale.sol";
import "../crowdsale/CappedCrowdsale.sol";
import "../../crowdsale/RefundableCrowdsale.sol";
import "../crowdsale/RefundableCrowdsale.sol";
import "./SampleCrowdsaleToken.sol";
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";
uint8 public constant decimals = 18;
}
/**
/**
* @title SampleCrowdsale
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale that incorporates
* @dev This is an example of a fully fledged crowdsale.
* ability to finalize sale and checks for both cap and goal.
* The way to add new features to a base crowdsale is by multiple inheritance.
* In this example we are providing following extensions:
* CappedCrowdsale - sets a max boundary for raised funds
* RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
*
* After adding multiple features it's good practice to run integration tests
* to ensure that subcontracts works together as intended.
*/
*/
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {
...
@@ -17,6 +36,8 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {
...
@@ -17,6 +36,8 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {
RefundableCrowdsale(_goal)
RefundableCrowdsale(_goal)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
{
{
//As goal needs to be met for a successful crowdsale
//the value needs to less or equal than a cap which is limit for accepted funds
require(_goal <= _cap);
require(_goal <= _cap);
}
}
...
...
contracts/examples/crowdsale/SampleCrowdsaleToken.sol
deleted
100644 → 0
View file @
04e0b2e5
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;
}
test/SampleCrowdsale.js
View file @
a9e1fcd6
...
@@ -34,7 +34,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
...
@@ -34,7 +34,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
(
await
this
.
crowdsale
.
startBlock
()).
should
.
be
.
bignumber
.
equal
(
this
.
startBlock
);
(
await
this
.
crowdsale
.
startBlock
()).
should
.
be
.
bignumber
.
equal
(
this
.
startBlock
);
(
await
this
.
crowdsale
.
endBlock
()).
should
.
be
.
bignumber
.
equal
(
this
.
endBlock
);
(
await
this
.
crowdsale
.
endBlock
()).
should
.
be
.
bignumber
.
equal
(
this
.
endBlock
);
(
await
this
.
crowdsale
.
rate
()).
should
.
be
.
bignumber
.
equal
(
RATE
);
(
await
this
.
crowdsale
.
rate
()).
should
.
be
.
bignumber
.
equal
(
RATE
);
(
await
this
.
crowdsale
.
wallet
()).
should
.
be
.
bignumber
.
equal
(
wallet
);
(
await
this
.
crowdsale
.
wallet
()).
should
.
be
.
equal
(
wallet
);
(
await
this
.
crowdsale
.
goal
()).
should
.
be
.
bignumber
.
equal
(
GOAL
);
(
await
this
.
crowdsale
.
goal
()).
should
.
be
.
bignumber
.
equal
(
GOAL
);
(
await
this
.
crowdsale
.
cap
()).
should
.
be
.
bignumber
.
equal
(
CAP
);
(
await
this
.
crowdsale
.
cap
()).
should
.
be
.
bignumber
.
equal
(
CAP
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment