Blockwell

AdEx

ERC20

This contract is an ERC20 token.

Name AdEx
Symbol ADX
Decimals 4
Total Supply 0 ADX

About

Stats

Public Functions 19
Event Types 5
Code Size 25,852 bytes

Events (5) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
spender
address help
value
uint help

Buy Event

Parameters help
_recipient
address help
_amount
uint help

NewTokenGrant Event

Parameters help
from
address help
to
address help
value
uint256 help
grantId
uint256 help

PreBuy Event

Parameters help
_amount
uint help

Transfer Event

Parameters help
from
address help
to
address help
value
uint help

STAGE_ONE_TIME_END Constant

uint help
24 hours

STAGE_TWO_TIME_END Constant

uint help
1 weeks

STAGE_THREE_TIME_END Constant

uint help
4 weeks

DECIMALS Constant

uint help
10000

PRICE_STANDARD Constant

uint help

PRICE_STAGE_ONE Constant

uint help

PRICE_STAGE_TWO Constant

uint help

PRICE_STAGE_THREE Constant

uint help

ALLOC_TEAM Constant

uint help

ALLOC_BOUNTIES Constant

uint help

ALLOC_WINGS Constant

uint help

ALLOC_CROWDSALE Constant

uint help

PREBUY_PORTION_MAX Constant

uint help

name Variable

string help

symbol Variable

string help

decimals Variable

uint help

publicStartTime Variable

uint help

privateStartTime Variable

uint help

publicEndTime Variable

uint help

hardcapInEth Variable

uint help

multisigAddress Variable

address help

adexTeamAddress Variable

address help

ownerAddress Variable

address help

preBuy1 Variable

address help

preBuy2 Variable

address help

preBuy3 Variable

address help

preBuyPrice1 Variable

uint help

preBuyPrice2 Variable

uint help

preBuyPrice3 Variable

uint help

etherRaised Variable

uint help

ADXSold Variable

uint help

prebuyPortionTotal Variable

uint help

halted Variable

bool help

totalSupply Variable

uint help

MAX_GRANTS_PER_ADDRESS Variable

uint256 help
Internal Variable

grants Variable

mapping(address => TokenGrant[]) help
Internal Variable

allowed Variable

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

balances Variable

mapping(address => uint) help
Internal Variable

Functions Expand All Collapse All

Parameters help

Name Type
_owner
address help

Properties

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

Parameters help

Name Type
_to
address help
_value
uint help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transfer(address _to, uint256 _value) {
  if (_to == msg.sender) return; // no-op, allow even during crowdsale, in order to work around using grantVestedTokens() while in crowdsale
  if (!isCrowdfundCompleted()) throw;
  super.transfer(_to, _value);
}

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)
  constant
  returns (uint256 remaining)
{
  return allowed[_owner][_spender];
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint help

Properties

Visibility help public
Mutability help transaction

Modifiers help

is_crowdfund_completed checks for the following:
Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) is_crowdfund_completed {
  super.transferFrom(_from, _to, _value);
}

Parameters help

Name Type
_spender
address help
_value
uint help

Properties

Visibility help public
Mutability help transaction

Requirements help

One or more of the following:
Source Code
function approve(address _spender, uint256 _value) {
  // To change the approve amount you first have to reduce the addresses`
  //  allowance to zero by calling `approve(_spender, 0)` if it is not
  //  already 0 to mitigate the race condition described here:
  //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;

  allowed[msg.sender][_spender] = _value;
  Approval(msg.sender, _spender, _value);
}

Parameters help

Name Type
holder
address help
time
uint64 help

Properties

Visibility help public
Mutability help constant
Source Code
function transferableTokens(address holder, uint64 time)
  public
  constant
  returns (uint256)
{
  uint256 grantIndex = tokenGrantsCount(holder);

  if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants

  // Iterate through all the grants the holder has, and add all non-vested tokens
  uint256 nonVested = 0;
  for (uint256 i = 0; i < grantIndex; i++) {
    nonVested = SafeMath.add(
      nonVested,
      nonVestedTokens(grants[holder][i], time)
    );
  }

  // Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
  uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);

  // Return the minimum of how many vested can transfer and other value
  // in case there are other limiting transferability factors (default is balanceOf)
  return
    SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}

