Blockwell

HPBToken

ERC20

This contract is an ERC20 token.

Name HPBToken
Symbol HPB
Decimals
Total Supply NaN HPB

About

Stats

Public Functions 14
Event Types 9
Code Size 13,709 bytes

Events (9) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
spender
address help
value
uint help

InvalidCaller Event

Parameters help
caller
address help

InvalidState Event

Parameters help
msg
bytes help

Issue Event

Parameters help
issueIndex
uint help
addr
address help
ethAmount
uint help
tokenAmount
uint help

SaleEnded Event

Parameters help

SaleFailed Event

Parameters help

SaleStarted Event

Parameters help

SaleSucceeded Event

Parameters help

Transfer Event

Parameters help
from
address help
to
address help
value
uint help

NAME Constant

string help
HPBCoin

SYMBOL Constant

string help
HPB

DECIMALS Constant

uint help
18

NUM_OF_PHASE Constant

uint help
3

BLOCKS_PER_PHASE Constant

uint16 help
29000

GOAL Constant

uint256 help
3000 ether

HARD_CAP Constant

uint256 help
4500 ether

BASE_RATE Constant

uint256 help
1050

target Variable

address help

firstblock Variable

uint help

unsoldTokenIssued Variable

bool help

totalEthReceived Variable

uint help

issueIndex Variable

uint help

totalSupply Variable

uint help

bonusPercentages Variable

uint8[] help
Internal Variable

allowed Variable

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

balances Variable

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

Properties

Visibility help public
Mutability help transaction

Modifiers help

Source Code
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) {
  balances[msg.sender] = balances[msg.sender].sub(_value);
  balances[_to] = balances[_to].add(_value);
  Transfer(msg.sender, _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

Modifiers help

Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) onlyPayloadSize(3 * 32) {
  var _allowance = allowed[_from][msg.sender];

  // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
  // if (_value > _allowance) throw;

  balances[_to] = balances[_to].add(_value);
  balances[_from] = balances[_from].sub(_value);
  allowed[_from][msg.sender] = _allowance.sub(_value);
  Transfer(_from, _to, _value);
}

Parameters help

Name Type
_spender
address help
_value
uint help

Properties

Visibility help public
Mutability help transaction

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

Parameters help

Name Type
_firstblock
uint help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
beforeStart checks for the following:

Requirements help

Source Code
function start(uint256 _firstblock) public onlyOwner beforeStart {
  if (_firstblock <= block.number) {
    // Must specify a block in the future.
    throw;
  }

  firstblock = _firstblock;
  SaleStarted();
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
afterEnd checks for the following:
Source Code
function close() public onlyOwner afterEnd {
  if (totalEthReceived < GOAL) {
    SaleFailed();
  } else {
    SaleSucceeded();
  }
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function price() public constant returns (uint256 tokens) {
  return computeTokenAmount(1 ether);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function() payable {
  issueToken(msg.sender);
}

Parameters help

Name Type
recipient
address help

Properties

Visibility help public
Mutability help payable

Modifiers help

inProgress checks for the following:
Source Code
function issueToken(address recipient) payable inProgress {
  // We only accept minimum purchase of 0.01 ETH.
  assert(msg.value >= 0.01 ether);

  // We only accept maximum purchase of 35 ETH.
  assert(msg.value <= 35 ether);

  // We only accept totalEthReceived < HARD_CAP
  uint256 ethReceived = totalEthReceived + msg.value;
  assert(ethReceived <= HARD_CAP);

  uint256 tokens = computeTokenAmount(msg.value);
  totalEthReceived = totalEthReceived.add(msg.value);

  balances[msg.sender] = balances[msg.sender].add(tokens);
  balances[target] = balances[target].sub(tokens);

  Issue(issueIndex++, recipient, msg.value, tokens);

  if (!target.send(msg.value)) {
    throw;
  }
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function saleStarted() constant returns (bool) {
  return (firstblock > 0 && block.number >= firstblock);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function saleEnded() constant returns (bool) {
  return firstblock > 0 && (saleDue() || hardCapReached());
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function saleDue() constant returns (bool) {
  return block.number >= firstblock + BLOCKS_PER_PHASE * NUM_OF_PHASE;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help constant
Source Code
function hardCapReached() constant returns (bool) {
  return totalEthReceived >= HARD_CAP;
}

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 HPBToken.computeTokenAmount keyboard_arrow_up

Parameters help

Name Type
ethAmount
uint help

Properties

Visibility help internal
Mutability help constant
Source Code
function computeTokenAmount(uint256 ethAmount)
  internal
  constant
  returns (uint256 tokens)
{
  uint256 phase = (block.number - firstblock).div(BLOCKS_PER_PHASE);

  // A safe check
  if (phase >= bonusPercentages.length) {
    phase = bonusPercentages.length - 1;
  }

  uint256 tokenBase = ethAmount.mul(BASE_RATE);
  uint256 tokenBonus = tokenBase.mul(bonusPercentages[phase]).div(100);

  tokens = tokenBase.add(tokenBonus);
}