Blockwell

DADI

ERC20

This contract is an ERC20 token.

Name DADI
Symbol DADI
Decimals 18
Total Supply 100,000,000 DADI

About

Stats

Public Functions 37
Event Types 9
Code Size 34,479 bytes

Library Use

Uses SafeMath for uint256.

Events (9) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
spender
address help
value
uint256 help

LogClaimTokens Event

Parameters help
recipient
address help
tokens
uint256 help

LogFundTransfer Event

Parameters help
wallet
address help
value
uint256 help

LogRedistributeTokens Event

Parameters help
recipient
address help
state
SaleState help
tokens
uint256 help

LogRefundFailed Event

Parameters help
recipient
address help
value
uint256 help

LogRefundProcessed Event

Parameters help
recipient
address help
value
uint256 help

LogTokenPurchase Event

Parameters help
purchaser
address help
beneficiary
address help
value
uint256 help
tokens
uint256 help

OwnershipTransferred Event

Parameters help
previousOwner
address help
newOwner
address help

Transfer Event

Parameters help
from
address help
to
address help
value
uint256 help

name Variable

string help

symbol Variable

string help

decimals Variable

uint8 help

version Variable

string help

owner Variable

address help

hundredPercent Variable

uint256 help

foundersPercentOfTotal Variable

uint256 help

referralPercentOfTotal Variable

uint256 help

ecosystemPercentOfTotal Variable

uint256 help

operationsPercentOfTotal Variable

uint256 help

investorCount Variable

uint256 help

totalRaised Variable

uint256 help

preSaleRaised Variable

uint256 help

publicSaleRaised Variable

uint256 help

partnerSaleTokensAvailable Variable

uint256 help

partnerSaleTokensPurchased Variable

uint256 help

preSaleTokensAvailable Variable

uint256 help

preSaleTokensPurchased Variable

uint256 help

publicSaleTokensAvailable Variable

uint256 help

publicSaleTokensPurchased Variable

uint256 help

partnerSaleTokenPrice Variable

uint256 help

partnerSaleTokenValue Variable

uint256 help

preSaleTokenPrice Variable

uint256 help

publicSaleTokenPrice Variable

uint256 help

ethRate Variable

uint256 help

fundsWallet Variable

address help

ecosystemWallet Variable

address help

operationsWallet Variable

address help

referralProgrammeWallet Variable

address help

state Variable

SaleState help

totalSupply Variable

uint256 help

owner Variable

address help

purchasedTokens Variable

mapping(address => uint256) help

partnerSaleWei Variable

mapping(address => uint256) help

foundingTeamWallets Variable

address[] help
Internal Variable

partnerSaleWallets Variable

address[] help
Internal Variable

preSaleWallets Variable

address[] help
Internal Variable

publicSaleWallets Variable

address[] help
Internal Variable

allowed Variable

mapping(address => mapping(address => uint256)) help
Internal Variable

balances Variable

mapping(address => uint256) help
Internal Variable

Functions Expand All Collapse All

transferOwnership keyboard_arrow_up

Parameters help

Name Type
newOwner
address help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transferOwnership(address newOwner) public onlyOwner {
  require(newOwner != address(0));
  OwnershipTransferred(owner, newOwner);
  owner = newOwner;
}

Parameters help

Name Type
_owner
address help

Properties

Visibility help public
Mutability help constant
Source Code
function balanceOf(address _owner) public constant returns (uint256 balance) {
  return balances[_owner];
}

Parameters help

Name Type
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transfer(address _to, uint256 _value) public returns (bool) {
  require(_to != address(0));

  // SafeMath.sub will throw if there is not enough balance.
  balances[msg.sender] = balances[msg.sender].sub(_value);
  balances[_to] = balances[_to].add(_value);
  Transfer(msg.sender, _to, _value);
  return true;
}

Parameters help

