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
Constants (13) keyboard_arrow_up
State Variables (25) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
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);
}
allowance keyboard_arrow_up
transferFrom keyboard_arrow_up
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);
}
approve keyboard_arrow_up
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);
}
transferableTokens keyboard_arrow_up
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));
}
grantVestedTokens keyboard_arrow_up
Parameters help
Requirements help
MAX_GRANTS_PER_ADDRESS
must be greater than or equal to
the result of calling tokenGrantsCount with the sender's address
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);
}
revokeTokenGrant keyboard_arrow_up
Requirements help
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);
}
tokenGrantsCount keyboard_arrow_up
calculateVestedTokens keyboard_arrow_up
Parameters help
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;
}
tokenGrant keyboard_arrow_up
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));
}
lastTokenIsTransferableDate keyboard_arrow_up
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);
}
}
getPriceRate keyboard_arrow_up
Parameters help
This function has no parameters.
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);
}
calcAmount keyboard_arrow_up
preBuy keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
is_pre_crowdfund_period checks for the following:
is_not_halted checks for the following:
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
MAX_GRANTS_PER_ADDRESS
must be greater than or equal to
the result of calling tokenGrantsCount with the sender's address
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);
}
constructor keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
is_crowdfund_period checks for the following:
null
is_not_halted checks for the following:
Source Code
function() payable is_crowdfund_period is_not_halted {
uint256 amount = processPurchase(
getPriceRate(),
SafeMath.sub(ALLOC_CROWDSALE, ADXSold)
);
Buy(msg.sender, amount);
}
grantVested keyboard_arrow_up
Modifiers help
is_crowdfund_completed checks for the following:
only_owner checks for the following:
is_not_halted checks for the following:
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
MAX_GRANTS_PER_ADDRESS
must be greater than or equal to
the result of calling tokenGrantsCount with the sender's address
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
MAX_GRANTS_PER_ADDRESS
must be greater than or equal to
the result of calling tokenGrantsCount with the sender's address
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
);
}
toggleHalt keyboard_arrow_up
Modifiers help
only_owner checks for the following:
Source Code
function toggleHalt(bool _halted) only_owner {
halted = _halted;
}
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 ADXToken.isCrowdfundCompleted keyboard_arrow_up
internal ADXToken.processPurchase keyboard_arrow_up
Requirements help
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;
}
internal VestedToken.vestedTokens keyboard_arrow_up
Source Code
function vestedTokens(TokenGrant grant, uint64 time)
private
constant
returns (uint256)
{
return
calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}