Divi Exchange Token
ERC20
This contract is an ERC20 token.
Name
Divi Exchange Token
Symbol
DIVX
Decimals
18
Total Supply
6,171,607 DIVX
About
Stats
Public Functions
13
Event Types
5
Code Size
11,184 bytes
Events (5) keyboard_arrow_up
Constants (9) keyboard_arrow_up
State Variables (14) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address _to, uint256 _value) returns (bool success) {
require(totalReceivedWei >= receivedWeiMin);
return super.transfer(_to, _value);
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address _from,
address _to,
uint256 _value
) returns (bool success) {
require(totalReceivedWei >= receivedWeiMin);
return super.transferFrom(_from, _to, _value);
}
approve keyboard_arrow_up
Source Code
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
allowance keyboard_arrow_up
createTokens keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
function createTokens() external payable isNotPaused {
require(block.number >= fundingStartBlock);
require(block.number <= fundingEndBlock);
require(msg.value > 0);
// Check that this transaction wouldn't exceed the ETH cap
uint256 checkedReceivedWei = safeAdd(totalReceivedWei, msg.value);
require(checkedReceivedWei <= receivedWeiCap);
// Calculate how many tokens (in units of Wei) should be awarded
// on this transaction
uint256 tokens = safeMult(msg.value, getCurrentTokenPrice());
// Calculate how many tokens (in units of Wei) should be awarded to the project (20%)
uint256 projectTokens = safeDiv(tokens, 5);
// Increment the total received ETH
totalReceivedWei = checkedReceivedWei;
// Only update our accounting of how much ETH this contributor has sent us if
// we're already on the public sale (since private sale contributions are going
// to be used before the end of end of the sale period, they don't get a refund)
if (block.number >= firstXRChangeBlock) weiBalances[msg.sender] += msg.value;
// Increment the total supply of tokens and then deposit the tokens
// to the contributor
totalSupply = safeAdd(totalSupply, tokens);
balances[msg.sender] += tokens;
// Increment the total supply of tokens and then deposit the tokens
// to the project
totalSupply = safeAdd(totalSupply, projectTokens);
balances[fundDeposit] += projectTokens;
LogCreate(msg.sender, msg.value, tokens); // logs token creation
}
withdrawWei keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
isNotPaused checks for the following:
Requirements help
One or more of the following:
Source Code
function withdrawWei(uint256 _value) external onlyOwner isNotPaused {
require(_value <= this.balance);
// Allow withdrawal during the private sale, but after that, only allow
// withdrawal if we already met the minimum
require(
(block.number < firstXRChangeBlock) || (totalReceivedWei >= receivedWeiMin)
);
// send the eth to the project multisig wallet
fundDeposit.transfer(_value);
}
pause keyboard_arrow_up
resume keyboard_arrow_up
startRedeeming keyboard_arrow_up
stopRedeeming keyboard_arrow_up
refund keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
function refund() external {
// prevents refund until sale period is over
require(block.number > fundingEndBlock);
// Refunds are only available if the minimum was not reached
require(totalReceivedWei < receivedWeiMin);
// Retrieve how much DIVX (in units of Wei) this account has
uint256 divxVal = balances[msg.sender];
require(divxVal > 0);
// Retrieve how much ETH (in units of Wei) this account contributed
uint256 weiVal = weiBalances[msg.sender];
require(weiVal > 0);
// Destroy this contributor's tokens and reduce the total supply
balances[msg.sender] = 0;
totalSupply = safeSubtract(totalSupply, divxVal);
// Log this refund operation
LogRefund(msg.sender, weiVal, divxVal);
// Send the money back
msg.sender.transfer(weiVal);
}
redeem keyboard_arrow_up
Requirements help
isRedeeming must be true
Source Code
function redeem(bytes32 diviAddress) external {
// Only allow this function to be called when on the redeeming state
require(isRedeeming);
// Retrieve how much DIVX (in units of Wei) this account has
uint256 divxVal = balances[msg.sender];
require(divxVal > 0);
// Move the tokens of the caller to the project's address
assert(super.transfer(fundDeposit, divxVal));
// Log the redeeming of this tokens
LogRedeem(msg.sender, divxVal, diviAddress);
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal DIVXToken.getCurrentTokenPrice keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function getCurrentTokenPrice()
private
constant
returns (uint256 currentPrice)
{
if (block.number < firstXRChangeBlock) {
return privateExchangeRate;
} else if (block.number < secondXRChangeBlock) {
return firstExchangeRate;
} else if (block.number < thirdXRChangeBlock) {
return secondExchangeRate;
} else {
return thirdExchangeRate;
}
}
internal SafeMath.safeAdd keyboard_arrow_up
internal SafeMath.safeSubtract keyboard_arrow_up
internal SafeMath.safeMult keyboard_arrow_up
Requirements help
One or more of the following:
Source Code
function safeMult(uint256 x, uint256 y) internal constant returns (uint256) {
uint256 z = x * y;
assert((x == 0) || (z / x == y));
return z;
}