Description:
ERC20 token contract with Factory capabilities. Standard implementation for fungible tokens on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"sos.sol": {
"content": "// 0.5.1-c8a2\r
// Enable optimization\r
pragma solidity ^0.5.0;\r
\r
interface IERC20 {\r
/**\r
* @dev Returns the amount of tokens in existence.\r
*/\r
function totalSupply() external view returns (uint256);\r
\r
/**\r
* @dev Returns the amount of tokens owned by `account`.\r
*/\r
function balanceOf(address account) external view returns (uint256);\r
\r
function transfer(address recipient, uint256 amount) external returns (bool);\r
\r
\r
function allowance(address owner, address spender) external view returns (uint256);\r
\r
\r
function approve(address spender, uint256 amount) external returns (bool);\r
\r
\r
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\r
\r
\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
\r
/**\r
* @dev Emitted when the allowance of a `spender` for an `owner` is set by\r
* a call to {approve}. `value` is the new allowance.\r
*/\r
event Approval(address indexed owner, address indexed spender, uint256 value);\r
}\r
\r
\r
contract ERC20 is IERC20 {\r
using SafeMath for uint256;\r
\r
mapping (address => uint256) private _balances;\r
\r
mapping (address => mapping (address => uint256)) private _allowances;\r
\r
uint256 private _totalSupply;\r
\r
/**\r
* @dev See {IERC20-totalSupply}.\r
*/\r
function totalSupply() public view returns (uint256) {\r
return _totalSupply;\r
}\r
\r
/**\r
* @dev See {IERC20-balanceOf}.\r
*/\r
function balanceOf(address account) public view returns (uint256) {\r
return _balances[account];\r
}\r
\r
function transfer(address recipient, uint256 amount) public returns (bool) {\r
_transfer(msg.sender, recipient, amount);\r
return true;\r
}\r
\r
/**\r
* @dev See {IERC20-allowance}.\r
*/\r
function allowance(address owner, address spender) public view returns (uint256) {\r
return _allowances[owner][spender];\r
}\r
\r
\r
function approve(address spender, uint256 value) public returns (bool) {\r
_approve(msg.sender, spender, value);\r
return true;\r
}\r
\r
\r
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {\r
_transfer(sender, recipient, amount);\r
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));\r
return true;\r
}\r
\r
\r
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\r
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));\r
return true;\r
}\r
\r
\r
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\r
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));\r
return true;\r
}\r
\r
\r
function _transfer(address sender, address recipient, uint256 amount) internal {\r
require(sender != address(0), "ERC20: transfer from the zero address");\r
require(recipient != address(0), "ERC20: transfer to the zero address");\r
\r
_balances[sender] = _balances[sender].sub(amount);\r
_balances[recipient] = _balances[recipient].add(amount);\r
emit Transfer(sender, recipient, amount);\r
}\r
\r
\r
function _mint(address account, uint256 amount) internal {\r
require(account != address(0), "ERC20: mint to the zero address");\r
\r
_totalSupply = _totalSupply.add(amount);\r
_balances[account] = _balances[account].add(amount);\r
emit Transfer(address(0), account, amount);\r
}\r
\r
\r
function _burn(address account, uint256 value) internal {\r
require(account != address(0), "ERC20: burn from the zero address");\r
\r
_totalSupply = _totalSupply.sub(value);\r
_balances[account] = _balances[account].sub(value);\r
emit Transfer(account, address(0), value);\r
}\r
\r
\r
function _approve(address owner, address spender, uint256 value) internal {\r
require(owner != address(0), "ERC20: approve from the zero address");\r
require(spender != address(0), "ERC20: approve to the zero address");\r
\r
_allowances[owner][spender] = value;\r
emit Approval(owner, spender, value);\r
}\r
\r
/**\r
* @dev Destoys `amount` tokens from `account`.`amount` is then deducted\r
* from the caller's allowance.\r
*\r
* See {_burn} and {_approve}.\r
*/\r
function _burnFrom(address account, uint256 amount) internal {\r
_burn(account, amount);\r
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));\r
}\r
}\r
\r
\r
/**\r
* @dev Optional functions from the ERC20 standard.\r
*/\r
contract ERC20Detailed is IERC20 {\r
string private _name;\r
string private _symbol;\r
uint8 private _decimals;\r
\r
/**\r
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of\r
* these values are immutable: they can only be set once during\r
* construction.\r
*/\r
constructor (string memory name, string memory symbol, uint8 decimals) public {\r
_name = name;\r
_symbol = symbol;\r
_decimals = decimals;\r
}\r
\r
/**\r
* @dev Returns the name of the token.\r
*/\r
function name() public view returns (string memory) {\r
return _name;\r
}\r
\r
/**\r
* @dev Returns the symbol of the token, usually a shorter version of the\r
* name.\r
*/\r
function symbol() public view returns (string memory) {\r
return _symbol;\r
}\r
\r
\r
function decimals() public view returns (uint8) {\r
return _decimals;\r
}\r
}\r
\r
library SafeMath {\r
/**\r
* @dev Returns the addition of two unsigned integers, reverting on\r
* overflow.\r
*\r
* Counterpart to Solidity's `+` operator.\r
*\r
* Requirements:\r
* - Addition cannot overflow.\r
*/\r
function add(uint256 a, uint256 b) internal pure returns (uint256) {\r
uint256 c = a + b;\r
require(c >= a, "SafeMath: addition overflow");\r
\r
return c;\r
}\r
\r
\r
function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r
require(b <= a, "SafeMath: subtraction overflow");\r
uint256 c = a - b;\r
\r
return c;\r
}\r
\r
\r
function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r
// benefit is lost if 'b' is also tested.\r
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r
if (a == 0) {\r
return 0;\r
}\r
\r
uint256 c = a * b;\r
require(c / a == b, "SafeMath: multiplication overflow");\r
\r
return c;\r
}\r
\r
function div(uint256 a, uint256 b) internal pure returns (uint256) {\r
// Solidity only automatically asserts when dividing by 0\r
require(b > 0, "SafeMath: division by zero");\r
uint256 c = a / b;\r
// assert(a == b * c + a % b); // There is no case in which this doesn't hold\r
\r
return c;\r
}\r
\r
\r
function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r
require(b != 0, "SafeMath: modulo by zero");\r
return a % b;\r
}\r
}\r
\r
\r
contract Token is ERC20, ERC20Detailed {\r
\r
/**\r
* @dev Constructor that gives msg.sender all of existing tokens.\r
*/\r
constructor () public ERC20Detailed("PINETW", "PIW", 6) {\r
_mint(msg.sender, 21000000* (10 ** uint256(decimals())));\r
}\r
}\r
\r
"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-11-01 13:20:42
Comments
Log in to comment.
No comments yet.