Parameters help

Name Type
_to
address help
_value
uint256 help
_start
uint64 help
_cliff
uint64 help
_vesting
uint64 help
_revokable
bool help
_burnsOnRevoke
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function grantVestedTokens(
  address _to,
  uint256 _value,
  uint64 _start,
  uint64 _cliff,
  uint64 _vesting,
  bool _revokable,
  bool _burnsOnRevoke
) public {
  // Check for date inconsistencies that may cause unexpected behavior
  if (_cliff < _start || _vesting < _cliff) {
    throw;
  }

  if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).

  uint256 count = grants[_to].push(
    TokenGrant(
      _revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
      _value,
      _cliff,
      _vesting,
      _start,
      _revokable,
      _burnsOnRevoke
    )
  );

  transfer(_to, _value);

  NewTokenGrant(msg.sender, _to, _value, count - 1);
}

Parameters help

Name Type
_holder
address help
_grantId
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function revokeTokenGrant(address _holder, uint256 _grantId) public {
  TokenGrant grant = grants[_holder][_grantId];

  if (!grant.revokable) {
    // Check if grant was revokable
    throw;
  }

  if (grant.granter != msg.sender) {
    // Only granter can revoke it
    throw;
  }

  address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;

  uint256 nonVested = nonVestedTokens(grant, uint64(now));

  // remove grant from array
  delete grants[_holder][_grantId];
  grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
  grants[_holder].length -= 1;

  balances[receiver] = balances[receiver].add(nonVested);
  balances[_holder] = balances[_holder].sub(nonVested);

  Transfer(_holder, receiver, nonVested);
}

Parameters help

Name Type
_holder
address help

Properties

Visibility help public
Mutability help constant
Source Code
function tokenGrantsCount(address _holder) constant returns (uint256 index) {
  return grants[_holder].length;
}

Parameters help

Name Type
tokens
uint256 help
time
uint256 help
start
uint256 help
cliff
uint256 help
vesting
uint256 help

Properties

Visibility help public
Mutability help constant
Source Code
function calculateVestedTokens(
  uint256 tokens,
  uint256 time,
  uint256 start,
  uint256 cliff,
  uint256 vesting
) constant returns (uint256) {
  // Shortcuts for before cliff and after vesting cases.
  if (time < cliff) return 0;
  if (time >= vesting) return tokens;

  // Interpolate all vested tokens.
  // As before cliff the shortcut returns 0, we can use just calculate a value
  // in the vesting rect (as shown in above's figure)

  // vestedTokens = tokens * (time - start) / (vesting - start)
  uint256 vestedTokens = SafeMath.div(
    SafeMath.mul(tokens, SafeMath.sub(time, start)),
    SafeMath.sub(vesting, start)
  );

  return vestedTokens;
}

Parameters help

Name Type
_holder
address help
_grantId
uint help

Properties

Visibility help public
Mutability help constant
Source Code
function tokenGrant(address _holder, uint256 _grantId)
  constant
  returns (
    address granter,
    uint256 value,
    uint256 vested,
    uint64 start,
    uint64 cliff,
    uint64 vesting,
    bool revokable,
    bool burnsOnRevoke
  )
{
  TokenGrant grant = grants[_holder][_grantId];

  granter = grant.granter;
  value = grant.value;
  start = grant.start;
  cliff = grant.cliff;
  vesting = grant.vesting;
  revokable = grant.revokable;
  burnsOnRevoke = grant.burnsOnRevoke;

  vested = vestedTokens(grant, uint64(now));
}

Parameters help

Name Type
holder
address help

Properties

