Blockwell

district0x Network Token

ERC20

This contract is an ERC20 token.

Name district0x Network Token
Symbol DNT
Decimals 18
Total Supply 1,000,000,000 DNT

About link description

district0x (DNT) is a cryptocurrency and operates on the Ethereum platform. district0x has a current supply of 1,000,000,000 with 600,000,000 in circulation. The last known price of district0x is 0.13952375 USD and is up 22.58 over the last 24 hours. It is currently trading on 27 active market(s) with $60,639,785.74 traded over the last 24 hours. More information can be found at https://district0x.io/.

Stats

Public Functions 28
Event Types 7
Code Size 58,393 bytes

Events (7) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
spender
address help
value
uint help

Approval Event

Parameters help
_owner
address help
_spender
address help
_amount
uint256 help

ClaimedTokens Event

Parameters help
_token
address help
_claimer
address help
_amount
uint help

NewCloneToken Event

Parameters help
_cloneToken
address help
_snapshotBlock
uint help

NewTokenGrant Event

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

Transfer Event

Parameters help
from
address help
to
address help
value
uint help

Transfer Event

Parameters help
_from
address help
_to
address help
_amount
uint256 help

name Variable

string help

decimals Variable

uint8 help

symbol Variable

string help

version Variable

string help

parentToken Variable

address help

parentSnapShotBlock Variable

uint help

creationBlock Variable

uint help

transfersEnabled Variable

bool help

tokenFactory Variable

address help

controller Variable

address help

grantsController Variable

address help

balances Variable

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

allowed Variable

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

totalSupplyHistory Variable

Checkpoint[] help
Internal Variable

balances Variable

mapping(address => uint) help
Internal Variable

MAX_GRANTS_PER_ADDRESS Variable

uint256 help
Internal Variable

grants Variable

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

Functions Expand All Collapse All

Parameters help

Name Type
_newController
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function changeGrantsController(address _newController) onlyGrantsController {
  grantsController = _newController;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function totalSupply() constant returns (uint256) {
  return totalSupplyAt(block.number);
}

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 balanceOfAt(_owner, block.number);
}

Parameters help

Name Type
_to
address help
_value
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function transfer(address _to, uint256 _value)
  canTransfer(msg.sender, _value)
  returns (bool)
{
  return 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
Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) canTransfer(_from, _value) returns (bool) {
  return super.transferFrom(_from, _to, _value);
}

Parameters help

Name Type
spender
address help
value
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function approve(address spender, uint256 value) returns (bool);

Parameters help

Name Type
_spender
address help
_amount
uint256 help
_extraData
bytes help

Properties

Visibility help public
Mutability help transaction
Source Code
function approveAndCall(
  address _spender,
  uint256 _amount,
  bytes _extraData
) returns (bool success) {
  if (!approve(_spender, _amount)) throw;

  ApproveAndCallFallBack(_spender).receiveApproval(
    msg.sender,
    _amount,
    this,
    _extraData
  );

  return true;
}

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 onlyGrantsController {
  // 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;

  // This will call MiniMe's doTransfer method, so token is transferred according to
  // MiniMe Token logic
  doTransfer(_holder, receiver, nonVested);

  Transfer(_holder, receiver, nonVested);
}

Parameters help

Name Type
_holder
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function revokeAllTokenGrants(address _holder) {
  var grandsCount = tokenGrantsCount(_holder);
  for (uint256 i = 0; i < grandsCount; i++) {
    revokeTokenGrant(_holder, 0);
  }
}

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

Name Type
_newController
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function changeController(address _newController) onlyController {
  controller = _newController;
}

Parameters help

Name Type
_to
address help
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function transfer(address _to, uint256 _amount) returns (bool success) {
  if (!transfersEnabled) throw;
  return doTransfer(msg.sender, _to, _amount);
}

Parameters help

Name Type
_from
address help
_to
address help
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _amount
) returns (bool success) {
  // The controller of this contract can move tokens around at will,
  //  this is important to recognize! Confirm that you trust the
  //  controller of this contract, which in most situations should be
  //  another open source smart contract or 0x0
  if (msg.sender != controller) {
    if (!transfersEnabled) throw;

    // The standard ERC 20 transferFrom functionality
    if (allowed[_from][msg.sender] < _amount) return false;
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
  }
  return doTransfer(_from, _to, _amount);
}

Parameters help

Name Type
_spender
address help
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function approve(address _spender, uint256 _amount) returns (bool success) {
  if (!transfersEnabled) throw;

  // 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 ((_amount != 0) && (allowed[msg.sender][_spender] != 0)) throw;

  // Alerts the token controller of the approve function call
  if (isContract(controller)) {
    if (!TokenController(controller).onApprove(msg.sender, _spender, _amount))
      throw;
  }

  allowed[msg.sender][_spender] = _amount;
  Approval(msg.sender, _spender, _amount);
  return true;
}

