contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Ownable | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
548,
673
]
} | 1,500 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Haltable | contract Haltable is Ownable {
bool public halted;
event Halted(bool halted);
modifier stopInEmergency {
require(!halted);
_;
}
modifier onlyInEmergency {
require(halted);
_;
}
// called by the owner on emergency, triggers stopped state
function halt() external onlyOwner {
halted = true;
Halted(true);
}
// called by the owner on end of emergency, returns to normal state
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
Halted(false);
}
} | /**
* Abstract contract that allows children to implement an
* emergency stop mechanism. Differs from Pausable by causing a throw when in halt mode.
*
*/ | NatSpecMultiLine | halt | function halt() external onlyOwner {
halted = true;
Halted(true);
}
| // called by the owner on emergency, triggers stopped state | LineComment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
287,
370
]
} | 1,501 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Haltable | contract Haltable is Ownable {
bool public halted;
event Halted(bool halted);
modifier stopInEmergency {
require(!halted);
_;
}
modifier onlyInEmergency {
require(halted);
_;
}
// called by the owner on emergency, triggers stopped state
function halt() external onlyOwner {
halted = true;
Halted(true);
}
// called by the owner on end of emergency, returns to normal state
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
Halted(false);
}
} | /**
* Abstract contract that allows children to implement an
* emergency stop mechanism. Differs from Pausable by causing a throw when in halt mode.
*
*/ | NatSpecMultiLine | unhalt | function unhalt() external onlyOwner onlyInEmergency {
halted = false;
Halted(false);
}
| // called by the owner on end of emergency, returns to normal state | LineComment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
444,
547
]
} | 1,502 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
/**
* Obsolete. Removed this check based on:
* https://blog.coinfabrik.com/smart-contract-short-address-attack-mitigation-failure/
* @dev Fix for the ERC20 short address attack.
*
* modifier onlyPayloadSize(uint size) {
* require(msg.data.length >= size + 4);
* _;
* }
*/
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint _value) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
581,
832
]
} | 1,503 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
/**
* Obsolete. Removed this check based on:
* https://blog.coinfabrik.com/smart-contract-short-address-attack-mitigation-failure/
* @dev Fix for the ERC20 short address attack.
*
* modifier onlyPayloadSize(uint size) {
* require(msg.data.length >= size + 4);
* _;
* }
*/
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1036,
1149
]
} | 1,504 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | isToken | function isToken() public constant returns (bool weAre) {
return true;
}
| /* Interface declaration */ | Comment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
265,
348
]
} | 1,505 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
623,
1229
]
} | 1,506 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1464,
2021
]
} | 1,507 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | allowance | function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2339,
2481
]
} | 1,508 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | addApproval | function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2639,
2948
]
} | 1,509 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require(_value <= _allowance);
// SafeMath uses assert instead of require though, beware when using an analysis tool
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public returns (bool success) {
// 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
require (_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
/**
* Atomic increment of approved spending
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
*/
function addApproval(address _spender, uint _addedValue) public
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
allowed[msg.sender][_spender] = oldValue.add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | subApproval | function subApproval(address _spender, uint _subtractedValue) public
returns (bool success) {
uint oldVal = allowed[msg.sender][_spender];
if (_subtractedValue > oldVal) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* Atomic decrement of approved spending.
*
* Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
3101,
3535
]
} | 1,510 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | ReleasableToken | contract ReleasableToken is StandardToken, Ownable {
/* The finalizer contract that allows lifting the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
/**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
/**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/** We restrict transfer by overriding it */
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
/** We restrict transferFrom by overriding it */
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
} | /**
* Define interface for releasing the token transfer after a successful crowdsale.
*/ | NatSpecMultiLine | setReleaseAgent | function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
| /**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
830,
1060
]
} | 1,511 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | ReleasableToken | contract ReleasableToken is StandardToken, Ownable {
/* The finalizer contract that allows lifting the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
/**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
/**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/** We restrict transfer by overriding it */
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
/** We restrict transferFrom by overriding it */
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
} | /**
* Define interface for releasing the token transfer after a successful crowdsale.
*/ | NatSpecMultiLine | setTransferAgent | function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
| /**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1195,
1330
]
} | 1,512 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | ReleasableToken | contract ReleasableToken is StandardToken, Ownable {
/* The finalizer contract that allows lifting the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
/**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
/**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/** We restrict transfer by overriding it */
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
/** We restrict transferFrom by overriding it */
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
} | /**
* Define interface for releasing the token transfer after a successful crowdsale.
*/ | NatSpecMultiLine | releaseTokenTransfer | function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
| /**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1637,
1724
]
} | 1,513 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | ReleasableToken | contract ReleasableToken is StandardToken, Ownable {
/* The finalizer contract that allows lifting the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
/**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
/**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/** We restrict transfer by overriding it */
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
/** We restrict transferFrom by overriding it */
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
} | /**
* Define interface for releasing the token transfer after a successful crowdsale.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
| /** We restrict transfer by overriding it */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2309,
2494
]
} | 1,514 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | ReleasableToken | contract ReleasableToken is StandardToken, Ownable {
/* The finalizer contract that allows lifting the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Set the contract that can call release and make the token transferable.
*
* Since the owner of this contract is (or should be) the crowdsale,
* it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
releaseAgent = addr;
}
/**
* Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
/**
* One way function to release the tokens into the wild.
*
* Can be called only from the release agent that should typically be the finalize agent ICO contract.
* In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached).
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/** We restrict transfer by overriding it */
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
// Call StandardToken.transfer()
return super.transfer(_to, _value);
}
/** We restrict transferFrom by overriding it */
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
} | /**
* Define interface for releasing the token transfer after a successful crowdsale.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
// Call StandardToken.transferForm()
return super.transferFrom(_from, _to, _value);
}
| /** We restrict transferFrom by overriding it */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2549,
2764
]
} | 1,515 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
using SafeMath for uint;
bool public mintingFinished = false;
/** List of agents that are allowed to create new tokens */
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state);
function MintableToken(uint _initialSupply, address _multisig, bool _mintable) internal {
require(_multisig != address(0));
// Cannot create a token without supply and no minting
require(_mintable || _initialSupply != 0);
// Create initially all balance on the team multisig
if (_initialSupply > 0)
mintInternal(_multisig, _initialSupply);
// No more new supply allowed after the token creation
mintingFinished = !_mintable;
}
/**
* Create new tokens and allocate them to an address.
*
* Only callable by a crowdsale contract (mint agent).
*/
function mint(address receiver, uint amount) onlyMintAgent public {
mintInternal(receiver, amount);
}
function mintInternal(address receiver, uint amount) canMint private {
totalSupply = totalSupply.add(amount);
balances[receiver] = balances[receiver].add(amount);
// Removed because this may be confused with anonymous transfers in the upcoming fork.
// This will make the mint transaction appear in EtherScan.io
// We can remove this after there is a standardized minting event
// Transfer(0, receiver, amount);
Minted(receiver, amount);
}
/**
* Owner can allow a crowdsale contract to mint new tokens.
*/
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
// Only mint agents are allowed to mint new tokens
require(mintAgents[msg.sender]);
_;
}
/** Make sure we are not done yet. */
modifier canMint() {
require(!mintingFinished);
_;
}
} | /**
* A token that can increase its supply by another contract.
*
* This allows uncapped crowdsale by dynamically increasing the supply when money pours in.
* Only mint agents, contracts whitelisted by owner, can mint new tokens.
*
*/ | NatSpecMultiLine | mint | function mint(address receiver, uint amount) onlyMintAgent public {
mintInternal(receiver, amount);
}
| /**
* Create new tokens and allocate them to an address.
*
* Only callable by a crowdsale contract (mint agent).
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
913,
1025
]
} | 1,516 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
using SafeMath for uint;
bool public mintingFinished = false;
/** List of agents that are allowed to create new tokens */
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state);
function MintableToken(uint _initialSupply, address _multisig, bool _mintable) internal {
require(_multisig != address(0));
// Cannot create a token without supply and no minting
require(_mintable || _initialSupply != 0);
// Create initially all balance on the team multisig
if (_initialSupply > 0)
mintInternal(_multisig, _initialSupply);
// No more new supply allowed after the token creation
mintingFinished = !_mintable;
}
/**
* Create new tokens and allocate them to an address.
*
* Only callable by a crowdsale contract (mint agent).
*/
function mint(address receiver, uint amount) onlyMintAgent public {
mintInternal(receiver, amount);
}
function mintInternal(address receiver, uint amount) canMint private {
totalSupply = totalSupply.add(amount);
balances[receiver] = balances[receiver].add(amount);
// Removed because this may be confused with anonymous transfers in the upcoming fork.
// This will make the mint transaction appear in EtherScan.io
// We can remove this after there is a standardized minting event
// Transfer(0, receiver, amount);
Minted(receiver, amount);
}
/**
* Owner can allow a crowdsale contract to mint new tokens.
*/
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
// Only mint agents are allowed to mint new tokens
require(mintAgents[msg.sender]);
_;
}
/** Make sure we are not done yet. */
modifier canMint() {
require(!mintingFinished);
_;
}
} | /**
* A token that can increase its supply by another contract.
*
* This allows uncapped crowdsale by dynamically increasing the supply when money pours in.
* Only mint agents, contracts whitelisted by owner, can mint new tokens.
*
*/ | NatSpecMultiLine | setMintAgent | function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
| /**
* Owner can allow a crowdsale contract to mint new tokens.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1592,
1744
]
} | 1,517 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeAgent | contract UpgradeAgent {
/** This value should be the same as the original token's total supply */
uint public originalSupply;
/** Interface to ensure the contract is correctly configured */
function isUpgradeAgent() public constant returns (bool) {
return true;
}
/**
Upgrade an account
When the token contract is in the upgrade status the each user will
have to call `upgrade(value)` function from UpgradeableToken.
The upgrade function adjust the balance of the user and the supply
of the previous token and then call `upgradeFrom(value)`.
The UpgradeAgent is the responsible to create the tokens for the user
in the new contract.
* @param _from Account to upgrade.
* @param _value Tokens to upgrade.
*/
function upgradeFrom(address _from, uint _value) public;
} | /**
* Upgrade agent transfers tokens to a new contract.
* Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting.
*
* The Upgrade agent is the interface used to implement a token
* migration in the case of an emergency.
* The function upgradeFrom has to implement the part of the creation
* of new tokens on behalf of the user doing the upgrade.
*
* The new token can implement this interface directly, or use.
*/ | NatSpecMultiLine | isUpgradeAgent | function isUpgradeAgent() public constant returns (bool) {
return true;
}
| /** Interface to ensure the contract is correctly configured */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
204,
288
]
} | 1,518 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeAgent | contract UpgradeAgent {
/** This value should be the same as the original token's total supply */
uint public originalSupply;
/** Interface to ensure the contract is correctly configured */
function isUpgradeAgent() public constant returns (bool) {
return true;
}
/**
Upgrade an account
When the token contract is in the upgrade status the each user will
have to call `upgrade(value)` function from UpgradeableToken.
The upgrade function adjust the balance of the user and the supply
of the previous token and then call `upgradeFrom(value)`.
The UpgradeAgent is the responsible to create the tokens for the user
in the new contract.
* @param _from Account to upgrade.
* @param _value Tokens to upgrade.
*/
function upgradeFrom(address _from, uint _value) public;
} | /**
* Upgrade agent transfers tokens to a new contract.
* Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting.
*
* The Upgrade agent is the interface used to implement a token
* migration in the case of an emergency.
* The function upgradeFrom has to implement the part of the creation
* of new tokens on behalf of the user doing the upgrade.
*
* The new token can implement this interface directly, or use.
*/ | NatSpecMultiLine | upgradeFrom | function upgradeFrom(address _from, uint _value) public;
| /**
Upgrade an account
When the token contract is in the upgrade status the each user will
have to call `upgrade(value)` function from UpgradeableToken.
The upgrade function adjust the balance of the user and the supply
of the previous token and then call `upgradeFrom(value)`.
The UpgradeAgent is the responsible to create the tokens for the user
in the new contract.
* @param _from Account to upgrade.
* @param _value Tokens to upgrade.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
776,
835
]
} | 1,519 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | UpgradeableToken | function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
| /**
* Do not allow construction without upgrade master set.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1203,
1301
]
} | 1,520 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | upgrade | function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
| /**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1398,
2016
]
} | 1,521 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | setUpgradeAgent | function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
| /**
* Set an upgrade agent that handles the upgrade process
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2093,
2763
]
} | 1,522 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | getUpgradeState | function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
| /**
* Get the state of the token upgrade.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
2822,
3145
]
} | 1,523 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | changeUpgradeMaster | function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
| /**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
3268,
3411
]
} | 1,524 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | setUpgradeMaster | function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
| /**
* Internal upgrade master setter.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
3466,
3595
]
} | 1,525 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | UpgradeableToken | contract UpgradeableToken is StandardToken {
/** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
address public upgradeMaster;
/** The next contract where the tokens will be migrated. */
UpgradeAgent public upgradeAgent;
/** How many tokens we have upgraded by now. */
uint public totalUpgraded;
/**
* Upgrade states.
*
* - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
* - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
* - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
* - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
*
*/
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
/**
* Somebody has upgraded some of his tokens.
*/
event Upgrade(address indexed _from, address indexed _to, uint _value);
/**
* New upgrade agent available.
*/
event UpgradeAgentSet(address agent);
/**
* Do not allow construction without upgrade master set.
*/
function UpgradeableToken(address _upgradeMaster) {
setUpgradeMaster(_upgradeMaster);
}
/**
* Allow the token holder to upgrade some of their tokens to a new contract.
*/
function upgrade(uint value) public {
UpgradeState state = getUpgradeState();
// Ensure it's not called in a bad state
require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);
// Validate input value.
require(value != 0);
balances[msg.sender] = balances[msg.sender].sub(value);
// Take tokens out from circulation
totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
/**
* Set an upgrade agent that handles the upgrade process
*/
function setUpgradeAgent(address agent) external {
// Check whether the token is in a state that we could think of upgrading
require(canUpgrade());
require(agent != 0x0);
// Only a master can designate the next agent
require(msg.sender == upgradeMaster);
// Upgrade has already begun for an agent
require(getUpgradeState() != UpgradeState.Upgrading);
upgradeAgent = UpgradeAgent(agent);
// Bad interface
require(upgradeAgent.isUpgradeAgent());
// Make sure that token supplies match in source and target
require(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
/**
* Get the state of the token upgrade.
*/
function getUpgradeState() public constant returns(UpgradeState) {
if (!canUpgrade()) return UpgradeState.NotAllowed;
else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
/**
* Change the upgrade master.
*
* This allows us to set a new owner for the upgrade mechanism.
*/
function changeUpgradeMaster(address new_master) public {
require(msg.sender == upgradeMaster);
setUpgradeMaster(new_master);
}
/**
* Internal upgrade master setter.
*/
function setUpgradeMaster(address new_master) private {
require(new_master != 0x0);
upgradeMaster = new_master;
}
/**
* Child contract can enable to provide the condition when the upgrade can begin.
*/
function canUpgrade() public constant returns(bool) {
return true;
}
} | /**
* A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
*
*/ | NatSpecMultiLine | canUpgrade | function canUpgrade() public constant returns(bool) {
return true;
}
| /**
* Child contract can enable to provide the condition when the upgrade can begin.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
3697,
3777
]
} | 1,526 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CrowdsaleToken | contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, FractionalERC20 {
event UpdatedTokenInformation(string newName, string newSymbol);
string public name;
string public symbol;
/**
* Construct the token.
*
* This token must be created through a team multisig wallet, so that it is owned by that wallet.
*
* @param _name Token name
* @param _symbol Token symbol - typically it's all caps
* @param _initialSupply How many tokens we start with
* @param _decimals Number of decimal places
* @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
*/
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, address _multisig, bool _mintable)
UpgradeableToken(_multisig) MintableToken(_initialSupply, _multisig, _mintable) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
/**
* When token is released to be transferable, prohibit new token creation.
*/
function releaseTokenTransfer() public onlyReleaseAgent {
mintingFinished = true;
super.releaseTokenTransfer();
}
/**
* Allow upgrade agent functionality to kick in only if the crowdsale was a success.
*/
function canUpgrade() public constant returns(bool) {
return released && super.canUpgrade();
}
/**
* Owner can update token information here
*/
function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
} | /**
* A crowdsale token.
*
* An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
*
* - The token transfer() is disabled until the crowdsale is over
* - The token contract gives an opt-in upgrade path to a new contract
* - The same token can be part of several crowdsales through the approve() mechanism
* - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
*
*/ | NatSpecMultiLine | CrowdsaleToken | function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, address _multisig, bool _mintable)
UpgradeableToken(_multisig) MintableToken(_initialSupply, _multisig, _mintable) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
| /**
* Construct the token.
*
* This token must be created through a team multisig wallet, so that it is owned by that wallet.
*
* @param _name Token name
* @param _symbol Token symbol - typically it's all caps
* @param _initialSupply How many tokens we start with
* @param _decimals Number of decimal places
* @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
751,
1041
]
} | 1,527 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CrowdsaleToken | contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, FractionalERC20 {
event UpdatedTokenInformation(string newName, string newSymbol);
string public name;
string public symbol;
/**
* Construct the token.
*
* This token must be created through a team multisig wallet, so that it is owned by that wallet.
*
* @param _name Token name
* @param _symbol Token symbol - typically it's all caps
* @param _initialSupply How many tokens we start with
* @param _decimals Number of decimal places
* @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
*/
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, address _multisig, bool _mintable)
UpgradeableToken(_multisig) MintableToken(_initialSupply, _multisig, _mintable) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
/**
* When token is released to be transferable, prohibit new token creation.
*/
function releaseTokenTransfer() public onlyReleaseAgent {
mintingFinished = true;
super.releaseTokenTransfer();
}
/**
* Allow upgrade agent functionality to kick in only if the crowdsale was a success.
*/
function canUpgrade() public constant returns(bool) {
return released && super.canUpgrade();
}
/**
* Owner can update token information here
*/
function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
} | /**
* A crowdsale token.
*
* An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
*
* - The token transfer() is disabled until the crowdsale is over
* - The token contract gives an opt-in upgrade path to a new contract
* - The same token can be part of several crowdsales through the approve() mechanism
* - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
*
*/ | NatSpecMultiLine | releaseTokenTransfer | function releaseTokenTransfer() public onlyReleaseAgent {
mintingFinished = true;
super.releaseTokenTransfer();
}
| /**
* When token is released to be transferable, prohibit new token creation.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1136,
1265
]
} | 1,528 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CrowdsaleToken | contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, FractionalERC20 {
event UpdatedTokenInformation(string newName, string newSymbol);
string public name;
string public symbol;
/**
* Construct the token.
*
* This token must be created through a team multisig wallet, so that it is owned by that wallet.
*
* @param _name Token name
* @param _symbol Token symbol - typically it's all caps
* @param _initialSupply How many tokens we start with
* @param _decimals Number of decimal places
* @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
*/
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, address _multisig, bool _mintable)
UpgradeableToken(_multisig) MintableToken(_initialSupply, _multisig, _mintable) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
/**
* When token is released to be transferable, prohibit new token creation.
*/
function releaseTokenTransfer() public onlyReleaseAgent {
mintingFinished = true;
super.releaseTokenTransfer();
}
/**
* Allow upgrade agent functionality to kick in only if the crowdsale was a success.
*/
function canUpgrade() public constant returns(bool) {
return released && super.canUpgrade();
}
/**
* Owner can update token information here
*/
function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
} | /**
* A crowdsale token.
*
* An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
*
* - The token transfer() is disabled until the crowdsale is over
* - The token contract gives an opt-in upgrade path to a new contract
* - The same token can be part of several crowdsales through the approve() mechanism
* - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
*
*/ | NatSpecMultiLine | canUpgrade | function canUpgrade() public constant returns(bool) {
return released && super.canUpgrade();
}
| /**
* Allow upgrade agent functionality to kick in only if the crowdsale was a success.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1370,
1475
]
} | 1,529 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CrowdsaleToken | contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, FractionalERC20 {
event UpdatedTokenInformation(string newName, string newSymbol);
string public name;
string public symbol;
/**
* Construct the token.
*
* This token must be created through a team multisig wallet, so that it is owned by that wallet.
*
* @param _name Token name
* @param _symbol Token symbol - typically it's all caps
* @param _initialSupply How many tokens we start with
* @param _decimals Number of decimal places
* @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
*/
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, address _multisig, bool _mintable)
UpgradeableToken(_multisig) MintableToken(_initialSupply, _multisig, _mintable) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
/**
* When token is released to be transferable, prohibit new token creation.
*/
function releaseTokenTransfer() public onlyReleaseAgent {
mintingFinished = true;
super.releaseTokenTransfer();
}
/**
* Allow upgrade agent functionality to kick in only if the crowdsale was a success.
*/
function canUpgrade() public constant returns(bool) {
return released && super.canUpgrade();
}
/**
* Owner can update token information here
*/
function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
} | /**
* A crowdsale token.
*
* An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
*
* - The token transfer() is disabled until the crowdsale is over
* - The token contract gives an opt-in upgrade path to a new contract
* - The same token can be part of several crowdsales through the approve() mechanism
* - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
*
*/ | NatSpecMultiLine | setTokenInformation | function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
| /**
* Owner can update token information here
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1538,
1704
]
} | 1,530 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | function() payable {
require(false);
}
| /**
* Don't expect to just send in money and get tokens.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
3783,
3832
]
} | 1,531 |
||
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | investInternal | function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
| /**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
4158,
5232
]
} | 1,532 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | preallocate | function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
| /**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
5692,
6117
]
} | 1,533 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | updateInvestorFunds | function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
| /**
* Private function to update accounting in the crowdsale.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
6196,
6770
]
} | 1,534 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setFundingCap | function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
| /**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
7008,
7241
]
} | 1,535 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | buyWithCustomerId | function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
| /**
* Invest to tokens, recognize the payer.
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
7309,
7480
]
} | 1,536 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | buy | function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
| /**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
7643,
7813
]
} | 1,537 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | finalize | function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
| /**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
7988,
8159
]
} | 1,538 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setRequireCustomerId | function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
| /**
* Set policy do we need to have server-side customer ids for the investments.
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
8264,
8429
]
} | 1,539 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setEarlyParticipantWhitelist | function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
| /**
* Allow addresses to do early participation.
*
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
8501,
8699
]
} | 1,540 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setPricingStrategy | function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
| /**
* Allow to (re)set pricing strategy.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
8757,
8931
]
} | 1,541 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setCeilingStrategy | function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
| /**
* Allow to (re)set ceiling strategy.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
8989,
9163
]
} | 1,542 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setFinalizeAgent | function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
| /**
* Allow to (re)set finalize agent.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
9219,
9418
]
} | 1,543 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setMultisig | function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
| /**
* Internal setter for the multisig wallet
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
9481,
9587
]
} | 1,544 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | loadRefund | function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
| /**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
9791,
10105
]
} | 1,545 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | refund | function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
| /**
* Investors can claim refund.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
10156,
10467
]
} | 1,546 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | isMinimumGoalReached | function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
| /**
* @return true if the crowdsale has raised enough money to be a success
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
10560,
10685
]
} | 1,547 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | isFinalizerSane | function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
| /**
* Check if the contract relationship looks good.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
10755,
10868
]
} | 1,548 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | getState | function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
| /**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
11044,
11536
]
} | 1,549 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | setOwnerTestValue | function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
| /** This is for manual testing of multisig wallet interaction */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
11607,
11714
]
} | 1,550 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | Crowdsale | contract Crowdsale is Haltable {
using SafeMath for uint;
/* The token we are selling */
CrowdsaleToken public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* How we are going to limit our offering */
CeilingStrategy public ceilingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* ether will be transferred to this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the funding cannot exceed this cap; may be set later on during the crowdsale */
uint public weiFundingCap = 0;
/* the starting block number of the crowdsale */
uint public startsAt;
/* the ending block number of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How many wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How many wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have a unique contributor id for each customer */
bool public requireCustomerId;
/** How many ETH each address has invested in this crowdsale */
mapping (address => uint) public investedAmountOf;
/** How many tokens this crowdsale has credited for each investor address */
mapping (address => uint) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manual testing of the interaction with the owner's wallet. You can set it to any value and inspect this in a blockchain explorer to see that crowdsale interaction works. */
uint8 public ownerTestValue;
/** State machine
*
* - Prefunding: We have not reached the starting block yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before the ending block
* - Finalized: The finalize function has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract to be reclaimed by investors.
*/
enum State{Unknown, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules about what kind of investments we accept were changed
event InvestmentPolicyChanged(bool requireCId);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale's finalize function has been called
event Finalized();
// A new funding cap has been set
event FundingCapSet(uint newFundingCap);
function Crowdsale(address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) internal {
setMultisig(_multisigWallet);
// Don't mess the dates
require(_start != 0 && _end != 0);
require(block.number < _start && _start < _end);
startsAt = _start;
endsAt = _end;
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
require(false);
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[receiver]);
}
uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
uint weiToReturn = msg.value.sub(weiAmount);
if (weiToReturn > 0) {
msg.sender.transfer(weiToReturn);
}
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner notFinished {
require(receiver != address(0));
uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
require(tokenAmount != 0);
uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
}
/**
* Private function to update accounting in the crowdsale.
*/
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
// Update totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us that the investment was completed successfully
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Allow the owner to set a funding cap on the crowdsale.
* The new cap should be higher than the minimum funding goal.
*
* @param newCap minimum target cap that may be relaxed if it was already broken.
*/
function setFundingCap(uint newCap) public onlyOwner notFinished {
weiFundingCap = ceilingStrategy.relaxFundingCap(newCap, weiRaised);
require(weiFundingCap >= minimumFundingGoal);
FundingCapSet(weiFundingCap);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
require(customerId != 0); // UUIDv4 sanity check
investInternal(msg.sender, customerId);
}
/**
* The basic entry point to participate in the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
require(!requireCustomerId); // Crowdsale needs to track participants for thank you email
investInternal(msg.sender, 0);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can trigger a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
finalizeAgent.finalizeCrowdsale(token);
finalized = true;
Finalized();
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner stopInEmergency {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId);
}
/**
* Allow addresses to do early participation.
*
*/
function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow to (re)set pricing strategy.
*/
function setPricingStrategy(PricingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isPricingStrategy());
pricingStrategy = addr;
}
/**
* Allow to (re)set ceiling strategy.
*/
function setCeilingStrategy(CeilingStrategy addr) internal {
// Disallow setting a bad agent
require(addr.isCeilingStrategy());
ceilingStrategy = addr;
}
/**
* Allow to (re)set finalize agent.
*/
function setFinalizeAgent(FinalizeAgent addr) internal {
// Disallow setting a bad agent
require(addr.isFinalizeAgent());
finalizeAgent = addr;
require(isFinalizerSane());
}
/**
* Internal setter for the multisig wallet
*/
function setMultisig(address addr) internal {
require(addr != 0);
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case that the minimum goal was not reached.
*/
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
}
/**
* Investors can claim refund.
*/
function refund() public inState(State.Refunding) stopInEmergency {
uint weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
/**
* @return true if the crowdsale has raised enough money to be a success
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane(token);
}
/**
* Crowdfund state machine management.
*
* This function has the timed transition builtin.
* So there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if (finalized) return State.Finalized;
else if (block.number < startsAt) return State.PreFunding;
else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint8 val) public onlyOwner stopInEmergency {
ownerTestValue = val;
}
function assignTokens(address receiver, uint tokenAmount) private {
token.mint(receiver, tokenAmount);
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modifier allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
require(getState() == state);
_;
}
modifier notFinished() {
State current_state = getState();
require(current_state == State.PreFunding || current_state == State.Funding);
_;
}
} | /**
* Abstract base contract for token sales.
*
* Handles
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/ | NatSpecMultiLine | isCrowdsale | function isCrowdsale() public constant returns (bool) {
return true;
}
| /** Interface marker. */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
11863,
11944
]
} | 1,551 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | PricingStrategy | contract PricingStrategy {
/** Interface declaration. */
function isPricingStrategy() public constant returns (bool) {
return true;
}
/**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction sent in as wei
* @param weiRaised - how much money has been raised this far
* @param tokensSold - how many tokens have been sold this far
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
} | /**
* Interface for defining crowdsale pricing.
*/ | NatSpecMultiLine | isPricingStrategy | function isPricingStrategy() public constant returns (bool) {
return true;
}
| /** Interface declaration. */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
63,
150
]
} | 1,552 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | PricingStrategy | contract PricingStrategy {
/** Interface declaration. */
function isPricingStrategy() public constant returns (bool) {
return true;
}
/**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction sent in as wei
* @param weiRaised - how much money has been raised this far
* @param tokensSold - how many tokens have been sold this far
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
} | /**
* Interface for defining crowdsale pricing.
*/ | NatSpecMultiLine | calculatePrice | function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
| /**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction sent in as wei
* @param weiRaised - how much money has been raised this far
* @param tokensSold - how many tokens have been sold this far
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
649,
798
]
} | 1,553 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | FlatPricing | contract FlatPricing is PricingStrategy {
using SafeMath for uint;
/* How many weis one token costs */
uint public oneTokenInWei;
function FlatPricing(uint _oneTokenInWei) {
oneTokenInWei = _oneTokenInWei;
}
/**
* Calculate the current price for buy in amount.
*
* @ param {uint value} Buy-in value in wei.
* @ param
* @ param
* @ param
* @ param {uint decimals} The decimals used by the token representation (e.g. given by FractionalERC20).
*/
function calculatePrice(uint value, uint, uint, address, uint decimals) public constant returns (uint) {
uint multiplier = 10 ** decimals;
return value.mul(multiplier).div(oneTokenInWei);
}
} | /**
* Fixed crowdsale pricing - everybody gets the same price.
*/ | NatSpecMultiLine | calculatePrice | function calculatePrice(uint value, uint, uint, address, uint decimals) public constant returns (uint) {
uint multiplier = 10 ** decimals;
return value.mul(multiplier).div(oneTokenInWei);
}
| /**
* Calculate the current price for buy in amount.
*
* @ param {uint value} Buy-in value in wei.
* @ param
* @ param
* @ param
* @ param {uint decimals} The decimals used by the token representation (e.g. given by FractionalERC20).
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
511,
716
]
} | 1,554 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CeilingStrategy | contract CeilingStrategy {
/** Interface declaration. */
function isCeilingStrategy() public constant returns (bool) {
return true;
}
/**
* When somebody tries to buy tokens for X wei, calculate how many weis they are allowed to use.
*
*
* @param _value - What is the value of the transaction sent in as wei.
* @param _weiRaised - How much money has been raised so far.
* @param _weiInvestedBySender - the investment made by the address that is sending the transaction.
* @param _weiFundingCap - the caller's declared total cap. May be reinterpreted by the implementation of the CeilingStrategy.
* @return Amount of wei the crowdsale can receive.
*/
function weiAllowedToReceive(uint _value, uint _weiRaised, uint _weiInvestedBySender, uint _weiFundingCap) public constant returns (uint amount);
function isCrowdsaleFull(uint _weiRaised, uint _weiFundingCap) public constant returns (bool);
/**
* Calculate a new cap if the provided one is not above the amount already raised.
*
*
* @param _newCap - The potential new cap.
* @param _weiRaised - How much money has been raised so far.
* @return The adjusted cap.
*/
function relaxFundingCap(uint _newCap, uint _weiRaised) public constant returns (uint);
} | /**
* Interface for defining crowdsale ceiling.
*/ | NatSpecMultiLine | isCeilingStrategy | function isCeilingStrategy() public constant returns (bool) {
return true;
}
| /** Interface declaration. */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
63,
150
]
} | 1,555 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CeilingStrategy | contract CeilingStrategy {
/** Interface declaration. */
function isCeilingStrategy() public constant returns (bool) {
return true;
}
/**
* When somebody tries to buy tokens for X wei, calculate how many weis they are allowed to use.
*
*
* @param _value - What is the value of the transaction sent in as wei.
* @param _weiRaised - How much money has been raised so far.
* @param _weiInvestedBySender - the investment made by the address that is sending the transaction.
* @param _weiFundingCap - the caller's declared total cap. May be reinterpreted by the implementation of the CeilingStrategy.
* @return Amount of wei the crowdsale can receive.
*/
function weiAllowedToReceive(uint _value, uint _weiRaised, uint _weiInvestedBySender, uint _weiFundingCap) public constant returns (uint amount);
function isCrowdsaleFull(uint _weiRaised, uint _weiFundingCap) public constant returns (bool);
/**
* Calculate a new cap if the provided one is not above the amount already raised.
*
*
* @param _newCap - The potential new cap.
* @param _weiRaised - How much money has been raised so far.
* @return The adjusted cap.
*/
function relaxFundingCap(uint _newCap, uint _weiRaised) public constant returns (uint);
} | /**
* Interface for defining crowdsale ceiling.
*/ | NatSpecMultiLine | weiAllowedToReceive | function weiAllowedToReceive(uint _value, uint _weiRaised, uint _weiInvestedBySender, uint _weiFundingCap) public constant returns (uint amount);
| /**
* When somebody tries to buy tokens for X wei, calculate how many weis they are allowed to use.
*
*
* @param _value - What is the value of the transaction sent in as wei.
* @param _weiRaised - How much money has been raised so far.
* @param _weiInvestedBySender - the investment made by the address that is sending the transaction.
* @param _weiFundingCap - the caller's declared total cap. May be reinterpreted by the implementation of the CeilingStrategy.
* @return Amount of wei the crowdsale can receive.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
708,
856
]
} | 1,556 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | CeilingStrategy | contract CeilingStrategy {
/** Interface declaration. */
function isCeilingStrategy() public constant returns (bool) {
return true;
}
/**
* When somebody tries to buy tokens for X wei, calculate how many weis they are allowed to use.
*
*
* @param _value - What is the value of the transaction sent in as wei.
* @param _weiRaised - How much money has been raised so far.
* @param _weiInvestedBySender - the investment made by the address that is sending the transaction.
* @param _weiFundingCap - the caller's declared total cap. May be reinterpreted by the implementation of the CeilingStrategy.
* @return Amount of wei the crowdsale can receive.
*/
function weiAllowedToReceive(uint _value, uint _weiRaised, uint _weiInvestedBySender, uint _weiFundingCap) public constant returns (uint amount);
function isCrowdsaleFull(uint _weiRaised, uint _weiFundingCap) public constant returns (bool);
/**
* Calculate a new cap if the provided one is not above the amount already raised.
*
*
* @param _newCap - The potential new cap.
* @param _weiRaised - How much money has been raised so far.
* @return The adjusted cap.
*/
function relaxFundingCap(uint _newCap, uint _weiRaised) public constant returns (uint);
} | /**
* Interface for defining crowdsale ceiling.
*/ | NatSpecMultiLine | relaxFundingCap | function relaxFundingCap(uint _newCap, uint _weiRaised) public constant returns (uint);
| /**
* Calculate a new cap if the provided one is not above the amount already raised.
*
*
* @param _newCap - The potential new cap.
* @param _weiRaised - How much money has been raised so far.
* @return The adjusted cap.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1214,
1304
]
} | 1,557 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | FixedCeiling | contract FixedCeiling is CeilingStrategy {
using SafeMath for uint;
/* When relaxing a cap is necessary, we use this multiple to determine the relaxed cap */
uint public chunkedWeiMultiple;
/* The limit an individual address can invest */
uint public weiLimitPerAddress;
function FixedCeiling(uint multiple, uint limit) {
chunkedWeiMultiple = multiple;
weiLimitPerAddress = limit;
}
function weiAllowedToReceive(uint tentativeAmount, uint weiRaised, uint weiInvestedBySender, uint weiFundingCap) public constant returns (uint) {
// First, we limit per address investment
uint totalOfSender = tentativeAmount.add(weiInvestedBySender);
if (totalOfSender > weiLimitPerAddress) tentativeAmount = weiLimitPerAddress.sub(weiInvestedBySender);
// Then, we check the funding cap
if (weiFundingCap == 0) return tentativeAmount;
uint total = tentativeAmount.add(weiRaised);
if (total < weiFundingCap) return tentativeAmount;
else return weiFundingCap.sub(weiRaised);
}
function isCrowdsaleFull(uint weiRaised, uint weiFundingCap) public constant returns (bool) {
return weiFundingCap > 0 && weiRaised >= weiFundingCap;
}
/* If the new target cap has not been reached yet, it's fine as it is */
function relaxFundingCap(uint newCap, uint weiRaised) public constant returns (uint) {
if (newCap > weiRaised) return newCap;
else return weiRaised.div(chunkedWeiMultiple).add(1).mul(chunkedWeiMultiple);
}
} | /**
* Fixed cap investment per address and crowdsale
*/ | NatSpecMultiLine | relaxFundingCap | function relaxFundingCap(uint newCap, uint weiRaised) public constant returns (uint) {
if (newCap > weiRaised) return newCap;
else return weiRaised.div(chunkedWeiMultiple).add(1).mul(chunkedWeiMultiple);
}
| /* If the new target cap has not been reached yet, it's fine as it is */ | Comment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1354,
1587
]
} | 1,558 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | FinalizeAgent | contract FinalizeAgent {
function isFinalizeAgent() public constant returns(bool) {
return true;
}
/** Return true if we can run finalizeCrowdsale() properly.
*
* This is a safety check function that doesn't allow crowdsale to begin
* unless the finalizer has been set up properly.
*/
function isSane(CrowdsaleToken token) public constant returns (bool);
/** Called once by crowdsale finalize() if the sale was a success. */
function finalizeCrowdsale(CrowdsaleToken token) public;
} | /**
* Finalize agent defines what happens at the end of a succesful crowdsale.
*
* - Allocate tokens for founders, bounties and community
* - Make tokens transferable
* - etc.
*/ | NatSpecMultiLine | isSane | function isSane(CrowdsaleToken token) public constant returns (bool);
| /** Return true if we can run finalizeCrowdsale() properly.
*
* This is a safety check function that doesn't allow crowdsale to begin
* unless the finalizer has been set up properly.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
320,
392
]
} | 1,559 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | FinalizeAgent | contract FinalizeAgent {
function isFinalizeAgent() public constant returns(bool) {
return true;
}
/** Return true if we can run finalizeCrowdsale() properly.
*
* This is a safety check function that doesn't allow crowdsale to begin
* unless the finalizer has been set up properly.
*/
function isSane(CrowdsaleToken token) public constant returns (bool);
/** Called once by crowdsale finalize() if the sale was a success. */
function finalizeCrowdsale(CrowdsaleToken token) public;
} | /**
* Finalize agent defines what happens at the end of a succesful crowdsale.
*
* - Allocate tokens for founders, bounties and community
* - Make tokens transferable
* - etc.
*/ | NatSpecMultiLine | finalizeCrowdsale | function finalizeCrowdsale(CrowdsaleToken token) public;
| /** Called once by crowdsale finalize() if the sale was a success. */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
468,
527
]
} | 1,560 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | BonusFinalizeAgent | contract BonusFinalizeAgent is FinalizeAgent {
using SafeMath for uint;
Crowdsale public crowdsale;
/** Total percent of tokens minted to the team at the end of the sale as base points
bonus tokens = tokensSold * bonusBasePoints * 0.0001 */
uint public bonusBasePoints;
/** Implementation detail. This is the divisor of the base points **/
uint private constant basePointsDivisor = 10000;
/** Where we move the tokens at the end of the sale. */
address public teamMultisig;
/* How many bonus tokens we allocated */
uint public allocatedBonus;
function BonusFinalizeAgent(Crowdsale _crowdsale, uint _bonusBasePoints, address _teamMultisig) {
require(address(_crowdsale) != 0 && address(_teamMultisig) != 0);
crowdsale = _crowdsale;
teamMultisig = _teamMultisig;
bonusBasePoints = _bonusBasePoints;
}
/* Can we run finalize properly */
function isSane(CrowdsaleToken token) public constant returns (bool) {
return token.mintAgents(address(this)) && token.releaseAgent() == address(this);
}
/** Called once by crowdsale finalize() if the sale was a success. */
function finalizeCrowdsale(CrowdsaleToken token) {
require(msg.sender == address(crowdsale));
// How many % points of tokens the founders and others get
uint tokensSold = crowdsale.tokensSold();
uint saleBasePoints = basePointsDivisor.sub(bonusBasePoints);
allocatedBonus = tokensSold.mul(bonusBasePoints).div(saleBasePoints);
// Move tokens to the team multisig wallet
token.mint(teamMultisig, allocatedBonus);
// Make token transferable
token.releaseTokenTransfer();
}
} | /**
* At the end of the successful crowdsale allocate % bonus of tokens to the team.
*
* Unlock tokens.
*
* BonusAllocationFinal must be set as the minting agent for the MintableToken.
*
*/ | NatSpecMultiLine | isSane | function isSane(CrowdsaleToken token) public constant returns (bool) {
return token.mintAgents(address(this)) && token.releaseAgent() == address(this);
}
| /* Can we run finalize properly */ | Comment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
921,
1085
]
} | 1,561 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | BonusFinalizeAgent | contract BonusFinalizeAgent is FinalizeAgent {
using SafeMath for uint;
Crowdsale public crowdsale;
/** Total percent of tokens minted to the team at the end of the sale as base points
bonus tokens = tokensSold * bonusBasePoints * 0.0001 */
uint public bonusBasePoints;
/** Implementation detail. This is the divisor of the base points **/
uint private constant basePointsDivisor = 10000;
/** Where we move the tokens at the end of the sale. */
address public teamMultisig;
/* How many bonus tokens we allocated */
uint public allocatedBonus;
function BonusFinalizeAgent(Crowdsale _crowdsale, uint _bonusBasePoints, address _teamMultisig) {
require(address(_crowdsale) != 0 && address(_teamMultisig) != 0);
crowdsale = _crowdsale;
teamMultisig = _teamMultisig;
bonusBasePoints = _bonusBasePoints;
}
/* Can we run finalize properly */
function isSane(CrowdsaleToken token) public constant returns (bool) {
return token.mintAgents(address(this)) && token.releaseAgent() == address(this);
}
/** Called once by crowdsale finalize() if the sale was a success. */
function finalizeCrowdsale(CrowdsaleToken token) {
require(msg.sender == address(crowdsale));
// How many % points of tokens the founders and others get
uint tokensSold = crowdsale.tokensSold();
uint saleBasePoints = basePointsDivisor.sub(bonusBasePoints);
allocatedBonus = tokensSold.mul(bonusBasePoints).div(saleBasePoints);
// Move tokens to the team multisig wallet
token.mint(teamMultisig, allocatedBonus);
// Make token transferable
token.releaseTokenTransfer();
}
} | /**
* At the end of the successful crowdsale allocate % bonus of tokens to the team.
*
* Unlock tokens.
*
* BonusAllocationFinal must be set as the minting agent for the MintableToken.
*
*/ | NatSpecMultiLine | finalizeCrowdsale | function finalizeCrowdsale(CrowdsaleToken token) {
require(msg.sender == address(crowdsale));
// How many % points of tokens the founders and others get
uint tokensSold = crowdsale.tokensSold();
uint saleBasePoints = basePointsDivisor.sub(bonusBasePoints);
allocatedBonus = tokensSold.mul(bonusBasePoints).div(saleBasePoints);
// Move tokens to the team multisig wallet
token.mint(teamMultisig, allocatedBonus);
// Make token transferable
token.releaseTokenTransfer();
}
| /** Called once by crowdsale finalize() if the sale was a success. */ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1161,
1688
]
} | 1,562 |
|
HubiiCrowdsale | HubiiCrowdsale.sol | 0xb9aac097f4dadcd6f06761eb470346415ef28d5a | Solidity | HubiiCrowdsale | contract HubiiCrowdsale is Crowdsale {
uint private constant chunked_multiple = 18000 * (10 ** 18); // in wei
uint private constant limit_per_address = 100000 * (10 ** 18); // in wei
uint private constant hubii_minimum_funding = 17000 * (10 ** 18); // in wei
uint private constant token_initial_supply = 0;
uint8 private constant token_decimals = 15;
bool private constant token_mintable = true;
string private constant token_name = "Hubiits";
string private constant token_symbol = "HBT";
uint private constant token_in_wei = 10 ** 15;
// The fraction of 10,000 out of the total target tokens that is used to mint bonus tokens. These are allocated to the team's multisig wallet.
uint private constant bonus_base_points = 3000;
function HubiiCrowdsale(address _teamMultisig, uint _start, uint _end) Crowdsale(_teamMultisig, _start, _end, hubii_minimum_funding) public {
PricingStrategy p_strategy = new FlatPricing(token_in_wei);
CeilingStrategy c_strategy = new FixedCeiling(chunked_multiple, limit_per_address);
FinalizeAgent f_agent = new BonusFinalizeAgent(this, bonus_base_points, _teamMultisig);
setPricingStrategy(p_strategy);
setCeilingStrategy(c_strategy);
// Testing values
token = new CrowdsaleToken(token_name, token_symbol, token_initial_supply, token_decimals, _teamMultisig, token_mintable);
token.setMintAgent(address(this), true);
token.setMintAgent(address(f_agent), true);
token.setReleaseAgent(address(f_agent));
setFinalizeAgent(f_agent);
}
// These two setters are present only to correct block numbers if they are off from their target date by more than, say, a day
function setStartingBlock(uint startingBlock) public onlyOwner inState(State.PreFunding) {
require(startingBlock > block.number && startingBlock < endsAt);
startsAt = startingBlock;
}
function setEndingBlock(uint endingBlock) public onlyOwner notFinished {
require(endingBlock > block.number && endingBlock > startsAt);
endsAt = endingBlock;
}
} | // This contract has the sole objective of providing a sane concrete instance of the Crowdsale contract. | LineComment | setStartingBlock | function setStartingBlock(uint startingBlock) public onlyOwner inState(State.PreFunding) {
require(startingBlock > block.number && startingBlock < endsAt);
startsAt = startingBlock;
}
| // These two setters are present only to correct block numbers if they are off from their target date by more than, say, a day | LineComment | v0.4.13+commit.fb4cb1a | bzzr://81828f9ae489ed77919587782a892cfe871396b934c3819f5804c4d9732b6c1e | {
"func_code_index": [
1762,
1973
]
} | 1,563 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/ | NatSpecMultiLine | mul | function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
| /**
* @dev Multiplies two numbers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
90,
493
]
} | 1,564 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/ | NatSpecMultiLine | div | function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
605,
893
]
} | 1,565 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/ | NatSpecMultiLine | sub | function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
| /**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
1008,
1153
]
} | 1,566 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/ | NatSpecMultiLine | add | function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
| /**
* @dev Adds two numbers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
1218,
1362
]
} | 1,567 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
| /**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
1497,
1614
]
} | 1,568 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
281,
369
]
} | 1,569 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
575,
680
]
} | 1,570 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
1004,
1170
]
} | 1,571 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
1328,
1665
]
} | 1,572 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
2291,
2487
]
} | 1,573 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
2767,
3265
]
} | 1,574 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | increaseApproval | function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
3726,
4039
]
} | 1,575 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
4505,
4959
]
} | 1,576 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | _mint | function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
| /**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
5295,
5551
]
} | 1,577 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | _burn | function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
| /**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
5771,
6075
]
} | 1,578 |
|
HGGToken | HGGToken.sol | 0x2e963aa99892c403039a93573a43607b547f5b88 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param _account The account that will receive the created tokens.
* @param _amount The amount that will be created.
*/
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
balances_[_account] = balances_[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | _burnFrom | function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
| /**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://52c192a0b725629aab5d8e5e6f0ffbeb2f3f9c56f98688c6bf5fc58a9bd97af9 | {
"func_code_index": [
6391,
6805
]
} | 1,579 |
|
Sequences | contracts/sequences.sol | 0xe5ae9912bf5c8621d411461e7f53144c407d3a79 | Solidity | Base64 | library Base64 {
bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return "";
// multiply by 4/3 rounded up
uint256 encodedLen = 4 * ((len + 2) / 3);
// Add some extra buffer at the end
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
} | /// [MIT License]
/// @title Base64
/// @notice Provides a function for encoding some bytes in base64
/// @author Brecht Devos <[email protected]> | NatSpecSingleLine | encode | function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return "";
// multiply by 4/3 rounded up
uint256 encodedLen = 4 * ((len + 2) / 3);
// Add some extra buffer at the end
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
| /// @notice Encodes some bytes to the base64 representation | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
190,
1802
]
} | 1,580 |
||
PresaleAllocation | contracts/TempleERC20Token.sol | 0x6cf2a119f98a4b4a7fa4fd08a1e72d7af3ba72fe | Solidity | TempleERC20Token | contract TempleERC20Token is ERC20, ERC20Burnable, Pausable, Ownable, AccessControl {
bytes32 public constant CAN_MINT = keccak256("CAN_MINT");
constructor() ERC20("Temple", "TEMPLE") {
_setupRole(DEFAULT_ADMIN_ROLE, owner());
}
/**
* For use in emergencies to pause all token transfers
*/
function pause() external onlyOwner {
_pause();
}
/**
* Revert back to normal operations once P0 which caused pause has been
* triaged and fixed.
*/
function unpause() external onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) external {
require(hasRole(CAN_MINT, msg.sender), "Caller cannot mint");
_mint(to, amount);
}
function addMinter(address account) external onlyOwner {
grantRole(CAN_MINT, account);
}
function removeMinter(address account) external onlyOwner {
revokeRole(CAN_MINT, account);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
} | pause | function pause() external onlyOwner {
_pause();
}
| /**
* For use in emergencies to pause all token transfers
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
326,
391
]
} | 1,581 |
||||
PresaleAllocation | contracts/TempleERC20Token.sol | 0x6cf2a119f98a4b4a7fa4fd08a1e72d7af3ba72fe | Solidity | TempleERC20Token | contract TempleERC20Token is ERC20, ERC20Burnable, Pausable, Ownable, AccessControl {
bytes32 public constant CAN_MINT = keccak256("CAN_MINT");
constructor() ERC20("Temple", "TEMPLE") {
_setupRole(DEFAULT_ADMIN_ROLE, owner());
}
/**
* For use in emergencies to pause all token transfers
*/
function pause() external onlyOwner {
_pause();
}
/**
* Revert back to normal operations once P0 which caused pause has been
* triaged and fixed.
*/
function unpause() external onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) external {
require(hasRole(CAN_MINT, msg.sender), "Caller cannot mint");
_mint(to, amount);
}
function addMinter(address account) external onlyOwner {
grantRole(CAN_MINT, account);
}
function removeMinter(address account) external onlyOwner {
revokeRole(CAN_MINT, account);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
} | unpause | function unpause() external onlyOwner {
_unpause();
}
| /**
* Revert back to normal operations once P0 which caused pause has been
* triaged and fixed.
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
511,
580
]
} | 1,582 |
||||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | totalSupply | function totalSupply() constant returns (uint256 supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
61,
125
]
} | 1,583 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
234,
311
]
} | 1,584 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transfer | function transfer(address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
549,
626
]
} | 1,585 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
950,
1046
]
} | 1,586 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | approve | function approve(address _spender, uint256 _value) returns (bool success) {}
| /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
1331,
1412
]
} | 1,587 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
| /// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
1621,
1718
]
} | 1,588 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Coinware | contract Coinware is StandardToken { // CHANGE THIS. Update the contract name.
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function Coinware() {
balances[msg.sender] = 40000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
totalSupply = 40000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS)
name = "Coinware"; // Set the name for display purposes (CHANGE THIS)
decimals = 18; // Amount of decimals for display purposes (CHANGE THIS)
symbol = "CWT"; // Set the symbol for display purposes (CHANGE THIS)
unitsOneEthCanBuy = 50000; // Set the price of your token for the ICO (CHANGE THIS)
fundsWallet = msg.sender; // The owner of the contract gets ETH
}
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | Coinware | function Coinware() {
balances[msg.sender] = 40000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
totalSupply = 40000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS)
name = "Coinware"; // Set the name for display purposes (CHANGE THIS)
decimals = 18; // Amount of decimals for display purposes (CHANGE THIS)
symbol = "CWT"; // Set the symbol for display purposes (CHANGE THIS)
unitsOneEthCanBuy = 50000; // Set the price of your token for the ICO (CHANGE THIS)
fundsWallet = msg.sender; // The owner of the contract gets ETH
}
| // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
1196,
2211
]
} | 1,589 |
|||
Coinware | Coinware.sol | 0x32ad7ee1d8e3e487674ea0e0980a530785c1a408 | Solidity | Coinware | contract Coinware is StandardToken { // CHANGE THIS. Update the contract name.
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function Coinware() {
balances[msg.sender] = 40000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
totalSupply = 40000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS)
name = "Coinware"; // Set the name for display purposes (CHANGE THIS)
decimals = 18; // Amount of decimals for display purposes (CHANGE THIS)
symbol = "CWT"; // Set the symbol for display purposes (CHANGE THIS)
unitsOneEthCanBuy = 50000; // Set the price of your token for the ICO (CHANGE THIS)
fundsWallet = msg.sender; // The owner of the contract gets ETH
}
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.25+commit.59dbf8f1 | bzzr://e2acfb89a7859da5364ca68c2b5f544ef95846d708c3b26474d909dda885a2ce | {
"func_code_index": [
2807,
3612
]
} | 1,590 |
|||
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
251,
437
]
} | 1,591 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
707,
848
]
} | 1,592 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
1138,
1335
]
} | 1,593 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
1581,
2057
]
} | 1,594 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
2520,
2657
]
} | 1,595 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
3140,
3490
]
} | 1,596 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
3942,
4077
]
} | 1,597 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
4549,
4720
]
} | 1,598 |
Unbonded | Unbonded.sol | 0x833bed908817dad9c93a52ca21040afa33da9a56 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function burn(uint256 amount) external;
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.11+commit.5ef660b1 | None | ipfs://c271b942d941496cfa53d8ea0c4fc9079e4e7144ff292e1bc898ad6e3434b201 | {
"func_code_index": [
94,
154
]
} | 1,599 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.