Blockwell

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

Approval Event

Parameters help
_owner
address help
_spender
address help
_value
uint256 help

LogCreateNET Event

Parameters help
_to
address help
_value
uint256 help

LogRedeemNET Event

Parameters help
_to
address help
_value
uint256 help
_nimiqAddress
bytes32 help

LogRefund Event

Parameters help
_to
address help
_value
uint256 help

Transfer Event

Parameters help
_from
address help
_to
address help
_value
uint256 help

name Constant

string help
Nimiq Network Interim Token

symbol Constant

string help
NET

decimals Constant

uint256 help
18

TOKEN_FIRST_EXCHANGE_RATE Constant

uint256 help
175

TOKEN_SECOND_EXCHANGE_RATE Constant

uint256 help
125

TOKEN_CREATION_CAP Constant

uint256 help
10.5 * UNKNOWN VALUE * UNKNOWN VALUE

ETH_RECEIVED_CAP Constant

uint256 help
60 * UNKNOWN VALUE * UNKNOWN VALUE

ETH_RECEIVED_MIN Constant

uint256 help
5 * UNKNOWN VALUE * UNKNOWN VALUE

TOKEN_MIN Constant

uint256 help
1 * UNKNOWN VALUE

version Variable

string help

ethFundDeposit Variable

address help

state Variable

ContractState help

fundingStartBlock Variable

uint256 help

fundingEndBlock Variable

uint256 help

exchangeRateChangesBlock Variable

uint256 help

totalReceivedEth Variable

uint256 help

totalSupply Variable

uint256 help

savedState Variable

ContractState help
Internal Variable

ethBalances Variable

mapping(address => uint256) help
Internal Variable

balances Variable

mapping(address => uint256) help
Internal Variable

allowed Variable

mapping(address => mapping(address => uint256)) 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
uint256 help

Properties

Visibility help public
Mutability help transaction
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);
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
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);
}

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

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;
}

Parameters help

Name Type
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help constant

Modifiers help

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.

Properties

Visibility help public
Mutability help payable

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

Parameters help

Name Type
nimiqAddress
bytes32 help

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function retrieveEth(uint256 _value) external minimumReached onlyOwner {
  require(_value <= this.balance);

  // send the eth to Nimiq Creators
  ethFundDeposit.transfer(_value);
}

finalize keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
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.

Properties

Visibility help public
Mutability help transaction
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.

Properties

Visibility help public
Mutability help transaction
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.

Properties

Visibility help public
Mutability help transaction
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.

Properties

Visibility help public
Mutability help transaction

Modifiers 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 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 NEToken.getCurrentTokenPrice keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

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

Parameters help

Name Type
x
uint256 help
y
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function safeAdd(uint256 x, uint256 y) internal returns (uint256) {
  uint256 z = x + y;
  assert((z >= x) && (z >= y));
  return z;
}

internal SafeMath.safeSubtract keyboard_arrow_up

Parameters help

Name Type
x
uint256 help
y
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

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

Parameters help

Name Type
x
uint256 help
y
uint256 help

Properties

Visibility help internal
Mutability help transaction

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;
}