Parameters help

Name Type
_owner
address help
_blockNumber
uint help

Properties

Visibility help public
Mutability help constant
Source Code
function balanceOfAt(address _owner, uint256 _blockNumber)
  constant
  returns (uint256)
{
  // These next few lines are used when the balance of the token is
  //  requested before a check point was ever created for this token, it
  //  requires that the `parentToken.balanceOfAt` be queried at the
  //  genesis block for that token as this contains initial balance of
  //  this token
  if (
    (balances[_owner].length == 0) ||
    (balances[_owner][0].fromBlock > _blockNumber)
  ) {
    if (address(parentToken) != 0) {
      return
        parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
    } else {
      // Has no parent
      return 0;
    }

    // This will return the expected balance during normal situations
  } else {
    return getValueAt(balances[_owner], _blockNumber);
  }
}

Parameters help

Name Type
_blockNumber
uint help

Properties

Visibility help public
Mutability help constant
Source Code
function totalSupplyAt(uint256 _blockNumber) constant returns (uint256) {
  // These next few lines are used when the totalSupply of the token is
  //  requested before a check point was ever created for this token, it
  //  requires that the `parentToken.totalSupplyAt` be queried at the
  //  genesis block for this token as that contains totalSupply of this
  //  token at this block number.
  if (
    (totalSupplyHistory.length == 0) ||
    (totalSupplyHistory[0].fromBlock > _blockNumber)
  ) {
    if (address(parentToken) != 0) {
      return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
    } else {
      return 0;
    }

    // This will return the expected totalSupply during normal situations
  } else {
    return getValueAt(totalSupplyHistory, _blockNumber);
  }
}

Parameters help

Name Type
_cloneTokenName
string help
_cloneDecimalUnits
uint8 help
_cloneTokenSymbol
string help
_snapshotBlock
uint help
_transfersEnabled
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function createCloneToken(
  string _cloneTokenName,
  uint8 _cloneDecimalUnits,
  string _cloneTokenSymbol,
  uint256 _snapshotBlock,
  bool _transfersEnabled
) returns (address) {
  if (_snapshotBlock == 0) _snapshotBlock = block.number;
  MiniMeToken cloneToken = tokenFactory.createCloneToken(
    this,
    _snapshotBlock,
    _cloneTokenName,
    _cloneDecimalUnits,
    _cloneTokenSymbol,
    _transfersEnabled
  );

  cloneToken.changeController(msg.sender);

  // An event to make the token easy to find on the blockchain
  NewCloneToken(address(cloneToken), _snapshotBlock);
  return address(cloneToken);
}

Parameters help

Name Type
_owner
address help
_amount
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function generateTokens(address _owner, uint256 _amount)
  onlyController
  returns (bool)
{
  uint256 curTotalSupply = getValueAt(totalSupplyHistory, block.number);
  updateValueAtNow(totalSupplyHistory, curTotalSupply.add(_amount));
  var previousBalanceTo = balanceOf(_owner);
  updateValueAtNow(balances[_owner], previousBalanceTo.add(_amount));
  Transfer(0, _owner, _amount);
  return true;
}

Parameters help

Name Type
_owner
address help
_amount
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
function destroyTokens(address _owner, uint256 _amount)
  onlyController
  returns (bool)
{
  uint256 curTotalSupply = getValueAt(totalSupplyHistory, block.number);
  if (curTotalSupply < _amount) throw;
  updateValueAtNow(totalSupplyHistory, curTotalSupply.sub(_amount));
  var previousBalanceFrom = balanceOf(_owner);
  if (previousBalanceFrom < _amount) throw;
  updateValueAtNow(balances[_owner], previousBalanceFrom.sub(_amount));
  Transfer(_owner, 0, _amount);
  return true;
}

Parameters help