Name Type
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help constant
Source Code
function allowance(address _owner, address _spender)
  public
  constant
  returns (uint256 remaining)
{
  return allowed[_owner][_spender];
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) public returns (bool) {
  require(_to != address(0));

  uint256 _allowance = allowed[_from][msg.sender];

  // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
  // require (_value <= _allowance);

  balances[_from] = balances[_from].sub(_value);
  balances[_to] = balances[_to].add(_value);
  allowed[_from][msg.sender] = _allowance.sub(_value);
  Transfer(_from, _to, _value);
  return true;
}

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function approve(address _spender, uint256 _value) public returns (bool) {
  allowed[msg.sender][_spender] = _value;
  Approval(msg.sender, _spender, _value);
  return true;
}

increaseApproval keyboard_arrow_up

Parameters help

Name Type
_spender
address help
_addedValue
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function increaseApproval(address _spender, uint256 _addedValue)
  returns (bool success)
{
  allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(
    _addedValue
  );
  Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  return true;
}

decreaseApproval keyboard_arrow_up

Parameters help

Name Type
_spender
address help
_subtractedValue
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function decreaseApproval(address _spender, uint256 _subtractedValue)
  returns (bool success)
{
  uint256 oldValue = allowed[msg.sender][_spender];
  if (_subtractedValue > oldValue) {
    allowed[msg.sender][_spender] = 0;
  } else {
    allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
  }
  Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  return true;
}

constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function() payable {
  require(
    state == SaleState.PartnerSale ||
      state == SaleState.PreSale ||
      state == SaleState.PublicSale
  );

  buyTokens(msg.sender, msg.value);
}

offlineTransaction keyboard_arrow_up

Parameters help

Name Type
_recipient
address help
_tokens
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function offlineTransaction(address _recipient, uint256 _tokens)
  public
  onlyOwner
  returns (bool)
{
  require(state == SaleState.PartnerSale);
  require(_tokens > 0);

  // Convert to a token with decimals
  uint256 tokens = _tokens * (uint256(10)**decimals);

  purchasedTokens[_recipient] = purchasedTokens[_recipient].add(tokens);

  // Use original _token argument to increase the count of tokens purchased in the PartnerSale
  partnerSaleTokensPurchased = partnerSaleTokensPurchased.add(_tokens);

  // Finalize the PartnerSale if necessary
  if (partnerSaleTokensPurchased >= partnerSaleTokensAvailable) {
    state = SaleState.PartnerSaleFinalized;
  }

  LogTokenPurchase(msg.sender, _recipient, 0, tokens);

  return true;
}

updateEthRate keyboard_arrow_up

Parameters help

Name Type
rate
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function updateEthRate(uint256 rate) public onlyOwner returns (bool) {
  require(rate >= 100000);

  ethRate = rate;
  return true;
}

addPartnerSaleWallet keyboard_arrow_up

Parameters help

Name Type
_wallet
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function addPartnerSaleWallet(address _wallet) public onlyOwner returns (bool) {
  require(state < SaleState.PartnerSaleFinalized);
  require(_wallet != address(0));
  partnerSaleWallets.push(_wallet);
  return true;
}

addPreSaleWallet keyboard_arrow_up

Parameters help

Name Type
_wallet
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function addPreSaleWallet(address _wallet) public onlyOwner returns (bool) {
  require(state != SaleState.PreSale);
  require(_wallet != address(0));
  preSaleWallets.push(_wallet);
  return true;
}

addPublicSaleWallet keyboard_arrow_up

Parameters help

Name Type
_wallet
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function addPublicSaleWallet(address _wallet) public onlyOwner returns (bool) {
  require(state != SaleState.PublicSale);
  require(_wallet != address(0));
  publicSaleWallets.push(_wallet);
  return true;
}

calculateTokens keyboard_arrow_up

Parameters help

Name Type
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function calculateTokens(uint256 _amount) public returns (uint256 tokens) {
  if (isStatePartnerSale()) {
    tokens = (_amount * ethRate) / partnerSaleTokenPrice;
  } else if (isStatePreSale()) {
    tokens = (_amount * ethRate) / preSaleTokenPrice;
  } else if (isStatePublicSale()) {
    tokens = (_amount * ethRate) / publicSaleTokenPrice;
  } else {
    tokens = 0;
  }

  return tokens;
}

setPhase keyboard_arrow_up

Parameters help

