Nimiq Network Interim Token
ERC20
This contract is an ERC20 token.
Name
Nimiq Network Interim Token
Symbol
NET
Decimals
18
Total Supply
10,500,000 NET
About
Stats
Public Functions
13
Event Types
5
Code Size
13,510 bytes
Events (5) keyboard_arrow_up
Constants (9) keyboard_arrow_up
State Variables (12) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Modifiers help
isFinalized checks for the following:
onlyPayloadSize checks for the following:
Source Code
function transfer(address _to, uint256 _value)
isFinalized // Only allow token transfer after the fundraising has ended
onlyPayloadSize(2)
returns (bool success)
{
return super.transfer(_to, _value);
}
transferFrom keyboard_arrow_up
Modifiers help
isFinalized checks for the following:
onlyPayloadSize checks for the following:
Source Code
function transferFrom(
address _from,
address _to,
uint256 _value
)
isFinalized // Only allow token transfer after the fundraising has ended
onlyPayloadSize(3)
returns (bool success)
{
return super.transferFrom(_from, _to, _value);
}
approve keyboard_arrow_up
Modifiers help
onlyPayloadSize checks for the following:
Source Code
function approve(address _spender, uint256 _value)
onlyPayloadSize(2)
returns (bool success)
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
allowance keyboard_arrow_up
Modifiers help
onlyPayloadSize checks for the following:
Source Code
function allowance(address _owner, address _spender)
constant
onlyPayloadSize(2)
returns (uint256 remaining)
{
return allowed[_owner][_spender];
}
createTokens keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
isFundraising checks for the following:
Requirements help
Source Code
function createTokens() external payable isFundraising {
require(block.number >= fundingStartBlock);
require(block.number <= fundingEndBlock);
require(msg.value > 0);
// First we check the ETH cap, as it's easier to calculate, return
// the contribution if the cap has been reached already
uint256 checkedReceivedEth = safeAdd(totalReceivedEth, msg.value);
require(checkedReceivedEth <= ETH_RECEIVED_CAP);
// If all is fine with the ETH cap, we continue to check the
// minimum amount of tokens and the cap for how many tokens
// have been generated so far
uint256 tokens = safeMult(msg.value, getCurrentTokenPrice());
require(tokens >= TOKEN_MIN);
uint256 checkedSupply = safeAdd(totalSupply, tokens);
require(checkedSupply <= TOKEN_CREATION_CAP);
// Only when all the checks have passed, then we update the state (ethBalances,
// totalReceivedEth, totalSupply, and balances) of the contract
ethBalances[msg.sender] = safeAdd(ethBalances[msg.sender], msg.value);
totalReceivedEth = checkedReceivedEth;
totalSupply = checkedSupply;
balances[msg.sender] += tokens; // safeAdd not needed; bad semantics to use here
// Log the creation of this tokens
LogCreateNET(msg.sender, tokens);
}
redeemTokens keyboard_arrow_up
Modifiers help
isRedeeming checks for the following:
Requirements help
Source Code
function redeemTokens(bytes32 nimiqAddress) external isRedeeming {
uint256 netVal = balances[msg.sender];
require(netVal >= TOKEN_MIN); // At least TOKEN_MIN tokens have to be redeemed
// Move the tokens of the caller to Nimiq's address
if (!super.transfer(ethFundDeposit, netVal)) throw;
// Log the redeeming of this tokens
LogRedeemNET(msg.sender, netVal, nimiqAddress);
}
retrieveEth keyboard_arrow_up
finalize keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
isFundraising checks for the following:
minimumReached checks for the following:
onlyOwner checks for the following:
Requirements help
One or more of the following:
-
totalReceivedEth
must be greater than or equal to
ETH_RECEIVED_CAP
- OR
totalSupply
must be greater than or equal to
TOKEN_CREATION_CAP
- OR
fundingEndBlock
must be less than
block.number
Source Code
function finalize()
external
isFundraising
minimumReached
onlyOwner // Only the owner of the ethFundDeposit address can finalize the contract
{
require(
block.number > fundingEndBlock ||
totalSupply >= TOKEN_CREATION_CAP ||
totalReceivedEth >= ETH_RECEIVED_CAP
); // Only allow to finalize the contract before the ending block if we already reached any of the two caps
// Move the contract to Finalized state
state = ContractState.Finalized;
savedState = ContractState.Finalized;
// Send the ETH to Nimiq Creators
ethFundDeposit.transfer(this.balance);
}
startRedeeming keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
isFinalized checks for the following:
onlyOwner checks for the following:
Source Code
function startRedeeming()
external
isFinalized // The redeeming period can only be started after the contract is finalized
onlyOwner // Only the owner of the ethFundDeposit address can start the redeeming period
{
// Move the contract to Redeeming state
state = ContractState.Redeeming;
savedState = ContractState.Redeeming;
}
pause keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
notPaused checks for the following:
onlyOwner checks for the following:
Source Code
function pause()
external
notPaused // Prevent the contract getting stuck in the Paused state
onlyOwner // Only the owner of the ethFundDeposit address can pause the contract
{
// Move the contract to Paused state
savedState = state;
state = ContractState.Paused;
}
proceed keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
isPaused checks for the following:
onlyOwner checks for the following:
Source Code
function proceed()
external
isPaused
onlyOwner // Only the owner of the ethFundDeposit address can proceed with the contract
{
// Move the contract to the previous state
state = savedState;
}
refund keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
isFundraisingIgnorePaused checks for the following:
Requirements help
Source Code
function refund()
external
isFundraisingIgnorePaused // Refunding is only possible in the fundraising phase (no matter if paused) by definition
{
require(block.number > fundingEndBlock); // Prevents refund until fundraising period is over
require(totalReceivedEth < ETH_RECEIVED_MIN); // No refunds if the minimum has been reached
uint256 netVal = balances[msg.sender];
require(netVal > 0);
uint256 ethVal = ethBalances[msg.sender];
require(ethVal > 0);
// Update the state only after all the checks have passed
balances[msg.sender] = 0;
ethBalances[msg.sender] = 0;
totalSupply = safeSubtract(totalSupply, netVal); // Extra safe
// Log this refund
LogRefund(msg.sender, ethVal);
// Send the contributions only after we have updated all the balances
// If you're using a contract, make sure it works with .transfer() gas limits
msg.sender.transfer(ethVal);
}
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 NEToken.getCurrentTokenPrice keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function getCurrentTokenPrice()
private
constant
returns (uint256 currentPrice)
{
if (block.number < exchangeRateChangesBlock) {
return TOKEN_FIRST_EXCHANGE_RATE;
} else {
return TOKEN_SECOND_EXCHANGE_RATE;
}
}
internal SafeMath.safeAdd keyboard_arrow_up
internal SafeMath.safeSubtract keyboard_arrow_up
Source Code
function safeSubtract(uint256 x, uint256 y) internal returns (uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
internal SafeMath.safeMult keyboard_arrow_up
Requirements help
One or more of the following:
Source Code
function safeMult(uint256 x, uint256 y) internal returns (uint256) {
uint256 z = x * y;
assert((x == 0) || (z / x == y));
return z;
}