Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
0a0f8c58
Commit
0a0f8c58
authored
Oct 13, 2016
by
Manuel Araoz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StandardToken first version
parent
f8c486ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
16 deletions
+45
-16
SafeMath.sol
contracts/SafeMath.sol
+28
-0
StandardToken.sol
contracts/StandardToken.sol
+17
-16
No files found.
contracts/SafeMath.sol
0 → 100644
View file @
0a0f8c58
pragma solidity ^0.4.0;
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function assert(bool assertion) internal {
if (!assertion) throw;
}
}
contracts/
Base
Token.sol
→
contracts/
Standard
Token.sol
View file @
0a0f8c58
pragma solidity ^0.4.0;
pragma solidity ^0.4.0;
// Everything throws instead of returning false on failure.
import './ERC20.sol';
import './ERC20.sol';
import './SafeMath.sol';
/**
/**
* ERC
20 token
* ERC20 token
*
*
* https://github.com/ethereum/EIPs/issues/20
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood:
* Based on code by FirstBlood:
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
*/
contract
BaseToken is ERC20
{
contract
StandardToken is ERC20, SafeMath
{
mapping(address => uint256) balances;
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
uint256 public totalSupply;
function transfer(address _to, uint256 _value) returns (bool success) {
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value &&
if (balances[msg.sender] < _value) {
balances[_to] + _value > balances[_to]) {
throw;
balances[msg.sender] -= _value;
}
balances[_to] += _value;
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, _to, _value);
return true;
return true;
} else { return false; }
}
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value &&
var _allowance = allowed[_from][msg.sender];
allowed[_from][msg.sender] >= _value &&
if (balances[_from] < _value ||
balances[_to] + _value > balances[_to]) {
_allowance < _value)) {
balances[_to] += _value;
throw;
balances[_from] -= _value;
}
allowed[_from][msg.sender] -= _value;
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSub(balances[_from], _value);
allowed[_from][msg.sender] = safeSub(_allowance, _value);
Transfer(_from, _to, _value);
Transfer(_from, _to, _value);
return true;
return true;
} else { return false; }
}
}
function balanceOf(address _owner) constant returns (uint256 balance) {
function balanceOf(address _owner) constant returns (uint256 balance) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment