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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EthPledgePool | EthPledgePool.sol | 0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73 | Solidity | EthPledgePool | contract EthPledgePool is PledgePoolBase {
using SafeMath for uint256;
using AddressUtils for address;
// -----------------------------------------
// TokenPool external interface
// -----------------------------------------
/**
* @dev fallback function
*/
function() external payable {}
/**
* @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked.
* @param _amount Number of eth to withdraw
* @param _contract Multi-signature contracts, for the fair and just treatment of funds.
*/
function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) {
require(_amount <= address(this).balance && _contract.isContract());
_contract.transfer(_amount);
return true;
}
/**
* @dev kill, kills the contract and send everything to `_address`..
*/
function kills() public onlyOwner {
selfdestruct(owner);
}
// -----------------------------------------
// token pool internal interface (extensible)
// -----------------------------------------
/**
* @dev Executed when a Refund has been validated and is ready to be executed.
* Not necessarily emits/sends tokens.
*/
function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal {
super._processRefund(_returnSum, _targetAddress, _pledgeId);
require(address(this).balance >= _returnSum);
_targetAddress.transfer(_returnSum);
}
/**
* @dev Withdraw pledge token.
*/
function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal {
super._processWithdraw(_maker, _num, _pledgeId);
require(address(this).balance >= _num);
_maker.transfer(_num);
}
} | /**
* @title eth pledge pool.
* @dev the tokenPool for ETH.
*/ | NatSpecMultiLine | _processWithdraw | function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal {
super._processWithdraw(_maker, _num, _pledgeId);
require(address(this).balance >= _num);
_maker.transfer(_num);
}
| /**
* @dev Withdraw pledge token.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c | {
"func_code_index": [
1545,
1765
]
} | 3,800 |
|
IdleStrategyWBTCMainnet | contracts/hardworkInterface/IVault.sol | 0xb8e9db02262d37233442932e1a6626d88c649c6e | Solidity | IVault | interface IVault {
function underlyingBalanceInVault() external view returns (uint256);
function underlyingBalanceWithInvestment() external view returns (uint256);
// function store() external view returns (address);
function governance() external view returns (address);
function controller() external view returns (address);
function underlying() external view returns (address);
function strategy() external view returns (address);
function setStrategy(address _strategy) external;
function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external;
function deposit(uint256 amountWei) external;
function depositFor(uint256 amountWei, address holder) external;
function withdrawAll() external;
function withdraw(uint256 numberOfShares) external;
function getPricePerFullShare() external view returns (uint256);
function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256);
// hard work should be callable only by the controller (by the hard worker) or by governance
function doHardWork() external;
} | governance | function governance() external view returns (address);
| // function store() external view returns (address); | LineComment | v0.5.16+commit.9c3226ce | None | bzzr://c0dd9563bd94314d73c3583a2dec6a96c718f825c39f3c637edf981f1b33b27f | {
"func_code_index": [
237,
296
]
} | 3,801 |
||
IdleStrategyWBTCMainnet | contracts/hardworkInterface/IVault.sol | 0xb8e9db02262d37233442932e1a6626d88c649c6e | Solidity | IVault | interface IVault {
function underlyingBalanceInVault() external view returns (uint256);
function underlyingBalanceWithInvestment() external view returns (uint256);
// function store() external view returns (address);
function governance() external view returns (address);
function controller() external view returns (address);
function underlying() external view returns (address);
function strategy() external view returns (address);
function setStrategy(address _strategy) external;
function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external;
function deposit(uint256 amountWei) external;
function depositFor(uint256 amountWei, address holder) external;
function withdrawAll() external;
function withdraw(uint256 numberOfShares) external;
function getPricePerFullShare() external view returns (uint256);
function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256);
// hard work should be callable only by the controller (by the hard worker) or by governance
function doHardWork() external;
} | doHardWork | function doHardWork() external;
| // hard work should be callable only by the controller (by the hard worker) or by governance | LineComment | v0.5.16+commit.9c3226ce | None | bzzr://c0dd9563bd94314d73c3583a2dec6a96c718f825c39f3c637edf981f1b33b27f | {
"func_code_index": [
1117,
1153
]
} | 3,802 |
||
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
981,
1102
]
} | 3,803 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
1322,
1451
]
} | 3,804 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transfer | function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
1795,
2077
]
} | 3,805 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approve | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
2355,
2568
]
} | 3,806 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferFrom | function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
3099,
3462
]
} | 3,807 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| // ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
3745,
3901
]
} | 3,808 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approveAndCall | function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
4256,
4578
]
} | 3,809 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | function () public payable {
revert();
}
| // ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
4770,
4829
]
} | 3,810 |
||
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
5062,
5251
]
} | 3,811 |
|
SodaCoin | SodaCoin.sol | 0x1dd7c1a2be393644bf56420aa64d53058a3c430a | Solidity | SodaCoin | contract SodaCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SOC";
name = "SODA Coin";
decimals = 18;
_totalSupply = 2000000000000000000000000000;
balances[0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76] = _totalSupply;
emit Transfer(address(0), 0xC713b7c600Bb0e70c2d4b466b923Cab1E45e7c76, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// Increase issuance.
function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | totalSupplyIncrease | function totalSupplyIncrease(uint256 _supply) public onlyOwner{
_totalSupply = _totalSupply + _supply;
balances[msg.sender] = balances[msg.sender] + _supply;
}
| // Increase issuance. | LineComment | v0.4.24+commit.e67f0147 | bzzr://59b0d8d4cec1be13bf0c9d0a9913f1b9abc681a8bee176b35fb05fe2b1ad93ea | {
"func_code_index": [
5279,
5448
]
} | 3,812 |
|
CurrentCrowdsale | contracts/CurrentCrowdsale.sol | 0x778e7132383bfe51d8a3b73d641f959deb3c8f03 | Solidity | CurrentCrowdsale | contract CurrentCrowdsale is Pausable, TokenRate {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public HARDCAP_TOKENS_PRE_ICO = 100e6 * (10 ** DECIMALS);
uint256 constant public HARDCAP_TOKENS_ICO = 499e8 * (10 ** DECIMALS);
uint256 public startPhase1 = 0;
uint256 public startPhase2 = 0;
uint256 public startPhase3 = 0;
uint256 public endOfPhase3 = 0;
uint256 public maxcap = 0;
uint256 public tokensSoldIco = 0;
uint256 public tokensRemainingIco = HARDCAP_TOKENS_ICO;
uint256 public tokensSoldTotal = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
address private withdrawalWallet;
CurrentToken public token;
Whitelist public whitelist;
modifier beforeReachingHardCap() {
require(tokensRemainingIco > 0 && weiRaisedIco < maxcap);
_;
}
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
/**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/
function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
/**
* @dev Fallback function can be used to buy tokens.
*/
function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
/**
* @dev Check whether the ICO is active at the moment.
*/
function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
function sellTokensIco() beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
sellTokens(address(0));
}
function sellTokensIcoWithReferal(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
if (referral != msg.sender && whitelist.isWhitelisted(referral)) {
sellTokens(referral);
} else {
revert();
}
}
/**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
/**
* @dev Sell tokens during ICO with referral.
*/
function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
} | CurrentCrowdsale | function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
| /**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://69f0797bf871f56f74bf43c4b4a5e008b055e14afab1758d5b57ce67c4533b67 | {
"func_code_index": [
1688,
2838
]
} | 3,813 |
|||
CurrentCrowdsale | contracts/CurrentCrowdsale.sol | 0x778e7132383bfe51d8a3b73d641f959deb3c8f03 | Solidity | CurrentCrowdsale | contract CurrentCrowdsale is Pausable, TokenRate {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public HARDCAP_TOKENS_PRE_ICO = 100e6 * (10 ** DECIMALS);
uint256 constant public HARDCAP_TOKENS_ICO = 499e8 * (10 ** DECIMALS);
uint256 public startPhase1 = 0;
uint256 public startPhase2 = 0;
uint256 public startPhase3 = 0;
uint256 public endOfPhase3 = 0;
uint256 public maxcap = 0;
uint256 public tokensSoldIco = 0;
uint256 public tokensRemainingIco = HARDCAP_TOKENS_ICO;
uint256 public tokensSoldTotal = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
address private withdrawalWallet;
CurrentToken public token;
Whitelist public whitelist;
modifier beforeReachingHardCap() {
require(tokensRemainingIco > 0 && weiRaisedIco < maxcap);
_;
}
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
/**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/
function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
/**
* @dev Fallback function can be used to buy tokens.
*/
function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
/**
* @dev Check whether the ICO is active at the moment.
*/
function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
function sellTokensIco() beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
sellTokens(address(0));
}
function sellTokensIcoWithReferal(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
if (referral != msg.sender && whitelist.isWhitelisted(referral)) {
sellTokens(referral);
} else {
revert();
}
}
/**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
/**
* @dev Sell tokens during ICO with referral.
*/
function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
} | function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
| /**
* @dev Fallback function can be used to buy tokens.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://69f0797bf871f56f74bf43c4b4a5e008b055e14afab1758d5b57ce67c4533b67 | {
"func_code_index": [
2915,
3060
]
} | 3,814 |
||||
CurrentCrowdsale | contracts/CurrentCrowdsale.sol | 0x778e7132383bfe51d8a3b73d641f959deb3c8f03 | Solidity | CurrentCrowdsale | contract CurrentCrowdsale is Pausable, TokenRate {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public HARDCAP_TOKENS_PRE_ICO = 100e6 * (10 ** DECIMALS);
uint256 constant public HARDCAP_TOKENS_ICO = 499e8 * (10 ** DECIMALS);
uint256 public startPhase1 = 0;
uint256 public startPhase2 = 0;
uint256 public startPhase3 = 0;
uint256 public endOfPhase3 = 0;
uint256 public maxcap = 0;
uint256 public tokensSoldIco = 0;
uint256 public tokensRemainingIco = HARDCAP_TOKENS_ICO;
uint256 public tokensSoldTotal = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
address private withdrawalWallet;
CurrentToken public token;
Whitelist public whitelist;
modifier beforeReachingHardCap() {
require(tokensRemainingIco > 0 && weiRaisedIco < maxcap);
_;
}
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
/**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/
function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
/**
* @dev Fallback function can be used to buy tokens.
*/
function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
/**
* @dev Check whether the ICO is active at the moment.
*/
function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
function sellTokensIco() beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
sellTokens(address(0));
}
function sellTokensIcoWithReferal(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
if (referral != msg.sender && whitelist.isWhitelisted(referral)) {
sellTokens(referral);
} else {
revert();
}
}
/**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
/**
* @dev Sell tokens during ICO with referral.
*/
function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
} | isIco | function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
| /**
* @dev Check whether the ICO is active at the moment.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://69f0797bf871f56f74bf43c4b4a5e008b055e14afab1758d5b57ce67c4533b67 | {
"func_code_index": [
3139,
3258
]
} | 3,815 |
|||
CurrentCrowdsale | contracts/CurrentCrowdsale.sol | 0x778e7132383bfe51d8a3b73d641f959deb3c8f03 | Solidity | CurrentCrowdsale | contract CurrentCrowdsale is Pausable, TokenRate {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public HARDCAP_TOKENS_PRE_ICO = 100e6 * (10 ** DECIMALS);
uint256 constant public HARDCAP_TOKENS_ICO = 499e8 * (10 ** DECIMALS);
uint256 public startPhase1 = 0;
uint256 public startPhase2 = 0;
uint256 public startPhase3 = 0;
uint256 public endOfPhase3 = 0;
uint256 public maxcap = 0;
uint256 public tokensSoldIco = 0;
uint256 public tokensRemainingIco = HARDCAP_TOKENS_ICO;
uint256 public tokensSoldTotal = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
address private withdrawalWallet;
CurrentToken public token;
Whitelist public whitelist;
modifier beforeReachingHardCap() {
require(tokensRemainingIco > 0 && weiRaisedIco < maxcap);
_;
}
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
/**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/
function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
/**
* @dev Fallback function can be used to buy tokens.
*/
function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
/**
* @dev Check whether the ICO is active at the moment.
*/
function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
function sellTokensIco() beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
sellTokens(address(0));
}
function sellTokensIcoWithReferal(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
if (referral != msg.sender && whitelist.isWhitelisted(referral)) {
sellTokens(referral);
} else {
revert();
}
}
/**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
/**
* @dev Sell tokens during ICO with referral.
*/
function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
} | manualSendTokens | function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
| /**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://69f0797bf871f56f74bf43c4b4a5e008b055e14afab1758d5b57ce67c4533b67 | {
"func_code_index": [
3898,
4330
]
} | 3,816 |
|||
CurrentCrowdsale | contracts/CurrentCrowdsale.sol | 0x778e7132383bfe51d8a3b73d641f959deb3c8f03 | Solidity | CurrentCrowdsale | contract CurrentCrowdsale is Pausable, TokenRate {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public HARDCAP_TOKENS_PRE_ICO = 100e6 * (10 ** DECIMALS);
uint256 constant public HARDCAP_TOKENS_ICO = 499e8 * (10 ** DECIMALS);
uint256 public startPhase1 = 0;
uint256 public startPhase2 = 0;
uint256 public startPhase3 = 0;
uint256 public endOfPhase3 = 0;
uint256 public maxcap = 0;
uint256 public tokensSoldIco = 0;
uint256 public tokensRemainingIco = HARDCAP_TOKENS_ICO;
uint256 public tokensSoldTotal = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
address private withdrawalWallet;
CurrentToken public token;
Whitelist public whitelist;
modifier beforeReachingHardCap() {
require(tokensRemainingIco > 0 && weiRaisedIco < maxcap);
_;
}
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
/**
* @dev Constructor for CurrentCrowdsale contract.
* @dev Set the owner who can manage whitelist and token.
* @param _maxcap The maxcap value.
* @param _startPhase1 The phase1 ICO start time.
* @param _startPhase2 The phase2 ICO start time.
* @param _startPhase3 The phase3 ICO start time.
* @param _endOfPhase3 The end time of ICO.
* @param _withdrawalWallet The address to which raised funds will be withdrawn.
* @param _rate exchange rate for ico.
* @param _token address of token used for ico.
* @param _whitelist address of whitelist contract used for ico.
*/
function CurrentCrowdsale(
uint256 _maxcap,
uint256 _startPhase1,
uint256 _startPhase2,
uint256 _startPhase3,
uint256 _endOfPhase3,
address _withdrawalWallet,
uint256 _rate,
CurrentToken _token,
Whitelist _whitelist
) TokenRate(_rate) public
{
require(_withdrawalWallet != address(0));
require(_token != address(0) && _whitelist != address(0));
require(_startPhase1 >= now);
require(_endOfPhase3 > _startPhase3);
require(_maxcap > 0);
token = _token;
whitelist = _whitelist;
startPhase1 = _startPhase1;
startPhase2 = _startPhase2;
startPhase3 = _startPhase3;
endOfPhase3 = _endOfPhase3;
withdrawalWallet = _withdrawalWallet;
maxcap = _maxcap;
tokensSoldTotal = HARDCAP_TOKENS_PRE_ICO;
weiRaisedTotal = tokensSoldTotal.div(_rate.mul(2));
pushModifier(RateModifier(200, startPhase1));
pushModifier(RateModifier(150, startPhase2));
pushModifier(RateModifier(100, startPhase3));
}
/**
* @dev Fallback function can be used to buy tokens.
*/
function() public payable {
if (isIco()) {
sellTokensIco();
} else {
revert();
}
}
/**
* @dev Check whether the ICO is active at the moment.
*/
function isIco() public constant returns (bool) {
return now >= startPhase1 && now <= endOfPhase3;
}
function sellTokensIco() beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
sellTokens(address(0));
}
function sellTokensIcoWithReferal(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused public payable {
if (referral != msg.sender && whitelist.isWhitelisted(referral)) {
sellTokens(referral);
} else {
revert();
}
}
/**
* @dev Manual send tokens to the specified address.
* @param _beneficiary The address of a investor.
* @param _tokensAmount Amount of tokens.
*/
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner {
require(_beneficiary != address(0));
require(_tokensAmount > 0);
token.transfer(_beneficiary, _tokensAmount);
tokensSoldIco = tokensSoldIco.add(_tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(_tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(_tokensAmount);
}
/**
* @dev Sell tokens during ICO with referral.
*/
function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
} | sellTokens | function sellTokens(address referral) beforeReachingHardCap whenWhitelisted(msg.sender) whenNotPaused internal {
require(isIco());
require(msg.value > 0);
uint256 weiAmount = msg.value;
uint256 excessiveFunds = 0;
uint256 plannedWeiTotal = weiRaisedIco.add(weiAmount);
if (plannedWeiTotal > maxcap) {
excessiveFunds = plannedWeiTotal.sub(maxcap);
weiAmount = maxcap.sub(weiRaisedIco);
}
bool isReferred = referral != address(0);
uint256 tokensForUser = _getTokenAmountForBuyer(weiAmount, isReferred);
uint256 tokensForReferral = _getTokenAmountForReferral(weiAmount, isReferred);
uint256 tokensAmount = tokensForUser.add(tokensForReferral);
if (tokensAmount > tokensRemainingIco) {
uint256 weiToAccept = _getWeiValueOfTokens(tokensRemainingIco, isReferred);
tokensForReferral = _getTokenAmountForReferral(weiToAccept, isReferred);
tokensForUser = tokensRemainingIco.sub(tokensForReferral);
excessiveFunds = excessiveFunds.add(weiAmount.sub(weiToAccept));
tokensAmount = tokensRemainingIco;
weiAmount = weiToAccept;
}
tokensSoldIco = tokensSoldIco.add(tokensAmount);
tokensSoldTotal = tokensSoldTotal.add(tokensAmount);
tokensRemainingIco = tokensRemainingIco.sub(tokensAmount);
weiRaisedIco = weiRaisedIco.add(weiAmount);
weiRaisedTotal = weiRaisedTotal.add(weiAmount);
token.transfer(msg.sender, tokensForUser);
if (isReferred) {
token.transfer(referral, tokensForReferral);
}
if (excessiveFunds > 0) {
msg.sender.transfer(excessiveFunds);
}
withdrawalWallet.transfer(this.balance);
}
| /**
* @dev Sell tokens during ICO with referral.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://69f0797bf871f56f74bf43c4b4a5e008b055e14afab1758d5b57ce67c4533b67 | {
"func_code_index": [
4400,
6261
]
} | 3,817 |
|||
FuddCrowdsale | FuddCrowdsale.sol | 0xf0fd80b2cce26d5b0441250a0414e8174f315b73 | Solidity | FuddCrowdsale | contract FuddCrowdsale {
using SafeMath for uint256;
mapping (address => uint256) balances;
Token public fuddToken;
// Crowdsale details
address public beneficiary;
address public creator;
address public confirmedBy;
uint256 public maxSupply;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
uint256 public startTimestamp;
uint256 public rate;
uint256 public firstBonus;
uint256 public secondBonus;
uint256 public firstTimer;
uint256 public secondTimer;
uint256 public endTimer;
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.PreSale) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
purchasingAllowed = true;
startTimestamp = now;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function hasEnded() atStage(Stages.InProgress) {
if (now >= startTimestamp.add(endTimer)){
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function enableNewPurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.Withdrawn) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
totalSupplied = 0;
startTimestamp = now;
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return fuddToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
} | FuddCrowdsale | function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
| /**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://acc983dced9655ea5c9c72a7385af2b2d2d726a29708ddb669f1718548e6b8df | {
"func_code_index": [
921,
1129
]
} | 3,818 |
|||
FuddCrowdsale | FuddCrowdsale.sol | 0xf0fd80b2cce26d5b0441250a0414e8174f315b73 | Solidity | FuddCrowdsale | contract FuddCrowdsale {
using SafeMath for uint256;
mapping (address => uint256) balances;
Token public fuddToken;
// Crowdsale details
address public beneficiary;
address public creator;
address public confirmedBy;
uint256 public maxSupply;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
uint256 public startTimestamp;
uint256 public rate;
uint256 public firstBonus;
uint256 public secondBonus;
uint256 public firstTimer;
uint256 public secondTimer;
uint256 public endTimer;
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.PreSale) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
purchasingAllowed = true;
startTimestamp = now;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function hasEnded() atStage(Stages.InProgress) {
if (now >= startTimestamp.add(endTimer)){
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function enableNewPurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.Withdrawn) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
totalSupplied = 0;
startTimestamp = now;
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return fuddToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
} | balanceOf | function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
| /**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://acc983dced9655ea5c9c72a7385af2b2d2d726a29708ddb669f1718548e6b8df | {
"func_code_index": [
1852,
1975
]
} | 3,819 |
|||
FuddCrowdsale | FuddCrowdsale.sol | 0xf0fd80b2cce26d5b0441250a0414e8174f315b73 | Solidity | FuddCrowdsale | contract FuddCrowdsale {
using SafeMath for uint256;
mapping (address => uint256) balances;
Token public fuddToken;
// Crowdsale details
address public beneficiary;
address public creator;
address public confirmedBy;
uint256 public maxSupply;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
uint256 public startTimestamp;
uint256 public rate;
uint256 public firstBonus;
uint256 public secondBonus;
uint256 public firstTimer;
uint256 public secondTimer;
uint256 public endTimer;
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.PreSale) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
purchasingAllowed = true;
startTimestamp = now;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function hasEnded() atStage(Stages.InProgress) {
if (now >= startTimestamp.add(endTimer)){
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function enableNewPurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.Withdrawn) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
totalSupplied = 0;
startTimestamp = now;
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return fuddToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
} | withdraw | function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
| /**
* Transfer raised amount to the beneficiary address
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://acc983dced9655ea5c9c72a7385af2b2d2d726a29708ddb669f1718548e6b8df | {
"func_code_index": [
3572,
3765
]
} | 3,820 |
|||
FuddCrowdsale | FuddCrowdsale.sol | 0xf0fd80b2cce26d5b0441250a0414e8174f315b73 | Solidity | FuddCrowdsale | contract FuddCrowdsale {
using SafeMath for uint256;
mapping (address => uint256) balances;
Token public fuddToken;
// Crowdsale details
address public beneficiary;
address public creator;
address public confirmedBy;
uint256 public maxSupply;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
uint256 public startTimestamp;
uint256 public rate;
uint256 public firstBonus;
uint256 public secondBonus;
uint256 public firstTimer;
uint256 public secondTimer;
uint256 public endTimer;
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.PreSale) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
purchasingAllowed = true;
startTimestamp = now;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function hasEnded() atStage(Stages.InProgress) {
if (now >= startTimestamp.add(endTimer)){
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function enableNewPurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.Withdrawn) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
totalSupplied = 0;
startTimestamp = now;
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return fuddToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
} | confirmBeneficiary | function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
| /**
* For testing purposes
*
* @return The beneficiary address
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://acc983dced9655ea5c9c72a7385af2b2d2d726a29708ddb669f1718548e6b8df | {
"func_code_index": [
3859,
3953
]
} | 3,821 |
|||
FuddCrowdsale | FuddCrowdsale.sol | 0xf0fd80b2cce26d5b0441250a0414e8174f315b73 | Solidity | FuddCrowdsale | contract FuddCrowdsale {
using SafeMath for uint256;
mapping (address => uint256) balances;
Token public fuddToken;
// Crowdsale details
address public beneficiary;
address public creator;
address public confirmedBy;
uint256 public maxSupply;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
uint256 public startTimestamp;
uint256 public rate;
uint256 public firstBonus;
uint256 public secondBonus;
uint256 public firstTimer;
uint256 public secondTimer;
uint256 public endTimer;
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
function FuddCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
fuddToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.PreSale) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
purchasingAllowed = true;
startTimestamp = now;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function hasEnded() atStage(Stages.InProgress) {
if (now >= startTimestamp.add(endTimer)){
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function enableNewPurchasing(uint256 _firstTimer, uint256 _secondTimer, uint256 _endTimer,
uint256 _maxSupply, uint256 _rate, uint256 _firstBonus, uint256 _secondBonus) onlyBeneficiary atStage(Stages.Withdrawn) {
firstTimer = _firstTimer;
secondTimer = _secondTimer;
endTimer = _endTimer;
maxSupply = _maxSupply;
rate = _rate;
firstBonus = _firstBonus;
secondBonus = _secondBonus;
totalSupplied = 0;
startTimestamp = now;
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return fuddToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
} | function () payable atStage(Stages.InProgress) {
hasEnded();
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
if (msg.value >= 10 finney) {
if (now <= startTimestamp.add(firstTimer)){
uint256 firstBonusToken = (tokens.div(100)).mul(firstBonus);
tokens = tokens.add(firstBonusToken);
}
if (startTimestamp.add(firstTimer) < now &&
now <= startTimestamp.add(secondTimer)){
uint256 secondBonusToken = (tokens.div(100)).mul(secondBonus);
tokens = tokens.add(secondBonusToken);
}
}
sendTokens(msg.sender, tokens);
fuddToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
| /**
* Receives Eth and issue tokens to the sender
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://acc983dced9655ea5c9c72a7385af2b2d2d726a29708ddb669f1718548e6b8df | {
"func_code_index": [
4088,
5253
]
} | 3,822 |
||||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | _transfer | function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
| /**
* Internal transfer, only can be called by this contract
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
1646,
2493
]
} | 3,823 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
| /**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
2699,
2898
]
} | 3,824 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | ban | function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
| /**
* Ban address
*
* @param addr ban addr
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
2977,
3096
]
} | 3,825 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | enable | function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
| /**
* Enable address
*
* @param addr enable addr
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
3182,
3305
]
} | 3,826 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| /**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
3580,
3960
]
} | 3,827 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | approve | function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
4224,
4493
]
} | 3,828 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
| /**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
4887,
5273
]
} | 3,829 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | burn | function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
| /**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
5443,
5905
]
} | 3,830 |
||
TokenGBTG | TokenGBTG.sol | 0xa0a25c992b5b5e019573fb0e571b3f3c81070dfb | Solidity | TokenGBTG | contract TokenGBTG {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
mapping (address => bool) public blacklist;
address admin;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
admin = msg.sender;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Ban address
*
* @param addr ban addr
*/
function ban(address addr) public {
require(msg.sender == admin);
blacklist[addr] = true;
}
/**
* Enable address
*
* @param addr enable addr
*/
function enable(address addr) public {
require(msg.sender == admin);
blacklist[addr] = false;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!blacklist[msg.sender]);
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
require(!blacklist[msg.sender]);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value <= totalSupply);
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | burnFrom | function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!blacklist[msg.sender]);
require(!blacklist[_from]);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
require(_value <= totalSupply);
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
| /**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | None | bzzr://a1095513b599c11351c07bd6d2947e74e033a8d00eb53f2e0d2294f86f7aef26 | {
"func_code_index": [
6163,
6899
]
} | 3,831 |
||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
60,
124
]
} | 3,832 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
232,
309
]
} | 3,833 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
546,
623
]
} | 3,834 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
946,
1042
]
} | 3,835 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
1326,
1407
]
} | 3,836 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | 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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
1615,
1712
]
} | 3,837 |
|||
CYBERGAME | CYBERGAME.sol | 0xea5eb17d519a9165fd2d7e024d83856f314958d1 | Solidity | CYBERGAME | contract CYBERGAME is StandardToken {
/* 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;
uint8 public decimals;
string public symbol;
string public version = 'CYBG1.0';
uint256 public unitsOneEthCanBuy;
uint256 public totalEthInWei;
address public fundsWallet;
function CYBERGAME() {
balances[msg.sender] = 3000000000000000000000000000;
totalSupply = 3000000000000000000000000000;
name = "CYBERGAME";
decimals = 18;
symbol = "CYBG";
unitsOneEthCanBuy = 200000; //7% bonus= OneEth//
fundsWallet = msg.sender;
}
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);
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);
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);
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://0d9eb25989fc8dfd3924e7553c0403222204dcde1b0f4f714371fd8695238eef | {
"func_code_index": [
1704,
2097
]
} | 3,838 |
|||
Treasury | contracts/Treasury.sol | 0xa6236cba34883c983ca5c9dee8349d072192ed5c | Solidity | Treasury | contract Treasury is Ownable, ITreasury {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public override defaultToken;
SwapRouter public swapRouter;
address public ecoFund;
address public gov;
address internal govSetter;
mapping(address => uint256) public ecoFundAmts;
// 1% = 100
uint256 public constant MAX_FUND_PERCENTAGE = 1500; // 15%
uint256 public constant PERCENTAGE_PRECISION = 10000; // 100%
uint256 public fundPercentage = 500; // 5%
constructor(SwapRouter _swapRouter, IERC20 _defaultToken, address _ecoFund) public {
swapRouter = _swapRouter;
defaultToken = _defaultToken;
ecoFund = _ecoFund;
govSetter = msg.sender;
}
function setGov(address _gov) external {
require(msg.sender == govSetter, "not authorized");
gov = _gov;
govSetter = address(0);
}
function setSwapRouter(SwapRouter _swapRouter) external onlyOwner {
swapRouter = _swapRouter;
}
function setEcoFund(address _ecoFund) external onlyOwner {
ecoFund = _ecoFund;
}
function setFundPercentage(uint256 _fundPercentage) external onlyOwner {
require(_fundPercentage <= MAX_FUND_PERCENTAGE, "exceed max percent");
fundPercentage = _fundPercentage;
}
function balanceOf(IERC20 token) public view returns (uint256) {
return token.balanceOf(address(this)).sub(ecoFundAmts[address(token)]);
}
function deposit(IERC20 token, uint256 amount) external override {
// portion allocated to ecoFund
ecoFundAmts[address(token)] = amount.mul(fundPercentage).div(PERCENTAGE_PRECISION);
token.safeTransferFrom(msg.sender, address(this), amount);
}
// only default token withdrawals allowed
function withdraw(uint256 amount, address withdrawAddress) external override {
require(msg.sender == gov, "caller not gov");
require(balanceOf(defaultToken) >= amount, "insufficient funds");
defaultToken.safeTransfer(withdrawAddress, amount);
}
function convertToDefaultToken(address[] calldata routeDetails, uint256 amount) external {
require(routeDetails[0] != address(defaultToken), "src can't be defaultToken");
require(routeDetails[routeDetails.length - 1] == address(defaultToken), "dest not defaultToken");
IERC20 srcToken = IERC20(routeDetails[0]);
require(balanceOf(srcToken) >= amount, "insufficient funds");
if (srcToken.allowance(address(this), address(swapRouter)) <= amount) {
srcToken.safeApprove(address(swapRouter), uint256(-1));
}
uint[] memory swappedAmounts = swapRouter.swapExactTokensForTokens(
amount,
0,
routeDetails,
address(this),
block.timestamp + 100
);
require(swappedAmounts.length != 0, "Swap failed");
}
function withdrawEcoFund(IERC20 token, uint256 amount) external {
ecoFundAmts[address(token)] = ecoFundAmts[address(token)].sub(amount);
token.safeTransfer(ecoFund, amount);
}
} | withdraw | function withdraw(uint256 amount, address withdrawAddress) external override {
require(msg.sender == gov, "caller not gov");
require(balanceOf(defaultToken) >= amount, "insufficient funds");
defaultToken.safeTransfer(withdrawAddress, amount);
}
| // only default token withdrawals allowed | LineComment | v0.6.2+commit.bacdbe57 | MIT | ipfs://b681445e14e2d0d9634bf2cbc4b058851c8a0ed66e37adda9e148b9898f0d8e9 | {
"func_code_index": [
1864,
2145
]
} | 3,839 |
||
ChainGifts | contracts/ChainGifts.sol | 0x15462a7aba4c6caa55a78a9ff9a2763d67f17975 | 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.9+commit.e5eed63a | {
"func_code_index": [
186,
1747
]
} | 3,840 |
||
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | mint | function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). | NatSpecSingleLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
156,
323
]
} | 3,841 |
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | delegates | function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
| /**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
2319,
2473
]
} | 3,842 |
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | delegate | function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
| /**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
2612,
2721
]
} | 3,843 |
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | delegateBySig | function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
| /**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
3150,
4330
]
} | 3,844 |
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | getCurrentVotes | function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
| /**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
4526,
4786
]
} | 3,845 |
HFIToken | contracts/HFIToken.sol | 0xc8c1a2d3ba6228e044f5b7564b9752c69ca85e25 | Solidity | HFIToken | contract HFIToken is ERC20("HFIToken", "HFI"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "HFI::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "HFI::delegateBySig: invalid nonce");
require(now <= expiry, "HFI::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HFIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "HFI::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | // HFIToken with Governance. | LineComment | getPriorVotes | function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "HFI::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
| /**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://e18ca33f7612371bc73fbbf6507d98698fe2fc8d0ac952a01b9af99bd85c1e69 | {
"func_code_index": [
5212,
6469
]
} | 3,846 |
OXG | contracts/NodeManager.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | NodeManager | contract NodeManager is Ownable, Pausable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
struct NodeEntity {
string name;
uint256 creationTime;
uint256 lastClaimTime;
uint256 amount;
uint256 tier;
uint256 totalClaimed;
uint256 borrowedRewards;
uint256[3] bondedMolecules; // tokenId of bonded molecules
uint256 bondedMols; //number of molecules bonded
}
IterableMapping.Map private nodeOwners;
mapping(address => NodeEntity[]) private _nodesOfUser;
Molecules public molecules;
address public token;
uint256 public totalNodesCreated = 0;
uint256 public totalStaked = 0;
uint256 public totalClaimed = 0;
uint256 public levelMultiplier = 250; // bps 250 = 2.5%
uint256[] public _tiersPrice = [1, 6, 20, 50, 150];
uint256[] public _tiersRewards = [1250,8000,30000,87500,300000]; // 10000 => 1 OXG
uint256[] public _boostMultipliers = [102, 105, 110, 130, 200]; // %
uint256[] public _boostRequiredDays = [35, 56, 84, 183, 365]; // days
uint256[] public _paperHandsTaxes = [150, 100, 40, 0]; // %; 10 => 1
uint256[] public _paperHandsWeeks = [1, 2, 3, 4]; // weeks
uint256[] public _claimTaxFees = [8, 8, 8, 8, 8]; // %, match with tiers
event NodeCreated(
address indexed account,
uint256 indexed blockTime,
uint256 indexed amount
);
event NodeBondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
event NodeUnbondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
modifier onlyGuard() {
require(owner() == _msgSender() || token == _msgSender(), "NOT_GUARD");
_;
}
constructor() {}
// Private methods
function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
function _getNodeWithCreatime(
NodeEntity[] storage nodes,
uint256 _creationTime
) private view returns (NodeEntity storage) {
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
bool found = false;
int256 index = _binarySearch(nodes, 0, numberOfNodes, _creationTime);
uint256 validIndex;
if (index >= 0) {
found = true;
validIndex = uint256(index);
}
require(found, "NODE SEARCH: No NODE Found with this blocktime");
return nodes[validIndex];
}
function _binarySearch(
NodeEntity[] memory arr,
uint256 low,
uint256 high,
uint256 x
) private view returns (int256) {
if (high >= low) {
uint256 mid = (high + low).div(2);
if (arr[mid].creationTime == x) {
return int256(mid);
} else if (arr[mid].creationTime > x) {
return _binarySearch(arr, low, mid - 1, x);
} else {
return _binarySearch(arr, mid + 1, high, x);
}
} else {
return -1;
}
}
function _uint2str(uint256 _i)
private
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function _calculateNodeRewards(
uint256 _lastClaimTime,
uint256 _tier
) private view returns (uint256 rewards) {
uint256 elapsedTime_ = (block.timestamp - _lastClaimTime);
uint256 boostMultiplier = _calculateBoost(elapsedTime_);
uint256 rewardPerMonth = _tiersRewards[_tier];
return
rewardPerMonth.mul(1e18).div(2628000).mul(elapsedTime_).mul(boostMultiplier).div(100).div(10000);
}
function _calculateBoost(uint256 elapsedTime_)
internal
view
returns (uint256)
{
uint256 elapsedTimeInDays_ = elapsedTime_ / 1 days;
if (elapsedTimeInDays_ >= _boostRequiredDays[4]) {
return _boostMultipliers[4];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[3]) {
return _boostMultipliers[3];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[2]) {
return _boostMultipliers[2];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[1]) {
return _boostMultipliers[1];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[0]) {
return _boostMultipliers[0];
} else {
return 100;
}
}
// External methods
function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
function borrowRewards(address account, uint256 blocktime, uint256 amount)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: blocktime must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't have any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
uint256 rewardsAvailable = _calculateNodeRewards(node.lastClaimTime, node.tier).sub(node.borrowedRewards);
require(rewardsAvailable >= amount,"You do not have enough rewards available");
node.borrowedRewards += amount;
}
function createNode(
address account,
string memory nodeName,
uint256 _tier
) external onlyGuard whenNotPaused {
require(_isNameAvailable(account, nodeName), "Name not available");
NodeEntity[] storage _nodes = _nodesOfUser[account];
require(_nodes.length <= 100, "Max nodes exceeded");
uint256 amount = getNodePrice(_tier);
_nodes.push(
NodeEntity({
name: nodeName,
creationTime: block.timestamp,
lastClaimTime: block.timestamp,
amount: amount,
tier: _tier,
totalClaimed: 0,
borrowedRewards: 0,
bondedMolecules: [uint256(0),0,0],
bondedMols: 0
})
);
nodeOwners.set(account, _nodesOfUser[account].length);
emit NodeCreated(account, block.timestamp, amount);
totalNodesCreated++;
totalStaked += amount;
}
function getNodeReward(address account, uint256 _creationTime)
public
view
returns (uint256)
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
return _calculateNodeRewards(node.lastClaimTime, node.tier).mul(getNodeAPRIncrease(account, _creationTime)).div(10000).sub(node.borrowedRewards);
}
function getAllNodesRewards(address account) external view returns (uint256[2] memory) {
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
uint256 rewardsTotal = 0;
uint256 taxTotal = 0;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 nodeReward = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
nodeReward = nodeReward;
taxTotal += getNodeFee(account, _node.creationTime, nodeReward);
rewardsTotal += nodeReward;
}
return [rewardsTotal, taxTotal];
}
function cashoutNodeReward(address account, uint256 _creationTime)
external
onlyGuard
whenNotPaused
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 toClaim = _calculateNodeRewards(
node.lastClaimTime,
node.tier
).sub(node.borrowedRewards);
node.totalClaimed += toClaim;
node.lastClaimTime = block.timestamp;
node.borrowedRewards = 0;
}
function cashoutAllNodesRewards(address account)
external
onlyGuard
whenNotPaused
{
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 toClaim = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
_node.totalClaimed += toClaim;
_node.lastClaimTime = block.timestamp;
_node.borrowedRewards = 0;
}
}
function setMoleculeAddress(address _moleculesAddress) external onlyOwner {
molecules = Molecules(_moleculesAddress);
}
function bondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols < 3,"Already bonded to enough molecules");
molecules.bondMolecule(account, _tokenId, node.creationTime);
node.bondedMolecules[node.bondedMols] = _tokenId;
node.bondedMols += 1;
emit NodeBondedToMolecule(account, _tokenId, _creationTime);
}
// function to unbond NFT
function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
function getNodesNames(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory names = nodes[0].name;
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
names = string(abi.encodePacked(names, separator, _node.name));
}
return names;
}
function getNodesRewards(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory rewards = _uint2str(_calculateNodeRewards(nodes[0].lastClaimTime, nodes[0].tier).mul(getNodeAPRIncrease(account, nodes[0].creationTime)).div(10000).sub(nodes[0].borrowedRewards));
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
string memory _rewardStr = _uint2str(_calculateNodeRewards(_node.lastClaimTime, _node.tier).mul(getNodeAPRIncrease(account, _node.creationTime)).div(10000).sub(_node.borrowedRewards));
rewards = string(abi.encodePacked(rewards, separator, _rewardStr));
}
return rewards;
}
function getNodesCreationTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _creationTimes = _uint2str(nodes[0].creationTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_creationTimes = string(
abi.encodePacked(
_creationTimes,
separator,
_uint2str(_node.creationTime)
)
);
}
return _creationTimes;
}
function getNodeAPRIncrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalApyBenefit = 10000;
return totalApyBenefit;
}
else {
uint256 totalApyBenefit = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 2 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalApyBenefit += APYBenefit;
}
}
totalApyBenefit += 10000;
return totalApyBenefit;
}
}
function getNodeTaxDecrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalTaxDecrease = 0;
return totalTaxDecrease;
}
else {
uint256 totalTaxDecrease = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 1 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalTaxDecrease += APYBenefit;
}
}
if (totalTaxDecrease > 10000) {
totalTaxDecrease = 10000;
}
return totalTaxDecrease;
}
}
function getNodesLastClaimTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _lastClaimTimes = _uint2str(nodes[0].lastClaimTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_lastClaimTimes = string(
abi.encodePacked(
_lastClaimTimes,
separator,
_uint2str(_node.lastClaimTime)
)
);
}
return _lastClaimTimes;
}
function getNodeFee(
address account,
uint256 _creationTime,
uint256 _rewardsAmount
) public view returns (uint256) {
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 paperHandsTax = 0;
uint256 claimTx = _rewardsAmount.mul(_claimTaxFees[node.tier]).div(100);
uint256 elapsedSeconds = block.timestamp - node.lastClaimTime;
if (elapsedSeconds >= _paperHandsWeeks[3].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[3]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[2].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[2]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[1].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[1]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[0].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[0]).div(1000);
} else {
paperHandsTax = _rewardsAmount.mul(200).div(1000);
}
uint256 totalTax = claimTx.add(paperHandsTax);
uint256 taxRebate = totalTax.mul(getNodeTaxDecrease(account,_creationTime)).div(10000);
return totalTax.sub(taxRebate);
}
function updateToken(address newToken) external onlyOwner {
token = newToken;
}
function updateTiersRewards(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersRewards = newVal;
}
function updateTiersPrice(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersPrice = newVal;
}
function updateBoostMultipliers(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostMultipliers = newVal;
}
function updateBoostRequiredDays(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostRequiredDays = newVal;
}
function getNodeTier(address account, uint256 blocktime) public view returns (uint256) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.tier;
}
function getNodePrice(uint256 _tierIndex) public view returns (uint256) {
return _tiersPrice[_tierIndex];
}
function getNodeNumberOf(address account) external view returns (uint256) {
return nodeOwners.get(account);
}
function isNodeOwner(address account) public view returns (bool) {
return nodeOwners.get(account) > 0;
}
function getNodeMolecules(address account, uint256 blocktime) public view returns (uint256[3] memory) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.bondedMolecules;
}
function getAllNodes(address account)
external
view
returns (NodeEntity[] memory)
{
return _nodesOfUser[account];
}
function getIndexOfKey(address account)
external
view
onlyOwner
returns (int256)
{
require(account != address(0));
return nodeOwners.getIndexOfKey(account);
}
function burn(uint256 index) external onlyOwner {
require(index < nodeOwners.size());
nodeOwners.remove(nodeOwners.getKeyAtIndex(index));
}
// User Methods
function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
// Firewall methods
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
} | _isNameAvailable | function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
| // Private methods | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
1798,
2159
]
} | 3,847 |
||
OXG | contracts/NodeManager.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | NodeManager | contract NodeManager is Ownable, Pausable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
struct NodeEntity {
string name;
uint256 creationTime;
uint256 lastClaimTime;
uint256 amount;
uint256 tier;
uint256 totalClaimed;
uint256 borrowedRewards;
uint256[3] bondedMolecules; // tokenId of bonded molecules
uint256 bondedMols; //number of molecules bonded
}
IterableMapping.Map private nodeOwners;
mapping(address => NodeEntity[]) private _nodesOfUser;
Molecules public molecules;
address public token;
uint256 public totalNodesCreated = 0;
uint256 public totalStaked = 0;
uint256 public totalClaimed = 0;
uint256 public levelMultiplier = 250; // bps 250 = 2.5%
uint256[] public _tiersPrice = [1, 6, 20, 50, 150];
uint256[] public _tiersRewards = [1250,8000,30000,87500,300000]; // 10000 => 1 OXG
uint256[] public _boostMultipliers = [102, 105, 110, 130, 200]; // %
uint256[] public _boostRequiredDays = [35, 56, 84, 183, 365]; // days
uint256[] public _paperHandsTaxes = [150, 100, 40, 0]; // %; 10 => 1
uint256[] public _paperHandsWeeks = [1, 2, 3, 4]; // weeks
uint256[] public _claimTaxFees = [8, 8, 8, 8, 8]; // %, match with tiers
event NodeCreated(
address indexed account,
uint256 indexed blockTime,
uint256 indexed amount
);
event NodeBondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
event NodeUnbondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
modifier onlyGuard() {
require(owner() == _msgSender() || token == _msgSender(), "NOT_GUARD");
_;
}
constructor() {}
// Private methods
function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
function _getNodeWithCreatime(
NodeEntity[] storage nodes,
uint256 _creationTime
) private view returns (NodeEntity storage) {
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
bool found = false;
int256 index = _binarySearch(nodes, 0, numberOfNodes, _creationTime);
uint256 validIndex;
if (index >= 0) {
found = true;
validIndex = uint256(index);
}
require(found, "NODE SEARCH: No NODE Found with this blocktime");
return nodes[validIndex];
}
function _binarySearch(
NodeEntity[] memory arr,
uint256 low,
uint256 high,
uint256 x
) private view returns (int256) {
if (high >= low) {
uint256 mid = (high + low).div(2);
if (arr[mid].creationTime == x) {
return int256(mid);
} else if (arr[mid].creationTime > x) {
return _binarySearch(arr, low, mid - 1, x);
} else {
return _binarySearch(arr, mid + 1, high, x);
}
} else {
return -1;
}
}
function _uint2str(uint256 _i)
private
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function _calculateNodeRewards(
uint256 _lastClaimTime,
uint256 _tier
) private view returns (uint256 rewards) {
uint256 elapsedTime_ = (block.timestamp - _lastClaimTime);
uint256 boostMultiplier = _calculateBoost(elapsedTime_);
uint256 rewardPerMonth = _tiersRewards[_tier];
return
rewardPerMonth.mul(1e18).div(2628000).mul(elapsedTime_).mul(boostMultiplier).div(100).div(10000);
}
function _calculateBoost(uint256 elapsedTime_)
internal
view
returns (uint256)
{
uint256 elapsedTimeInDays_ = elapsedTime_ / 1 days;
if (elapsedTimeInDays_ >= _boostRequiredDays[4]) {
return _boostMultipliers[4];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[3]) {
return _boostMultipliers[3];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[2]) {
return _boostMultipliers[2];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[1]) {
return _boostMultipliers[1];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[0]) {
return _boostMultipliers[0];
} else {
return 100;
}
}
// External methods
function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
function borrowRewards(address account, uint256 blocktime, uint256 amount)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: blocktime must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't have any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
uint256 rewardsAvailable = _calculateNodeRewards(node.lastClaimTime, node.tier).sub(node.borrowedRewards);
require(rewardsAvailable >= amount,"You do not have enough rewards available");
node.borrowedRewards += amount;
}
function createNode(
address account,
string memory nodeName,
uint256 _tier
) external onlyGuard whenNotPaused {
require(_isNameAvailable(account, nodeName), "Name not available");
NodeEntity[] storage _nodes = _nodesOfUser[account];
require(_nodes.length <= 100, "Max nodes exceeded");
uint256 amount = getNodePrice(_tier);
_nodes.push(
NodeEntity({
name: nodeName,
creationTime: block.timestamp,
lastClaimTime: block.timestamp,
amount: amount,
tier: _tier,
totalClaimed: 0,
borrowedRewards: 0,
bondedMolecules: [uint256(0),0,0],
bondedMols: 0
})
);
nodeOwners.set(account, _nodesOfUser[account].length);
emit NodeCreated(account, block.timestamp, amount);
totalNodesCreated++;
totalStaked += amount;
}
function getNodeReward(address account, uint256 _creationTime)
public
view
returns (uint256)
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
return _calculateNodeRewards(node.lastClaimTime, node.tier).mul(getNodeAPRIncrease(account, _creationTime)).div(10000).sub(node.borrowedRewards);
}
function getAllNodesRewards(address account) external view returns (uint256[2] memory) {
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
uint256 rewardsTotal = 0;
uint256 taxTotal = 0;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 nodeReward = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
nodeReward = nodeReward;
taxTotal += getNodeFee(account, _node.creationTime, nodeReward);
rewardsTotal += nodeReward;
}
return [rewardsTotal, taxTotal];
}
function cashoutNodeReward(address account, uint256 _creationTime)
external
onlyGuard
whenNotPaused
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 toClaim = _calculateNodeRewards(
node.lastClaimTime,
node.tier
).sub(node.borrowedRewards);
node.totalClaimed += toClaim;
node.lastClaimTime = block.timestamp;
node.borrowedRewards = 0;
}
function cashoutAllNodesRewards(address account)
external
onlyGuard
whenNotPaused
{
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 toClaim = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
_node.totalClaimed += toClaim;
_node.lastClaimTime = block.timestamp;
_node.borrowedRewards = 0;
}
}
function setMoleculeAddress(address _moleculesAddress) external onlyOwner {
molecules = Molecules(_moleculesAddress);
}
function bondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols < 3,"Already bonded to enough molecules");
molecules.bondMolecule(account, _tokenId, node.creationTime);
node.bondedMolecules[node.bondedMols] = _tokenId;
node.bondedMols += 1;
emit NodeBondedToMolecule(account, _tokenId, _creationTime);
}
// function to unbond NFT
function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
function getNodesNames(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory names = nodes[0].name;
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
names = string(abi.encodePacked(names, separator, _node.name));
}
return names;
}
function getNodesRewards(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory rewards = _uint2str(_calculateNodeRewards(nodes[0].lastClaimTime, nodes[0].tier).mul(getNodeAPRIncrease(account, nodes[0].creationTime)).div(10000).sub(nodes[0].borrowedRewards));
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
string memory _rewardStr = _uint2str(_calculateNodeRewards(_node.lastClaimTime, _node.tier).mul(getNodeAPRIncrease(account, _node.creationTime)).div(10000).sub(_node.borrowedRewards));
rewards = string(abi.encodePacked(rewards, separator, _rewardStr));
}
return rewards;
}
function getNodesCreationTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _creationTimes = _uint2str(nodes[0].creationTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_creationTimes = string(
abi.encodePacked(
_creationTimes,
separator,
_uint2str(_node.creationTime)
)
);
}
return _creationTimes;
}
function getNodeAPRIncrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalApyBenefit = 10000;
return totalApyBenefit;
}
else {
uint256 totalApyBenefit = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 2 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalApyBenefit += APYBenefit;
}
}
totalApyBenefit += 10000;
return totalApyBenefit;
}
}
function getNodeTaxDecrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalTaxDecrease = 0;
return totalTaxDecrease;
}
else {
uint256 totalTaxDecrease = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 1 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalTaxDecrease += APYBenefit;
}
}
if (totalTaxDecrease > 10000) {
totalTaxDecrease = 10000;
}
return totalTaxDecrease;
}
}
function getNodesLastClaimTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _lastClaimTimes = _uint2str(nodes[0].lastClaimTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_lastClaimTimes = string(
abi.encodePacked(
_lastClaimTimes,
separator,
_uint2str(_node.lastClaimTime)
)
);
}
return _lastClaimTimes;
}
function getNodeFee(
address account,
uint256 _creationTime,
uint256 _rewardsAmount
) public view returns (uint256) {
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 paperHandsTax = 0;
uint256 claimTx = _rewardsAmount.mul(_claimTaxFees[node.tier]).div(100);
uint256 elapsedSeconds = block.timestamp - node.lastClaimTime;
if (elapsedSeconds >= _paperHandsWeeks[3].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[3]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[2].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[2]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[1].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[1]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[0].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[0]).div(1000);
} else {
paperHandsTax = _rewardsAmount.mul(200).div(1000);
}
uint256 totalTax = claimTx.add(paperHandsTax);
uint256 taxRebate = totalTax.mul(getNodeTaxDecrease(account,_creationTime)).div(10000);
return totalTax.sub(taxRebate);
}
function updateToken(address newToken) external onlyOwner {
token = newToken;
}
function updateTiersRewards(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersRewards = newVal;
}
function updateTiersPrice(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersPrice = newVal;
}
function updateBoostMultipliers(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostMultipliers = newVal;
}
function updateBoostRequiredDays(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostRequiredDays = newVal;
}
function getNodeTier(address account, uint256 blocktime) public view returns (uint256) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.tier;
}
function getNodePrice(uint256 _tierIndex) public view returns (uint256) {
return _tiersPrice[_tierIndex];
}
function getNodeNumberOf(address account) external view returns (uint256) {
return nodeOwners.get(account);
}
function isNodeOwner(address account) public view returns (bool) {
return nodeOwners.get(account) > 0;
}
function getNodeMolecules(address account, uint256 blocktime) public view returns (uint256[3] memory) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.bondedMolecules;
}
function getAllNodes(address account)
external
view
returns (NodeEntity[] memory)
{
return _nodesOfUser[account];
}
function getIndexOfKey(address account)
external
view
onlyOwner
returns (int256)
{
require(account != address(0));
return nodeOwners.getIndexOfKey(account);
}
function burn(uint256 index) external onlyOwner {
require(index < nodeOwners.size());
nodeOwners.remove(nodeOwners.getKeyAtIndex(index));
}
// User Methods
function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
// Firewall methods
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
} | upgradeNode | function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
| // External methods | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
4956,
5444
]
} | 3,848 |
||
OXG | contracts/NodeManager.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | NodeManager | contract NodeManager is Ownable, Pausable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
struct NodeEntity {
string name;
uint256 creationTime;
uint256 lastClaimTime;
uint256 amount;
uint256 tier;
uint256 totalClaimed;
uint256 borrowedRewards;
uint256[3] bondedMolecules; // tokenId of bonded molecules
uint256 bondedMols; //number of molecules bonded
}
IterableMapping.Map private nodeOwners;
mapping(address => NodeEntity[]) private _nodesOfUser;
Molecules public molecules;
address public token;
uint256 public totalNodesCreated = 0;
uint256 public totalStaked = 0;
uint256 public totalClaimed = 0;
uint256 public levelMultiplier = 250; // bps 250 = 2.5%
uint256[] public _tiersPrice = [1, 6, 20, 50, 150];
uint256[] public _tiersRewards = [1250,8000,30000,87500,300000]; // 10000 => 1 OXG
uint256[] public _boostMultipliers = [102, 105, 110, 130, 200]; // %
uint256[] public _boostRequiredDays = [35, 56, 84, 183, 365]; // days
uint256[] public _paperHandsTaxes = [150, 100, 40, 0]; // %; 10 => 1
uint256[] public _paperHandsWeeks = [1, 2, 3, 4]; // weeks
uint256[] public _claimTaxFees = [8, 8, 8, 8, 8]; // %, match with tiers
event NodeCreated(
address indexed account,
uint256 indexed blockTime,
uint256 indexed amount
);
event NodeBondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
event NodeUnbondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
modifier onlyGuard() {
require(owner() == _msgSender() || token == _msgSender(), "NOT_GUARD");
_;
}
constructor() {}
// Private methods
function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
function _getNodeWithCreatime(
NodeEntity[] storage nodes,
uint256 _creationTime
) private view returns (NodeEntity storage) {
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
bool found = false;
int256 index = _binarySearch(nodes, 0, numberOfNodes, _creationTime);
uint256 validIndex;
if (index >= 0) {
found = true;
validIndex = uint256(index);
}
require(found, "NODE SEARCH: No NODE Found with this blocktime");
return nodes[validIndex];
}
function _binarySearch(
NodeEntity[] memory arr,
uint256 low,
uint256 high,
uint256 x
) private view returns (int256) {
if (high >= low) {
uint256 mid = (high + low).div(2);
if (arr[mid].creationTime == x) {
return int256(mid);
} else if (arr[mid].creationTime > x) {
return _binarySearch(arr, low, mid - 1, x);
} else {
return _binarySearch(arr, mid + 1, high, x);
}
} else {
return -1;
}
}
function _uint2str(uint256 _i)
private
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function _calculateNodeRewards(
uint256 _lastClaimTime,
uint256 _tier
) private view returns (uint256 rewards) {
uint256 elapsedTime_ = (block.timestamp - _lastClaimTime);
uint256 boostMultiplier = _calculateBoost(elapsedTime_);
uint256 rewardPerMonth = _tiersRewards[_tier];
return
rewardPerMonth.mul(1e18).div(2628000).mul(elapsedTime_).mul(boostMultiplier).div(100).div(10000);
}
function _calculateBoost(uint256 elapsedTime_)
internal
view
returns (uint256)
{
uint256 elapsedTimeInDays_ = elapsedTime_ / 1 days;
if (elapsedTimeInDays_ >= _boostRequiredDays[4]) {
return _boostMultipliers[4];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[3]) {
return _boostMultipliers[3];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[2]) {
return _boostMultipliers[2];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[1]) {
return _boostMultipliers[1];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[0]) {
return _boostMultipliers[0];
} else {
return 100;
}
}
// External methods
function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
function borrowRewards(address account, uint256 blocktime, uint256 amount)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: blocktime must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't have any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
uint256 rewardsAvailable = _calculateNodeRewards(node.lastClaimTime, node.tier).sub(node.borrowedRewards);
require(rewardsAvailable >= amount,"You do not have enough rewards available");
node.borrowedRewards += amount;
}
function createNode(
address account,
string memory nodeName,
uint256 _tier
) external onlyGuard whenNotPaused {
require(_isNameAvailable(account, nodeName), "Name not available");
NodeEntity[] storage _nodes = _nodesOfUser[account];
require(_nodes.length <= 100, "Max nodes exceeded");
uint256 amount = getNodePrice(_tier);
_nodes.push(
NodeEntity({
name: nodeName,
creationTime: block.timestamp,
lastClaimTime: block.timestamp,
amount: amount,
tier: _tier,
totalClaimed: 0,
borrowedRewards: 0,
bondedMolecules: [uint256(0),0,0],
bondedMols: 0
})
);
nodeOwners.set(account, _nodesOfUser[account].length);
emit NodeCreated(account, block.timestamp, amount);
totalNodesCreated++;
totalStaked += amount;
}
function getNodeReward(address account, uint256 _creationTime)
public
view
returns (uint256)
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
return _calculateNodeRewards(node.lastClaimTime, node.tier).mul(getNodeAPRIncrease(account, _creationTime)).div(10000).sub(node.borrowedRewards);
}
function getAllNodesRewards(address account) external view returns (uint256[2] memory) {
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
uint256 rewardsTotal = 0;
uint256 taxTotal = 0;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 nodeReward = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
nodeReward = nodeReward;
taxTotal += getNodeFee(account, _node.creationTime, nodeReward);
rewardsTotal += nodeReward;
}
return [rewardsTotal, taxTotal];
}
function cashoutNodeReward(address account, uint256 _creationTime)
external
onlyGuard
whenNotPaused
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 toClaim = _calculateNodeRewards(
node.lastClaimTime,
node.tier
).sub(node.borrowedRewards);
node.totalClaimed += toClaim;
node.lastClaimTime = block.timestamp;
node.borrowedRewards = 0;
}
function cashoutAllNodesRewards(address account)
external
onlyGuard
whenNotPaused
{
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 toClaim = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
_node.totalClaimed += toClaim;
_node.lastClaimTime = block.timestamp;
_node.borrowedRewards = 0;
}
}
function setMoleculeAddress(address _moleculesAddress) external onlyOwner {
molecules = Molecules(_moleculesAddress);
}
function bondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols < 3,"Already bonded to enough molecules");
molecules.bondMolecule(account, _tokenId, node.creationTime);
node.bondedMolecules[node.bondedMols] = _tokenId;
node.bondedMols += 1;
emit NodeBondedToMolecule(account, _tokenId, _creationTime);
}
// function to unbond NFT
function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
function getNodesNames(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory names = nodes[0].name;
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
names = string(abi.encodePacked(names, separator, _node.name));
}
return names;
}
function getNodesRewards(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory rewards = _uint2str(_calculateNodeRewards(nodes[0].lastClaimTime, nodes[0].tier).mul(getNodeAPRIncrease(account, nodes[0].creationTime)).div(10000).sub(nodes[0].borrowedRewards));
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
string memory _rewardStr = _uint2str(_calculateNodeRewards(_node.lastClaimTime, _node.tier).mul(getNodeAPRIncrease(account, _node.creationTime)).div(10000).sub(_node.borrowedRewards));
rewards = string(abi.encodePacked(rewards, separator, _rewardStr));
}
return rewards;
}
function getNodesCreationTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _creationTimes = _uint2str(nodes[0].creationTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_creationTimes = string(
abi.encodePacked(
_creationTimes,
separator,
_uint2str(_node.creationTime)
)
);
}
return _creationTimes;
}
function getNodeAPRIncrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalApyBenefit = 10000;
return totalApyBenefit;
}
else {
uint256 totalApyBenefit = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 2 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalApyBenefit += APYBenefit;
}
}
totalApyBenefit += 10000;
return totalApyBenefit;
}
}
function getNodeTaxDecrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalTaxDecrease = 0;
return totalTaxDecrease;
}
else {
uint256 totalTaxDecrease = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 1 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalTaxDecrease += APYBenefit;
}
}
if (totalTaxDecrease > 10000) {
totalTaxDecrease = 10000;
}
return totalTaxDecrease;
}
}
function getNodesLastClaimTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _lastClaimTimes = _uint2str(nodes[0].lastClaimTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_lastClaimTimes = string(
abi.encodePacked(
_lastClaimTimes,
separator,
_uint2str(_node.lastClaimTime)
)
);
}
return _lastClaimTimes;
}
function getNodeFee(
address account,
uint256 _creationTime,
uint256 _rewardsAmount
) public view returns (uint256) {
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 paperHandsTax = 0;
uint256 claimTx = _rewardsAmount.mul(_claimTaxFees[node.tier]).div(100);
uint256 elapsedSeconds = block.timestamp - node.lastClaimTime;
if (elapsedSeconds >= _paperHandsWeeks[3].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[3]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[2].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[2]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[1].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[1]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[0].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[0]).div(1000);
} else {
paperHandsTax = _rewardsAmount.mul(200).div(1000);
}
uint256 totalTax = claimTx.add(paperHandsTax);
uint256 taxRebate = totalTax.mul(getNodeTaxDecrease(account,_creationTime)).div(10000);
return totalTax.sub(taxRebate);
}
function updateToken(address newToken) external onlyOwner {
token = newToken;
}
function updateTiersRewards(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersRewards = newVal;
}
function updateTiersPrice(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersPrice = newVal;
}
function updateBoostMultipliers(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostMultipliers = newVal;
}
function updateBoostRequiredDays(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostRequiredDays = newVal;
}
function getNodeTier(address account, uint256 blocktime) public view returns (uint256) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.tier;
}
function getNodePrice(uint256 _tierIndex) public view returns (uint256) {
return _tiersPrice[_tierIndex];
}
function getNodeNumberOf(address account) external view returns (uint256) {
return nodeOwners.get(account);
}
function isNodeOwner(address account) public view returns (bool) {
return nodeOwners.get(account) > 0;
}
function getNodeMolecules(address account, uint256 blocktime) public view returns (uint256[3] memory) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.bondedMolecules;
}
function getAllNodes(address account)
external
view
returns (NodeEntity[] memory)
{
return _nodesOfUser[account];
}
function getIndexOfKey(address account)
external
view
onlyOwner
returns (int256)
{
require(account != address(0));
return nodeOwners.getIndexOfKey(account);
}
function burn(uint256 index) external onlyOwner {
require(index < nodeOwners.size());
nodeOwners.remove(nodeOwners.getKeyAtIndex(index));
}
// User Methods
function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
// Firewall methods
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
} | unbondNFT | function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
| // function to unbond NFT | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
10554,
11442
]
} | 3,849 |
||
OXG | contracts/NodeManager.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | NodeManager | contract NodeManager is Ownable, Pausable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
struct NodeEntity {
string name;
uint256 creationTime;
uint256 lastClaimTime;
uint256 amount;
uint256 tier;
uint256 totalClaimed;
uint256 borrowedRewards;
uint256[3] bondedMolecules; // tokenId of bonded molecules
uint256 bondedMols; //number of molecules bonded
}
IterableMapping.Map private nodeOwners;
mapping(address => NodeEntity[]) private _nodesOfUser;
Molecules public molecules;
address public token;
uint256 public totalNodesCreated = 0;
uint256 public totalStaked = 0;
uint256 public totalClaimed = 0;
uint256 public levelMultiplier = 250; // bps 250 = 2.5%
uint256[] public _tiersPrice = [1, 6, 20, 50, 150];
uint256[] public _tiersRewards = [1250,8000,30000,87500,300000]; // 10000 => 1 OXG
uint256[] public _boostMultipliers = [102, 105, 110, 130, 200]; // %
uint256[] public _boostRequiredDays = [35, 56, 84, 183, 365]; // days
uint256[] public _paperHandsTaxes = [150, 100, 40, 0]; // %; 10 => 1
uint256[] public _paperHandsWeeks = [1, 2, 3, 4]; // weeks
uint256[] public _claimTaxFees = [8, 8, 8, 8, 8]; // %, match with tiers
event NodeCreated(
address indexed account,
uint256 indexed blockTime,
uint256 indexed amount
);
event NodeBondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
event NodeUnbondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
modifier onlyGuard() {
require(owner() == _msgSender() || token == _msgSender(), "NOT_GUARD");
_;
}
constructor() {}
// Private methods
function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
function _getNodeWithCreatime(
NodeEntity[] storage nodes,
uint256 _creationTime
) private view returns (NodeEntity storage) {
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
bool found = false;
int256 index = _binarySearch(nodes, 0, numberOfNodes, _creationTime);
uint256 validIndex;
if (index >= 0) {
found = true;
validIndex = uint256(index);
}
require(found, "NODE SEARCH: No NODE Found with this blocktime");
return nodes[validIndex];
}
function _binarySearch(
NodeEntity[] memory arr,
uint256 low,
uint256 high,
uint256 x
) private view returns (int256) {
if (high >= low) {
uint256 mid = (high + low).div(2);
if (arr[mid].creationTime == x) {
return int256(mid);
} else if (arr[mid].creationTime > x) {
return _binarySearch(arr, low, mid - 1, x);
} else {
return _binarySearch(arr, mid + 1, high, x);
}
} else {
return -1;
}
}
function _uint2str(uint256 _i)
private
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function _calculateNodeRewards(
uint256 _lastClaimTime,
uint256 _tier
) private view returns (uint256 rewards) {
uint256 elapsedTime_ = (block.timestamp - _lastClaimTime);
uint256 boostMultiplier = _calculateBoost(elapsedTime_);
uint256 rewardPerMonth = _tiersRewards[_tier];
return
rewardPerMonth.mul(1e18).div(2628000).mul(elapsedTime_).mul(boostMultiplier).div(100).div(10000);
}
function _calculateBoost(uint256 elapsedTime_)
internal
view
returns (uint256)
{
uint256 elapsedTimeInDays_ = elapsedTime_ / 1 days;
if (elapsedTimeInDays_ >= _boostRequiredDays[4]) {
return _boostMultipliers[4];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[3]) {
return _boostMultipliers[3];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[2]) {
return _boostMultipliers[2];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[1]) {
return _boostMultipliers[1];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[0]) {
return _boostMultipliers[0];
} else {
return 100;
}
}
// External methods
function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
function borrowRewards(address account, uint256 blocktime, uint256 amount)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: blocktime must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't have any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
uint256 rewardsAvailable = _calculateNodeRewards(node.lastClaimTime, node.tier).sub(node.borrowedRewards);
require(rewardsAvailable >= amount,"You do not have enough rewards available");
node.borrowedRewards += amount;
}
function createNode(
address account,
string memory nodeName,
uint256 _tier
) external onlyGuard whenNotPaused {
require(_isNameAvailable(account, nodeName), "Name not available");
NodeEntity[] storage _nodes = _nodesOfUser[account];
require(_nodes.length <= 100, "Max nodes exceeded");
uint256 amount = getNodePrice(_tier);
_nodes.push(
NodeEntity({
name: nodeName,
creationTime: block.timestamp,
lastClaimTime: block.timestamp,
amount: amount,
tier: _tier,
totalClaimed: 0,
borrowedRewards: 0,
bondedMolecules: [uint256(0),0,0],
bondedMols: 0
})
);
nodeOwners.set(account, _nodesOfUser[account].length);
emit NodeCreated(account, block.timestamp, amount);
totalNodesCreated++;
totalStaked += amount;
}
function getNodeReward(address account, uint256 _creationTime)
public
view
returns (uint256)
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
return _calculateNodeRewards(node.lastClaimTime, node.tier).mul(getNodeAPRIncrease(account, _creationTime)).div(10000).sub(node.borrowedRewards);
}
function getAllNodesRewards(address account) external view returns (uint256[2] memory) {
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
uint256 rewardsTotal = 0;
uint256 taxTotal = 0;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 nodeReward = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
nodeReward = nodeReward;
taxTotal += getNodeFee(account, _node.creationTime, nodeReward);
rewardsTotal += nodeReward;
}
return [rewardsTotal, taxTotal];
}
function cashoutNodeReward(address account, uint256 _creationTime)
external
onlyGuard
whenNotPaused
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 toClaim = _calculateNodeRewards(
node.lastClaimTime,
node.tier
).sub(node.borrowedRewards);
node.totalClaimed += toClaim;
node.lastClaimTime = block.timestamp;
node.borrowedRewards = 0;
}
function cashoutAllNodesRewards(address account)
external
onlyGuard
whenNotPaused
{
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 toClaim = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
_node.totalClaimed += toClaim;
_node.lastClaimTime = block.timestamp;
_node.borrowedRewards = 0;
}
}
function setMoleculeAddress(address _moleculesAddress) external onlyOwner {
molecules = Molecules(_moleculesAddress);
}
function bondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols < 3,"Already bonded to enough molecules");
molecules.bondMolecule(account, _tokenId, node.creationTime);
node.bondedMolecules[node.bondedMols] = _tokenId;
node.bondedMols += 1;
emit NodeBondedToMolecule(account, _tokenId, _creationTime);
}
// function to unbond NFT
function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
function getNodesNames(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory names = nodes[0].name;
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
names = string(abi.encodePacked(names, separator, _node.name));
}
return names;
}
function getNodesRewards(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory rewards = _uint2str(_calculateNodeRewards(nodes[0].lastClaimTime, nodes[0].tier).mul(getNodeAPRIncrease(account, nodes[0].creationTime)).div(10000).sub(nodes[0].borrowedRewards));
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
string memory _rewardStr = _uint2str(_calculateNodeRewards(_node.lastClaimTime, _node.tier).mul(getNodeAPRIncrease(account, _node.creationTime)).div(10000).sub(_node.borrowedRewards));
rewards = string(abi.encodePacked(rewards, separator, _rewardStr));
}
return rewards;
}
function getNodesCreationTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _creationTimes = _uint2str(nodes[0].creationTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_creationTimes = string(
abi.encodePacked(
_creationTimes,
separator,
_uint2str(_node.creationTime)
)
);
}
return _creationTimes;
}
function getNodeAPRIncrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalApyBenefit = 10000;
return totalApyBenefit;
}
else {
uint256 totalApyBenefit = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 2 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalApyBenefit += APYBenefit;
}
}
totalApyBenefit += 10000;
return totalApyBenefit;
}
}
function getNodeTaxDecrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalTaxDecrease = 0;
return totalTaxDecrease;
}
else {
uint256 totalTaxDecrease = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 1 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalTaxDecrease += APYBenefit;
}
}
if (totalTaxDecrease > 10000) {
totalTaxDecrease = 10000;
}
return totalTaxDecrease;
}
}
function getNodesLastClaimTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _lastClaimTimes = _uint2str(nodes[0].lastClaimTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_lastClaimTimes = string(
abi.encodePacked(
_lastClaimTimes,
separator,
_uint2str(_node.lastClaimTime)
)
);
}
return _lastClaimTimes;
}
function getNodeFee(
address account,
uint256 _creationTime,
uint256 _rewardsAmount
) public view returns (uint256) {
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 paperHandsTax = 0;
uint256 claimTx = _rewardsAmount.mul(_claimTaxFees[node.tier]).div(100);
uint256 elapsedSeconds = block.timestamp - node.lastClaimTime;
if (elapsedSeconds >= _paperHandsWeeks[3].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[3]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[2].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[2]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[1].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[1]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[0].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[0]).div(1000);
} else {
paperHandsTax = _rewardsAmount.mul(200).div(1000);
}
uint256 totalTax = claimTx.add(paperHandsTax);
uint256 taxRebate = totalTax.mul(getNodeTaxDecrease(account,_creationTime)).div(10000);
return totalTax.sub(taxRebate);
}
function updateToken(address newToken) external onlyOwner {
token = newToken;
}
function updateTiersRewards(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersRewards = newVal;
}
function updateTiersPrice(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersPrice = newVal;
}
function updateBoostMultipliers(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostMultipliers = newVal;
}
function updateBoostRequiredDays(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostRequiredDays = newVal;
}
function getNodeTier(address account, uint256 blocktime) public view returns (uint256) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.tier;
}
function getNodePrice(uint256 _tierIndex) public view returns (uint256) {
return _tiersPrice[_tierIndex];
}
function getNodeNumberOf(address account) external view returns (uint256) {
return nodeOwners.get(account);
}
function isNodeOwner(address account) public view returns (bool) {
return nodeOwners.get(account) > 0;
}
function getNodeMolecules(address account, uint256 blocktime) public view returns (uint256[3] memory) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.bondedMolecules;
}
function getAllNodes(address account)
external
view
returns (NodeEntity[] memory)
{
return _nodesOfUser[account];
}
function getIndexOfKey(address account)
external
view
onlyOwner
returns (int256)
{
require(account != address(0));
return nodeOwners.getIndexOfKey(account);
}
function burn(uint256 index) external onlyOwner {
require(index < nodeOwners.size());
nodeOwners.remove(nodeOwners.getKeyAtIndex(index));
}
// User Methods
function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
// Firewall methods
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
} | changeNodeName | function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
| // User Methods | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
20195,
20708
]
} | 3,850 |
||
OXG | contracts/NodeManager.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | NodeManager | contract NodeManager is Ownable, Pausable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
struct NodeEntity {
string name;
uint256 creationTime;
uint256 lastClaimTime;
uint256 amount;
uint256 tier;
uint256 totalClaimed;
uint256 borrowedRewards;
uint256[3] bondedMolecules; // tokenId of bonded molecules
uint256 bondedMols; //number of molecules bonded
}
IterableMapping.Map private nodeOwners;
mapping(address => NodeEntity[]) private _nodesOfUser;
Molecules public molecules;
address public token;
uint256 public totalNodesCreated = 0;
uint256 public totalStaked = 0;
uint256 public totalClaimed = 0;
uint256 public levelMultiplier = 250; // bps 250 = 2.5%
uint256[] public _tiersPrice = [1, 6, 20, 50, 150];
uint256[] public _tiersRewards = [1250,8000,30000,87500,300000]; // 10000 => 1 OXG
uint256[] public _boostMultipliers = [102, 105, 110, 130, 200]; // %
uint256[] public _boostRequiredDays = [35, 56, 84, 183, 365]; // days
uint256[] public _paperHandsTaxes = [150, 100, 40, 0]; // %; 10 => 1
uint256[] public _paperHandsWeeks = [1, 2, 3, 4]; // weeks
uint256[] public _claimTaxFees = [8, 8, 8, 8, 8]; // %, match with tiers
event NodeCreated(
address indexed account,
uint256 indexed blockTime,
uint256 indexed amount
);
event NodeBondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
event NodeUnbondedToMolecule(
address account,
uint256 tokenID,
uint256 nodeCreationTime
);
modifier onlyGuard() {
require(owner() == _msgSender() || token == _msgSender(), "NOT_GUARD");
_;
}
constructor() {}
// Private methods
function _isNameAvailable(address account, string memory nodeName)
private
view
returns (bool)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
for (uint256 i = 0; i < nodes.length; i++) {
if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) {
return false;
}
}
return true;
}
function _getNodeWithCreatime(
NodeEntity[] storage nodes,
uint256 _creationTime
) private view returns (NodeEntity storage) {
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
bool found = false;
int256 index = _binarySearch(nodes, 0, numberOfNodes, _creationTime);
uint256 validIndex;
if (index >= 0) {
found = true;
validIndex = uint256(index);
}
require(found, "NODE SEARCH: No NODE Found with this blocktime");
return nodes[validIndex];
}
function _binarySearch(
NodeEntity[] memory arr,
uint256 low,
uint256 high,
uint256 x
) private view returns (int256) {
if (high >= low) {
uint256 mid = (high + low).div(2);
if (arr[mid].creationTime == x) {
return int256(mid);
} else if (arr[mid].creationTime > x) {
return _binarySearch(arr, low, mid - 1, x);
} else {
return _binarySearch(arr, mid + 1, high, x);
}
} else {
return -1;
}
}
function _uint2str(uint256 _i)
private
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function _calculateNodeRewards(
uint256 _lastClaimTime,
uint256 _tier
) private view returns (uint256 rewards) {
uint256 elapsedTime_ = (block.timestamp - _lastClaimTime);
uint256 boostMultiplier = _calculateBoost(elapsedTime_);
uint256 rewardPerMonth = _tiersRewards[_tier];
return
rewardPerMonth.mul(1e18).div(2628000).mul(elapsedTime_).mul(boostMultiplier).div(100).div(10000);
}
function _calculateBoost(uint256 elapsedTime_)
internal
view
returns (uint256)
{
uint256 elapsedTimeInDays_ = elapsedTime_ / 1 days;
if (elapsedTimeInDays_ >= _boostRequiredDays[4]) {
return _boostMultipliers[4];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[3]) {
return _boostMultipliers[3];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[2]) {
return _boostMultipliers[2];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[1]) {
return _boostMultipliers[1];
} else if (elapsedTimeInDays_ >= _boostRequiredDays[0]) {
return _boostMultipliers[0];
} else {
return 100;
}
}
// External methods
function upgradeNode(address account, uint256 blocktime)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
node.tier += 1;
}
function borrowRewards(address account, uint256 blocktime, uint256 amount)
external
onlyGuard
whenNotPaused
{
require(blocktime > 0, "NODE: blocktime must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't have any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
uint256 rewardsAvailable = _calculateNodeRewards(node.lastClaimTime, node.tier).sub(node.borrowedRewards);
require(rewardsAvailable >= amount,"You do not have enough rewards available");
node.borrowedRewards += amount;
}
function createNode(
address account,
string memory nodeName,
uint256 _tier
) external onlyGuard whenNotPaused {
require(_isNameAvailable(account, nodeName), "Name not available");
NodeEntity[] storage _nodes = _nodesOfUser[account];
require(_nodes.length <= 100, "Max nodes exceeded");
uint256 amount = getNodePrice(_tier);
_nodes.push(
NodeEntity({
name: nodeName,
creationTime: block.timestamp,
lastClaimTime: block.timestamp,
amount: amount,
tier: _tier,
totalClaimed: 0,
borrowedRewards: 0,
bondedMolecules: [uint256(0),0,0],
bondedMols: 0
})
);
nodeOwners.set(account, _nodesOfUser[account].length);
emit NodeCreated(account, block.timestamp, amount);
totalNodesCreated++;
totalStaked += amount;
}
function getNodeReward(address account, uint256 _creationTime)
public
view
returns (uint256)
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
return _calculateNodeRewards(node.lastClaimTime, node.tier).mul(getNodeAPRIncrease(account, _creationTime)).div(10000).sub(node.borrowedRewards);
}
function getAllNodesRewards(address account) external view returns (uint256[2] memory) {
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
uint256 rewardsTotal = 0;
uint256 taxTotal = 0;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 nodeReward = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
nodeReward = nodeReward;
taxTotal += getNodeFee(account, _node.creationTime, nodeReward);
rewardsTotal += nodeReward;
}
return [rewardsTotal, taxTotal];
}
function cashoutNodeReward(address account, uint256 _creationTime)
external
onlyGuard
whenNotPaused
{
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 toClaim = _calculateNodeRewards(
node.lastClaimTime,
node.tier
).sub(node.borrowedRewards);
node.totalClaimed += toClaim;
node.lastClaimTime = block.timestamp;
node.borrowedRewards = 0;
}
function cashoutAllNodesRewards(address account)
external
onlyGuard
whenNotPaused
{
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
require(nodesCount > 0, "NODE: CREATIME must be higher than zero");
NodeEntity storage _node;
for (uint256 i = 0; i < nodesCount; i++) {
_node = nodes[i];
uint256 toClaim = _calculateNodeRewards(
_node.lastClaimTime,
_node.tier
).sub(_node.borrowedRewards);
_node.totalClaimed += toClaim;
_node.lastClaimTime = block.timestamp;
_node.borrowedRewards = 0;
}
}
function setMoleculeAddress(address _moleculesAddress) external onlyOwner {
molecules = Molecules(_moleculesAddress);
}
function bondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols < 3,"Already bonded to enough molecules");
molecules.bondMolecule(account, _tokenId, node.creationTime);
node.bondedMolecules[node.bondedMols] = _tokenId;
node.bondedMols += 1;
emit NodeBondedToMolecule(account, _tokenId, _creationTime);
}
// function to unbond NFT
function unbondNFT(uint256 _creationTime, uint256 _tokenId) external {
address account = _msgSender();
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
require(node.bondedMols > 0,"No Molecules Bonded");
molecules.unbondMolecule(account, _tokenId, node.creationTime);
uint256[3] memory newArray = [uint256(0),0,0];
for (uint256 i = 0 ; i < node.bondedMols; i++) {
if (node.bondedMolecules[i] != _tokenId) {
newArray[i] = node.bondedMolecules[i];
}
}
node.bondedMolecules = newArray;
node.bondedMols -= 1;
emit NodeUnbondedToMolecule(account, _tokenId, _creationTime);
}
function getNodesNames(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory names = nodes[0].name;
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
names = string(abi.encodePacked(names, separator, _node.name));
}
return names;
}
function getNodesRewards(address account) public view returns (string memory) {
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory rewards = _uint2str(_calculateNodeRewards(nodes[0].lastClaimTime, nodes[0].tier).mul(getNodeAPRIncrease(account, nodes[0].creationTime)).div(10000).sub(nodes[0].borrowedRewards));
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
string memory _rewardStr = _uint2str(_calculateNodeRewards(_node.lastClaimTime, _node.tier).mul(getNodeAPRIncrease(account, _node.creationTime)).div(10000).sub(_node.borrowedRewards));
rewards = string(abi.encodePacked(rewards, separator, _rewardStr));
}
return rewards;
}
function getNodesCreationTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _creationTimes = _uint2str(nodes[0].creationTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_creationTimes = string(
abi.encodePacked(
_creationTimes,
separator,
_uint2str(_node.creationTime)
)
);
}
return _creationTimes;
}
function getNodeAPRIncrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalApyBenefit = 10000;
return totalApyBenefit;
}
else {
uint256 totalApyBenefit = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 2 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalApyBenefit += APYBenefit;
}
}
totalApyBenefit += 10000;
return totalApyBenefit;
}
}
function getNodeTaxDecrease(address account, uint256 _creationTime) public view returns (uint256){
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"You don't own any nodes"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
if (node.bondedMols == 0){
uint256 totalTaxDecrease = 0;
return totalTaxDecrease;
}
else {
uint256 totalTaxDecrease = 0;
for (uint256 i = 0; i < node.bondedMols; i++) {
if (molecules.getMoleculeKind(node.bondedMolecules[i]) == 1 || molecules.getMoleculeKind(node.bondedMolecules[i]) == 3) {
uint256 APYBenefit = molecules.getMoleculeLevel(node.bondedMolecules[i]).mul(levelMultiplier).add(250);
totalTaxDecrease += APYBenefit;
}
}
if (totalTaxDecrease > 10000) {
totalTaxDecrease = 10000;
}
return totalTaxDecrease;
}
}
function getNodesLastClaimTime(address account)
public
view
returns (string memory)
{
NodeEntity[] memory nodes = _nodesOfUser[account];
uint256 nodesCount = nodes.length;
NodeEntity memory _node;
string memory _lastClaimTimes = _uint2str(nodes[0].lastClaimTime);
string memory separator = "#";
for (uint256 i = 1; i < nodesCount; i++) {
_node = nodes[i];
_lastClaimTimes = string(
abi.encodePacked(
_lastClaimTimes,
separator,
_uint2str(_node.lastClaimTime)
)
);
}
return _lastClaimTimes;
}
function getNodeFee(
address account,
uint256 _creationTime,
uint256 _rewardsAmount
) public view returns (uint256) {
require(_creationTime > 0, "NODE: CREATIME must be higher than zero");
NodeEntity[] storage nodes = _nodesOfUser[account];
require(
nodes.length > 0,
"CASHOUT ERROR: You don't have nodes to cash-out"
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
uint256 paperHandsTax = 0;
uint256 claimTx = _rewardsAmount.mul(_claimTaxFees[node.tier]).div(100);
uint256 elapsedSeconds = block.timestamp - node.lastClaimTime;
if (elapsedSeconds >= _paperHandsWeeks[3].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[3]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[2].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[2]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[1].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[1]).div(1000);
} else if (elapsedSeconds >= _paperHandsWeeks[0].mul(86400).mul(7)) {
paperHandsTax = _rewardsAmount.mul(_paperHandsTaxes[0]).div(1000);
} else {
paperHandsTax = _rewardsAmount.mul(200).div(1000);
}
uint256 totalTax = claimTx.add(paperHandsTax);
uint256 taxRebate = totalTax.mul(getNodeTaxDecrease(account,_creationTime)).div(10000);
return totalTax.sub(taxRebate);
}
function updateToken(address newToken) external onlyOwner {
token = newToken;
}
function updateTiersRewards(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersRewards = newVal;
}
function updateTiersPrice(uint256[] memory newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_tiersPrice = newVal;
}
function updateBoostMultipliers(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostMultipliers = newVal;
}
function updateBoostRequiredDays(uint8[] calldata newVal) external onlyOwner {
require(newVal.length == 5, "Wrong length");
_boostRequiredDays = newVal;
}
function getNodeTier(address account, uint256 blocktime) public view returns (uint256) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.tier;
}
function getNodePrice(uint256 _tierIndex) public view returns (uint256) {
return _tiersPrice[_tierIndex];
}
function getNodeNumberOf(address account) external view returns (uint256) {
return nodeOwners.get(account);
}
function isNodeOwner(address account) public view returns (bool) {
return nodeOwners.get(account) > 0;
}
function getNodeMolecules(address account, uint256 blocktime) public view returns (uint256[3] memory) {
require(blocktime > 0, "Creation Time has to be higher than 0");
require(isNodeOwner(account), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[account];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, blocktime);
return node.bondedMolecules;
}
function getAllNodes(address account)
external
view
returns (NodeEntity[] memory)
{
return _nodesOfUser[account];
}
function getIndexOfKey(address account)
external
view
onlyOwner
returns (int256)
{
require(account != address(0));
return nodeOwners.getIndexOfKey(account);
}
function burn(uint256 index) external onlyOwner {
require(index < nodeOwners.size());
nodeOwners.remove(nodeOwners.getKeyAtIndex(index));
}
// User Methods
function changeNodeName(uint256 _creationTime, string memory newName)
public
{
address sender = msg.sender;
require(isNodeOwner(sender), "NOT NODE OWNER");
NodeEntity[] storage nodes = _nodesOfUser[sender];
uint256 numberOfNodes = nodes.length;
require(
numberOfNodes > 0,
"You don't own any nodes."
);
NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime);
node.name = newName;
}
// Firewall methods
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
} | pause | function pause() external onlyOwner {
_pause();
}
| // Firewall methods | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
20738,
20798
]
} | 3,851 |
||
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
94,
154
]
} | 3,852 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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 | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
237,
310
]
} | 3,853 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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 | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
534,
616
]
} | 3,854 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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 | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
895,
983
]
} | 3,855 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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 | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1647,
1726
]
} | 3,856 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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);
/**
* @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 | transferFrom | function transferFrom(address sender, address recipient, 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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2039,
2141
]
} | 3,857 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
259,
445
]
} | 3,858 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
723,
864
]
} | 3,859 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1162,
1359
]
} | 3,860 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1613,
2089
]
} | 3,861 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2560,
2697
]
} | 3,862 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3188,
3471
]
} | 3,863 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3931,
4066
]
} | 3,864 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | 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) {
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.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
4546,
4717
]
} | 3,865 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
606,
1033
]
} | 3,866 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1963,
2365
]
} | 3,867 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3121,
3299
]
} | 3,868 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3524,
3725
]
} | 3,869 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
4095,
4326
]
} | 3,870 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
4577,
4898
]
} | 3,871 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | SafeERC20 | library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
} | /**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/ | NatSpecMultiLine | safeApprove | function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
| /**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
747,
1374
]
} | 3,872 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | SafeERC20 | library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
} | /**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/ | NatSpecMultiLine | _callOptionalReturn | function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
| /**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2393,
3159
]
} | 3,873 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
497,
581
]
} | 3,874 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1139,
1292
]
} | 3,875 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1442,
1691
]
} | 3,876 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | name | function name() public view returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
902,
990
]
} | 3,877 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | symbol | function symbol() public view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1104,
1196
]
} | 3,878 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decimals | function decimals() public view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1829,
1917
]
} | 3,879 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
1977,
2082
]
} | 3,880 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2140,
2264
]
} | 3,881 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2472,
2652
]
} | 3,882 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
2710,
2866
]
} | 3,883 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3008,
3182
]
} | 3,884 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
3651,
3977
]
} | 3,885 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
4381,
4604
]
} | 3,886 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
5102,
5376
]
} | 3,887 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
5861,
6405
]
} | 3,888 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
6681,
7064
]
} | 3,889 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
7391,
7814
]
} | 3,890 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
8249,
8600
]
} | 3,891 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _setupDecimals | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| /**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
8927,
9022
]
} | 3,892 |
TKFToken | TKFToken.sol | 0x03701347a7920e585d3c1437b6464101ea00afb2 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
| /**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://39c4fb579840cb1fd7fc5df9a30e4c66592f05f582a3d235a5cb8f0294015a76 | {
"func_code_index": [
9620,
9717
]
} | 3,893 |
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
1005,
1126
]
} | 3,894 |
|
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
1346,
1475
]
} | 3,895 |
|
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transfer | function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
1819,
2101
]
} | 3,896 |
|
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approve | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
2609,
2822
]
} | 3,897 |
|
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferFrom | function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
3353,
3716
]
} | 3,898 |
|
KinesisVelocityToken | KinesisVelocityToken.sol | 0x9f376b37c27209b8ed048710345d8e490555ab47 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "KVT";
name = "Kinesis Velocity Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x18192649AEa026632948EFCBB88a2669870b6569] = _totalSupply;
emit Transfer(address(0), 0x18192649AEa026632948EFCBB88a2669870b6569, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| // ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://b274496aceedddc6062389ba132d71dbf83990ace7a529bcbe96fe0a75c6a495 | {
"func_code_index": [
3999,
4155
]
} | 3,899 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.