Description:
ERC20 token contract. Standard implementation for fungible tokens on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{"EIP20.sol":{"content":"/*\r
Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md\r
.*/\r
\r
\r
pragma solidity ^0.4.21;\r
\r
import "./EIP20Interface.sol";\r
\r
\r
contract EIP20 is EIP20Interface {\r
\r
uint256 constant private MAX_UINT256 = 2**256 - 1;\r
mapping (address =\u003e uint256) public balances;\r
mapping (address =\u003e mapping (address =\u003e uint256)) public allowed;\r
/*\r
NOTE:\r
The following variables are OPTIONAL vanities. One does not have to include them.\r
They allow one to customise the token contract \u0026 in no way influences the core functionality.\r
Some wallets/interfaces might not even bother to look at this information.\r
*/\r
string public name; //fancy name: eg Simon Bucks\r
uint8 public decimals; //How many decimals to show.\r
string public symbol; //An identifier: eg SBX\r
\r
function EIP20(\r
uint256 _initialAmount,\r
string _tokenName,\r
uint8 _decimalUnits,\r
string _tokenSymbol\r
) public {\r
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens\r
totalSupply = _initialAmount; // Update total supply\r
name = _tokenName; // Set the name for display purposes\r
decimals = _decimalUnits; // Amount of decimals for display purposes\r
symbol = _tokenSymbol; // Set the symbol for display purposes\r
}\r
\r
function transfer(address _to, uint256 _value) public returns (bool success) {\r
require(balances[msg.sender] \u003e= _value);\r
balances[msg.sender] -= _value;\r
balances[_to] += _value;\r
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars\r
return true;\r
}\r
\r
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {\r
uint256 allowance = allowed[_from][msg.sender];\r
require(balances[_from] \u003e= _value \u0026\u0026 allowance \u003e= _value);\r
balances[_to] += _value;\r
balances[_from] -= _value;\r
if (allowance \u003c MAX_UINT256) {\r
allowed[_from][msg.sender] -= _value;\r
}\r
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars\r
return true;\r
}\r
\r
function balanceOf(address _owner) public view returns (uint256 balance) {\r
return balances[_owner];\r
}\r
\r
function approve(address _spender, uint256 _value) public returns (bool success) {\r
allowed[msg.sender][_spender] = _value;\r
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars\r
return true;\r
}\r
\r
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {\r
return allowed[_owner][_spender];\r
}\r
}"},"EIP20Interface.sol":{"content":"// Abstract contract for the full ERC 20 Token standard\r
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md\r
pragma solidity ^0.4.21;\r
\r
\r
contract EIP20Interface {\r
/* This is a slight change to the ERC20 base standard.\r
function totalSupply() constant returns (uint256 supply);\r
is replaced with:\r
uint256 public totalSupply;\r
This automatically creates a getter function for the totalSupply.\r
This is moved to the base contract since public getter functions are not\r
currently recognised as an implementation of the matching abstract\r
function by the compiler.\r
*/\r
/// total amount of tokens\r
uint256 public totalSupply;\r
\r
/// @param _owner The address from which the balance will be retrieved\r
/// @return The balance\r
function balanceOf(address _owner) public view returns (uint256 balance);\r
\r
/// @notice send `_value` token to `_to` from `msg.sender`\r
/// @param _to The address of the recipient\r
/// @param _value The amount of token to be transferred\r
/// @return Whether the transfer was successful or not\r
function transfer(address _to, uint256 _value) public returns (bool success);\r
\r
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`\r
/// @param _from The address of the sender\r
/// @param _to The address of the recipient\r
/// @param _value The amount of token to be transferred\r
/// @return Whether the transfer was successful or not\r
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);\r
\r
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens\r
/// @param _spender The address of the account able to transfer the tokens\r
/// @param _value The amount of tokens to be approved for transfer\r
/// @return Whether the approval was successful or not\r
function approve(address _spender, uint256 _value) public returns (bool success);\r
\r
/// @param _owner The address of the account owning tokens\r
/// @param _spender The address of the account able to transfer the tokens\r
/// @return Amount of remaining tokens allowed to spent\r
function allowance(address _owner, address _spender) public view returns (uint256 remaining);\r
\r
// solhint-disable-next-line no-simple-event-func-name\r
event Transfer(address indexed _from, address indexed _to, uint256 _value);\r
event Approval(address indexed _owner, address indexed _spender, uint256 _value);\r
}"}}
Submitted on: 2025-10-13 10:50:35
Comments
Log in to comment.
No comments yet.