-
Notifications
You must be signed in to change notification settings - Fork 0
/
Crowdsale Smart Contract
104 lines (69 loc) · 3.21 KB
/
Crowdsale Smart Contract
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//Crowdsale Smart Contract
//Address
//Read-Only Functions
function isOpen() public view returns (bool)
//Returns true if the crowdsale is currently in progress
function auctionSuccessful() public view returns (bool)
//Returns true if the crowdsale has reached the goal of raising a specified amount
function calculateCommitment(uint256 _commitment)
//Calculates the commitment the user can make with constraint that it is not greater than the amount available to commit.
function tokensClaimable(address _user) public
//The amount of token a user is available to claim
function tokenPrice() public view returns (uint256)
//Current price of the token
//init function
function initCrowdsale(
address _funder,
address _token,
address _paymentCurrency,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
uint256 _goal,
address _admin,
address _pointList,
address payable _wallet
) public
/Name
Description
_funder
The address that funds the auction
_token
The token that needs to be sold
_paymentCurrency
The currency the Crowdsale accepts as payment. Can be ETH or token
_totalTokens
The total number of tokens for Crowdsale
_startTime
Crowdsale start time
_endTime
Crowdsale end time
_rate
Number of token units a buyer gets per wei or token
_goal
Minimum amount of funds to be raised in weis or tokens
_admin
The Address with Admin Privileges
_pointlist
Gives point to estimate how much a investor can invest. Can be zero address if not required
_wallet
Address where collected funds will be forwarded to/
function initMarket(bytes calldata _data) public
/Receives bytes of data which is abi decoded into respective parameters. These parameters are sent to the initCrowdsale function to initialize crowdsale./
//Buy a token
function commitEth(
address payable _beneficiary,
bool readAndAgreedToMarketParticipationAgreement
)
/A gateway to buy a token using Eth as a payment currency. Here the payment currency should be ETH address and beneficiary balance of the token is incremented as per value of wei sent/
function commitTokens(uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public
/A gateway to buy token using a specific ERC20 Token as payment currency. Here the payment currency should be the ERC20 Token and beneficiary balance of the token is incremented proportional to the amount of token/
//Finalize sale
function finalize() public
/We can finalize the market auction if we have the required role or the time for auction has expired. If the auction is successfully finalized, the payment is forwarded to the specified wallet. If the auction is not successful, all the auction token is sent back to the wallet./
function withdrawTokens(address payable beneficiary) public
/This function delivers the token to beneficiary if the sale is successful ie. goal is reached. If the sale does not reach the goal it returns the payment back to the beneficiary/
function cancelAuction() public
/Can call this function to cancel the auction if need be. Only the admin can cancel the auction. If the auction is finalized or fund is already raised, the auction can not be cancelled./