Name Type
phase
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function setPhase(uint256 phase) public onlyOwner {
  state = SaleState(uint256(phase));
}

startPartnerSale keyboard_arrow_up

Parameters help

Name Type
rate
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function startPartnerSale(uint256 rate) public onlyOwner {
  state = SaleState.PartnerSale;
  updateEthRate(rate);
}

startPreSale keyboard_arrow_up

Parameters help

Name Type
rate
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function startPreSale(uint256 rate) public onlyOwner {
  state = SaleState.PreSale;
  updateEthRate(rate);
}

startPublicSale keyboard_arrow_up

Parameters help

Name Type
rate
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function startPublicSale(uint256 rate) public onlyOwner {
  state = SaleState.PublicSale;
  updateEthRate(rate);
}

finalizePartnerSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function finalizePartnerSale() public onlyOwner {
  require(state == SaleState.PartnerSale);

  state = SaleState.PartnerSaleFinalized;
}

finalizePreSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function finalizePreSale() public onlyOwner {
  require(state == SaleState.PreSale);

  state = SaleState.PreSaleFinalized;
}

finalizePublicSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function finalizePublicSale() public onlyOwner {
  require(state == SaleState.PublicSale);

  state = SaleState.PublicSaleFinalized;
}

finalizeIco keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function finalizeIco() public onlyOwner {
  require(state == SaleState.PublicSaleFinalized);

  state = SaleState.Success;

  // 2.5% of total goes to DADI ecosystem
  distribute(ecosystemWallet, ecosystemPercentOfTotal);

  // 2.5% of total goes to DADI+ operations
  distribute(operationsWallet, operationsPercentOfTotal);

  // 5% of total goes to referral programme
  distribute(referralProgrammeWallet, referralPercentOfTotal);

  // 20% of total goes to the founding team wallets
  distributeFoundingTeamTokens(foundingTeamWallets);

  // redistribute unsold tokens to DADI ecosystem
  uint256 remainingPreSaleTokens = getPreSaleTokensAvailable();
  preSaleTokensAvailable = 0;

  uint256 remainingPublicSaleTokens = getPublicSaleTokensAvailable();
  publicSaleTokensAvailable = 0;

  // we need to represent the tokens with included decimals
  // `2640 ** (10 ^ 18)` not `2640`
  if (remainingPreSaleTokens > 0) {
    remainingPreSaleTokens = remainingPreSaleTokens * (uint256(10)**decimals);
    balances[owner] = balances[owner].sub(remainingPreSaleTokens);
    balances[ecosystemWallet] = balances[ecosystemWallet].add(
      remainingPreSaleTokens
    );
    Transfer(0, ecosystemWallet, remainingPreSaleTokens);
  }

  if (remainingPublicSaleTokens > 0) {
    remainingPublicSaleTokens =
      remainingPublicSaleTokens *
      (uint256(10)**decimals);
    balances[owner] = balances[owner].sub(remainingPublicSaleTokens);
    balances[ecosystemWallet] = balances[ecosystemWallet].add(
      remainingPublicSaleTokens
    );
    Transfer(0, ecosystemWallet, remainingPublicSaleTokens);
  }

  // Transfer ETH to the funding wallet.
  if (!fundsWallet.send(this.balance)) {
    revert();
  }
}

closeIco keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function closeIco() public onlyOwner {
  state = SaleState.Closed;
}

claimTokens keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function claimTokens() public returns (bool) {
  require(state == SaleState.Success);

  // get the tokens available for the sender
  uint256 tokens = purchasedTokens[msg.sender];
  require(tokens > 0);

  purchasedTokens[msg.sender] = 0;

  balances[owner] = balances[owner].sub(tokens);
  balances[msg.sender] = balances[msg.sender].add(tokens);

  LogClaimTokens(msg.sender, tokens);
  Transfer(owner, msg.sender, tokens);
  return true;
}

refund keyboard_arrow_up

Parameters help

