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 Network is a collective of decentralized marketplaces and communities, otherwise known as 'districts'. Districts exist as decentralized autonomous organizations (DAO) on the district0x Network and are built upon d0xINFRAa (standard open source framework comprised of Ethereum smart contracts and front-end libraries). d0xINFRA provides districts with the core functionalities required to operate an online market or community.
The DNT ERC-20 token can be used to vote on what districts should be built by the district0x team, and can be staked to gain access to voting rights in any district on the district0x Network.
Stats
Public Functions
28
Event Types
7
Code Size
58,393 bytes
Events (7) keyboard_arrow_up
Functions
changeGrantsController keyboard_arrow_up
Modifiers help
onlyGrantsController checks for the following:
Source Code
function changeGrantsController(address _newController) onlyGrantsController {
grantsController = _newController;
}
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Modifiers help
canTransfer checks for the following:
_value
must be less than or equal to
the result of calling transferableTokens with the sender's address, UNKNOWN ARGUMENT
Source Code
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) returns (bool) {
return super.transfer(_to, _value);
}
allowance keyboard_arrow_up
transferFrom keyboard_arrow_up
Modifiers help
canTransfer checks for the following:
_value
must be less than or equal to
the result of calling transferableTokens with the sender's address, UNKNOWN ARGUMENT
Source Code
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) returns (bool) {
return super.transferFrom(_from, _to, _value);
}
approve keyboard_arrow_up
approveAndCall keyboard_arrow_up
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;
}
transferableTokens keyboard_arrow_up
Source Code
function transferableTokens(address holder, uint64 time) constant public 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
Modifiers help
onlyGrantsController checks for the following:
Requirements help
MAX_GRANTS_PER_ADDRESS
must be greater than or equal to
the result of calling tokenGrantsCount with _to
Source Code
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) onlyGrantsController 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).
uint 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, uint _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);
}
revokeAllTokenGrants keyboard_arrow_up
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, uint _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) constant public 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);
}
}
changeController keyboard_arrow_up
Modifiers help
onlyController checks for the following:
Source Code
function changeController(address _newController) onlyController {
controller = _newController;
}
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address _to, uint256 _amount) returns (bool success) {
if (!transfersEnabled) throw;
return doTransfer(msg.sender, _to, _amount);
}
transferFrom keyboard_arrow_up
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);
}
approve keyboard_arrow_up
Requirements help
One or more of the following:
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;
}
balanceOfAt keyboard_arrow_up
Source Code
function balanceOfAt(address _owner, uint _blockNumber) constant
returns (uint) {
// 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);
}
}
totalSupplyAt keyboard_arrow_up
Source Code
function totalSupplyAt(uint _blockNumber) constant returns(uint) {
// 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);
}
}
createCloneToken keyboard_arrow_up
Parameters help
Source Code
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _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);
}
generateTokens keyboard_arrow_up
Modifiers help
onlyController checks for the following:
Source Code
function generateTokens(address _owner, uint _amount
) onlyController returns (bool) {
uint 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;
}
destroyTokens keyboard_arrow_up
Modifiers help
onlyController checks for the following:
Requirements help
Source Code
function destroyTokens(address _owner, uint _amount
) onlyController returns (bool) {
uint 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;
}
enableTransfers keyboard_arrow_up
Modifiers help
onlyController checks for the following:
Source Code
function enableTransfers(bool _transfersEnabled) onlyController {
transfersEnabled = _transfersEnabled;
}
constructor keyboard_arrow_up
claimTokens keyboard_arrow_up
Modifiers help
onlyController checks for the following:
Source Code
function claimTokens(address _token, address _claimer) onlyController {
if (_token == 0x0) {
_claimer.transfer(this.balance);
return;
}
ERC20Basic token = ERC20Basic(_token);
uint balance = token.balanceOf(this);
token.transfer(_claimer, balance);
ClaimedTokens(_token, _claimer, balance);
}