Iammrjude

Sparkle Token. Sol

Oct 29th, 2020 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *Submitted for verification at Etherscan.io on 2018-11-26
  3. */
  4.  
  5. pragma solidity 0.4.25;
  6.  
  7. // File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol
  8.  
  9. /**
  10.  * @title ERC20 interface
  11.  * @dev see https://github.com/ethereum/EIPs/issues/20
  12.  */
  13. interface IERC20 {
  14.   function totalSupply() external view returns (uint256);
  15.  
  16.   function balanceOf(address who) external view returns (uint256);
  17.  
  18.   function allowance(address owner, address spender)
  19.     external view returns (uint256);
  20.  
  21.   function transfer(address to, uint256 value) external returns (bool);
  22.  
  23.   function approve(address spender, uint256 value)
  24.     external returns (bool);
  25.  
  26.   function transferFrom(address from, address to, uint256 value)
  27.     external returns (bool);
  28.  
  29.   event Transfer(
  30.     address indexed from,
  31.     address indexed to,
  32.     uint256 value
  33.   );
  34.  
  35.   event Approval(
  36.     address indexed owner,
  37.     address indexed spender,
  38.     uint256 value
  39.   );
  40. }
  41.  
  42. // File: openzeppelin-solidity/contracts/math/SafeMath.sol
  43.  
  44. /**
  45.  * @title SafeMath
  46.  * @dev Math operations with safety checks that revert on error
  47.  */
  48. library SafeMath {
  49.  
  50.   /**
  51.   * @dev Multiplies two numbers, reverts on overflow.
  52.   */
  53.   function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  54.     // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
  55.     // benefit is lost if 'b' is also tested.
  56.     // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
  57.     if (a == 0) {
  58.       return 0;
  59.     }
  60.  
  61.     uint256 c = a * b;
  62.     require(c / a == b);
  63.  
  64.     return c;
  65.   }
  66.  
  67.   /**
  68.   * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
  69.   */
  70.   function div(uint256 a, uint256 b) internal pure returns (uint256) {
  71.     require(b > 0); // Solidity only automatically asserts when dividing by 0
  72.     uint256 c = a / b;
  73.     // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  74.  
  75.     return c;
  76.   }
  77.  
  78.   /**
  79.   * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
  80.   */
  81.   function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  82.     require(b <= a);
  83.     uint256 c = a - b;
  84.  
  85.     return c;
  86.   }
  87.  
  88.   /**
  89.   * @dev Adds two numbers, reverts on overflow.
  90.   */
  91.   function add(uint256 a, uint256 b) internal pure returns (uint256) {
  92.     uint256 c = a + b;
  93.     require(c >= a);
  94.  
  95.     return c;
  96.   }
  97.  
  98.   /**
  99.   * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
  100.   * reverts when dividing by zero.
  101.   */
  102.   function mod(uint256 a, uint256 b) internal pure returns (uint256) {
  103.     require(b != 0);
  104.     return a % b;
  105.   }
  106. }
  107.  
  108. // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol
  109.  
  110. /**
  111.  * @title Standard ERC20 token
  112.  *
  113.  * @dev Implementation of the basic standard token.
  114.  * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
  115.  * Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
  116.  */
  117. contract ERC20 is IERC20 {
  118.   using SafeMath for uint256;
  119.  
  120.   mapping (address => uint256) private _balances;
  121.  
  122.   mapping (address => mapping (address => uint256)) private _allowed;
  123.  
  124.   uint256 private _totalSupply;
  125.  
  126.   /**
  127.   * @dev Total number of tokens in existence
  128.   */
  129.   function totalSupply() public view returns (uint256) {
  130.     return _totalSupply;
  131.   }
  132.  
  133.   /**
  134.   * @dev Gets the balance of the specified address.
  135.   * @param owner The address to query the balance of.
  136.   * @return An uint256 representing the amount owned by the passed address.
  137.   */
  138.   function balanceOf(address owner) public view returns (uint256) {
  139.     return _balances[owner];
  140.   }
  141.  
  142.   /**
  143.    * @dev Function to check the amount of tokens that an owner allowed to a spender.
  144.    * @param owner address The address which owns the funds.
  145.    * @param spender address The address which will spend the funds.
  146.    * @return A uint256 specifying the amount of tokens still available for the spender.
  147.    */
  148.   function allowance(
  149.     address owner,
  150.     address spender
  151.    )
  152.     public
  153.     view
  154.     returns (uint256)
  155.   {
  156.     return _allowed[owner][spender];
  157.   }
  158.  
  159.   /**
  160.   * @dev Transfer token for a specified address
  161.   * @param to The address to transfer to.
  162.   * @param value The amount to be transferred.
  163.   */
  164.   function transfer(address to, uint256 value) public returns (bool) {
  165.     _transfer(msg.sender, to, value);
  166.     return true;
  167.   }
  168.  
  169.   /**
  170.    * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
  171.    * Beware that changing an allowance with this method brings the risk that someone may use both the old
  172.    * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
  173.    * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
  174.    * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  175.    * @param spender The address which will spend the funds.
  176.    * @param value The amount of tokens to be spent.
  177.    */
  178.   function approve(address spender, uint256 value) public returns (bool) {
  179.     require(spender != address(0));
  180.  
  181.     _allowed[msg.sender][spender] = value;
  182.     emit Approval(msg.sender, spender, value);
  183.     return true;
  184.   }
  185.  
  186.   /**
  187.    * @dev Transfer tokens from one address to another
  188.    * @param from address The address which you want to send tokens from
  189.    * @param to address The address which you want to transfer to
  190.    * @param value uint256 the amount of tokens to be transferred
  191.    */
  192.   function transferFrom(
  193.     address from,
  194.     address to,
  195.     uint256 value
  196.   )
  197.     public
  198.     returns (bool)
  199.   {
  200.     require(value <= _allowed[from][msg.sender]);
  201.  
  202.     _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
  203.     _transfer(from, to, value);
  204.     return true;
  205.   }
  206.  
  207.   /**
  208.    * @dev Increase the amount of tokens that an owner allowed to a spender.
  209.    * approve should be called when allowed_[_spender] == 0. To increment
  210.    * allowed value is better to use this function to avoid 2 calls (and wait until
  211.    * the first transaction is mined)
  212.    * From MonolithDAO Token.sol
  213.    * @param spender The address which will spend the funds.
  214.    * @param addedValue The amount of tokens to increase the allowance by.
  215.    */
  216.   function increaseAllowance(
  217.     address spender,
  218.     uint256 addedValue
  219.   )
  220.     public
  221.     returns (bool)
  222.   {
  223.     require(spender != address(0));
  224.  
  225.     _allowed[msg.sender][spender] = (
  226.       _allowed[msg.sender][spender].add(addedValue));
  227.     emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
  228.     return true;
  229.   }
  230.  
  231.   /**
  232.    * @dev Decrease the amount of tokens that an owner allowed to a spender.
  233.    * approve should be called when allowed_[_spender] == 0. To decrement
  234.    * allowed value is better to use this function to avoid 2 calls (and wait until
  235.    * the first transaction is mined)
  236.    * From MonolithDAO Token.sol
  237.    * @param spender The address which will spend the funds.
  238.    * @param subtractedValue The amount of tokens to decrease the allowance by.
  239.    */
  240.   function decreaseAllowance(
  241.     address spender,
  242.     uint256 subtractedValue
  243.   )
  244.     public
  245.     returns (bool)
  246.   {
  247.     require(spender != address(0));
  248.  
  249.     _allowed[msg.sender][spender] = (
  250.       _allowed[msg.sender][spender].sub(subtractedValue));
  251.     emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
  252.     return true;
  253.   }
  254.  
  255.   /**
  256.   * @dev Transfer token for a specified addresses
  257.   * @param from The address to transfer from.
  258.   * @param to The address to transfer to.
  259.   * @param value The amount to be transferred.
  260.   */
  261.   function _transfer(address from, address to, uint256 value) internal {
  262.     require(value <= _balances[from]);
  263.     require(to != address(0));
  264.  
  265.     _balances[from] = _balances[from].sub(value);
  266.     _balances[to] = _balances[to].add(value);
  267.     emit Transfer(from, to, value);
  268.   }
  269.  
  270.   /**
  271.    * @dev Internal function that mints an amount of the token and assigns it to
  272.    * an account. This encapsulates the modification of balances such that the
  273.    * proper events are emitted.
  274.    * @param account The account that will receive the created tokens.
  275.    * @param value The amount that will be created.
  276.    */
  277.   function _mint(address account, uint256 value) internal {
  278.     require(account != 0);
  279.     _totalSupply = _totalSupply.add(value);
  280.     _balances[account] = _balances[account].add(value);
  281.     emit Transfer(address(0), account, value);
  282.   }
  283.  
  284.   /**
  285.    * @dev Internal function that burns an amount of the token of a given
  286.    * account.
  287.    * @param account The account whose tokens will be burnt.
  288.    * @param value The amount that will be burnt.
  289.    */
  290.   function _burn(address account, uint256 value) internal {
  291.     require(account != 0);
  292.     require(value <= _balances[account]);
  293.  
  294.     _totalSupply = _totalSupply.sub(value);
  295.     _balances[account] = _balances[account].sub(value);
  296.     emit Transfer(account, address(0), value);
  297.   }
  298.  
  299.   /**
  300.    * @dev Internal function that burns an amount of the token of a given
  301.    * account, deducting from the sender's allowance for said account. Uses the
  302.    * internal burn function.
  303.    * @param account The account whose tokens will be burnt.
  304.    * @param value The amount that will be burnt.
  305.    */
  306.   function _burnFrom(address account, uint256 value) internal {
  307.     require(value <= _allowed[account][msg.sender]);
  308.  
  309.     // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
  310.     // this function needs to emit an event with the updated approval.
  311.     _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
  312.       value);
  313.     _burn(account, value);
  314.   }
  315. }
  316.  
  317. // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol
  318.  
  319. /**
  320.  * @title ERC20Detailed token
  321.  * @dev The decimals are only for visualization purposes.
  322.  * All the operations are done using the smallest and indivisible token unit,
  323.  * just as on Ethereum all the operations are done in wei.
  324.  */
  325. contract ERC20Detailed is IERC20 {
  326.   string private _name;
  327.   string private _symbol;
  328.   uint8 private _decimals;
  329.  
  330.   constructor(string name, string symbol, uint8 decimals) public {
  331.     _name = name;
  332.     _symbol = symbol;
  333.     _decimals = decimals;
  334.   }
  335.  
  336.   /**
  337.    * @return the name of the token.
  338.    */
  339.   function name() public view returns(string) {
  340.     return _name;
  341.   }
  342.  
  343.   /**
  344.    * @return the symbol of the token.
  345.    */
  346.   function symbol() public view returns(string) {
  347.     return _symbol;
  348.   }
  349.  
  350.   /**
  351.    * @return the number of decimals of the token.
  352.    */
  353.   function decimals() public view returns(uint8) {
  354.     return _decimals;
  355.   }
  356. }
  357.  
  358. // File: openzeppelin-solidity/contracts/ownership/Ownable.sol
  359.  
  360. /**
  361.  * @title Ownable
  362.  * @dev The Ownable contract has an owner address, and provides basic authorization control
  363.  * functions, this simplifies the implementation of "user permissions".
  364.  */
  365. contract Ownable {
  366.   address private _owner;
  367.  
  368.   event OwnershipTransferred(
  369.     address indexed previousOwner,
  370.     address indexed newOwner
  371.   );
  372.  
  373.   /**
  374.    * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  375.    * account.
  376.    */
  377.   constructor() internal {
  378.     _owner = msg.sender;
  379.     emit OwnershipTransferred(address(0), _owner);
  380.   }
  381.  
  382.   /**
  383.    * @return the address of the owner.
  384.    */
  385.   function owner() public view returns(address) {
  386.     return _owner;
  387.   }
  388.  
  389.   /**
  390.    * @dev Throws if called by any account other than the owner.
  391.    */
  392.   modifier onlyOwner() {
  393.     require(isOwner());
  394.     _;
  395.   }
  396.  
  397.   /**
  398.    * @return true if `msg.sender` is the owner of the contract.
  399.    */
  400.   function isOwner() public view returns(bool) {
  401.     return msg.sender == _owner;
  402.   }
  403.  
  404.   /**
  405.    * @dev Allows the current owner to relinquish control of the contract.
  406.    * @notice Renouncing to ownership will leave the contract without an owner.
  407.    * It will not be possible to call the functions with the `onlyOwner`
  408.    * modifier anymore.
  409.    */
  410.   function renounceOwnership() public onlyOwner {
  411.     emit OwnershipTransferred(_owner, address(0));
  412.     _owner = address(0);
  413.   }
  414.  
  415.   /**
  416.    * @dev Allows the current owner to transfer control of the contract to a newOwner.
  417.    * @param newOwner The address to transfer ownership to.
  418.    */
  419.   function transferOwnership(address newOwner) public onlyOwner {
  420.     _transferOwnership(newOwner);
  421.   }
  422.  
  423.   /**
  424.    * @dev Transfers control of the contract to a newOwner.
  425.    * @param newOwner The address to transfer ownership to.
  426.    */
  427.   function _transferOwnership(address newOwner) internal {
  428.     require(newOwner != address(0));
  429.     emit OwnershipTransferred(_owner, newOwner);
  430.     _owner = newOwner;
  431.   }
  432. }
  433.  
  434. // File: contracts/SparkleToken.sol
  435.  
  436. /**
  437.  * @dev OpenZeppelin Solidity v2.0.0 imports (Using: npm openzeppelin-solidity@2.0.0)
  438.  */
  439.  
  440.  
  441.  
  442.  
  443. /**
  444.  * @title Sparkle
  445.  * @dev Fully compliant ERC20 Token contract.
  446.  * Inherits Ownable, ERC20 and ERC20Detailed from OpenZeppelin-Solidity v2.0.0
  447.  */
  448. contract Sparkle is Ownable, ERC20, ERC20Detailed {
  449.     /**
  450.      * @dev ERC20 Compliance variables
  451.      */
  452.     string  public _tokenName      = "Sparkle";
  453.     string  public _tokenSymbol    = "SPRKL";
  454.     uint8   public _tokenDecimals  = 8;
  455.     /**
  456.      * @dev Max supply to be minted at Sparkle Token creation
  457.      */
  458.     uint256 public _tokenMaxSupply = 70000000 * (10 ** 8);
  459.  
  460.     /**
  461.      * @dev The SparkleToken constructor specifies ERC20 details
  462.      * to be used.
  463.      */
  464.     constructor()
  465.     Ownable()
  466.     ERC20()
  467.     ERC20Detailed(_tokenName, _tokenSymbol, _tokenDecimals)
  468.     public {
  469.         /**
  470.          * @dev Mint the total maximum supply of tokens at creation time
  471.          */
  472.         _mint(owner(), _tokenMaxSupply);
  473.     }
  474.  
  475. }
Add Comment
Please, Sign In to add comment