forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Smart Contract Solutions, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
e9dd7bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// SPDX-License-Identifier: MIT
pragma solidity 0.5.16;
interface IBEP20 {
/**
*/
function totalSupply() external view returns (uint256);
/**
*/
function decimals() external view returns (uint8);
/**
*/
function symbol() external view returns (string memory);
/**
*/
function name() external view returns (string memory);
/**
*/
function getOwner() external view returns (address);
/**
account
.*/
function balanceOf(address account) external view returns (uint256);
/**
amount
tokens from the caller's account torecipient
.*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
spender
will beowner
through {transferFrom}. This is*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
amount
as the allowance ofspender
over the caller's tokens.*/
function approve(address spender, uint256 amount) external returns (bool);
/**
amount
tokens fromsender
torecipient
using theamount
is then deducted from the caller's*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
value
tokens are moved from one account (from
) toto
).value
may be zero.*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
spender
for anowner
is set byvalue
is the new allowance.*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/*
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see ethereum/solidity#2691
return msg.data;
}
}
/**
@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 anoperation overflows.
Using this library instead of the unchecked operations eliminates an entire
class of bugs, so it's recommended to use it always.
/
library SafeMath {
/*
+
operator.*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
-
operator.*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
-
operator.*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
}
/**
*
operator.*/
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: improve mul performance and reduce gas cost OpenZeppelin/openzeppelin-contracts#522
if (a == 0) {
return 0;
}
}
/**
/
operator. Note: this function uses arevert
opcode (which leaves remaining gas untouched) while Solidity*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
/
operator. Note: this function uses arevert
opcode (which leaves remaining gas untouched) while Solidity*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
}
/**
%
operator. This function uses arevert
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
%
operator. This function uses arevert
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
onlyOwner
, which can be applied to your functions to restrict their use to*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
*/
function owner() public view returns (address) {
return _owner;
}
/**
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
onlyOwner
functions anymore. Can only be called by the current owner.*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
newOwner
).*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
newOwner
).*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract BEP20Token is Context, IBEP20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _symbol;
string private _name;
constructor() public {
_name = "Binance Smart Chain Mainnet Token";
_symbol = "IIXXGOLD";
_decimals = 18;
_totalSupply = 100000000*10**18;
_balances[msg.sender] = _totalSupply;
}
/**
*/
function getOwner() external view returns (address) {
return owner();
}
/**
*/
function decimals() external view returns (uint8) {
return _decimals;
}
/**
*/
function symbol() external view returns (string memory) {
return _symbol;
}
/**
*/
function name() external view returns (string memory) {
return _name;
}
/**
*/
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
/**
*/
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
/**
recipient
cannot be the zero address.amount
.*/
function transfer(address recipient, uint256 amount) external returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
*/
function allowance(address owner, address spender) external view returns (uint256) {
return _allowances[owner][spender];
}
/**
spender
cannot be the zero address.*/
function approve(address spender, uint256 amount) external returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
sender
andrecipient
cannot be the zero address.sender
must have a balance of at leastamount
.sender
's tokens of at leastamount
.*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance"));
return true;
}
/**
spender
by the caller.spender
cannot be the zero address.*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
spender
by the caller.spender
cannot be the zero address.spender
must have allowance for the caller of at leastsubtractedValue
.*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero"));
return true;
}
/**
amount
tokens and assigns them tomsg.sender
, increasingmsg.sender
must be the token owner*/
function mint(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
amount
fromsender
torecipient
.sender
cannot be the zero address.recipient
cannot be the zero address.sender
must have a balance of at leastamount
.*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "BEP20: transfer from the zero address");
require(recipient != address(0), "BEP20: transfer to the zero address");
}
/** @dev Creates
amount
tokens and assigns them toaccount
, increasingfrom
set to the zero address.to
cannot be the zero address.*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "BEP20: mint to the zero address");
}
/**
amount
tokens fromaccount
, reducing theto
set to the zero address.account
cannot be the zero address.account
must have at leastamount
tokens.*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "BEP20: burn from the zero address");
}
/**
amount
as the allowance ofspender
over theowner
s tokens.approve
, and can be used toowner
cannot be the zero address.spender
cannot be the zero address.*/
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "BEP20: approve from the zero address");
require(spender != address(0), "BEP20: approve to the zero address");
}
/**
amount
tokens fromaccount
.amount
is then deducted*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance"));
}
}