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
Constants (8) keyboard_arrow_up
State Variables (9) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Modifiers help
onlyPayloadSize checks for the following:
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);
}
allowance keyboard_arrow_up
transferFrom keyboard_arrow_up
Modifiers help
onlyPayloadSize checks for the following:
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);
}
approve keyboard_arrow_up
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);
}
start keyboard_arrow_up
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();
}
close keyboard_arrow_up
price keyboard_arrow_up
constructor keyboard_arrow_up
issueToken keyboard_arrow_up
Modifiers help
inProgress checks for the following:
Requirements help
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;
}
}
saleStarted keyboard_arrow_up
saleEnded keyboard_arrow_up
saleDue keyboard_arrow_up
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 HPBToken.computeTokenAmount keyboard_arrow_up
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);
}