Name Type
_recipient
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function refund(address _recipient) public onlyOwner returns (bool) {
  require(state == SaleState.Refunding);

  uint256 value = partnerSaleWei[_recipient];

  require(value > 0);

  partnerSaleWei[_recipient] = 0;

  if (!_recipient.send(value)) {
    partnerSaleWei[_recipient] = value;
    LogRefundFailed(_recipient, value);
  }

  LogRefundProcessed(_recipient, value);
  return true;
}

withdrawFunds keyboard_arrow_up

Parameters help

Name Type
_address
address help
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function withdrawFunds(address _address, uint256 _amount) public onlyOwner {
  _address.transfer(_amount);
}

getRandom keyboard_arrow_up

Parameters help

Name Type
max
uint help

Properties

Visibility help public
Mutability help constant
Source Code
function getRandom(uint256 max) public constant returns (uint256 randomNumber) {
  return (uint256(sha3(block.blockhash(block.number - 1))) % max) + 1;
}

setRefunding keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function setRefunding() public onlyOwner {
  require(state == SaleState.PartnerSaleFinalized);

  state = SaleState.Refunding;
}

isSuccessful keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function isSuccessful() public constant returns (bool) {
  return state == SaleState.Success;
}

getPreSaleTokensAvailable keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getPreSaleTokensAvailable() public constant returns (uint256) {
  if (preSaleTokensAvailable == 0) {
    return 0;
  }

  return preSaleTokensAvailable - preSaleTokensPurchased;
}

getPublicSaleTokensAvailable keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getPublicSaleTokensAvailable() public constant returns (uint256) {
  if (publicSaleTokensAvailable == 0) {
    return 0;
  }

  return publicSaleTokensAvailable - publicSaleTokensPurchased;
}

getTokensPurchased keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getTokensPurchased() public constant returns (uint256) {
  return
    partnerSaleTokensPurchased +
    preSaleTokensPurchased +
    publicSaleTokensPurchased;
}

getTotalRaised keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getTotalRaised() public constant returns (uint256) {
  return preSaleRaised + publicSaleRaised;
}

getBalance keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getBalance() public constant returns (uint256) {
  return this.balance;
}

getFundsWalletBalance keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getFundsWalletBalance() public constant onlyOwner returns (uint256) {
  return fundsWallet.balance;
}

getInvestorCount keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getInvestorCount() public constant returns (uint256) {
  return investorCount;
}

Internal Functions Expand All Collapse All

Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.

internal DadiToken.forwardFunds keyboard_arrow_up

Parameters help

Name Type
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function forwardFunds(uint256 _value) internal {
  // if (isStatePartnerSale()) {
  //     // move funds to a partnerSaleWallet
  //     if (partnerSaleWallets.length > 0) {
  //         // Transfer ETH to a random wallet
  //         uint accountNumber = getRandom(partnerSaleWallets.length) - 1;
  //         address account = partnerSaleWallets[accountNumber];
  //         account.transfer(_value);
  //         LogFundTransfer(account, _value);
  //     }
  // }

  uint256 accountNumber;
  address account;

  if (isStatePreSale()) {
    // move funds to a preSaleWallet
    if (preSaleWallets.length > 0) {
      // Transfer ETH to a random wallet
      accountNumber = getRandom(preSaleWallets.length) - 1;
      account = preSaleWallets[accountNumber];
      account.transfer(_value);
      LogFundTransfer(account, _value);
    }
  } else if (isStatePublicSale()) {
    // move funds to a publicSaleWallet
    if (publicSaleWallets.length > 0) {
      // Transfer ETH to a random wallet
      accountNumber = getRandom(publicSaleWallets.length) - 1;
      account = publicSaleWallets[accountNumber];
      account.transfer(_value);
      LogFundTransfer(account, _value);
    }
  }
}

internal DadiToken.buyTokens keyboard_arrow_up

Parameters help