Visibility help public
Mutability help constant
Source Code
function lastTokenIsTransferableDate(address holder)
  public
  constant
  returns (uint64 date)
{
  date = uint64(now);
  uint256 grantIndex = grants[holder].length;
  for (uint256 i = 0; i < grantIndex; i++) {
    date = SafeMath.max64(grants[holder][i].vesting, date);
  }
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function getPriceRate() constant returns (uint256 o_rate) {
  uint256 delta = SafeMath.sub(now, publicStartTime);

  if (delta > STAGE_TWO_TIME_END) return PRICE_STAGE_THREE;
  if (delta > STAGE_ONE_TIME_END) return PRICE_STAGE_TWO;

  return (PRICE_STAGE_ONE);
}

Parameters help

Name Type
_wei
uint help
_rate
uint help

Properties

Visibility help public
Mutability help constant
Source Code
function calcAmount(uint256 _wei, uint256 _rate) constant returns (uint256) {
  return SafeMath.div(SafeMath.mul(_wei, _rate), 1 ether);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function preBuy() payable is_pre_crowdfund_period is_not_halted {
  // Pre-buy participants would get the first-day price, as well as a bonus of vested tokens
  uint256 priceVested = 0;

  if (msg.sender == preBuy1) priceVested = preBuyPrice1;
  if (msg.sender == preBuy2) priceVested = preBuyPrice2;
  if (msg.sender == preBuy3) priceVested = preBuyPrice3;

  if (priceVested == 0) throw;

  uint256 amount = processPurchase(
    PRICE_STAGE_ONE + priceVested,
    SafeMath.sub(PREBUY_PORTION_MAX, prebuyPortionTotal)
  );
  grantVestedTokens(
    msg.sender,
    calcAmount(msg.value, priceVested),
    uint64(now),
    uint64(now) + 91 days,
    uint64(now) + 365 days,
    false,
    false
  );
  prebuyPortionTotal += amount;
  PreBuy(amount);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function() payable is_crowdfund_period is_not_halted {
  uint256 amount = processPurchase(
    getPriceRate(),
    SafeMath.sub(ALLOC_CROWDSALE, ADXSold)
  );
  Buy(msg.sender, amount);
}

Parameters help

Name Type
_adexTeamAddress
address help
_adexFundAddress
address help

Properties

Visibility help public
Mutability help transaction

Requirements help

UNKNOWN VALUE + 365 days must be greater than or equal to UNKNOWN VALUE + 91 days
UNKNOWN VALUE + 91 days must be greater than or equal to UNKNOWN VALUE
UNKNOWN VALUE + 365 days must be greater than or equal to UNKNOWN VALUE + 91 days
UNKNOWN VALUE + 91 days must be greater than or equal to UNKNOWN VALUE
Source Code
function grantVested(address _adexTeamAddress, address _adexFundAddress)
  is_crowdfund_completed
  only_owner
  is_not_halted
{
  // Grant tokens pre-allocated for the team
  grantVestedTokens(
    _adexTeamAddress,
    ALLOC_TEAM,
    uint64(now),
    uint64(now) + 91 days,
    uint64(now) + 365 days,
    false,
    false
  );

  // Grant tokens that remain after crowdsale to the AdEx fund, vested for 2 years
  grantVestedTokens(
    _adexFundAddress,
    balances[ownerAddress],
    uint64(now),
    uint64(now) + 182 days,
    uint64(now) + 730 days,
    false,
    false
  );
}

Parameters help

Name Type
_halted
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function toggleHalt(bool _halted) only_owner {
  halted = _halted;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function drain() only_owner {
  if (!ownerAddress.send(this.balance)) throw;
}

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 ADXToken.isCrowdfundCompleted keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help transaction
Source Code
function isCrowdfundCompleted() internal returns (bool) {
  if (
    now > publicEndTime ||
    ADXSold >= ALLOC_CROWDSALE ||
    etherRaised >= hardcapInEth
  ) return true;
  return false;
}

internal ADXToken.processPurchase keyboard_arrow_up

Parameters help

Name Type
_rate
uint help
_remaining
uint help

Properties

Visibility help internal
Mutability help transaction
Source Code
function processPurchase(uint256 _rate, uint256 _remaining)
  internal
  returns (uint256 o_amount)
{
  o_amount = calcAmount(msg.value, _rate);

  if (o_amount > _remaining) throw;
  if (!multisigAddress.send(msg.value)) throw;

  balances[ownerAddress] = balances[ownerAddress].sub(o_amount);
  balances[msg.sender] = balances[msg.sender].add(o_amount);

  ADXSold += o_amount;
  etherRaised += msg.value;
}