Name Type
_transfersEnabled
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function enableTransfers(bool _transfersEnabled) onlyController {
  transfersEnabled = _transfersEnabled;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function() payable {
  if (isContract(controller)) {
    if (!TokenController(controller).proxyPayment.value(msg.value)(msg.sender))
      throw;
  } else {
    throw;
  }
}

Parameters help

Name Type
_token
address help
_claimer
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function claimTokens(address _token, address _claimer) onlyController {
  if (_token == 0x0) {
    _claimer.transfer(this.balance);
    return;
  }

  ERC20Basic token = ERC20Basic(_token);
  uint256 balance = token.balanceOf(this);
  token.transfer(_claimer, balance);
  ClaimedTokens(_token, _claimer, balance);
}

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 MiniMeToken.doTransfer keyboard_arrow_up

Parameters help

Name Type
_from
address help
_to
address help
_amount
uint help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function doTransfer(
  address _from,
  address _to,
  uint256 _amount
) internal returns (bool) {
  if (_amount == 0) {
    return true;
  }

  if (parentSnapShotBlock >= block.number) throw;

  // Do not allow transfer to 0x0 or the token contract itself
  if ((_to == 0) || (_to == address(this))) throw;

  // If the amount being transfered is more than the balance of the
  //  account the transfer returns false
  var previousBalanceFrom = balanceOfAt(_from, block.number);
  if (previousBalanceFrom < _amount) {
    return false;
  }

  // Alerts the token controller of the transfer
  if (isContract(controller)) {
    if (!TokenController(controller).onTransfer(_from, _to, _amount)) throw;
  }

  // First update the balance array with the new value for the address
  //  sending the tokens
  updateValueAtNow(balances[_from], previousBalanceFrom.sub(_amount));

  // Then update the balance array with the new value for the address
  //  receiving the tokens
  var previousBalanceTo = balanceOfAt(_to, block.number);
  updateValueAtNow(balances[_to], previousBalanceTo.add(_amount));

  // An event to make the transfer easy to find on the blockchain
  Transfer(_from, _to, _amount);

  return true;
}

internal MiniMeToken.getValueAt keyboard_arrow_up

Parameters help

Name Type
checkpoints
Checkpoint[] help
_block
uint help

Properties

Visibility help internal
Mutability help constant
Source Code
function getValueAt(Checkpoint[] storage checkpoints, uint256 _block)
  internal
  constant
  returns (uint256)
{
  if (checkpoints.length == 0) return 0;

  // Shortcut for the actual value
  if (_block >= checkpoints[checkpoints.length - 1].fromBlock)
    return checkpoints[checkpoints.length - 1].value;
  if (_block < checkpoints[0].fromBlock) return 0;

  // Binary search of the value in the array
  uint256 min = 0;
  uint256 max = checkpoints.length - 1;
  while (max > min) {
    uint256 mid = (max + min + 1) / 2;
    if (checkpoints[mid].fromBlock <= _block) {
      min = mid;
    } else {
      max = mid - 1;
    }
  }
  return checkpoints[min].value;
}

internal MiniMeToken.updateValueAtNow keyboard_arrow_up

Parameters help

Name Type
checkpoints
Checkpoint[] help
_value
uint help

Properties

Visibility help internal
Mutability help transaction
Source Code
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value)
  internal
{
  if (
    (checkpoints.length == 0) ||
    (checkpoints[checkpoints.length - 1].fromBlock < block.number)
  ) {
    Checkpoint newCheckPoint = checkpoints[checkpoints.length++];
    newCheckPoint.fromBlock = uint128(block.number);
    newCheckPoint.value = uint128(_value);
  } else {
    Checkpoint oldCheckPoint = checkpoints[checkpoints.length - 1];
    oldCheckPoint.value = uint128(_value);
  }
}

internal MiniMeToken.isContract keyboard_arrow_up

Parameters help

Name Type
_addr
address help

Properties

Visibility help internal
Mutability help constant
Source Code
function isContract(address _addr) internal constant returns (bool) {
  uint256 size;
  if (_addr == 0) return false;
  assembly {
    size := extcodesize(_addr)
  }
  return size > 0;
}

internal MiniMeToken.min keyboard_arrow_up

Parameters help

Name Type
a
uint help
b
uint help

Properties

Visibility help internal
Mutability help transaction
Source Code
function min(uint256 a, uint256 b) internal returns (uint256) {
  return a < b ? a : b;
}

internal ERC20.doTransfer keyboard_arrow_up

Parameters help

Name Type
_from
address help
_to
address help
_amount
uint help

Properties

Visibility help internal
Mutability help transaction
Source Code
function doTransfer(
  address _from,
  address _to,
  uint256 _amount
) internal returns (bool);

internal VestedToken.vestedTokens keyboard_arrow_up

Parameters help

Name Type
grant
TokenGrant help
time
uint64 help

Properties

Visibility help private
Mutability help constant
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)
    );
}

internal VestedToken.nonVestedTokens keyboard_arrow_up

Parameters help

Name Type
grant
TokenGrant help
time
uint64 help

Properties

Visibility help private
Mutability help constant
Source Code
function nonVestedTokens(TokenGrant grant, uint64 time)
  private
  constant
  returns (uint256)
{
  return grant.value.sub(vestedTokens(grant, time));
}

internal ERC20.doTransfer keyboard_arrow_up

Parameters help

Name Type
_from
address help
_to
address help
_amount
uint help

Properties

Visibility help internal
Mutability help transaction
Source Code
function doTransfer(
  address _from,
  address _to,
  uint256 _amount
) internal returns (bool);