source_idx
stringlengths
1
5
contract_name
stringlengths
1
48
func_name
stringlengths
0
52
masked_contract
stringlengths
105
184k
func_body
stringlengths
0
324k
func_requirement
stringlengths
1
28.3k
55
MintedCrowdsale
_deliverTokens
contract MintedCrowdsale is Crowdsale { /** * @dev Overrides delivery by minting tokens upon purchase. * @param beneficiary Token purchaser * @param tokenAmount Number of tokens to be minted */ function _deliverTokens( address beneficiary, uint256 tokenAmount ) internal {<FILL...
// Potentially dangerous assumption about the type of the token. require( ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
* * @dev Overrides delivery by minting tokens upon purchase. * @param beneficiary Token purchaser * @param tokenAmount Number of tokens to be minted
55
Ownable
null
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public {<FILL_FUNCTION_BODY>} ...
_owner = msg.sender; emit OwnershipTransferred(address(0), _owner);
* * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account.
55
Ownable
owner
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sen...
return _owner;
* * @return the address of the owner.
55
Ownable
isOwner
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sen...
return msg.sender == _owner;
* * @return true if `msg.sender` is the owner of the contract.
55
Ownable
renounceOwnership
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sen...
emit OwnershipTransferred(_owner, address(0)); _owner = address(0);
* * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore.
55
Ownable
transferOwnership
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sen...
_transferOwnership(newOwner);
* * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to.
55
Ownable
_transferOwnership
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sen...
require(newOwner != address(0), "Must provide a valid owner address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
* * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to.
55
PickflixGameMaster
null
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
gameName = _gameName; closeDate = _closeDate; openDate = block.timestamp; gameDone = false; oracleFeePercent = _oracleFeePercent;
owner is set to original message sender during contract migration
55
PickflixGameMaster
percent
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
// caution, keep this a private function so the numbers are safe uint _numerator = (numerator * 10 ** (precision+1)); // with rounding of last digit uint _quotient = ((_numerator / denominator)) / 10; return ( _quotient);
* * calculate a percentage with parts per notation. * the value returned will be in terms of 10e precision
55
PickflixGameMaster
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
emit Received(msg.sender, msg.value, address(this).balance);
* * @dev wallet can receive funds.
55
PickflixGameMaster
sendTo
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
require(_payee != 0 && _payee != address(this), "Burning tokens and self transfer not allowed"); require(_amount > 0, "Must transfer greater than zero"); _payee.transfer(_amount); emit Sent(_payee, _amount, address(this).balance);
* * @dev wallet can send funds
55
PickflixGameMaster
balanceOf
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
return address(this).balance;
* * @dev function to see the balance of Ether in the wallet
55
PickflixGameMaster
redeemTokens
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
require(acceptedToken(_tokenAddress), "Token must be a registered token"); require(block.timestamp >= closeDate, "Game must be closed"); require(gameDone == true, "Can't redeem tokens until results have been uploaded"); // instantiate a token contract instance from the deployed address IPickFl...
* * @dev function for the player to cash in tokens
55
PickflixGameMaster
acceptedToken
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
return movies[_tokenAddress].accepted;
checks if a token is an accepted game token
55
PickflixGameMaster
calculateTokensIssued
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
IPickFlixToken _token = IPickFlixToken(_tokenAddress); return _token.totalSupply();
* * @dev functions to calculate game results and payouts
55
PickflixGameMaster
calculateOracleFee
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
return balanceOf().mul(oracleFeePercent).div(100);
"15" in this function means 15%. Change that number to raise or lower the oracle fee.
55
PickflixGameMaster
calculateTotalPlayerRewards
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
return balanceOf().sub(oracleFee);
this calculates how much Ether is available for player rewards
55
PickflixGameMaster
calculateTotalBoxOffice
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
uint256 _totalBoxOffice = 0; for (uint256 i = 0; i < _boxOfficeTotals.length; i++) { _totalBoxOffice = _totalBoxOffice.add(_boxOfficeTotals[i]); } return _totalBoxOffice;
this calculates the total box office earnings of all movies in USD
55
PickflixGameMaster
calculateTotalPlayerRewardsPerMovie
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
// 234 means 23.4%, using parts-per notation with three decimals of precision uint256 _boxOfficePercentage = percent(_boxOfficeTotal, totalBoxOffice, 4); // calculate the Ether rewards available for each movie uint256 _rewards = totalPlayerRewards.mul(_boxOfficePercentage).div(10**4); return _...
this calculates how much Ether to reward for each game token
55
PickflixGameMaster
calculateGameResults
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
// check that there are as many box office totals as token addresses require(_tokenAddresses.length == _boxOfficeTotals.length, "Must have box office results per token"); // calculate Oracle Fee and amount of Ether available for player rewards require(gameDone == false, "Can only submit results onc...
* * @dev add box office results and token addresses for the movies, and calculate game results
55
PickflixGameMaster
abortGame
contract PickflixGameMaster is Ownable { // this library helps protect against overflows for large integers using SafeMath for uint256; // fires off events for receiving and sending Ether event Sent(address indexed payee, uint256 amount, uint256 balance); event Received(address indexed payer, uint256 a...
// calculate Oracle Fee and amount of Ether available for player rewards require(gameDone == false, "Can only submit results once"); oracleFee = 0; totalPlayerRewards = calculateTotalPlayerRewards(); closeDate = block.timestamp; for (uint256 i = 0; i < _tokenAddresses.length; i++) { ...
* * @dev add box office results and token addresses for the movies, and calculate game results
55
PickflixGameFactory
createGame
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
address gameMaster = new PickflixGameMaster(gameName, closeDate, oracleFeePercent); games.push(Game({ gameName: gameName, gameMaster: gameMaster, openDate: block.timestamp, closeDate: closeDate })); return gameMaster;
Create a new game master and add it to the factories game list
55
PickflixGameFactory
createTokenForGame
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
Game storage game = games[gameIndex]; address token = new PickFlixToken(tokenName, tokenSymbol, rate, game.gameMaster, game.closeDate, externalID); gameTokens[game.gameMaster].push(token); return token;
Create a token and associate it with a game
55
PickflixGameFactory
closeGame
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
PickflixGameMaster(games[gameIndex].gameMaster).calculateGameResults(_tokenAddresses, _boxOfficeTotals);
Upload the results for a game
55
PickflixGameFactory
abortGame
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
address gameMaster = games[gameIndex].gameMaster; PickflixGameMaster(gameMaster).abortGame(gameTokens[gameMaster]);
Cancel a game and refund participants
55
PickflixGameFactory
killGame
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
address gameMaster = games[gameIndex].gameMaster; PickflixGameMaster(gameMaster).killGame(gameTokens[gameMaster]); games[gameIndex] = games[games.length-1]; delete games[games.length-1]; games.length--;
Delete a game from the factory
55
PickflixGameFactory
setOwner
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
owner = newOwner;
Change the owner address
55
PickflixGameFactory
setOracleFeeReceiver
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
oracleFeeReceiver = newReceiver;
Change the address that receives the oracle fee
55
PickflixGameFactory
sendOraclePayout
contract PickflixGameFactory { struct Game { string gameName; address gameMaster; uint openDate; uint closeDate; } // The list of all games this factory has created Game[] public games; // Each game master has a list of tokens mapping(address => address[]) public gameTokens; ...
oracleFeeReceiver.transfer(address(this).balance);
Send the ether to the oracle fee receiver
57
Rapide
Rapide
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
totalSupply = initialSupply * 10 ** uint256(decimals); // 총 공급액을 소수로 업데이트합니다. balanceOf[msg.sender] = totalSupply; // 총 발행량 name = tokenName; // 토큰 이름 symbol = tokenSymbol; // 토큰 심볼 (EX: ...
* * 생성자 함수 * * 계약서 작성자에게 초기 공급 토큰과의 계약을 초기화합니다.
57
Rapide
_transfer
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
// Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // 발신자 점검 require(balanceOf[_from] >= _value); // 오버플로 확인 require(balanceOf[_to] + _value > balanceOf[_to]); // 미래의 주장을 위해 이것을 저장하십시오 uint previousBalances = balan...
* * 내부 전송, 이 계약으로만 호출할 수 있습니다.
57
Rapide
transfer
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
_transfer(msg.sender, _to, _value);
* * 토큰 전송 * @ _to 받는 사람의 주소에 대한 매개 변수 * @ _value 전송할 금액을 정하다.
57
Rapide
transferFrom
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
require(_value <= allowance[_from][msg.sender]); // 허용량 체크 allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true;
* * _from 보낸 사람의 주소 * _to 받는 사람의 주소 * _value 전송할 금액
57
Rapide
approve
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
allowance[msg.sender][_spender] = _value; return true;
* * 다른 주소에 대한 허용량 설정 * _spender 지출 할 수있는 주소 * _value 그들이 쓸 수 있는 지출 할 수있는 최대 금액
57
Rapide
approveAndCall
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; }
* * 다른 주소에 대한 허용치 설정 및 알림 * @param _spender 지출 할 수있는 주소 * @param _value 그들이 쓸 수 있는 지출 할 수있는 최대 금액 * @param _extraData 승인 된 계약서에 보낼 추가 정보
57
Rapide
burn
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
require(balanceOf[msg.sender] >= _value); // 보낸 사람이 충분히 있는지 확인하십시오. balanceOf[msg.sender] -= _value; // 발신자에게서 뺍니다. totalSupply -= _value; // 총 발행량 업데이트 Burn(msg.sender, _value); return true;
* * 토큰 파괴 * @param _value 소각되는 금액
57
Rapide
burnFrom
contract Rapide { // 변수 선언 string public name; string public symbol; uint8 public decimals = 18; // 18소수 점 이하는 강력하게 제안된 기본 값이므로 변경하지 마십시오. uint256 public totalSupply; // 모든 균형을 갖춘 배열을 생성합니다. mapping (address => uint256) public balanceOf; mapping (address => mappin...
require(balanceOf[_from] >= _value); // 목표 잔액이 충분한 지 확인하십시오. require(_value <= allowance[_from][msg.sender]); // 수당 확인 balanceOf[_from] -= _value; // 목표 잔액에서 차감 allowance[_from][msg.sender] -= _value; // 발송인의 허용량에서 차감 ...
* * 다른 계정에서 토큰 삭제 * @param _from 발신자 주소 * @param _value 소각되는 금액
59
MacTama
null
contract MacTama is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; string private _name = "MacTama"; string private _symbol = "$MCTAMA"; ...
to recieve ETH
59
MacTama
_tokenTransfer
contract MacTama is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; string private _name = "MacTama"; string private _symbol = "$MCTAMA"; ...
if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); ...
this method is responsible for taking all fee, if takeFee is true
60
PersonalERC20Factory
getContractCount
contract PersonalERC20Factory { // index of created contracts mapping (address => bool) public validContracts; address[] public contracts; // useful to know the row count in contracts index function getContractCount() public view returns(uint contractCount) {<FILL_FUNCTION_BOD...
return contracts.length;
useful to know the row count in contracts index
60
PersonalERC20Factory
getDeployedContracts
contract PersonalERC20Factory { // index of created contracts mapping (address => bool) public validContracts; address[] public contracts; // useful to know the row count in contracts index function getContractCount() public view returns(uint contractCount) { return contr...
return contracts;
get all contracts
60
PersonalERC20Factory
newPersonalERC20
contract PersonalERC20Factory { // index of created contracts mapping (address => bool) public validContracts; address[] public contracts; // useful to know the row count in contracts index function getContractCount() public view returns(uint contractCount) { return contr...
PersonalERC20 c = new PersonalERC20(name, symbol, init, owner); validContracts[c] = true; contracts.push(c); return c;
deploy a new contract
60
Pausable
null
contract Pausable is PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; ...
_paused = false;
* * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer.
60
Pausable
paused
contract Pausable is PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; ...
return _paused;
* * @dev Returns true if the contract is paused, and false otherwise.
60
Pausable
pause
contract Pausable is PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; ...
_paused = true; emit Paused(msg.sender);
* * @dev Called by a pauser to pause, triggers stopped state.
60
Pausable
unpause
contract Pausable is PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; ...
_paused = false; emit Unpaused(msg.sender);
* * @dev Called by a pauser to unpause, returns to normal state.
60
ERC20
totalSupply
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
return _totalSupply;
* * @dev See `IERC20.totalSupply`.
60
ERC20
balanceOf
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
return _balances[account];
* * @dev See `IERC20.balanceOf`.
60
ERC20
transfer
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_transfer(msg.sender, 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`.
60
ERC20
allowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
return _allowances[owner][spender];
* * @dev See `IERC20.allowance`.
60
ERC20
approve
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_approve(msg.sender, spender, value); return true;
* * @dev See `IERC20.approve`. * * Requirements: * * - `spender` cannot be the zero address.
60
ERC20
transferFrom
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 ha...
60
ERC20
increaseAllowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_approve(msg.sender, spender, _allowances[msg.sender][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. * * Requi...
60
ERC20
decreaseAllowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); 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. * * Requi...
60
ERC20
_transfer
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sende...
* * @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: * * - `s...
60
ERC20
_mint
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
require(account != address(0), "ERC20: mint to the zero address"); _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.
60
ERC20
_burn
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value);
* * @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.
60
ERC20
_approve
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value);
* * @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: ...
60
ERC20
_burnFrom
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() ...
_burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
* * @dev Destoys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See `_burn` and `_approve`.
60
ERC20Burnable
burn
contract ERC20Burnable is ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See `ERC20._burn`. */ function burn(uint256 amount) public {<FILL_FUNCTION_BODY>} /** * @dev See `ERC20._burnFrom`. */ function burnFrom(address account, uint256 amount) p...
_burn(msg.sender, amount);
* * @dev Destroys `amount` tokens from the caller. * * See `ERC20._burn`.
60
ERC20Burnable
burnFrom
contract ERC20Burnable is ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See `ERC20._burn`. */ function burn(uint256 amount) public { _burn(msg.sender, amount); } /** * @dev See `ERC20._burnFrom`. */ function burnFrom(address acco...
_burnFrom(account, amount);
* * @dev See `ERC20._burnFrom`.
60
PersonalERC20
null
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
_name = name; _symbol = symbol; _decimals = 18; _owner = owner; _balances[_owner] = init; // provides initial deposit to owner set by constructor _totalSupply = init; // initializes totalSupply with initial deposit _addMinter(_owner); _addPauser(_...
* * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can only be set once during * construction. Decimals are defaulted to '18', per ERC20 norms, imitating * the relationship between Ether and Wei.
60
PersonalERC20
mint
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
_mint(account, amount); return true;
* * @dev See `ERC20._mint`. * * Requirements: * * - the caller must have the `MinterRole`.
60
PersonalERC20
name
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
return _name;
* * @dev Returns the name of the token.
60
PersonalERC20
symbol
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
return _symbol;
* * @dev Returns the symbol of the token, usually a shorter version of the * name.
60
PersonalERC20
decimals
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
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 * ...
60
PersonalERC20
owner
contract PersonalERC20 is MinterRole, ERC20Burnable, ERC20Pausable { string private _name; string private _symbol; uint8 private _decimals; address private _owner; /** * @dev Sets the values for `name`, `symbol`, 'init', 'owner'. All four of * these values are immutable: they can ...
return _owner;
* * @dev Returns the token's initial owner.
61
Token
totalSupply
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {<FILL_FUNCTION_BODY>} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 bal...
/ @return total amount of tokens
61
Token
balanceOf
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) {<FILL_FUNCTIO...
/ @param _owner The address from which the balance will be retrieved / @return The balance
61
Token
transfer
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
61
Token
transferFrom
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 `_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
61
Token
approve
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 `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
61
Token
allowance
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) {} /// ...
/ @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
61
GateToken
GateToken
contract GateToken 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 mi...
balances[msg.sender] = 5000000000000000000000000000; totalSupply = 5000000000000000000000000000; name = "GateToken"; decimals = 18; symbol = "GATE"; unitsOneEthCanBuy = 100000000; fundsWallet = msg.sender;
Where should the raised ETH go? which means the following function name has to match the contract name declared above
61
GateToken
approveAndCall
contract GateToken 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 mi...
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApprov...
Approves and then calls the receiving contract
62
Ownable
Ownable
contract Ownable { address public owner; /** * @dev sets owner of contract */ function Ownable() public {<FILL_FUNCTION_BODY>} /** * @dev changes owner of contract * @param newOwner New owner */ function changeOwner(address newOwner) public ownerOnly { require(newOwner != a...
owner = msg.sender;
* * @dev sets owner of contract
62
Ownable
changeOwner
contract Ownable { address public owner; /** * @dev sets owner of contract */ function Ownable() public { owner = msg.sender; } /** * @dev changes owner of contract * @param newOwner New owner */ function changeOwner(address newOwner) public ownerOnly {<FILL_FUNCTION_BOD...
require(newOwner != address(0)); owner = newOwner;
* * @dev changes owner of contract * @param newOwner New owner
62
EmergencySafe
EmergencySafe
contract EmergencySafe is Ownable{ event PauseToggled(bool isPaused); bool public paused; /** * @dev Throws if contract is paused */ modifier isNotPaused() { require(!paused); _; } /** * @dev Throws if contract is not paused */ modifier isPaused() { require...
paused = false;
* * @dev Initialises contract to non-paused
62
EmergencySafe
emergencyERC20Drain
contract EmergencySafe is Ownable{ event PauseToggled(bool isPaused); bool public paused; /** * @dev Throws if contract is paused */ modifier isNotPaused() { require(!paused); _; } /** * @dev Throws if contract is not paused */ modifier isPaused() { require...
token.transfer(owner, amount);
* * @dev Allows draining of tokens (to owner) that might accidentally be sent to this address * @param token Address of ERC20 token * @param amount Amount to drain
62
EmergencySafe
emergencyEthDrain
contract EmergencySafe is Ownable{ event PauseToggled(bool isPaused); bool public paused; /** * @dev Throws if contract is paused */ modifier isNotPaused() { require(!paused); _; } /** * @dev Throws if contract is not paused */ modifier isPaused() { require...
return owner.send(amount);
* * @dev Allows draining of Ether * @param amount Amount to drain
62
EmergencySafe
togglePause
contract EmergencySafe is Ownable{ event PauseToggled(bool isPaused); bool public paused; /** * @dev Throws if contract is paused */ modifier isNotPaused() { require(!paused); _; } /** * @dev Throws if contract is not paused */ modifier isPaused() { require...
paused = !paused; emit PauseToggled(paused);
* * @dev Switches the contract from paused to non-paused or vice-versa
62
Upgradeable
Upgradeable
contract Upgradeable is Ownable{ address public lastContract; address public nextContract; bool public isOldVersion; bool public allowedToUpgrade; /** * @dev makes contract upgradeable */ function Upgradeable() public {<FILL_FUNCTION_BODY>} /** * @dev signals that new upgrade is ...
allowedToUpgrade = true;
* * @dev makes contract upgradeable
62
Upgradeable
upgradeTo
contract Upgradeable is Ownable{ address public lastContract; address public nextContract; bool public isOldVersion; bool public allowedToUpgrade; /** * @dev makes contract upgradeable */ function Upgradeable() public { allowedToUpgrade = true; } /** * @dev signals that n...
require(allowedToUpgrade && !isOldVersion); nextContract = newContract; isOldVersion = true; newContract.confirmUpgrade();
* * @dev signals that new upgrade is available, contract must be most recent * upgrade and allowed to upgrade * @param newContract Address of upgraded contract
62
Upgradeable
confirmUpgrade
contract Upgradeable is Ownable{ address public lastContract; address public nextContract; bool public isOldVersion; bool public allowedToUpgrade; /** * @dev makes contract upgradeable */ function Upgradeable() public { allowedToUpgrade = true; } /** * @dev signals that n...
require(lastContract == address(0)); lastContract = msg.sender;
* * @dev confirmation that this is indeed the next version, * called from previous version of contract. Anyone can call this function, * which basically makes this instance unusable if that happens. Once called, * this contract can not serve as upgrade to another contract. Not an ideal solution * bu...
62
Validator
add
contract Validator is Ownable, EmergencySafe, Upgradeable{ mapping(address => bool) private valid_contracts; string public whoAmI; function Validator(string _whoAmI) public { whoAmI = _whoAmI; } /** * @dev adds validated contract * @param addr Address of contract that's validated *...
valid_contracts[addr] = true;
* * @dev adds validated contract * @param addr Address of contract that's validated
62
Validator
remove
contract Validator is Ownable, EmergencySafe, Upgradeable{ mapping(address => bool) private valid_contracts; string public whoAmI; function Validator(string _whoAmI) public { whoAmI = _whoAmI; } /** * @dev adds validated contract * @param addr Address of contract that's validated *...
valid_contracts[addr] = false;
* * @dev removes validated contract * @param addr Address of contract to be removed
62
Validator
validate
contract Validator is Ownable, EmergencySafe, Upgradeable{ mapping(address => bool) private valid_contracts; string public whoAmI; function Validator(string _whoAmI) public { whoAmI = _whoAmI; } /** * @dev adds validated contract * @param addr Address of contract that's validated *...
return valid_contracts[addr];
* * @dev checks whether contract is valid * @param addr Address of contract to be ckecked
62
IXTPaymentContract
IXTPaymentContract
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
tokenContract = ERC20Interface(tokenAddress); allowed[owner] = true;
* * @dev sets up token address of IXT token * adds owner to allowds, if owner is changed in the future, remember to remove old * owner if desired * @param tokenAddress IXT token address
62
IXTPaymentContract
transferIXT
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
if (isOldVersion) { IXTPaymentContract newContract = IXTPaymentContract(nextContract); return newContract.transferIXT(from, to, action); } else { uint price = actionPrices[action]; if(price != 0 && !tokenContract.transferFrom(from, to, price)){ return false; } el...
* * @dev transfers IXT * @param from User address * @param to Recipient * @param action Service the user is paying for
62
IXTPaymentContract
setTokenAddress
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
tokenContract = ERC20Interface(erc20Token);
* * @dev sets new token address in case of update * @param erc20Token Token address
62
IXTPaymentContract
setAction
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
actionPrices[action] = price;
* * @dev creates/updates action * @param action Action to be paid for * @param price Price (in units * 10 ^ (<decimal places of token>))
62
IXTPaymentContract
getActionPrice
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
return actionPrices[action];
* * @dev retrieves price for action * @param action Name of action, e.g. 'create_insurance_contract'
62
IXTPaymentContract
setAllowed
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
allowed[allowedAddress] = true;
* * @dev add account to allow calling of transferIXT * @param allowedAddress Address of account
62
IXTPaymentContract
removeAllowed
contract IXTPaymentContract is Ownable, EmergencySafe, Upgradeable{ event IXTPayment(address indexed from, address indexed to, uint value, string indexed action); ERC20Interface public tokenContract; mapping(string => uint) private actionPrices; mapping(address => bool) private allowed; /** *...
allowed[allowedAddress] = false;
* * @dev remove account from allowed accounts * @param allowedAddress Address of account
63
BluzelleStakingRewards
totalSupply
contract BluzelleStakingRewards is ERC20Detailed { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply = 11000e18; uint256 public basePercent = 320; construct...
return _totalSupply;
/ @return Total number of tokens in circulation
64
Ownable
Ownable
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public {<FILL_FUNCTION_BODY>} /** * @dev Throws if called by any account other than the owner. *...
owner = msg.sender;
* * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account.
64
Ownable
transferOwnership
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the ...
if (newOwner != address(0)) { owner = newOwner; }
* * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to.
64
BasicToken
transfer
contract BasicToken is Ownable, ERC20Basic { using SafeMath for uint; mapping(address => uint) public balances; // additional variables for use if transaction fees ever became necessary uint public basisPointsRate = 0; uint public maximumFee = 0; /** * @dev Fix for the ERC20 sho...
uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } uint sendAmount = _value.sub(fee); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee...
* * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred.
64
BasicToken
balanceOf
contract BasicToken is Ownable, ERC20Basic { using SafeMath for uint; mapping(address => uint) public balances; // additional variables for use if transaction fees ever became necessary uint public basisPointsRate = 0; uint public maximumFee = 0; /** * @dev Fix for the ERC20 sho...
return balances[_owner];
* * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint representing the amount owned by the passed address.
64
StandardToken
transferFrom
contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) public allowed; uint public constant MAX_UINT = 2**256 - 1; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @par...
var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // if (_value > _allowance) throw; uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { ...
* * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint the amount of tokens to be transferred