harensarma

aldo

Jan 25th, 2023 (edited)
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.54 KB | Cryptocurrency | 0 0
  1. pragma solidity ^0.5.0;
  2.  
  3. //SPDX-License-Identifier: UNLICENSED
  4.  
  5. contract BEP20Interface {
  6.     /**
  7.     Returns the name of the token - e.g. "Aldo Token"
  8.      */
  9.     string public name;
  10.     /**
  11.     Returns the symbol of the token. E.g. "ALDO".
  12.      */
  13.     string public symbol;
  14.     /**
  15.     Returns the number of decimals the token uses - e. g. 8
  16.      */
  17.     uint8 public decimals;
  18.     /**
  19.     Returns the total token supply.
  20.      */
  21.     uint256 public totalSupply;
  22.     /**
  23.     Returns the account balance of another account with address _owner.
  24.      */
  25.     function balanceOf(address _owner) public view returns (uint256 balance);
  26.     /**
  27.     Transfers _value amount of tokens to address _to, and MUST fire the Transfer event.
  28.     The function SHOULD throw if the _from account balance does not have enough tokens to spend.
  29.      */
  30.     function transfer(address _to, uint256 _value) public returns (bool success);
  31.     /**
  32.     Transfers _value amount of tokens from address _from to address _to, and MUST fire the Transfer event.
  33.      */
  34.     function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
  35.     /**
  36.     Allows _spender to withdraw from your account multiple times, up to the _value amount.
  37.     If this function is called again it overwrites the current allowance with _value.
  38.      */
  39.     function approve(address _spender, uint256 _value) public returns (bool success);
  40.     /**
  41.     Returns the amount which _spender is still allowed to withdraw from _owner.
  42.      */
  43.     function allowance(address _owner, address _spender) public view returns (uint256 remaining);
  44.     /**
  45.     MUST trigger when tokens are transferred, including zero value transfers.
  46.      */
  47.     event Transfer(address indexed _from, address indexed _to, uint256 _value);
  48.     /**
  49.     MUST trigger on any successful call to approve(address _spender, uint256 _value).
  50.       */
  51.     event Approval(address indexed _owner, address indexed _spender, uint256 _value);
  52. }
  53.  
  54. /**
  55. Owned contract
  56.  */
  57. contract Owned {
  58.     address public owner;
  59.     address public newOwner;
  60.  
  61.     event OwnershipTransferred(address indexed _from, address indexed _to);
  62.  
  63.     constructor () public {
  64.         owner = msg.sender;
  65.     }
  66.  
  67.     modifier onlyOwner {
  68.         require(msg.sender == owner);
  69.         _;
  70.     }
  71.  
  72.     function transferOwnership(address _newOwner) public onlyOwner {
  73.         newOwner = _newOwner;
  74.     }
  75.  
  76.     function acceptOwnership() public {
  77.         require(msg.sender == newOwner);
  78.         emit OwnershipTransferred(owner, newOwner);
  79.         owner = newOwner;
  80.         newOwner = address(0);
  81.     }
  82. }
  83.  
  84. /**
  85. Function to receive approval and execute function in one call.
  86.  */
  87. contract TokenRecipient {
  88.     function receiveApproval(address _from, uint256 _value, address _token, bytes memory _extraData) public;
  89. }
  90.  
  91. /**
  92. Token implement
  93.  */
  94. contract Token is BEP20Interface, Owned {
  95.  
  96.     mapping(address => uint256) _balances;
  97.     mapping(address => mapping(address => uint256)) _allowed;
  98.  
  99.     // This notifies clients about the amount burnt
  100.     event Burn(address indexed from, uint256 value);
  101.  
  102.     function balanceOf(address _owner) public view returns (uint256 balance) {
  103.         return _balances[_owner];
  104.     }
  105.  
  106.     function transfer(address _to, uint256 _value) public returns (bool success) {
  107.         _transfer(msg.sender, _to, _value);
  108.         return true;
  109.     }
  110.  
  111.     function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
  112.         require(_value <= _allowed[_from][msg.sender]);
  113.         _allowed[_from][msg.sender] -= _value;
  114.         _transfer(_from, _to, _value);
  115.         return true;
  116.     }
  117.  
  118.     function approve(address _spender, uint256 _value) public returns (bool success) {
  119.         _allowed[msg.sender][_spender] = _value;
  120.         emit Approval(msg.sender, _spender, _value);
  121.         return true;
  122.     }
  123.  
  124.     function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
  125.         return _allowed[_owner][_spender];
  126.     }
  127.  
  128.     /**
  129.     Internal transfer, only can be called by this contract
  130.       */
  131.     function _transfer(address _from, address _to, uint _value) internal {
  132.         // Prevent transfer to 0x0 address. Use burn() instead
  133.         require(_to != address(0x0));
  134.         // Check if the sender has enough
  135.         require(_balances[_from] >= _value);
  136.         // Check for overflows
  137.         require(_balances[_to] + _value > _balances[_to]);
  138.         // Save this for an assertion in the future
  139.         uint previousBalances = _balances[_from] + _balances[_to];
  140.         // Subtract from the sender
  141.         _balances[_from] -= _value;
  142.         // Add the same to the recipient
  143.         _balances[_to] += _value;
  144.         emit Transfer(_from, _to, _value);
  145.         // Asserts are used to use static analysis to find bugs in your code. They should never fail
  146.         assert(_balances[_from] + _balances[_to] == previousBalances);
  147.     }
  148.  
  149. }
  150.  
  151. contract AldoContract is Token {
  152.  
  153.     constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _initialSupply) public {
  154.         name = _name;
  155.         symbol = _symbol;
  156.         decimals = _decimals;
  157.         totalSupply = _initialSupply * 10 ** uint256(decimals);
  158.         _balances[msg.sender] = totalSupply;
  159.     }
  160.  
  161.     /**
  162.     If ether is sent to this address, send it back.
  163.      */
  164.     function() external payable {
  165.         revert();
  166.     }
  167.  
  168. }
  169.  
  170. contract ALDO_TOKEN is AldoContract {
  171.     constructor() AldoContract("Aldo Token", "ALDO", 18, 100000000) public {}
  172. }
Advertisement
Add Comment
Please, Sign In to add comment