Name Type
_recipient
address help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function buyTokens(address _recipient, uint256 _value) internal returns (bool) {
  uint256 boughtTokens = calculateTokens(_value);
  require(boughtTokens != 0);

  if (isStatePartnerSale()) {
    // assign tokens to separate mapping
    purchasedTokens[_recipient] = purchasedTokens[_recipient].add(boughtTokens);
    partnerSaleWei[_recipient] = partnerSaleWei[_recipient].add(_value);
  } else {
    // increment the unique investor count
    if (purchasedTokens[_recipient] == 0) {
      investorCount++;
    }

    // assign tokens to separate mapping, that is not "balances"
    purchasedTokens[_recipient] = purchasedTokens[_recipient].add(boughtTokens);
  }

  LogTokenPurchase(msg.sender, _recipient, _value, boughtTokens);

  forwardFunds(_value);

  updateSaleParameters(_value, boughtTokens);

  return true;
}

internal DadiToken.updateSaleParameters keyboard_arrow_up

Parameters help

Name Type
_value
uint256 help
_tokens
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function updateSaleParameters(uint256 _value, uint256 _tokens)
  internal
  returns (bool)
{
  // we need to represent the integer value of tokens here
  // tokensPurchased = `2640`, not `2640 ** (10 ^ 18)`
  uint256 tokens = _tokens / (uint256(10)**decimals);

  if (isStatePartnerSale()) {
    partnerSaleTokensPurchased = partnerSaleTokensPurchased.add(tokens);

    // No PartnerSale tokens remaining
    if (partnerSaleTokensPurchased >= partnerSaleTokensAvailable) {
      state = SaleState.PartnerSaleFinalized;
    }
  } else if (isStatePreSale()) {
    preSaleTokensPurchased = preSaleTokensPurchased.add(tokens);

    preSaleRaised = preSaleRaised.add(_value);

    // No PreSale tokens remaining
    if (preSaleTokensPurchased >= preSaleTokensAvailable) {
      state = SaleState.PreSaleFinalized;
    }
  } else if (isStatePublicSale()) {
    publicSaleTokensPurchased = publicSaleTokensPurchased.add(tokens);

    publicSaleRaised = publicSaleRaised.add(_value);

    // No PublicSale tokens remaining
    if (publicSaleTokensPurchased >= publicSaleTokensAvailable) {
      state = SaleState.PublicSaleFinalized;
    }
  }
}

internal DadiToken.calculateValueFromTokens keyboard_arrow_up

Parameters help

Name Type
_tokens
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function calculateValueFromTokens(uint256 _tokens) internal returns (uint256) {
  uint256 amount = _tokens.div(ethRate.div(partnerSaleTokenPrice));
  return amount;
}

internal DadiToken.distributeFoundingTeamTokens keyboard_arrow_up

Parameters help

Name Type
_recipients
address[] help

Properties

Visibility help private
Mutability help transaction
Source Code
function distributeFoundingTeamTokens(address[] _recipients)
  private
  returns (bool)
{
  // determine the split between wallets
  // to arrive at a valid percentage we start the percentage the founding team has
  // available, which is 20% of the total supply. The percentage to distribute then is the
  // total percentage divided by the number of founding team wallets (likely 4).
  uint256 percentage = foundersPercentOfTotal / _recipients.length;

  for (uint256 i = 0; i < _recipients.length; i++) {
    distribute(_recipients[i], percentage);
  }
}

internal DadiToken.distribute keyboard_arrow_up

Parameters help

Name Type
_recipient
address help
percentage
uint help

Properties

Visibility help private
Mutability help transaction
Source Code
function distribute(address _recipient, uint256 percentage)
  private
  returns (bool)
{
  uint256 tokens = totalSupply / (hundredPercent / percentage);

  balances[owner] = balances[owner].sub(tokens);
  balances[_recipient] = balances[_recipient].add(tokens);
  Transfer(0, _recipient, tokens);
}

internal DadiToken.isStatePartnerSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help private
Mutability help constant
Source Code
function isStatePartnerSale() private constant returns (bool) {
  return state == SaleState.PartnerSale;
}

internal DadiToken.isStatePreSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help private
Mutability help constant
Source Code
function isStatePreSale() private constant returns (bool) {
  return state == SaleState.PreSale;
}

internal DadiToken.isStatePublicSale keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help private
Mutability help constant
Source Code
function isStatePublicSale() private constant returns (bool) {
  return state == SaleState.PublicSale;
}