Upload 190 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- benchmark2/integer overflow/21.sol +137 -0
- benchmark2/integer overflow/22.sol +418 -0
- benchmark2/integer overflow/225.sol +183 -0
- benchmark2/integer overflow/241.sol +287 -0
- benchmark2/integer overflow/253.sol +317 -0
- benchmark2/integer overflow/262.sol +223 -0
- benchmark2/integer overflow/274.sol +109 -0
- benchmark2/integer overflow/276.sol +325 -0
- benchmark2/integer overflow/281.sol +298 -0
- benchmark2/integer overflow/286.sol +232 -0
- benchmark2/integer overflow/291.sol +213 -0
- benchmark2/integer overflow/311.sol +232 -0
- benchmark2/integer overflow/333.sol +219 -0
- benchmark2/integer overflow/338.sol +316 -0
- benchmark2/integer overflow/339.sol +115 -0
- benchmark2/integer overflow/355.sol +198 -0
- benchmark2/integer overflow/373.sol +414 -0
- benchmark2/integer overflow/375.sol +366 -0
- benchmark2/integer overflow/382.sol +222 -0
- benchmark2/integer overflow/39.sol +1 -0
- benchmark2/integer overflow/394.sol +115 -0
- benchmark2/integer overflow/423.sol +234 -0
- benchmark2/integer overflow/440.sol +106 -0
- benchmark2/integer overflow/451.sol +115 -0
- benchmark2/integer overflow/453.sol +152 -0
- benchmark2/integer overflow/462.sol +398 -0
- benchmark2/integer overflow/465.sol +115 -0
- benchmark2/integer overflow/469.sol +172 -0
- benchmark2/integer overflow/480.sol +195 -0
- benchmark2/integer overflow/508.sol +1089 -0
- benchmark2/integer overflow/528.sol +269 -0
- benchmark2/integer overflow/548.sol +259 -0
- benchmark2/integer overflow/564.sol +1 -0
- benchmark2/integer overflow/571.sol +306 -0
- benchmark2/integer overflow/574.sol +269 -0
- benchmark2/integer overflow/575.sol +270 -0
- benchmark2/integer overflow/6.sol +144 -0
- benchmark2/integer overflow/600.sol +154 -0
- benchmark2/integer overflow/607.sol +311 -0
- benchmark2/integer overflow/609.sol +262 -0
- benchmark2/integer overflow/626.sol +185 -0
- benchmark2/integer overflow/634.sol +179 -0
- benchmark2/integer overflow/635.sol +179 -0
- benchmark2/integer overflow/638.sol +153 -0
- benchmark2/integer overflow/640.sol +203 -0
- benchmark2/integer overflow/651.sol +339 -0
- benchmark2/integer overflow/655.sol +1134 -0
- benchmark2/integer overflow/682.sol +147 -0
- benchmark2/integer overflow/683.sol +196 -0
- benchmark2/integer overflow/727.sol +137 -0
benchmark2/integer overflow/21.sol
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
library SafeMath {
|
| 5 |
+
function mul(uint256 a, uint256 b) pure internal returns (uint256) {
|
| 6 |
+
uint256 c = a * b;
|
| 7 |
+
assert(a == 0 || c / a == b);
|
| 8 |
+
return c;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function div(uint256 a, uint256 b) pure internal returns (uint256) {
|
| 12 |
+
|
| 13 |
+
uint256 c = a / b;
|
| 14 |
+
|
| 15 |
+
return c;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function sub(uint256 a, uint256 b) pure internal returns (uint256) {
|
| 19 |
+
assert(b <= a);
|
| 20 |
+
return a - b;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function add(uint256 a, uint256 b) pure internal returns (uint256) {
|
| 24 |
+
uint256 c = a + b;
|
| 25 |
+
assert(c >= a);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
contract ERC20Basic {
|
| 32 |
+
uint256 public totalSupply;
|
| 33 |
+
function balanceOf(address who) public constant returns (uint256);
|
| 34 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 35 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
contract BasicToken is ERC20Basic {
|
| 41 |
+
using SafeMath for uint256;
|
| 42 |
+
|
| 43 |
+
mapping(address => uint256) balances;
|
| 44 |
+
|
| 45 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 46 |
+
require(_to != address(0));
|
| 47 |
+
require(_value <= balances[msg.sender]);
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 51 |
+
balances[_to] = balances[_to].add(_value);
|
| 52 |
+
Transfer(msg.sender, _to, _value);
|
| 53 |
+
return true;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function balanceOf(address _owner) public constant returns (uint256 balance) {
|
| 57 |
+
return balances[_owner];
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
contract ERC20 is ERC20Basic {
|
| 64 |
+
function allowance(address owner, address spender) public constant returns (uint256);
|
| 65 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 66 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 67 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
contract StandardToken is ERC20, BasicToken {
|
| 72 |
+
|
| 73 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
| 78 |
+
require(_to != address(0));
|
| 79 |
+
require(_value <= balances[_from]);
|
| 80 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 81 |
+
|
| 82 |
+
balances[_from] = balances[_from].sub(_value);
|
| 83 |
+
balances[_to] = balances[_to].add(_value);
|
| 84 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 85 |
+
Transfer(_from, _to, _value);
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 91 |
+
allowed[msg.sender][_spender] = _value;
|
| 92 |
+
Approval(msg.sender, _spender, _value);
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
|
| 98 |
+
return allowed[_owner][_spender];
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
|
| 103 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 104 |
+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 105 |
+
return true;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
|
| 109 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 110 |
+
if (_subtractedValue > oldValue) {
|
| 111 |
+
allowed[msg.sender][_spender] = 0;
|
| 112 |
+
} else {
|
| 113 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 114 |
+
}
|
| 115 |
+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 116 |
+
return true;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
contract WPAYCoin is StandardToken {
|
| 124 |
+
|
| 125 |
+
string public constant name = "WPAYCoin";
|
| 126 |
+
string public constant symbol = "WPY";
|
| 127 |
+
uint8 public constant decimals = 6;
|
| 128 |
+
|
| 129 |
+
uint256 public constant INITIAL_SUPPLY = 600000000 * (10 ** uint256(decimals));
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
function WPAYCoin() public {
|
| 133 |
+
totalSupply = INITIAL_SUPPLY;
|
| 134 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
}
|
benchmark2/integer overflow/22.sol
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
contract ERC20Basic {
|
| 4 |
+
function totalSupply() public view returns (uint256);
|
| 5 |
+
function balanceOf(address _who) public view returns (uint256);
|
| 6 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 7 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
library SafeMath {
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if (_a == 0) {
|
| 19 |
+
return 0;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
c = _a * _b;
|
| 23 |
+
assert(c / _a == _b);
|
| 24 |
+
return c;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
return _a / _b;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 37 |
+
assert(_b <= _a);
|
| 38 |
+
return _a - _b;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 43 |
+
c = _a + _b;
|
| 44 |
+
assert(c >= _a);
|
| 45 |
+
return c;
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
contract BasicToken is ERC20Basic {
|
| 50 |
+
using SafeMath for uint256;
|
| 51 |
+
|
| 52 |
+
mapping(address => uint256) internal balances;
|
| 53 |
+
|
| 54 |
+
uint256 internal totalSupply_;
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
function totalSupply() public view returns (uint256) {
|
| 58 |
+
return totalSupply_;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 63 |
+
require(_value <= balances[msg.sender]);
|
| 64 |
+
require(_to != address(0));
|
| 65 |
+
|
| 66 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 67 |
+
balances[_to] = balances[_to].add(_value);
|
| 68 |
+
emit Transfer(msg.sender, _to, _value);
|
| 69 |
+
return true;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 74 |
+
return balances[_owner];
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
contract ERC20 is ERC20Basic {
|
| 80 |
+
function allowance(address _owner, address _spender)
|
| 81 |
+
public view returns (uint256);
|
| 82 |
+
|
| 83 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 84 |
+
public returns (bool);
|
| 85 |
+
|
| 86 |
+
function approve(address _spender, uint256 _value) public returns (bool);
|
| 87 |
+
event Approval(
|
| 88 |
+
address indexed owner,
|
| 89 |
+
address indexed spender,
|
| 90 |
+
uint256 value
|
| 91 |
+
);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
contract StandardToken is ERC20, BasicToken {
|
| 96 |
+
|
| 97 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
function transferFrom(
|
| 102 |
+
address _from,
|
| 103 |
+
address _to,
|
| 104 |
+
uint256 _value
|
| 105 |
+
)
|
| 106 |
+
public
|
| 107 |
+
returns (bool)
|
| 108 |
+
{
|
| 109 |
+
require(_value <= balances[_from]);
|
| 110 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 111 |
+
require(_to != address(0));
|
| 112 |
+
|
| 113 |
+
balances[_from] = balances[_from].sub(_value);
|
| 114 |
+
balances[_to] = balances[_to].add(_value);
|
| 115 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 116 |
+
emit Transfer(_from, _to, _value);
|
| 117 |
+
return true;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 122 |
+
allowed[msg.sender][_spender] = _value;
|
| 123 |
+
emit Approval(msg.sender, _spender, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
function allowance(
|
| 129 |
+
address _owner,
|
| 130 |
+
address _spender
|
| 131 |
+
)
|
| 132 |
+
public
|
| 133 |
+
view
|
| 134 |
+
returns (uint256)
|
| 135 |
+
{
|
| 136 |
+
return allowed[_owner][_spender];
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
function increaseApproval(
|
| 141 |
+
address _spender,
|
| 142 |
+
uint256 _addedValue
|
| 143 |
+
)
|
| 144 |
+
public
|
| 145 |
+
returns (bool)
|
| 146 |
+
{
|
| 147 |
+
allowed[msg.sender][_spender] = (
|
| 148 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 149 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 150 |
+
return true;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
function decreaseApproval(
|
| 155 |
+
address _spender,
|
| 156 |
+
uint256 _subtractedValue
|
| 157 |
+
)
|
| 158 |
+
public
|
| 159 |
+
returns (bool)
|
| 160 |
+
{
|
| 161 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 162 |
+
if (_subtractedValue >= oldValue) {
|
| 163 |
+
allowed[msg.sender][_spender] = 0;
|
| 164 |
+
} else {
|
| 165 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 166 |
+
}
|
| 167 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 168 |
+
return true;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
contract XinCoin is StandardToken {
|
| 174 |
+
address public admin;
|
| 175 |
+
string public name = "XinCoin";
|
| 176 |
+
string public symbol = "XC";
|
| 177 |
+
uint8 public decimals = 8;
|
| 178 |
+
uint256 public INITIAL_SUPPLY = 100000000000000000;
|
| 179 |
+
|
| 180 |
+
mapping (address => bool) public frozenAccount;
|
| 181 |
+
mapping (address => uint256) public frozenTimestamp;
|
| 182 |
+
|
| 183 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 184 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 185 |
+
event Burn(address indexed from, uint256 value);
|
| 186 |
+
|
| 187 |
+
constructor() public {
|
| 188 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 189 |
+
admin = msg.sender;
|
| 190 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
function() public payable {
|
| 194 |
+
require(msg.value > 0);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
function changeAdmin(
|
| 198 |
+
address _newAdmin
|
| 199 |
+
)
|
| 200 |
+
public returns (bool) {
|
| 201 |
+
require(msg.sender == admin);
|
| 202 |
+
require(_newAdmin != address(0));
|
| 203 |
+
balances[_newAdmin] = balances[_newAdmin].add(balances[admin]);
|
| 204 |
+
balances[admin] = 0;
|
| 205 |
+
admin = _newAdmin;
|
| 206 |
+
return true;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
function generateToken(
|
| 210 |
+
address _target,
|
| 211 |
+
uint256 _amount
|
| 212 |
+
)
|
| 213 |
+
public returns (bool) {
|
| 214 |
+
require(msg.sender == admin);
|
| 215 |
+
require(_target != address(0));
|
| 216 |
+
balances[_target] = balances[_target].add(_amount);
|
| 217 |
+
totalSupply_ = totalSupply_.add(_amount);
|
| 218 |
+
INITIAL_SUPPLY = totalSupply_;
|
| 219 |
+
return true;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function withdraw (
|
| 223 |
+
uint256 _amount
|
| 224 |
+
)
|
| 225 |
+
public returns (bool) {
|
| 226 |
+
require(msg.sender == admin);
|
| 227 |
+
msg.sender.transfer(_amount);
|
| 228 |
+
return true;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
function freeze(
|
| 232 |
+
address _target,
|
| 233 |
+
bool _freeze
|
| 234 |
+
)
|
| 235 |
+
public returns (bool) {
|
| 236 |
+
require(msg.sender == admin);
|
| 237 |
+
require(_target != address(0));
|
| 238 |
+
frozenAccount[_target] = _freeze;
|
| 239 |
+
return true;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
function freezeWithTimestamp(
|
| 243 |
+
address _target,
|
| 244 |
+
uint256 _timestamp
|
| 245 |
+
)
|
| 246 |
+
public returns (bool) {
|
| 247 |
+
require(msg.sender == admin);
|
| 248 |
+
require(_target != address(0));
|
| 249 |
+
frozenTimestamp[_target] = _timestamp;
|
| 250 |
+
return true;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
function multiFreeze(
|
| 254 |
+
address[] _targets,
|
| 255 |
+
bool[] _freezes
|
| 256 |
+
)
|
| 257 |
+
public returns (bool) {
|
| 258 |
+
require(msg.sender == admin);
|
| 259 |
+
require(_targets.length == _freezes.length);
|
| 260 |
+
uint256 len = _targets.length;
|
| 261 |
+
require(len > 0);
|
| 262 |
+
for (uint256 i = 0; i < len; i = i.add(1)) {
|
| 263 |
+
address _target = _targets[i];
|
| 264 |
+
require(_target != address(0));
|
| 265 |
+
bool _freeze = _freezes[i];
|
| 266 |
+
frozenAccount[_target] = _freeze;
|
| 267 |
+
}
|
| 268 |
+
return true;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
function multiFreezeWithTimestamp(
|
| 272 |
+
address[] _targets,
|
| 273 |
+
uint256[] _timestamps
|
| 274 |
+
)
|
| 275 |
+
public returns (bool) {
|
| 276 |
+
require(msg.sender == admin);
|
| 277 |
+
require(_targets.length == _timestamps.length);
|
| 278 |
+
uint256 len = _targets.length;
|
| 279 |
+
require(len > 0);
|
| 280 |
+
for (uint256 i = 0; i < len; i = i.add(1)) {
|
| 281 |
+
address _target = _targets[i];
|
| 282 |
+
require(_target != address(0));
|
| 283 |
+
uint256 _timestamp = _timestamps[i];
|
| 284 |
+
frozenTimestamp[_target] = _timestamp;
|
| 285 |
+
}
|
| 286 |
+
return true;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
function multiTransfer(
|
| 290 |
+
address[] _tos,
|
| 291 |
+
uint256[] _values
|
| 292 |
+
)
|
| 293 |
+
public returns (bool) {
|
| 294 |
+
require(!frozenAccount[msg.sender]);
|
| 295 |
+
require(now > frozenTimestamp[msg.sender]);
|
| 296 |
+
require(_tos.length == _values.length);
|
| 297 |
+
uint256 len = _tos.length;
|
| 298 |
+
require(len > 0);
|
| 299 |
+
uint256 amount = 0;
|
| 300 |
+
for (uint256 i = 0; i < len; i = i.add(1)) {
|
| 301 |
+
amount = amount.add(_values[i]);
|
| 302 |
+
}
|
| 303 |
+
require(amount <= balances[msg.sender]);
|
| 304 |
+
for (uint256 j = 0; j < len; j = j.add(1)) {
|
| 305 |
+
address _to = _tos[j];
|
| 306 |
+
require(_to != address(0));
|
| 307 |
+
balances[_to] = balances[_to].add(_values[j]);
|
| 308 |
+
balances[msg.sender] = balances[msg.sender].sub(_values[j]);
|
| 309 |
+
emit Transfer(msg.sender, _to, _values[j]);
|
| 310 |
+
}
|
| 311 |
+
return true;
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
function transfer(
|
| 315 |
+
address _to,
|
| 316 |
+
uint256 _value
|
| 317 |
+
)
|
| 318 |
+
public returns (bool) {
|
| 319 |
+
require(!frozenAccount[msg.sender]);
|
| 320 |
+
require(now > frozenTimestamp[msg.sender]);
|
| 321 |
+
require(_to != address(0));
|
| 322 |
+
require(_value <= balances[msg.sender]);
|
| 323 |
+
|
| 324 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 325 |
+
balances[_to] = balances[_to].add(_value);
|
| 326 |
+
|
| 327 |
+
emit Transfer(msg.sender, _to, _value);
|
| 328 |
+
return true;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
function transferFrom(
|
| 332 |
+
address _from,
|
| 333 |
+
address _to,
|
| 334 |
+
uint256 _value
|
| 335 |
+
)
|
| 336 |
+
public returns (bool)
|
| 337 |
+
{
|
| 338 |
+
require(!frozenAccount[_from]);
|
| 339 |
+
require(now > frozenTimestamp[msg.sender]);
|
| 340 |
+
require(_to != address(0));
|
| 341 |
+
require(_value <= balances[_from]);
|
| 342 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 343 |
+
|
| 344 |
+
balances[_from] = balances[_from].sub(_value);
|
| 345 |
+
balances[_to] = balances[_to].add(_value);
|
| 346 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 347 |
+
|
| 348 |
+
emit Transfer(_from, _to, _value);
|
| 349 |
+
return true;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
function approve(
|
| 353 |
+
address _spender,
|
| 354 |
+
uint256 _value
|
| 355 |
+
)
|
| 356 |
+
public returns (bool) {
|
| 357 |
+
require(_value <= balances[_spender]);
|
| 358 |
+
allowed[msg.sender][_spender] = _value;
|
| 359 |
+
emit Approval(msg.sender, _spender, _value);
|
| 360 |
+
return true;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
function burn(uint256 _value)
|
| 364 |
+
public returns (bool) {
|
| 365 |
+
require(_value <= balances[msg.sender]);
|
| 366 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 367 |
+
totalSupply_ = totalSupply_.sub(_value);
|
| 368 |
+
INITIAL_SUPPLY = totalSupply_;
|
| 369 |
+
emit Burn(msg.sender, _value);
|
| 370 |
+
return true;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
function getFrozenTimestamp(
|
| 374 |
+
address _target
|
| 375 |
+
)
|
| 376 |
+
public view returns (uint256) {
|
| 377 |
+
require(_target != address(0));
|
| 378 |
+
return frozenTimestamp[_target];
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
function getFrozenAccount(
|
| 382 |
+
address _target
|
| 383 |
+
)
|
| 384 |
+
public view returns (bool) {
|
| 385 |
+
require(_target != address(0));
|
| 386 |
+
return frozenAccount[_target];
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
function getBalance(address _owner)
|
| 390 |
+
public view returns (uint256) {
|
| 391 |
+
return balances[_owner];
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
function setName (
|
| 395 |
+
string _value
|
| 396 |
+
)
|
| 397 |
+
public returns (bool) {
|
| 398 |
+
require(msg.sender == admin);
|
| 399 |
+
name = _value;
|
| 400 |
+
return true;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
function setSymbol (
|
| 404 |
+
string _value
|
| 405 |
+
)
|
| 406 |
+
public returns (bool) {
|
| 407 |
+
require(msg.sender == admin);
|
| 408 |
+
symbol = _value;
|
| 409 |
+
return true;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
function kill()
|
| 413 |
+
public {
|
| 414 |
+
require(msg.sender == admin);
|
| 415 |
+
selfdestruct(admin);
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
}
|
benchmark2/integer overflow/225.sol
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 2 |
+
|
| 3 |
+
library SafeMath {
|
| 4 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 5 |
+
if (_a == 0) {
|
| 6 |
+
return 0;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
uint256 c = _a * _b;
|
| 10 |
+
require(c / _a == _b);
|
| 11 |
+
|
| 12 |
+
return c;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 16 |
+
require(_b > 0);
|
| 17 |
+
uint256 c = _a / _b;
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
return c;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 24 |
+
require(_b <= _a);
|
| 25 |
+
uint256 c = _a - _b;
|
| 26 |
+
|
| 27 |
+
return c;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 31 |
+
uint256 c = _a + _b;
|
| 32 |
+
require(c >= _a);
|
| 33 |
+
|
| 34 |
+
return c;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 38 |
+
require(b != 0);
|
| 39 |
+
return a % b;
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
contract ERC20 {
|
| 44 |
+
function totalSupply() public view returns (uint256);
|
| 45 |
+
function balanceOf(address _who) public view returns (uint256);
|
| 46 |
+
function allowance(address _owner, address _spender)
|
| 47 |
+
public view returns (uint256);
|
| 48 |
+
|
| 49 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 50 |
+
function approve(address _spender, uint256 _value)
|
| 51 |
+
public returns (bool);
|
| 52 |
+
|
| 53 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 54 |
+
public returns (bool);
|
| 55 |
+
|
| 56 |
+
event Transfer(
|
| 57 |
+
address indexed from,
|
| 58 |
+
address indexed to,
|
| 59 |
+
uint256 value
|
| 60 |
+
);
|
| 61 |
+
|
| 62 |
+
event Approval(
|
| 63 |
+
address indexed owner,
|
| 64 |
+
address indexed spender,
|
| 65 |
+
uint256 value
|
| 66 |
+
);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
contract StandardToken is ERC20 {
|
| 70 |
+
using SafeMath for uint256;
|
| 71 |
+
|
| 72 |
+
mapping (address => uint256) private balances;
|
| 73 |
+
|
| 74 |
+
mapping (address => mapping (address => uint256)) private allowed;
|
| 75 |
+
|
| 76 |
+
uint256 private totalSupply_;
|
| 77 |
+
|
| 78 |
+
function totalSupply() public view returns (uint256) {
|
| 79 |
+
return totalSupply_;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 83 |
+
return balances[_owner];
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
function allowance(
|
| 87 |
+
address _owner,
|
| 88 |
+
address _spender
|
| 89 |
+
)
|
| 90 |
+
public
|
| 91 |
+
view
|
| 92 |
+
returns (uint256)
|
| 93 |
+
{
|
| 94 |
+
return allowed[_owner][_spender];
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 98 |
+
require(_value <= balances[msg.sender]);
|
| 99 |
+
require(_to != address(0));
|
| 100 |
+
|
| 101 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 102 |
+
balances[_to] = balances[_to].add(_value);
|
| 103 |
+
emit Transfer(msg.sender, _to, _value);
|
| 104 |
+
return true;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 108 |
+
allowed[msg.sender][_spender] = _value;
|
| 109 |
+
emit Approval(msg.sender, _spender, _value);
|
| 110 |
+
return true;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function transferFrom(
|
| 114 |
+
address _from,
|
| 115 |
+
address _to,
|
| 116 |
+
uint256 _value
|
| 117 |
+
)
|
| 118 |
+
public
|
| 119 |
+
returns (bool)
|
| 120 |
+
{
|
| 121 |
+
require(_value <= balances[_from]);
|
| 122 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 123 |
+
require(_to != address(0));
|
| 124 |
+
|
| 125 |
+
balances[_from] = balances[_from].sub(_value);
|
| 126 |
+
balances[_to] = balances[_to].add(_value);
|
| 127 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 128 |
+
emit Transfer(_from, _to, _value);
|
| 129 |
+
return true;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
function increaseApproval(
|
| 133 |
+
address _spender,
|
| 134 |
+
uint256 _addedValue
|
| 135 |
+
)
|
| 136 |
+
public
|
| 137 |
+
returns (bool)
|
| 138 |
+
{
|
| 139 |
+
allowed[msg.sender][_spender] = (
|
| 140 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 141 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 142 |
+
return true;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
function decreaseApproval(
|
| 146 |
+
address _spender,
|
| 147 |
+
uint256 _subtractedValue
|
| 148 |
+
)
|
| 149 |
+
public
|
| 150 |
+
returns (bool)
|
| 151 |
+
{
|
| 152 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 153 |
+
if (_subtractedValue >= oldValue) {
|
| 154 |
+
allowed[msg.sender][_spender] = 0;
|
| 155 |
+
} else {
|
| 156 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 157 |
+
}
|
| 158 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 159 |
+
return true;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
function _mint(address _account, uint256 _amount) internal {
|
| 163 |
+
require(_account != 0);
|
| 164 |
+
totalSupply_ = totalSupply_.add(_amount);
|
| 165 |
+
balances[_account] = balances[_account].add(_amount);
|
| 166 |
+
emit Transfer(address(0), _account, _amount);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function _burn(address _account, uint256 _amount) internal {
|
| 170 |
+
require(_account != 0);
|
| 171 |
+
require(_amount <= balances[_account]);
|
| 172 |
+
|
| 173 |
+
totalSupply_ = totalSupply_.sub(_amount);
|
| 174 |
+
balances[_account] = balances[_account].sub(_amount);
|
| 175 |
+
emit Transfer(_account, address(0), _amount);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
function _burnFrom(address _account, uint256 _amount) internal {
|
| 179 |
+
require(_amount <= allowed[_account][msg.sender]);
|
| 180 |
+
allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount);
|
| 181 |
+
_burn(_account, _amount);
|
| 182 |
+
}
|
| 183 |
+
}
|
benchmark2/integer overflow/241.sol
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.19;
|
| 2 |
+
|
| 3 |
+
library SafeMath {
|
| 4 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 5 |
+
uint256 c = a * b;
|
| 6 |
+
assert(a == 0 || c / a == b);
|
| 7 |
+
return c;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 11 |
+
uint256 c = a / b;
|
| 12 |
+
return c;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 16 |
+
assert(b <= a);
|
| 17 |
+
return a - b;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 21 |
+
uint256 c = a + b;
|
| 22 |
+
assert(c >= a);
|
| 23 |
+
return c;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
contract ForeignToken {
|
| 28 |
+
function balanceOf(address _owner) constant public returns (uint256);
|
| 29 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
contract ERC20Basic {
|
| 33 |
+
uint256 public totalSupply;
|
| 34 |
+
function balanceOf(address who) public constant returns (uint256);
|
| 35 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 36 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
contract ERC20 is ERC20Basic {
|
| 40 |
+
function allowance(address owner, address spender) public constant returns (uint256);
|
| 41 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 42 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 43 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
interface Token {
|
| 47 |
+
function distr(address _to, uint256 _value) public returns (bool);
|
| 48 |
+
function totalSupply() constant public returns (uint256 supply);
|
| 49 |
+
function balanceOf(address _owner) constant public returns (uint256 balance);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
contract BEN is ERC20 {
|
| 53 |
+
|
| 54 |
+
using SafeMath for uint256;
|
| 55 |
+
address owner = msg.sender;
|
| 56 |
+
|
| 57 |
+
mapping (address => uint256) balances;
|
| 58 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 59 |
+
mapping (address => bool) public blacklist;
|
| 60 |
+
|
| 61 |
+
string public constant name = "BENetwork";
|
| 62 |
+
string public constant symbol = "BEN";
|
| 63 |
+
uint public constant decimals = 8;
|
| 64 |
+
|
| 65 |
+
uint256 public totalSupply = 100000000e8;
|
| 66 |
+
uint256 public totalDistributed = 10000000e8;
|
| 67 |
+
uint256 public totalRemaining = totalSupply.sub(totalDistributed);
|
| 68 |
+
uint256 public value;
|
| 69 |
+
|
| 70 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 71 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 72 |
+
|
| 73 |
+
event Distr(address indexed to, uint256 amount);
|
| 74 |
+
event DistrFinished();
|
| 75 |
+
|
| 76 |
+
event Burn(address indexed burner, uint256 value);
|
| 77 |
+
|
| 78 |
+
bool public distributionFinished = false;
|
| 79 |
+
|
| 80 |
+
modifier canDistr() {
|
| 81 |
+
require(!distributionFinished);
|
| 82 |
+
_;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
modifier onlyOwner() {
|
| 86 |
+
require(msg.sender == owner);
|
| 87 |
+
_;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
modifier onlyWhitelist() {
|
| 91 |
+
require(blacklist[msg.sender] == false);
|
| 92 |
+
_;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function BEN () public {
|
| 96 |
+
owner = msg.sender;
|
| 97 |
+
value = 400e8;
|
| 98 |
+
distr(owner, totalDistributed);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 102 |
+
if (newOwner != address(0)) {
|
| 103 |
+
owner = newOwner;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
function enableWhitelist(address[] addresses) onlyOwner public {
|
| 108 |
+
for (uint i = 0; i < addresses.length; i++) {
|
| 109 |
+
blacklist[addresses[i]] = false;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function disableWhitelist(address[] addresses) onlyOwner public {
|
| 114 |
+
for (uint i = 0; i < addresses.length; i++) {
|
| 115 |
+
blacklist[addresses[i]] = true;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function finishDistribution() onlyOwner canDistr public returns (bool) {
|
| 120 |
+
distributionFinished = true;
|
| 121 |
+
DistrFinished();
|
| 122 |
+
return true;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
|
| 126 |
+
totalDistributed = totalDistributed.add(_amount);
|
| 127 |
+
totalRemaining = totalRemaining.sub(_amount);
|
| 128 |
+
balances[_to] = balances[_to].add(_amount);
|
| 129 |
+
Distr(_to, _amount);
|
| 130 |
+
Transfer(address(0), _to, _amount);
|
| 131 |
+
return true;
|
| 132 |
+
|
| 133 |
+
if (totalDistributed >= totalSupply) {
|
| 134 |
+
distributionFinished = true;
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function airdrop(address[] addresses) onlyOwner canDistr public {
|
| 139 |
+
|
| 140 |
+
require(addresses.length <= 255);
|
| 141 |
+
require(value <= totalRemaining);
|
| 142 |
+
|
| 143 |
+
for (uint i = 0; i < addresses.length; i++) {
|
| 144 |
+
require(value <= totalRemaining);
|
| 145 |
+
distr(addresses[i], value);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
if (totalDistributed >= totalSupply) {
|
| 149 |
+
distributionFinished = true;
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
function distribution(address[] addresses, uint256 amount) onlyOwner canDistr public {
|
| 154 |
+
|
| 155 |
+
require(addresses.length <= 255);
|
| 156 |
+
require(amount <= totalRemaining);
|
| 157 |
+
|
| 158 |
+
for (uint i = 0; i < addresses.length; i++) {
|
| 159 |
+
require(amount <= totalRemaining);
|
| 160 |
+
distr(addresses[i], amount);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
if (totalDistributed >= totalSupply) {
|
| 164 |
+
distributionFinished = true;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public {
|
| 169 |
+
|
| 170 |
+
require(addresses.length <= 255);
|
| 171 |
+
require(addresses.length == amounts.length);
|
| 172 |
+
|
| 173 |
+
for (uint8 i = 0; i < addresses.length; i++) {
|
| 174 |
+
require(amounts[i] <= totalRemaining);
|
| 175 |
+
distr(addresses[i], amounts[i]);
|
| 176 |
+
|
| 177 |
+
if (totalDistributed >= totalSupply) {
|
| 178 |
+
distributionFinished = true;
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
function () external payable {
|
| 184 |
+
getTokens();
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function getTokens() payable canDistr onlyWhitelist public {
|
| 188 |
+
|
| 189 |
+
if (value > totalRemaining) {
|
| 190 |
+
value = totalRemaining;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
require(value <= totalRemaining);
|
| 194 |
+
|
| 195 |
+
address investor = msg.sender;
|
| 196 |
+
uint256 toGive = value;
|
| 197 |
+
|
| 198 |
+
distr(investor, toGive);
|
| 199 |
+
|
| 200 |
+
if (toGive > 0) {
|
| 201 |
+
blacklist[investor] = true;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
if (totalDistributed >= totalSupply) {
|
| 205 |
+
distributionFinished = true;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
value = value.div(100000).mul(99999);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
function balanceOf(address _owner) constant public returns (uint256) {
|
| 212 |
+
return balances[_owner];
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// mitigates the ERC20 short address attack
|
| 216 |
+
modifier onlyPayloadSize(uint size) {
|
| 217 |
+
assert(msg.data.length >= size + 4);
|
| 218 |
+
_;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
|
| 222 |
+
|
| 223 |
+
require(_to != address(0));
|
| 224 |
+
require(_amount <= balances[msg.sender]);
|
| 225 |
+
|
| 226 |
+
balances[msg.sender] = balances[msg.sender].sub(_amount);
|
| 227 |
+
balances[_to] = balances[_to].add(_amount);
|
| 228 |
+
Transfer(msg.sender, _to, _amount);
|
| 229 |
+
return true;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) {
|
| 233 |
+
|
| 234 |
+
require(_to != address(0));
|
| 235 |
+
require(_amount <= balances[_from]);
|
| 236 |
+
require(_amount <= allowed[_from][msg.sender]);
|
| 237 |
+
|
| 238 |
+
balances[_from] = balances[_from].sub(_amount);
|
| 239 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
|
| 240 |
+
balances[_to] = balances[_to].add(_amount);
|
| 241 |
+
Transfer(_from, _to, _amount);
|
| 242 |
+
return true;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
function approve(address _spender, uint256 _value) public returns (bool success) {
|
| 246 |
+
// mitigates the ERC20 spend/approval race condition
|
| 247 |
+
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
|
| 248 |
+
allowed[msg.sender][_spender] = _value;
|
| 249 |
+
Approval(msg.sender, _spender, _value);
|
| 250 |
+
return true;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
function allowance(address _owner, address _spender) constant public returns (uint256) {
|
| 254 |
+
return allowed[_owner][_spender];
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
function getTokenBalance(address tokenAddress, address who) constant public returns (uint){
|
| 258 |
+
ForeignToken t = ForeignToken(tokenAddress);
|
| 259 |
+
uint bal = t.balanceOf(who);
|
| 260 |
+
return bal;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
function withdraw() onlyOwner public {
|
| 264 |
+
uint256 etherBalance = this.balance;
|
| 265 |
+
owner.transfer(etherBalance);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
function burn(uint256 _value) onlyOwner public {
|
| 269 |
+
require(_value <= balances[msg.sender]);
|
| 270 |
+
// no need to require value <= totalSupply, since that would imply the
|
| 271 |
+
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
|
| 272 |
+
|
| 273 |
+
address burner = msg.sender;
|
| 274 |
+
balances[burner] = balances[burner].sub(_value);
|
| 275 |
+
totalSupply = totalSupply.sub(_value);
|
| 276 |
+
totalDistributed = totalDistributed.sub(_value);
|
| 277 |
+
Burn(burner, _value);
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
|
| 281 |
+
ForeignToken token = ForeignToken(_tokenContract);
|
| 282 |
+
uint256 amount = token.balanceOf(address(this));
|
| 283 |
+
return token.transfer(owner, amount);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
}
|
benchmark2/integer overflow/253.sol
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
contract SafeMath {
|
| 4 |
+
function safeMul(uint a, uint b) internal returns (uint) {
|
| 5 |
+
uint c = a * b;
|
| 6 |
+
assert(a == 0 || c / a == b);
|
| 7 |
+
return c;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function safeSub(uint a, uint b) internal returns (uint) {
|
| 11 |
+
assert(b <= a);
|
| 12 |
+
return a - b;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function safeAdd(uint a, uint b) internal returns (uint) {
|
| 16 |
+
uint c = a + b;
|
| 17 |
+
assert(c>=a && c>=b);
|
| 18 |
+
return c;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function assert(bool assertion) internal {
|
| 22 |
+
if (!assertion) throw;
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
contract AccessControl is SafeMath{
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
event ContractUpgrade(address newContract);
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
address public ceoAddress;
|
| 33 |
+
address public cfoAddress;
|
| 34 |
+
address public cooAddress;
|
| 35 |
+
|
| 36 |
+
address newContractAddress;
|
| 37 |
+
|
| 38 |
+
uint public tip_total = 0;
|
| 39 |
+
uint public tip_rate = 20000000000000000;
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
bool public paused = false;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
modifier onlyCEO() {
|
| 46 |
+
require(msg.sender == ceoAddress);
|
| 47 |
+
_;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
modifier onlyCFO() {
|
| 52 |
+
require(msg.sender == cfoAddress);
|
| 53 |
+
_;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
modifier onlyCOO() {
|
| 58 |
+
require(msg.sender == cooAddress);
|
| 59 |
+
_;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
modifier onlyCLevel() {
|
| 63 |
+
require(
|
| 64 |
+
msg.sender == cooAddress ||
|
| 65 |
+
msg.sender == ceoAddress ||
|
| 66 |
+
msg.sender == cfoAddress
|
| 67 |
+
);
|
| 68 |
+
_;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
function () public payable{
|
| 72 |
+
tip_total = safeAdd(tip_total, msg.value);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function amountWithTip(uint amount) internal returns(uint){
|
| 78 |
+
uint tip = safeMul(amount, tip_rate) / (1 ether);
|
| 79 |
+
tip_total = safeAdd(tip_total, tip);
|
| 80 |
+
return safeSub(amount, tip);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
function withdrawTip(uint amount) external onlyCFO {
|
| 85 |
+
require(amount > 0 && amount <= tip_total);
|
| 86 |
+
require(msg.sender.send(amount));
|
| 87 |
+
tip_total = tip_total - amount;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
function setNewAddress(address newContract) external onlyCEO whenPaused {
|
| 92 |
+
newContractAddress = newContract;
|
| 93 |
+
emit ContractUpgrade(newContract);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
function setCEO(address _newCEO) external onlyCEO {
|
| 99 |
+
require(_newCEO != address(0));
|
| 100 |
+
|
| 101 |
+
ceoAddress = _newCEO;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
function setCFO(address _newCFO) external onlyCEO {
|
| 107 |
+
require(_newCFO != address(0));
|
| 108 |
+
|
| 109 |
+
cfoAddress = _newCFO;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function setCOO(address _newCOO) external onlyCEO {
|
| 115 |
+
require(_newCOO != address(0));
|
| 116 |
+
|
| 117 |
+
cooAddress = _newCOO;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
modifier whenNotPaused() {
|
| 124 |
+
require(!paused);
|
| 125 |
+
_;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
modifier whenPaused {
|
| 130 |
+
require(paused);
|
| 131 |
+
_;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
function pause() external onlyCLevel whenNotPaused {
|
| 137 |
+
paused = true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
function unpause() public onlyCEO whenPaused {
|
| 146 |
+
|
| 147 |
+
paused = false;
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
contract RpsGame is SafeMath , AccessControl{
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
uint8 constant public NONE = 0;
|
| 156 |
+
uint8 constant public ROCK = 10;
|
| 157 |
+
uint8 constant public PAPER = 20;
|
| 158 |
+
uint8 constant public SCISSORS = 30;
|
| 159 |
+
uint8 constant public DEALERWIN = 201;
|
| 160 |
+
uint8 constant public PLAYERWIN = 102;
|
| 161 |
+
uint8 constant public DRAW = 101;
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
event CreateGame(uint gameid, address dealer, uint amount);
|
| 165 |
+
event JoinGame(uint gameid, address player, uint amount);
|
| 166 |
+
event Reveal(uint gameid, address player, uint8 choice);
|
| 167 |
+
event CloseGame(uint gameid,address dealer,address player, uint8 result);
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
struct Game {
|
| 171 |
+
uint expireTime;
|
| 172 |
+
address dealer;
|
| 173 |
+
uint dealerValue;
|
| 174 |
+
bytes32 dealerHash;
|
| 175 |
+
uint8 dealerChoice;
|
| 176 |
+
address player;
|
| 177 |
+
uint8 playerChoice;
|
| 178 |
+
uint playerValue;
|
| 179 |
+
uint8 result;
|
| 180 |
+
bool closed;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
mapping (uint => mapping(uint => uint8)) public payoff;
|
| 185 |
+
mapping (uint => Game) public games;
|
| 186 |
+
mapping (address => uint[]) public gameidsOf;
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
uint public maxgame = 0;
|
| 190 |
+
uint public expireTimeLimit = 30 minutes;
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
function RpsGame() {
|
| 194 |
+
payoff[ROCK][ROCK] = DRAW;
|
| 195 |
+
payoff[ROCK][PAPER] = PLAYERWIN;
|
| 196 |
+
payoff[ROCK][SCISSORS] = DEALERWIN;
|
| 197 |
+
payoff[PAPER][ROCK] = DEALERWIN;
|
| 198 |
+
payoff[PAPER][PAPER] = DRAW;
|
| 199 |
+
payoff[PAPER][SCISSORS] = PLAYERWIN;
|
| 200 |
+
payoff[SCISSORS][ROCK] = PLAYERWIN;
|
| 201 |
+
payoff[SCISSORS][PAPER] = DEALERWIN;
|
| 202 |
+
payoff[SCISSORS][SCISSORS] = DRAW;
|
| 203 |
+
payoff[NONE][NONE] = DRAW;
|
| 204 |
+
payoff[ROCK][NONE] = DEALERWIN;
|
| 205 |
+
payoff[PAPER][NONE] = DEALERWIN;
|
| 206 |
+
payoff[SCISSORS][NONE] = DEALERWIN;
|
| 207 |
+
payoff[NONE][ROCK] = PLAYERWIN;
|
| 208 |
+
payoff[NONE][PAPER] = PLAYERWIN;
|
| 209 |
+
payoff[NONE][SCISSORS] = PLAYERWIN;
|
| 210 |
+
|
| 211 |
+
ceoAddress = msg.sender;
|
| 212 |
+
cooAddress = msg.sender;
|
| 213 |
+
cfoAddress = msg.sender;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
function createGame(bytes32 dealerHash, address player) public payable whenNotPaused returns (uint){
|
| 218 |
+
require(dealerHash != 0x0);
|
| 219 |
+
|
| 220 |
+
maxgame += 1;
|
| 221 |
+
Game storage game = games[maxgame];
|
| 222 |
+
game.dealer = msg.sender;
|
| 223 |
+
game.player = player;
|
| 224 |
+
game.dealerHash = dealerHash;
|
| 225 |
+
game.dealerChoice = NONE;
|
| 226 |
+
game.dealerValue = msg.value;
|
| 227 |
+
game.expireTime = expireTimeLimit + now;
|
| 228 |
+
|
| 229 |
+
gameidsOf[msg.sender].push(maxgame);
|
| 230 |
+
|
| 231 |
+
emit CreateGame(maxgame, game.dealer, game.dealerValue);
|
| 232 |
+
|
| 233 |
+
return maxgame;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
function joinGame(uint gameid, uint8 choice) public payable whenNotPaused returns (uint){
|
| 238 |
+
Game storage game = games[gameid];
|
| 239 |
+
|
| 240 |
+
require(msg.value == game.dealerValue && game.dealer != address(0) && game.dealer != msg.sender && game.playerChoice==NONE);
|
| 241 |
+
require(game.player == address(0) || game.player == msg.sender);
|
| 242 |
+
require(!game.closed);
|
| 243 |
+
require(now < game.expireTime);
|
| 244 |
+
require(checkChoice(choice));
|
| 245 |
+
|
| 246 |
+
game.player = msg.sender;
|
| 247 |
+
game.playerChoice = choice;
|
| 248 |
+
game.playerValue = msg.value;
|
| 249 |
+
game.expireTime = expireTimeLimit + now;
|
| 250 |
+
|
| 251 |
+
gameidsOf[msg.sender].push(gameid);
|
| 252 |
+
|
| 253 |
+
emit JoinGame(gameid, game.player, game.playerValue);
|
| 254 |
+
|
| 255 |
+
return gameid;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
function reveal(uint gameid, uint8 choice, bytes32 randomSecret) public returns (bool) {
|
| 260 |
+
Game storage game = games[gameid];
|
| 261 |
+
bytes32 proof = getProof(msg.sender, choice, randomSecret);
|
| 262 |
+
|
| 263 |
+
require(!game.closed);
|
| 264 |
+
require(now < game.expireTime);
|
| 265 |
+
require(game.dealerHash != 0x0);
|
| 266 |
+
require(checkChoice(choice));
|
| 267 |
+
require(checkChoice(game.playerChoice));
|
| 268 |
+
require(game.dealer == msg.sender && proof == game.dealerHash );
|
| 269 |
+
|
| 270 |
+
game.dealerChoice = choice;
|
| 271 |
+
|
| 272 |
+
Reveal(gameid, msg.sender, choice);
|
| 273 |
+
|
| 274 |
+
close(gameid);
|
| 275 |
+
|
| 276 |
+
return true;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
function close(uint gameid) public returns(bool) {
|
| 281 |
+
Game storage game = games[gameid];
|
| 282 |
+
|
| 283 |
+
require(!game.closed);
|
| 284 |
+
require(now > game.expireTime || (game.dealerChoice != NONE && game.playerChoice != NONE));
|
| 285 |
+
|
| 286 |
+
uint8 result = payoff[game.dealerChoice][game.playerChoice];
|
| 287 |
+
|
| 288 |
+
if(result == DEALERWIN){
|
| 289 |
+
require(game.dealer.send(amountWithTip(safeAdd(game.dealerValue, game.playerValue))));
|
| 290 |
+
}else if(result == PLAYERWIN){
|
| 291 |
+
require(game.player.send(amountWithTip(safeAdd(game.dealerValue, game.playerValue))));
|
| 292 |
+
}else if(result == DRAW){
|
| 293 |
+
require(game.dealer.send(game.dealerValue) && game.player.send(game.playerValue));
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
game.closed = true;
|
| 297 |
+
game.result = result;
|
| 298 |
+
|
| 299 |
+
emit CloseGame(gameid, game.dealer, game.player, result);
|
| 300 |
+
|
| 301 |
+
return game.closed;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
function getProof(address sender, uint8 choice, bytes32 randomSecret) public view returns (bytes32){
|
| 306 |
+
return sha3(sender, choice, randomSecret);
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
function gameCountOf(address owner) public view returns (uint){
|
| 310 |
+
return gameidsOf[owner].length;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function checkChoice(uint8 choice) public view returns (bool){
|
| 314 |
+
return choice==ROCK||choice==PAPER||choice==SCISSORS;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
}
|
benchmark2/integer overflow/262.sol
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.18;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
contract SafeMath {
|
| 22 |
+
function safeAdd(uint a, uint b) public pure returns (uint c) {
|
| 23 |
+
c = a + b;
|
| 24 |
+
require(c >= a);
|
| 25 |
+
}
|
| 26 |
+
function safeSub(uint a, uint b) public pure returns (uint c) {
|
| 27 |
+
require(b <= a);
|
| 28 |
+
c = a - b;
|
| 29 |
+
}
|
| 30 |
+
function safeMul(uint a, uint b) public pure returns (uint c) {
|
| 31 |
+
c = a * b;
|
| 32 |
+
require(a == 0 || c / a == b);
|
| 33 |
+
}
|
| 34 |
+
function safeDiv(uint a, uint b) public pure returns (uint c) {
|
| 35 |
+
require(b > 0);
|
| 36 |
+
c = a / b;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
contract ERC20Interface {
|
| 46 |
+
function totalSupply() public constant returns (uint);
|
| 47 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance);
|
| 48 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
|
| 49 |
+
function transfer(address to, uint tokens) public returns (bool success);
|
| 50 |
+
function approve(address spender, uint tokens) public returns (bool success);
|
| 51 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success);
|
| 52 |
+
|
| 53 |
+
event Transfer(address indexed from, address indexed to, uint tokens);
|
| 54 |
+
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
contract ApproveAndCallFallBack {
|
| 64 |
+
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
contract Owned {
|
| 72 |
+
address public owner;
|
| 73 |
+
address public newOwner;
|
| 74 |
+
|
| 75 |
+
event OwnershipTransferred(address indexed _from, address indexed _to);
|
| 76 |
+
|
| 77 |
+
function Owned() public {
|
| 78 |
+
owner = msg.sender;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
modifier onlyOwner {
|
| 82 |
+
require(msg.sender == owner);
|
| 83 |
+
_;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 87 |
+
newOwner = _newOwner;
|
| 88 |
+
}
|
| 89 |
+
function acceptOwnership() public {
|
| 90 |
+
require(msg.sender == newOwner);
|
| 91 |
+
OwnershipTransferred(owner, newOwner);
|
| 92 |
+
owner = newOwner;
|
| 93 |
+
newOwner = address(0);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
contract GroovaToken is ERC20Interface, Owned, SafeMath {
|
| 103 |
+
string public symbol;
|
| 104 |
+
string public name;
|
| 105 |
+
uint8 public decimals;
|
| 106 |
+
uint public _totalSupply;
|
| 107 |
+
|
| 108 |
+
mapping(address => uint) balances;
|
| 109 |
+
mapping(address => mapping(address => uint)) allowed;
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
constructor() public {
|
| 116 |
+
symbol = "GRV";
|
| 117 |
+
name = "Groova Token";
|
| 118 |
+
decimals = 0;
|
| 119 |
+
_totalSupply = 1000000;
|
| 120 |
+
balances[0x7f0f94823D1b0fc4D251A72e9375F2AfdA2faba3] = _totalSupply;
|
| 121 |
+
Transfer(address(0), 0x7f0f94823D1b0fc4D251A72e9375F2AfdA2faba3, _totalSupply);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
function totalSupply() public constant returns (uint) {
|
| 129 |
+
return _totalSupply - balances[address(0)];
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance) {
|
| 137 |
+
return balances[tokenOwner];
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
function transfer(address to, uint tokens) public returns (bool success) {
|
| 147 |
+
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
|
| 148 |
+
balances[to] = safeAdd(balances[to], tokens);
|
| 149 |
+
Transfer(msg.sender, to, tokens);
|
| 150 |
+
return true;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
function approve(address spender, uint tokens) public returns (bool success) {
|
| 163 |
+
allowed[msg.sender][spender] = tokens;
|
| 164 |
+
Approval(msg.sender, spender, tokens);
|
| 165 |
+
return true;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
|
| 179 |
+
balances[from] = safeSub(balances[from], tokens);
|
| 180 |
+
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
|
| 181 |
+
balances[to] = safeAdd(balances[to], tokens);
|
| 182 |
+
Transfer(from, to, tokens);
|
| 183 |
+
return true;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
|
| 192 |
+
return allowed[tokenOwner][spender];
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
|
| 202 |
+
allowed[msg.sender][spender] = tokens;
|
| 203 |
+
Approval(msg.sender, spender, tokens);
|
| 204 |
+
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
|
| 205 |
+
return true;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
function () public payable {
|
| 213 |
+
revert();
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
|
| 221 |
+
return ERC20Interface(tokenAddress).transfer(owner, tokens);
|
| 222 |
+
}
|
| 223 |
+
}
|
benchmark2/integer overflow/274.sol
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.16;
|
| 2 |
+
|
| 3 |
+
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
|
| 4 |
+
|
| 5 |
+
contract Hacienda {
|
| 6 |
+
|
| 7 |
+
string public name;
|
| 8 |
+
string public symbol;
|
| 9 |
+
uint8 public decimals = 18;
|
| 10 |
+
|
| 11 |
+
uint256 public totalSupply;
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
mapping (address => uint256) public balanceOf;
|
| 15 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
event Burn(address indexed from, uint256 value);
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
function TokenERC20(
|
| 28 |
+
uint256 initialSupply,
|
| 29 |
+
string tokenName,
|
| 30 |
+
string tokenSymbol
|
| 31 |
+
) public {
|
| 32 |
+
totalSupply = initialSupply * 10 ** uint256(decimals);
|
| 33 |
+
balanceOf[msg.sender] = totalSupply;
|
| 34 |
+
name = tokenName;
|
| 35 |
+
symbol = tokenSymbol;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 40 |
+
|
| 41 |
+
require(_to != 0x0);
|
| 42 |
+
|
| 43 |
+
require(balanceOf[_from] >= _value);
|
| 44 |
+
|
| 45 |
+
require(balanceOf[_to] + _value >= balanceOf[_to]);
|
| 46 |
+
|
| 47 |
+
uint previousBalances = balanceOf[_from] + balanceOf[_to];
|
| 48 |
+
|
| 49 |
+
balanceOf[_from] -= _value;
|
| 50 |
+
|
| 51 |
+
balanceOf[_to] += _value;
|
| 52 |
+
emit Transfer(_from, _to, _value);
|
| 53 |
+
|
| 54 |
+
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 59 |
+
_transfer(msg.sender, _to, _value);
|
| 60 |
+
return true;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 65 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 66 |
+
allowance[_from][msg.sender] -= _value;
|
| 67 |
+
_transfer(_from, _to, _value);
|
| 68 |
+
return true;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
function approve(address _spender, uint256 _value) public
|
| 73 |
+
returns (bool success) {
|
| 74 |
+
allowance[msg.sender][_spender] = _value;
|
| 75 |
+
emit Approval(msg.sender, _spender, _value);
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
|
| 81 |
+
public
|
| 82 |
+
returns (bool success) {
|
| 83 |
+
tokenRecipient spender = tokenRecipient(_spender);
|
| 84 |
+
if (approve(_spender, _value)) {
|
| 85 |
+
spender.receiveApproval(msg.sender, _value, this, _extraData);
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 92 |
+
require(balanceOf[msg.sender] >= _value);
|
| 93 |
+
balanceOf[msg.sender] -= _value;
|
| 94 |
+
totalSupply -= _value;
|
| 95 |
+
emit Burn(msg.sender, _value);
|
| 96 |
+
return true;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 101 |
+
require(balanceOf[_from] >= _value);
|
| 102 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 103 |
+
balanceOf[_from] -= _value;
|
| 104 |
+
allowance[_from][msg.sender] -= _value;
|
| 105 |
+
totalSupply -= _value;
|
| 106 |
+
emit Burn(_from, _value);
|
| 107 |
+
return true;
|
| 108 |
+
}
|
| 109 |
+
}
|
benchmark2/integer overflow/276.sol
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
contract ERC20Basic {
|
| 7 |
+
function totalSupply() public view returns (uint256);
|
| 8 |
+
function balanceOf(address _who) public view returns (uint256);
|
| 9 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 10 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
library SafeMath {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if (_a == 0) {
|
| 24 |
+
return 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
c = _a * _b;
|
| 28 |
+
assert(c / _a == _b);
|
| 29 |
+
return c;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
return _a / _b;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 42 |
+
assert(_b <= _a);
|
| 43 |
+
return _a - _b;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 48 |
+
c = _a + _b;
|
| 49 |
+
assert(c >= _a);
|
| 50 |
+
return c;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
contract BasicToken is ERC20Basic {
|
| 58 |
+
using SafeMath for uint256;
|
| 59 |
+
|
| 60 |
+
mapping(address => uint256) internal balances;
|
| 61 |
+
|
| 62 |
+
uint256 internal totalSupply_;
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function totalSupply() public view returns (uint256) {
|
| 66 |
+
return totalSupply_;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 71 |
+
require(_value <= balances[msg.sender]);
|
| 72 |
+
require(_to != address(0));
|
| 73 |
+
|
| 74 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 75 |
+
balances[_to] = balances[_to].add(_value);
|
| 76 |
+
emit Transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 82 |
+
return balances[_owner];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
contract ERC20 is ERC20Basic {
|
| 91 |
+
function allowance(address _owner, address _spender)
|
| 92 |
+
public view returns (uint256);
|
| 93 |
+
|
| 94 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 95 |
+
public returns (bool);
|
| 96 |
+
|
| 97 |
+
function approve(address _spender, uint256 _value) public returns (bool);
|
| 98 |
+
event Approval(
|
| 99 |
+
address indexed owner,
|
| 100 |
+
address indexed spender,
|
| 101 |
+
uint256 value
|
| 102 |
+
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
contract StandardToken is ERC20, BasicToken {
|
| 109 |
+
|
| 110 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function transferFrom(
|
| 115 |
+
address _from,
|
| 116 |
+
address _to,
|
| 117 |
+
uint256 _value
|
| 118 |
+
)
|
| 119 |
+
public
|
| 120 |
+
returns (bool)
|
| 121 |
+
{
|
| 122 |
+
require(_value <= balances[_from]);
|
| 123 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 124 |
+
require(_to != address(0));
|
| 125 |
+
|
| 126 |
+
balances[_from] = balances[_from].sub(_value);
|
| 127 |
+
balances[_to] = balances[_to].add(_value);
|
| 128 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 129 |
+
emit Transfer(_from, _to, _value);
|
| 130 |
+
return true;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 135 |
+
allowed[msg.sender][_spender] = _value;
|
| 136 |
+
emit Approval(msg.sender, _spender, _value);
|
| 137 |
+
return true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function allowance(
|
| 142 |
+
address _owner,
|
| 143 |
+
address _spender
|
| 144 |
+
)
|
| 145 |
+
public
|
| 146 |
+
view
|
| 147 |
+
returns (uint256)
|
| 148 |
+
{
|
| 149 |
+
return allowed[_owner][_spender];
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
function increaseApproval(
|
| 154 |
+
address _spender,
|
| 155 |
+
uint256 _addedValue
|
| 156 |
+
)
|
| 157 |
+
public
|
| 158 |
+
returns (bool)
|
| 159 |
+
{
|
| 160 |
+
allowed[msg.sender][_spender] = (
|
| 161 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 162 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function decreaseApproval(
|
| 168 |
+
address _spender,
|
| 169 |
+
uint256 _subtractedValue
|
| 170 |
+
)
|
| 171 |
+
public
|
| 172 |
+
returns (bool)
|
| 173 |
+
{
|
| 174 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 175 |
+
if (_subtractedValue >= oldValue) {
|
| 176 |
+
allowed[msg.sender][_spender] = 0;
|
| 177 |
+
} else {
|
| 178 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 179 |
+
}
|
| 180 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 181 |
+
return true;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
contract DetailedERC20 is ERC20 {
|
| 190 |
+
string public name;
|
| 191 |
+
string public symbol;
|
| 192 |
+
uint8 public decimals;
|
| 193 |
+
|
| 194 |
+
constructor(string _name, string _symbol, uint8 _decimals) public {
|
| 195 |
+
name = _name;
|
| 196 |
+
symbol = _symbol;
|
| 197 |
+
decimals = _decimals;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
contract BurnableToken is BasicToken {
|
| 205 |
+
|
| 206 |
+
event Burn(address indexed burner, uint256 value);
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
function burn(uint256 _value) public {
|
| 210 |
+
_burn(msg.sender, _value);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function _burn(address _who, uint256 _value) internal {
|
| 214 |
+
require(_value <= balances[_who]);
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
balances[_who] = balances[_who].sub(_value);
|
| 219 |
+
totalSupply_ = totalSupply_.sub(_value);
|
| 220 |
+
emit Burn(_who, _value);
|
| 221 |
+
emit Transfer(_who, address(0), _value);
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
contract Ownable {
|
| 229 |
+
address public owner;
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 233 |
+
event OwnershipTransferred(
|
| 234 |
+
address indexed previousOwner,
|
| 235 |
+
address indexed newOwner
|
| 236 |
+
);
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
constructor() public {
|
| 241 |
+
owner = msg.sender;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
modifier onlyOwner() {
|
| 246 |
+
require(msg.sender == owner);
|
| 247 |
+
_;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
function renounceOwnership() public onlyOwner {
|
| 252 |
+
emit OwnershipRenounced(owner);
|
| 253 |
+
owner = address(0);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 258 |
+
_transferOwnership(_newOwner);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
function _transferOwnership(address _newOwner) internal {
|
| 263 |
+
require(_newOwner != address(0));
|
| 264 |
+
emit OwnershipTransferred(owner, _newOwner);
|
| 265 |
+
owner = _newOwner;
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
contract MintableToken is StandardToken, Ownable {
|
| 273 |
+
event Mint(address indexed to, uint256 amount);
|
| 274 |
+
event MintFinished();
|
| 275 |
+
|
| 276 |
+
bool public mintingFinished = false;
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
modifier canMint() {
|
| 280 |
+
require(!mintingFinished);
|
| 281 |
+
_;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
modifier hasMintPermission() {
|
| 285 |
+
require(msg.sender == owner);
|
| 286 |
+
_;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
function mint(
|
| 291 |
+
address _to,
|
| 292 |
+
uint256 _amount
|
| 293 |
+
)
|
| 294 |
+
public
|
| 295 |
+
hasMintPermission
|
| 296 |
+
canMint
|
| 297 |
+
returns (bool)
|
| 298 |
+
{
|
| 299 |
+
totalSupply_ = totalSupply_.add(_amount);
|
| 300 |
+
balances[_to] = balances[_to].add(_amount);
|
| 301 |
+
emit Mint(_to, _amount);
|
| 302 |
+
emit Transfer(address(0), _to, _amount);
|
| 303 |
+
return true;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
function finishMinting() public onlyOwner canMint returns (bool) {
|
| 308 |
+
mintingFinished = true;
|
| 309 |
+
emit MintFinished();
|
| 310 |
+
return true;
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
contract BSPCP is StandardToken, DetailedERC20, BurnableToken, MintableToken {
|
| 317 |
+
|
| 318 |
+
constructor(string _name, string _symbol, uint8 _decimals)
|
| 319 |
+
DetailedERC20(_name, _symbol, _decimals)
|
| 320 |
+
public
|
| 321 |
+
{
|
| 322 |
+
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
}
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.22;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
library SafeMath {
|
| 6 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 7 |
+
uint256 c = a * b;
|
| 8 |
+
assert(a == 0 || c / a == b);
|
| 9 |
+
return c;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 13 |
+
|
| 14 |
+
uint256 c = a / b;
|
| 15 |
+
|
| 16 |
+
return c;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 20 |
+
assert(b <= a);
|
| 21 |
+
return a - b;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 25 |
+
uint256 c = a + b;
|
| 26 |
+
assert(c >= a);
|
| 27 |
+
return c;
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
contract Ownable {
|
| 34 |
+
address public owner;
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
constructor() public {
|
| 38 |
+
owner = msg.sender;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
modifier onlyOwner() {
|
| 43 |
+
require(msg.sender == owner);
|
| 44 |
+
_;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
function transferOwnership(address newOwner) public onlyOwner {
|
| 49 |
+
if (newOwner != address(0)) {
|
| 50 |
+
owner = newOwner;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
contract Haltable is Ownable {
|
| 58 |
+
bool public halted;
|
| 59 |
+
|
| 60 |
+
modifier inNormalState {
|
| 61 |
+
assert(!halted);
|
| 62 |
+
_;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
modifier inEmergencyState {
|
| 66 |
+
assert(halted);
|
| 67 |
+
_;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
function halt() external onlyOwner inNormalState {
|
| 72 |
+
halted = true;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
function resume() external onlyOwner inEmergencyState {
|
| 77 |
+
halted = false;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
contract ERC20Basic {
|
| 85 |
+
uint256 public totalSupply;
|
| 86 |
+
|
| 87 |
+
function balanceOf(address who) public constant returns (uint256);
|
| 88 |
+
|
| 89 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 90 |
+
|
| 91 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
contract ERC20 is ERC20Basic {
|
| 97 |
+
function allowance(address owner, address spender) public constant returns (uint256);
|
| 98 |
+
|
| 99 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 100 |
+
|
| 101 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 102 |
+
|
| 103 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
contract BasicToken is ERC20Basic {
|
| 109 |
+
using SafeMath for uint256;
|
| 110 |
+
|
| 111 |
+
mapping(address => uint256) public balances;
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 115 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 116 |
+
balances[_to] = balances[_to].add(_value);
|
| 117 |
+
emit Transfer(msg.sender, _to, _value);
|
| 118 |
+
return true;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
function balanceOf(address _owner) public constant returns (uint256 balance) {
|
| 123 |
+
return balances[_owner];
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
contract StandardToken is ERC20, BasicToken {
|
| 131 |
+
|
| 132 |
+
mapping(address => mapping(address => uint256)) public allowed;
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
| 136 |
+
uint256 _allowance;
|
| 137 |
+
_allowance = allowed[_from][msg.sender];
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
balances[_to] = balances[_to].add(_value);
|
| 143 |
+
balances[_from] = balances[_from].sub(_value);
|
| 144 |
+
allowed[_from][msg.sender] = _allowance.sub(_value);
|
| 145 |
+
emit Transfer(_from, _to, _value);
|
| 146 |
+
return true;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
|
| 157 |
+
|
| 158 |
+
allowed[msg.sender][_spender] = _value;
|
| 159 |
+
emit Approval(msg.sender, _spender, _value);
|
| 160 |
+
return true;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
|
| 165 |
+
return allowed[_owner][_spender];
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
contract Burnable is StandardToken {
|
| 173 |
+
using SafeMath for uint;
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
event Burn(address indexed from, uint256 value);
|
| 177 |
+
|
| 178 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 179 |
+
require(balances[msg.sender] >= _value);
|
| 180 |
+
|
| 181 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 182 |
+
|
| 183 |
+
totalSupply = totalSupply.sub(_value);
|
| 184 |
+
|
| 185 |
+
emit Burn(msg.sender, _value);
|
| 186 |
+
return true;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 190 |
+
require(balances[_from] >= _value);
|
| 191 |
+
|
| 192 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 193 |
+
|
| 194 |
+
balances[_from] = balances[_from].sub(_value);
|
| 195 |
+
|
| 196 |
+
totalSupply = totalSupply.sub(_value);
|
| 197 |
+
|
| 198 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 199 |
+
emit Burn(_from, _value);
|
| 200 |
+
return true;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
function transfer(address _to, uint _value) public returns (bool success) {
|
| 204 |
+
require(_to != 0x0);
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
return super.transfer(_to, _value);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
|
| 211 |
+
require(_to != 0x0);
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
return super.transferFrom(_from, _to, _value);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
contract Centive is Burnable, Ownable {
|
| 221 |
+
|
| 222 |
+
string public name;
|
| 223 |
+
string public symbol;
|
| 224 |
+
uint8 public decimals = 18;
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
address public releaseAgent;
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
bool public released = false;
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
mapping(address => bool) public transferAgents;
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
modifier canTransfer(address _sender) {
|
| 237 |
+
require(transferAgents[_sender] || released);
|
| 238 |
+
_;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
modifier inReleaseState(bool releaseState) {
|
| 243 |
+
require(releaseState == released);
|
| 244 |
+
_;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
modifier onlyReleaseAgent() {
|
| 249 |
+
require(msg.sender == releaseAgent);
|
| 250 |
+
_;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
constructor(uint256 initialSupply, string tokenName, string tokenSymbol) public {
|
| 255 |
+
totalSupply = initialSupply * 10 ** uint256(decimals);
|
| 256 |
+
|
| 257 |
+
balances[msg.sender] = totalSupply;
|
| 258 |
+
|
| 259 |
+
name = tokenName;
|
| 260 |
+
|
| 261 |
+
symbol = tokenSymbol;
|
| 262 |
+
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
function setReleaseAgent(address addr) external onlyOwner inReleaseState(false) {
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
releaseAgent = addr;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
function release() external onlyReleaseAgent inReleaseState(false) {
|
| 273 |
+
released = true;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
function setTransferAgent(address addr, bool state) external onlyOwner inReleaseState(false) {
|
| 278 |
+
transferAgents[addr] = state;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function transfer(address _to, uint _value) public canTransfer(msg.sender) returns (bool success) {
|
| 282 |
+
|
| 283 |
+
return super.transfer(_to, _value);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
function transferFrom(address _from, address _to, uint _value) public canTransfer(_from) returns (bool success) {
|
| 287 |
+
|
| 288 |
+
return super.transferFrom(_from, _to, _value);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
function burn(uint256 _value) public onlyOwner returns (bool success) {
|
| 292 |
+
return super.burn(_value);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
function burnFrom(address _from, uint256 _value) public onlyOwner returns (bool success) {
|
| 296 |
+
return super.burnFrom(_from, _value);
|
| 297 |
+
}
|
| 298 |
+
}
|
benchmark2/integer overflow/286.sol
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract ERC20Basic {
|
| 5 |
+
function totalSupply() public view returns (uint256);
|
| 6 |
+
function balanceOf(address who) public view returns (uint256);
|
| 7 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 8 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
library SafeMath {
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if (a == 0) {
|
| 21 |
+
return 0;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
c = a * b;
|
| 25 |
+
assert(c / a == b);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
return a / b;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 39 |
+
assert(b <= a);
|
| 40 |
+
return a - b;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 45 |
+
c = a + b;
|
| 46 |
+
assert(c >= a);
|
| 47 |
+
return c;
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
contract BasicToken is ERC20Basic {
|
| 54 |
+
using SafeMath for uint256;
|
| 55 |
+
|
| 56 |
+
mapping(address => uint256) balances;
|
| 57 |
+
|
| 58 |
+
uint256 totalSupply_;
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
function totalSupply() public view returns (uint256) {
|
| 62 |
+
return totalSupply_;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 67 |
+
require(_to != address(0));
|
| 68 |
+
require(_value <= balances[msg.sender]);
|
| 69 |
+
|
| 70 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 71 |
+
balances[_to] = balances[_to].add(_value);
|
| 72 |
+
emit Transfer(msg.sender, _to, _value);
|
| 73 |
+
return true;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 78 |
+
return balances[_owner];
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
contract ERC20 is ERC20Basic {
|
| 86 |
+
function allowance(address owner, address spender)
|
| 87 |
+
public view returns (uint256);
|
| 88 |
+
|
| 89 |
+
function transferFrom(address from, address to, uint256 value)
|
| 90 |
+
public returns (bool);
|
| 91 |
+
|
| 92 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 93 |
+
event Approval(
|
| 94 |
+
address indexed owner,
|
| 95 |
+
address indexed spender,
|
| 96 |
+
uint256 value
|
| 97 |
+
);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
contract StandardToken is ERC20, BasicToken {
|
| 103 |
+
|
| 104 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
function transferFrom(
|
| 109 |
+
address _from,
|
| 110 |
+
address _to,
|
| 111 |
+
uint256 _value
|
| 112 |
+
)
|
| 113 |
+
public
|
| 114 |
+
returns (bool)
|
| 115 |
+
{
|
| 116 |
+
require(_to != address(0));
|
| 117 |
+
require(_value <= balances[_from]);
|
| 118 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 119 |
+
|
| 120 |
+
balances[_from] = balances[_from].sub(_value);
|
| 121 |
+
balances[_to] = balances[_to].add(_value);
|
| 122 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 123 |
+
emit Transfer(_from, _to, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 129 |
+
allowed[msg.sender][_spender] = _value;
|
| 130 |
+
emit Approval(msg.sender, _spender, _value);
|
| 131 |
+
return true;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
function allowance(
|
| 136 |
+
address _owner,
|
| 137 |
+
address _spender
|
| 138 |
+
)
|
| 139 |
+
public
|
| 140 |
+
view
|
| 141 |
+
returns (uint256)
|
| 142 |
+
{
|
| 143 |
+
return allowed[_owner][_spender];
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
function increaseApproval(
|
| 148 |
+
address _spender,
|
| 149 |
+
uint _addedValue
|
| 150 |
+
)
|
| 151 |
+
public
|
| 152 |
+
returns (bool)
|
| 153 |
+
{
|
| 154 |
+
allowed[msg.sender][_spender] = (
|
| 155 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 156 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 157 |
+
return true;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
function decreaseApproval(
|
| 162 |
+
address _spender,
|
| 163 |
+
uint _subtractedValue
|
| 164 |
+
)
|
| 165 |
+
public
|
| 166 |
+
returns (bool)
|
| 167 |
+
{
|
| 168 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 169 |
+
if (_subtractedValue > oldValue) {
|
| 170 |
+
allowed[msg.sender][_spender] = 0;
|
| 171 |
+
} else {
|
| 172 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 173 |
+
}
|
| 174 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 175 |
+
return true;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
contract LineageCode is StandardToken {
|
| 182 |
+
string public name = 'LineageCode';
|
| 183 |
+
string public symbol = 'LIN';
|
| 184 |
+
uint public decimals = 10;
|
| 185 |
+
uint public INITIAL_SUPPLY = 80 * 100000000 * (10 ** decimals);
|
| 186 |
+
address owner;
|
| 187 |
+
bool public released = false;
|
| 188 |
+
|
| 189 |
+
constructor() public {
|
| 190 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 191 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 192 |
+
owner = msg.sender;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function release() public {
|
| 196 |
+
require(owner == msg.sender);
|
| 197 |
+
require(!released);
|
| 198 |
+
released = true;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function lock() public {
|
| 202 |
+
require(owner == msg.sender);
|
| 203 |
+
require(released);
|
| 204 |
+
released = false;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function get_Release() view public returns (bool) {
|
| 208 |
+
return released;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
modifier onlyReleased() {
|
| 212 |
+
if (owner != msg.sender)
|
| 213 |
+
require(released);
|
| 214 |
+
_;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
function transfer(address to, uint256 value) public onlyReleased returns (bool) {
|
| 218 |
+
super.transfer(to, value);
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
function allowance(address _owner, address _spender) public onlyReleased view returns (uint256) {
|
| 222 |
+
super.allowance(_owner, _spender);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function transferFrom(address from, address to, uint256 value) public onlyReleased returns (bool) {
|
| 226 |
+
super.transferFrom(from, to, value);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function approve(address spender, uint256 value) public onlyReleased returns (bool) {
|
| 230 |
+
super.approve(spender, value);
|
| 231 |
+
}
|
| 232 |
+
}
|
benchmark2/integer overflow/291.sol
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.20;
|
| 2 |
+
|
| 3 |
+
contract SafeMath {
|
| 4 |
+
function safeMul(uint256 a, uint256 b) public pure returns (uint256) {
|
| 5 |
+
uint256 c = a * b;
|
| 6 |
+
assert(a == 0 || c / a == b);
|
| 7 |
+
return c;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function safeDiv(uint256 a, uint256 b)public pure returns (uint256) {
|
| 11 |
+
assert(b > 0);
|
| 12 |
+
uint256 c = a / b;
|
| 13 |
+
assert(a == b * c + a % b);
|
| 14 |
+
return c;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeSub(uint256 a, uint256 b)public pure returns (uint256) {
|
| 18 |
+
assert(b <= a);
|
| 19 |
+
return a - b;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function safeAdd(uint256 a, uint256 b)public pure returns (uint256) {
|
| 23 |
+
uint256 c = a + b;
|
| 24 |
+
assert(c>=a && c>=b);
|
| 25 |
+
return c;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function _assert(bool assertion)public pure {
|
| 29 |
+
assert(!assertion);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
contract ERC20Interface {
|
| 35 |
+
string public name;
|
| 36 |
+
string public symbol;
|
| 37 |
+
uint8 public decimals;
|
| 38 |
+
uint public totalSupply;
|
| 39 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 40 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 41 |
+
|
| 42 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 43 |
+
function allowance(address _owner, address _spender) view returns (uint256 remaining);
|
| 44 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 45 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
contract ERC20 is ERC20Interface,SafeMath {
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
mapping(address => uint256) public balanceOf;
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
mapping(address => mapping(address => uint256)) allowed;
|
| 55 |
+
|
| 56 |
+
constructor(string _name) public {
|
| 57 |
+
name = _name;
|
| 58 |
+
symbol = "REL";
|
| 59 |
+
decimals = 18;
|
| 60 |
+
totalSupply = 10000000000000000000000000000;
|
| 61 |
+
balanceOf[msg.sender] = totalSupply;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function transfer(address _to, uint256 _value) returns (bool success) {
|
| 66 |
+
require(_to != address(0));
|
| 67 |
+
require(balanceOf[msg.sender] >= _value);
|
| 68 |
+
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
|
| 69 |
+
|
| 70 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
|
| 71 |
+
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
emit Transfer(msg.sender, _to, _value);
|
| 75 |
+
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
| 81 |
+
require(_to != address(0));
|
| 82 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 83 |
+
require(balanceOf[_from] >= _value);
|
| 84 |
+
require(balanceOf[_to] + _value >= balanceOf[_to]);
|
| 85 |
+
|
| 86 |
+
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
|
| 87 |
+
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
|
| 88 |
+
|
| 89 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
|
| 90 |
+
|
| 91 |
+
emit Transfer(msg.sender, _to, _value);
|
| 92 |
+
return true;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function approve(address _spender, uint256 _value) returns (bool success) {
|
| 96 |
+
allowed[msg.sender][_spender] = _value;
|
| 97 |
+
|
| 98 |
+
emit Approval(msg.sender, _spender, _value);
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function allowance(address _owner, address _spender) view returns (uint256 remaining) {
|
| 103 |
+
return allowed[_owner][_spender];
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
contract owned {
|
| 110 |
+
address public owner;
|
| 111 |
+
|
| 112 |
+
constructor () public {
|
| 113 |
+
owner = msg.sender;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
modifier onlyOwner {
|
| 117 |
+
require(msg.sender == owner);
|
| 118 |
+
_;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
function transferOwnerShip(address newOwer) public onlyOwner {
|
| 122 |
+
owner = newOwer;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
contract SelfDesctructionContract is owned {
|
| 128 |
+
|
| 129 |
+
string public someValue;
|
| 130 |
+
modifier ownerRestricted {
|
| 131 |
+
require(owner == msg.sender);
|
| 132 |
+
_;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
function SelfDesctructionContract() {
|
| 136 |
+
owner = msg.sender;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function setSomeValue(string value){
|
| 140 |
+
someValue = value;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function destroyContract() ownerRestricted {
|
| 144 |
+
selfdestruct(owner);
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
contract AdvanceToken is ERC20, owned,SelfDesctructionContract{
|
| 151 |
+
|
| 152 |
+
mapping (address => bool) public frozenAccount;
|
| 153 |
+
|
| 154 |
+
event FrozenFunds(address target, bool frozen);
|
| 155 |
+
event Burn(address target, uint amount);
|
| 156 |
+
|
| 157 |
+
constructor (string _name) ERC20(_name) public {
|
| 158 |
+
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function freezeAccount(address target, bool freeze) public onlyOwner {
|
| 162 |
+
frozenAccount[target] = freeze;
|
| 163 |
+
emit FrozenFunds(target, freeze);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 168 |
+
success = _transfer(msg.sender, _to, _value);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 173 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 174 |
+
success = _transfer(_from, _to, _value);
|
| 175 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value) ;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
function _transfer(address _from, address _to, uint256 _value) internal returns (bool) {
|
| 179 |
+
require(_to != address(0));
|
| 180 |
+
require(!frozenAccount[_from]);
|
| 181 |
+
|
| 182 |
+
require(balanceOf[_from] >= _value);
|
| 183 |
+
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
|
| 184 |
+
|
| 185 |
+
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
|
| 186 |
+
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to],_value) ;
|
| 187 |
+
|
| 188 |
+
emit Transfer(_from, _to, _value);
|
| 189 |
+
return true;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 193 |
+
require(balanceOf[msg.sender] >= _value);
|
| 194 |
+
|
| 195 |
+
totalSupply =SafeMath.safeSub(totalSupply,_value) ;
|
| 196 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
|
| 197 |
+
|
| 198 |
+
emit Burn(msg.sender, _value);
|
| 199 |
+
return true;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 203 |
+
require(balanceOf[_from] >= _value);
|
| 204 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 205 |
+
|
| 206 |
+
totalSupply =SafeMath.safeSub(totalSupply,_value) ;
|
| 207 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender], _value);
|
| 208 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value);
|
| 209 |
+
|
| 210 |
+
emit Burn(msg.sender, _value);
|
| 211 |
+
return true;
|
| 212 |
+
}
|
| 213 |
+
}
|
benchmark2/integer overflow/311.sol
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract ERC20Basic {
|
| 5 |
+
function totalSupply() public view returns (uint256);
|
| 6 |
+
function balanceOf(address who) public view returns (uint256);
|
| 7 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 8 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
library SafeMath {
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if (a == 0) {
|
| 21 |
+
return 0;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
c = a * b;
|
| 25 |
+
assert(c / a == b);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
return a / b;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 39 |
+
assert(b <= a);
|
| 40 |
+
return a - b;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 45 |
+
c = a + b;
|
| 46 |
+
assert(c >= a);
|
| 47 |
+
return c;
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
contract BasicToken is ERC20Basic {
|
| 54 |
+
using SafeMath for uint256;
|
| 55 |
+
|
| 56 |
+
mapping(address => uint256) balances;
|
| 57 |
+
|
| 58 |
+
uint256 totalSupply_;
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
function totalSupply() public view returns (uint256) {
|
| 62 |
+
return totalSupply_;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 67 |
+
require(_to != address(0));
|
| 68 |
+
require(_value <= balances[msg.sender]);
|
| 69 |
+
|
| 70 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 71 |
+
balances[_to] = balances[_to].add(_value);
|
| 72 |
+
emit Transfer(msg.sender, _to, _value);
|
| 73 |
+
return true;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 78 |
+
return balances[_owner];
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
contract ERC20 is ERC20Basic {
|
| 86 |
+
function allowance(address owner, address spender)
|
| 87 |
+
public view returns (uint256);
|
| 88 |
+
|
| 89 |
+
function transferFrom(address from, address to, uint256 value)
|
| 90 |
+
public returns (bool);
|
| 91 |
+
|
| 92 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 93 |
+
event Approval(
|
| 94 |
+
address indexed owner,
|
| 95 |
+
address indexed spender,
|
| 96 |
+
uint256 value
|
| 97 |
+
);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
contract StandardToken is ERC20, BasicToken {
|
| 103 |
+
|
| 104 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
function transferFrom(
|
| 109 |
+
address _from,
|
| 110 |
+
address _to,
|
| 111 |
+
uint256 _value
|
| 112 |
+
)
|
| 113 |
+
public
|
| 114 |
+
returns (bool)
|
| 115 |
+
{
|
| 116 |
+
require(_to != address(0));
|
| 117 |
+
require(_value <= balances[_from]);
|
| 118 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 119 |
+
|
| 120 |
+
balances[_from] = balances[_from].sub(_value);
|
| 121 |
+
balances[_to] = balances[_to].add(_value);
|
| 122 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 123 |
+
emit Transfer(_from, _to, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 129 |
+
allowed[msg.sender][_spender] = _value;
|
| 130 |
+
emit Approval(msg.sender, _spender, _value);
|
| 131 |
+
return true;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
function allowance(
|
| 136 |
+
address _owner,
|
| 137 |
+
address _spender
|
| 138 |
+
)
|
| 139 |
+
public
|
| 140 |
+
view
|
| 141 |
+
returns (uint256)
|
| 142 |
+
{
|
| 143 |
+
return allowed[_owner][_spender];
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
function increaseApproval(
|
| 148 |
+
address _spender,
|
| 149 |
+
uint _addedValue
|
| 150 |
+
)
|
| 151 |
+
public
|
| 152 |
+
returns (bool)
|
| 153 |
+
{
|
| 154 |
+
allowed[msg.sender][_spender] = (
|
| 155 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 156 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 157 |
+
return true;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
function decreaseApproval(
|
| 162 |
+
address _spender,
|
| 163 |
+
uint _subtractedValue
|
| 164 |
+
)
|
| 165 |
+
public
|
| 166 |
+
returns (bool)
|
| 167 |
+
{
|
| 168 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 169 |
+
if (_subtractedValue > oldValue) {
|
| 170 |
+
allowed[msg.sender][_spender] = 0;
|
| 171 |
+
} else {
|
| 172 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 173 |
+
}
|
| 174 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 175 |
+
return true;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
contract LineageCode is StandardToken {
|
| 182 |
+
string public name = 'LinageCode';
|
| 183 |
+
string public symbol = 'LIN';
|
| 184 |
+
uint public decimals = 10;
|
| 185 |
+
uint public INITIAL_SUPPLY = 80 * 100000000 * (10 ** decimals);
|
| 186 |
+
address owner;
|
| 187 |
+
bool public released = false;
|
| 188 |
+
|
| 189 |
+
constructor() public {
|
| 190 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 191 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 192 |
+
owner = msg.sender;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function release() public {
|
| 196 |
+
require(owner == msg.sender);
|
| 197 |
+
require(!released);
|
| 198 |
+
released = true;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function lock() public {
|
| 202 |
+
require(owner == msg.sender);
|
| 203 |
+
require(released);
|
| 204 |
+
released = false;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function get_Release() view public returns (bool) {
|
| 208 |
+
return released;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
modifier onlyReleased() {
|
| 212 |
+
if (owner != msg.sender)
|
| 213 |
+
require(released);
|
| 214 |
+
_;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
function transfer(address to, uint256 value) public onlyReleased returns (bool) {
|
| 218 |
+
super.transfer(to, value);
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
function allowance(address _owner, address _spender) public onlyReleased view returns (uint256) {
|
| 222 |
+
super.allowance(_owner, _spender);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function transferFrom(address from, address to, uint256 value) public onlyReleased returns (bool) {
|
| 226 |
+
super.transferFrom(from, to, value);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function approve(address spender, uint256 value) public onlyReleased returns (bool) {
|
| 230 |
+
super.approve(spender, value);
|
| 231 |
+
}
|
| 232 |
+
}
|
benchmark2/integer overflow/333.sol
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.18;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
contract SafeMath {
|
| 18 |
+
function safeAdd(uint a, uint b) public pure returns (uint c) {
|
| 19 |
+
c = a + b;
|
| 20 |
+
require(c >= a);
|
| 21 |
+
}
|
| 22 |
+
function safeSub(uint a, uint b) public pure returns (uint c) {
|
| 23 |
+
require(b <= a);
|
| 24 |
+
c = a - b;
|
| 25 |
+
}
|
| 26 |
+
function safeMul(uint a, uint b) public pure returns (uint c) {
|
| 27 |
+
c = a * b;
|
| 28 |
+
require(a == 0 || c / a == b);
|
| 29 |
+
}
|
| 30 |
+
function safeDiv(uint a, uint b) public pure returns (uint c) {
|
| 31 |
+
require(b > 0);
|
| 32 |
+
c = a / b;
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
contract ERC20Interface {
|
| 42 |
+
function totalSupply() public constant returns (uint);
|
| 43 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance);
|
| 44 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
|
| 45 |
+
function transfer(address to, uint tokens) public returns (bool success);
|
| 46 |
+
function approve(address spender, uint tokens) public returns (bool success);
|
| 47 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success);
|
| 48 |
+
|
| 49 |
+
event Transfer(address indexed from, address indexed to, uint tokens);
|
| 50 |
+
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
contract ApproveAndCallFallBack {
|
| 60 |
+
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
contract Owned {
|
| 68 |
+
address public owner;
|
| 69 |
+
address public newOwner;
|
| 70 |
+
|
| 71 |
+
event OwnershipTransferred(address indexed _from, address indexed _to);
|
| 72 |
+
|
| 73 |
+
function Owned() public {
|
| 74 |
+
owner = msg.sender;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
modifier onlyOwner {
|
| 78 |
+
require(msg.sender == owner);
|
| 79 |
+
_;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 83 |
+
newOwner = _newOwner;
|
| 84 |
+
}
|
| 85 |
+
function acceptOwnership() public {
|
| 86 |
+
require(msg.sender == newOwner);
|
| 87 |
+
OwnershipTransferred(owner, newOwner);
|
| 88 |
+
owner = newOwner;
|
| 89 |
+
newOwner = address(0);
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
contract CoinDisplayNetwork is ERC20Interface, Owned, SafeMath {
|
| 99 |
+
string public symbol;
|
| 100 |
+
string public name;
|
| 101 |
+
uint8 public decimals;
|
| 102 |
+
uint public _totalSupply;
|
| 103 |
+
|
| 104 |
+
mapping(address => uint) balances;
|
| 105 |
+
mapping(address => mapping(address => uint)) allowed;
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
function CoinDisplayNetwork() public {
|
| 112 |
+
symbol = "CDN";
|
| 113 |
+
name = "Coin Display Network";
|
| 114 |
+
decimals = 18;
|
| 115 |
+
_totalSupply = 100000000000000000000000000;
|
| 116 |
+
balances[0xd76618b352D0bFC8014Fc44BF31Bd0F947331660] = _totalSupply;
|
| 117 |
+
Transfer(address(0), 0xd76618b352D0bFC8014Fc44BF31Bd0F947331660, _totalSupply);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
function totalSupply() public constant returns (uint) {
|
| 125 |
+
return _totalSupply - balances[address(0)];
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance) {
|
| 133 |
+
return balances[tokenOwner];
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
function transfer(address to, uint tokens) public returns (bool success) {
|
| 143 |
+
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
|
| 144 |
+
balances[to] = safeAdd(balances[to], tokens);
|
| 145 |
+
Transfer(msg.sender, to, tokens);
|
| 146 |
+
return true;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
function approve(address spender, uint tokens) public returns (bool success) {
|
| 159 |
+
allowed[msg.sender][spender] = tokens;
|
| 160 |
+
Approval(msg.sender, spender, tokens);
|
| 161 |
+
return true;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
|
| 175 |
+
balances[from] = safeSub(balances[from], tokens);
|
| 176 |
+
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
|
| 177 |
+
balances[to] = safeAdd(balances[to], tokens);
|
| 178 |
+
Transfer(from, to, tokens);
|
| 179 |
+
return true;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
|
| 188 |
+
return allowed[tokenOwner][spender];
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
|
| 198 |
+
allowed[msg.sender][spender] = tokens;
|
| 199 |
+
Approval(msg.sender, spender, tokens);
|
| 200 |
+
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
|
| 201 |
+
return true;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
function () public payable {
|
| 209 |
+
revert();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
|
| 217 |
+
return ERC20Interface(tokenAddress).transfer(owner, tokens);
|
| 218 |
+
}
|
| 219 |
+
}
|
benchmark2/integer overflow/338.sol
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
contract SafeMath {
|
| 4 |
+
function safeMul(uint a, uint b) internal returns (uint) {
|
| 5 |
+
uint c = a * b;
|
| 6 |
+
assert(a == 0 || c / a == b);
|
| 7 |
+
return c;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function safeSub(uint a, uint b) internal returns (uint) {
|
| 11 |
+
assert(b <= a);
|
| 12 |
+
return a - b;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function safeAdd(uint a, uint b) internal returns (uint) {
|
| 16 |
+
uint c = a + b;
|
| 17 |
+
assert(c>=a && c>=b);
|
| 18 |
+
return c;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function assert(bool assertion) internal {
|
| 22 |
+
if (!assertion) throw;
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
contract AccessControl is SafeMath{
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
event ContractUpgrade(address newContract);
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
address public ceoAddress;
|
| 33 |
+
address public cfoAddress;
|
| 34 |
+
address public cooAddress;
|
| 35 |
+
|
| 36 |
+
address newContractAddress;
|
| 37 |
+
|
| 38 |
+
uint public tip_total = 0;
|
| 39 |
+
uint public tip_rate = 20000000000000000;
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
bool public paused = false;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
modifier onlyCEO() {
|
| 46 |
+
require(msg.sender == ceoAddress);
|
| 47 |
+
_;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
modifier onlyCFO() {
|
| 52 |
+
require(msg.sender == cfoAddress);
|
| 53 |
+
_;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
modifier onlyCOO() {
|
| 58 |
+
require(msg.sender == cooAddress);
|
| 59 |
+
_;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
modifier onlyCLevel() {
|
| 63 |
+
require(
|
| 64 |
+
msg.sender == cooAddress ||
|
| 65 |
+
msg.sender == ceoAddress ||
|
| 66 |
+
msg.sender == cfoAddress
|
| 67 |
+
);
|
| 68 |
+
_;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
function () public payable{
|
| 72 |
+
tip_total = safeAdd(tip_total, msg.value);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function amountWithTip(uint amount) internal returns(uint){
|
| 78 |
+
uint tip = safeMul(amount, tip_rate) / (1 ether);
|
| 79 |
+
tip_total = safeAdd(tip_total, tip);
|
| 80 |
+
return safeSub(amount, tip);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
function withdrawTip(uint amount) external onlyCFO {
|
| 85 |
+
require(amount > 0 && amount <= tip_total);
|
| 86 |
+
require(msg.sender.send(amount));
|
| 87 |
+
tip_total = tip_total - amount;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
function setNewAddress(address newContract) external onlyCEO whenPaused {
|
| 92 |
+
newContractAddress = newContract;
|
| 93 |
+
emit ContractUpgrade(newContract);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
function setCEO(address _newCEO) external onlyCEO {
|
| 99 |
+
require(_newCEO != address(0));
|
| 100 |
+
|
| 101 |
+
ceoAddress = _newCEO;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
function setCFO(address _newCFO) external onlyCEO {
|
| 107 |
+
require(_newCFO != address(0));
|
| 108 |
+
|
| 109 |
+
cfoAddress = _newCFO;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function setCOO(address _newCOO) external onlyCEO {
|
| 115 |
+
require(_newCOO != address(0));
|
| 116 |
+
|
| 117 |
+
cooAddress = _newCOO;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
modifier whenNotPaused() {
|
| 124 |
+
require(!paused);
|
| 125 |
+
_;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
modifier whenPaused {
|
| 130 |
+
require(paused);
|
| 131 |
+
_;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
function pause() external onlyCLevel whenNotPaused {
|
| 137 |
+
paused = true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
function unpause() public onlyCEO whenPaused {
|
| 146 |
+
|
| 147 |
+
paused = false;
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
contract RpsGame is SafeMath , AccessControl{
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
uint8 constant public NONE = 0;
|
| 156 |
+
uint8 constant public ROCK = 10;
|
| 157 |
+
uint8 constant public PAPER = 20;
|
| 158 |
+
uint8 constant public SCISSORS = 30;
|
| 159 |
+
uint8 constant public DEALERWIN = 201;
|
| 160 |
+
uint8 constant public PLAYERWIN = 102;
|
| 161 |
+
uint8 constant public DRAW = 101;
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
event CreateGame(uint gameid, address dealer, uint amount);
|
| 165 |
+
event JoinGame(uint gameid, address player, uint amount);
|
| 166 |
+
event Reveal(uint gameid, address player, uint8 choice);
|
| 167 |
+
event CloseGame(uint gameid,address dealer,address player, uint8 result);
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
struct Game {
|
| 171 |
+
uint expireTime;
|
| 172 |
+
address dealer;
|
| 173 |
+
uint dealerValue;
|
| 174 |
+
bytes32 dealerHash;
|
| 175 |
+
uint8 dealerChoice;
|
| 176 |
+
address player;
|
| 177 |
+
uint8 playerChoice;
|
| 178 |
+
uint playerValue;
|
| 179 |
+
uint8 result;
|
| 180 |
+
bool closed;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
mapping (uint => mapping(uint => uint8)) public payoff;
|
| 185 |
+
mapping (uint => Game) public games;
|
| 186 |
+
mapping (address => uint[]) public gameidsOf;
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
uint public maxgame = 0;
|
| 190 |
+
uint public expireTimeLimit = 30 minutes;
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
function RpsGame() {
|
| 194 |
+
payoff[ROCK][ROCK] = DRAW;
|
| 195 |
+
payoff[ROCK][PAPER] = PLAYERWIN;
|
| 196 |
+
payoff[ROCK][SCISSORS] = DEALERWIN;
|
| 197 |
+
payoff[PAPER][ROCK] = DEALERWIN;
|
| 198 |
+
payoff[PAPER][PAPER] = DRAW;
|
| 199 |
+
payoff[PAPER][SCISSORS] = PLAYERWIN;
|
| 200 |
+
payoff[SCISSORS][ROCK] = PLAYERWIN;
|
| 201 |
+
payoff[SCISSORS][PAPER] = DEALERWIN;
|
| 202 |
+
payoff[SCISSORS][SCISSORS] = DRAW;
|
| 203 |
+
payoff[NONE][NONE] = DRAW;
|
| 204 |
+
payoff[ROCK][NONE] = DEALERWIN;
|
| 205 |
+
payoff[PAPER][NONE] = DEALERWIN;
|
| 206 |
+
payoff[SCISSORS][NONE] = DEALERWIN;
|
| 207 |
+
payoff[NONE][ROCK] = PLAYERWIN;
|
| 208 |
+
payoff[NONE][PAPER] = PLAYERWIN;
|
| 209 |
+
payoff[NONE][SCISSORS] = PLAYERWIN;
|
| 210 |
+
|
| 211 |
+
ceoAddress = msg.sender;
|
| 212 |
+
cooAddress = msg.sender;
|
| 213 |
+
cfoAddress = msg.sender;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
function createGame(bytes32 dealerHash, address player) public payable whenNotPaused returns (uint){
|
| 218 |
+
require(dealerHash != 0x0);
|
| 219 |
+
maxgame += 1;
|
| 220 |
+
Game storage game = games[maxgame];
|
| 221 |
+
game.dealer = msg.sender;
|
| 222 |
+
game.player = player;
|
| 223 |
+
game.dealerHash = dealerHash;
|
| 224 |
+
game.dealerChoice = NONE;
|
| 225 |
+
game.dealerValue = msg.value;
|
| 226 |
+
game.expireTime = expireTimeLimit + now;
|
| 227 |
+
|
| 228 |
+
gameidsOf[msg.sender].push(maxgame);
|
| 229 |
+
|
| 230 |
+
emit CreateGame(maxgame, game.dealer, game.dealerValue);
|
| 231 |
+
|
| 232 |
+
return maxgame;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
function joinGame(uint gameid, uint8 choice) public payable whenNotPaused returns (uint){
|
| 237 |
+
Game storage game = games[gameid];
|
| 238 |
+
require(msg.value == game.dealerValue && game.dealer != address(0) && game.dealer != msg.sender && game.playerChoice==NONE);
|
| 239 |
+
require(game.player == address(0) || game.player == msg.sender);
|
| 240 |
+
require(!game.closed);
|
| 241 |
+
require(now < game.expireTime);
|
| 242 |
+
require(checkChoice(choice));
|
| 243 |
+
|
| 244 |
+
game.player = msg.sender;
|
| 245 |
+
game.playerChoice = choice;
|
| 246 |
+
game.playerValue = msg.value;
|
| 247 |
+
game.expireTime = expireTimeLimit + now;
|
| 248 |
+
|
| 249 |
+
gameidsOf[msg.sender].push(gameid);
|
| 250 |
+
|
| 251 |
+
emit JoinGame(gameid, game.player, game.playerValue);
|
| 252 |
+
|
| 253 |
+
return gameid;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
function reveal(uint gameid, uint8 choice, bytes32 randomSecret) public returns (bool) {
|
| 258 |
+
Game storage game = games[gameid];
|
| 259 |
+
bytes32 proof = getProof(msg.sender, choice, randomSecret);
|
| 260 |
+
|
| 261 |
+
require(!game.closed);
|
| 262 |
+
require(now < game.expireTime);
|
| 263 |
+
require(game.dealerHash != 0x0);
|
| 264 |
+
require(checkChoice(choice));
|
| 265 |
+
require(checkChoice(game.playerChoice));
|
| 266 |
+
require(game.dealer == msg.sender && proof == game.dealerHash );
|
| 267 |
+
|
| 268 |
+
game.dealerChoice = choice;
|
| 269 |
+
|
| 270 |
+
Reveal(gameid, msg.sender, choice);
|
| 271 |
+
|
| 272 |
+
close(gameid);
|
| 273 |
+
|
| 274 |
+
return true;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
function close(uint gameid) public returns(bool) {
|
| 279 |
+
Game storage game = games[gameid];
|
| 280 |
+
require(!game.closed);
|
| 281 |
+
require(now > game.expireTime || (game.dealerChoice != NONE && game.playerChoice != NONE));
|
| 282 |
+
|
| 283 |
+
uint totalAmount = safeAdd(game.dealerValue, game.playerValue);
|
| 284 |
+
uint reward = amountWithTip(totalAmount);
|
| 285 |
+
uint8 result = payoff[game.dealerChoice][game.playerChoice];
|
| 286 |
+
|
| 287 |
+
if(result == DEALERWIN){
|
| 288 |
+
require(game.dealer.send(reward));
|
| 289 |
+
}else if(result == PLAYERWIN){
|
| 290 |
+
require(game.player.send(reward));
|
| 291 |
+
}else if(result == DRAW){
|
| 292 |
+
require(game.dealer.send(game.dealerValue) && game.player.send(game.playerValue));
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
game.closed = true;
|
| 296 |
+
game.result = result;
|
| 297 |
+
|
| 298 |
+
emit CloseGame(gameid, game.dealer, game.player, result);
|
| 299 |
+
|
| 300 |
+
return game.closed;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
function getProof(address sender, uint8 choice, bytes32 randomSecret) public view returns (bytes32){
|
| 305 |
+
return sha3(sender, choice, randomSecret);
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
function gameCountOf(address owner) public view returns (uint){
|
| 309 |
+
return gameidsOf[owner].length;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
function checkChoice(uint8 choice) public view returns (bool){
|
| 313 |
+
return choice==ROCK||choice==PAPER||choice==SCISSORS;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
}
|
benchmark2/integer overflow/339.sol
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.10;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
|
| 6 |
+
uint256 z = x + y;
|
| 7 |
+
assert((z >= x) && (z >= y));
|
| 8 |
+
return z;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function safeSubtract(uint256 x, uint256 y) internal returns(uint256) {
|
| 12 |
+
assert(x >= y);
|
| 13 |
+
uint256 z = x - y;
|
| 14 |
+
return z;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeMult(uint256 x, uint256 y) internal returns(uint256) {
|
| 18 |
+
uint256 z = x * y;
|
| 19 |
+
assert((x == 0)||(z/x == y));
|
| 20 |
+
return z;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
contract Token {
|
| 26 |
+
uint256 public totalSupply;
|
| 27 |
+
function balanceOf(address _owner) constant returns (uint256 balance);
|
| 28 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 29 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 30 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 31 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
|
| 32 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 33 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract StandardToken is Token , SafeMath {
|
| 40 |
+
|
| 41 |
+
bool public status = true;
|
| 42 |
+
modifier on() {
|
| 43 |
+
require(status == true);
|
| 44 |
+
_;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function transfer(address _to, uint256 _value) on returns (bool success) {
|
| 48 |
+
if (balances[msg.sender] >= _value && _value > 0 && _to != 0X0) {
|
| 49 |
+
balances[msg.sender] -= _value;
|
| 50 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 51 |
+
Transfer(msg.sender, _to, _value);
|
| 52 |
+
return true;
|
| 53 |
+
} else {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function transferFrom(address _from, address _to, uint256 _value) on returns (bool success) {
|
| 59 |
+
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
|
| 60 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 61 |
+
balances[_from] = safeSubtract(balances[_from],_value);
|
| 62 |
+
allowed[_from][msg.sender] = safeSubtract(allowed[_from][msg.sender],_value);
|
| 63 |
+
Transfer(_from, _to, _value);
|
| 64 |
+
return true;
|
| 65 |
+
} else {
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function balanceOf(address _owner) on constant returns (uint256 balance) {
|
| 71 |
+
return balances[_owner];
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function approve(address _spender, uint256 _value) on returns (bool success) {
|
| 75 |
+
allowed[msg.sender][_spender] = _value;
|
| 76 |
+
Approval(msg.sender, _spender, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function allowance(address _owner, address _spender) on constant returns (uint256 remaining) {
|
| 81 |
+
return allowed[_owner][_spender];
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
mapping (address => uint256) balances;
|
| 85 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
contract ExShellToken is StandardToken {
|
| 92 |
+
string public name = "ExShellToken";
|
| 93 |
+
uint8 public decimals = 8;
|
| 94 |
+
string public symbol = "ET";
|
| 95 |
+
bool private init =true;
|
| 96 |
+
function turnon() controller {
|
| 97 |
+
status = true;
|
| 98 |
+
}
|
| 99 |
+
function turnoff() controller {
|
| 100 |
+
status = false;
|
| 101 |
+
}
|
| 102 |
+
function ExShellToken() {
|
| 103 |
+
require(init==true);
|
| 104 |
+
totalSupply = 2000000000;
|
| 105 |
+
balances[0xa089a405b1df71a6155705fb2bce87df2a86a9e4] = totalSupply;
|
| 106 |
+
init = false;
|
| 107 |
+
}
|
| 108 |
+
address public controller1 =0xa089a405b1df71a6155705fb2bce87df2a86a9e4;
|
| 109 |
+
address public controller2 =0x5aa64423529e43a53c7ea037a07f94abc0c3a111;
|
| 110 |
+
|
| 111 |
+
modifier controller () {
|
| 112 |
+
require(msg.sender == controller1||msg.sender == controller2);
|
| 113 |
+
_;
|
| 114 |
+
}
|
| 115 |
+
}
|
benchmark2/integer overflow/355.sol
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
contract ERC20Basic {
|
| 7 |
+
function totalSupply() public view returns (uint256);
|
| 8 |
+
function balanceOf(address who) public view returns (uint256);
|
| 9 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 10 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
library SafeMath {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if (a == 0) {
|
| 24 |
+
return 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
c = a * b;
|
| 28 |
+
assert(c / a == b);
|
| 29 |
+
return c;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
return a / b;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 42 |
+
assert(b <= a);
|
| 43 |
+
return a - b;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 48 |
+
c = a + b;
|
| 49 |
+
assert(c >= a);
|
| 50 |
+
return c;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
contract BasicToken is ERC20Basic {
|
| 58 |
+
using SafeMath for uint256;
|
| 59 |
+
|
| 60 |
+
mapping(address => uint256) balances;
|
| 61 |
+
|
| 62 |
+
uint256 totalSupply_;
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function totalSupply() public view returns (uint256) {
|
| 66 |
+
return totalSupply_;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 71 |
+
require(_to != address(0));
|
| 72 |
+
require(_value <= balances[msg.sender]);
|
| 73 |
+
|
| 74 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 75 |
+
balances[_to] = balances[_to].add(_value);
|
| 76 |
+
emit Transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 82 |
+
return balances[_owner];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
contract ERC20 is ERC20Basic {
|
| 91 |
+
function allowance(address owner, address spender)
|
| 92 |
+
public view returns (uint256);
|
| 93 |
+
|
| 94 |
+
function transferFrom(address from, address to, uint256 value)
|
| 95 |
+
public returns (bool);
|
| 96 |
+
|
| 97 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 98 |
+
event Approval(
|
| 99 |
+
address indexed owner,
|
| 100 |
+
address indexed spender,
|
| 101 |
+
uint256 value
|
| 102 |
+
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
contract StandardToken is ERC20, BasicToken {
|
| 109 |
+
|
| 110 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function transferFrom(
|
| 115 |
+
address _from,
|
| 116 |
+
address _to,
|
| 117 |
+
uint256 _value
|
| 118 |
+
)
|
| 119 |
+
public
|
| 120 |
+
returns (bool)
|
| 121 |
+
{
|
| 122 |
+
require(_to != address(0));
|
| 123 |
+
require(_value <= balances[_from]);
|
| 124 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 125 |
+
|
| 126 |
+
balances[_from] = balances[_from].sub(_value);
|
| 127 |
+
balances[_to] = balances[_to].add(_value);
|
| 128 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 129 |
+
emit Transfer(_from, _to, _value);
|
| 130 |
+
return true;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 135 |
+
allowed[msg.sender][_spender] = _value;
|
| 136 |
+
emit Approval(msg.sender, _spender, _value);
|
| 137 |
+
return true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function allowance(
|
| 142 |
+
address _owner,
|
| 143 |
+
address _spender
|
| 144 |
+
)
|
| 145 |
+
public
|
| 146 |
+
view
|
| 147 |
+
returns (uint256)
|
| 148 |
+
{
|
| 149 |
+
return allowed[_owner][_spender];
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
function increaseApproval(
|
| 154 |
+
address _spender,
|
| 155 |
+
uint256 _addedValue
|
| 156 |
+
)
|
| 157 |
+
public
|
| 158 |
+
returns (bool)
|
| 159 |
+
{
|
| 160 |
+
allowed[msg.sender][_spender] = (
|
| 161 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 162 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function decreaseApproval(
|
| 168 |
+
address _spender,
|
| 169 |
+
uint256 _subtractedValue
|
| 170 |
+
)
|
| 171 |
+
public
|
| 172 |
+
returns (bool)
|
| 173 |
+
{
|
| 174 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 175 |
+
if (_subtractedValue > oldValue) {
|
| 176 |
+
allowed[msg.sender][_spender] = 0;
|
| 177 |
+
} else {
|
| 178 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 179 |
+
}
|
| 180 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 181 |
+
return true;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
contract PeopleWaveToken is StandardToken {
|
| 189 |
+
string public constant name = "PeopleWave Token";
|
| 190 |
+
string public constant symbol = "PPL";
|
| 191 |
+
uint8 public constant decimals = 18;
|
| 192 |
+
uint public constant initialSupply = 1200000000000000000000000000;
|
| 193 |
+
|
| 194 |
+
constructor() public {
|
| 195 |
+
totalSupply_ = initialSupply;
|
| 196 |
+
balances[msg.sender] = initialSupply;
|
| 197 |
+
}
|
| 198 |
+
}
|
benchmark2/integer overflow/373.sol
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract Ownable {
|
| 5 |
+
address public owner;
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 9 |
+
event OwnershipTransferred(
|
| 10 |
+
address indexed previousOwner,
|
| 11 |
+
address indexed newOwner
|
| 12 |
+
);
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
constructor() public {
|
| 17 |
+
owner = msg.sender;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
modifier onlyOwner() {
|
| 22 |
+
require(msg.sender == owner);
|
| 23 |
+
_;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
function renounceOwnership() public onlyOwner {
|
| 28 |
+
emit OwnershipRenounced(owner);
|
| 29 |
+
owner = address(0);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 34 |
+
_transferOwnership(_newOwner);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
function _transferOwnership(address _newOwner) internal {
|
| 39 |
+
require(_newOwner != address(0));
|
| 40 |
+
emit OwnershipTransferred(owner, _newOwner);
|
| 41 |
+
owner = _newOwner;
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
contract ERC20 {
|
| 47 |
+
function totalSupply() public view returns (uint256);
|
| 48 |
+
|
| 49 |
+
function balanceOf(address _who) public view returns (uint256);
|
| 50 |
+
|
| 51 |
+
function allowance(address _owner, address _spender)
|
| 52 |
+
public view returns (uint256);
|
| 53 |
+
|
| 54 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 55 |
+
|
| 56 |
+
function approve(address _spender, uint256 _value)
|
| 57 |
+
public returns (bool);
|
| 58 |
+
|
| 59 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 60 |
+
public returns (bool);
|
| 61 |
+
|
| 62 |
+
event Transfer(
|
| 63 |
+
address indexed from,
|
| 64 |
+
address indexed to,
|
| 65 |
+
uint256 value
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
event Approval(
|
| 69 |
+
address indexed owner,
|
| 70 |
+
address indexed spender,
|
| 71 |
+
uint256 value
|
| 72 |
+
);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
contract StandardToken is ERC20 {
|
| 78 |
+
using SafeMath for uint256;
|
| 79 |
+
|
| 80 |
+
mapping(address => uint256) balances;
|
| 81 |
+
|
| 82 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 83 |
+
|
| 84 |
+
uint256 totalSupply_;
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
function totalSupply() public view returns (uint256) {
|
| 88 |
+
return totalSupply_;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 93 |
+
return balances[_owner];
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
function allowance(
|
| 98 |
+
address _owner,
|
| 99 |
+
address _spender
|
| 100 |
+
)
|
| 101 |
+
public
|
| 102 |
+
view
|
| 103 |
+
returns (uint256)
|
| 104 |
+
{
|
| 105 |
+
return allowed[_owner][_spender];
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 110 |
+
require(_value <= balances[msg.sender]);
|
| 111 |
+
require(_to != address(0));
|
| 112 |
+
|
| 113 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 114 |
+
balances[_to] = balances[_to].add(_value);
|
| 115 |
+
emit Transfer(msg.sender, _to, _value);
|
| 116 |
+
return true;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 121 |
+
allowed[msg.sender][_spender] = _value;
|
| 122 |
+
emit Approval(msg.sender, _spender, _value);
|
| 123 |
+
return true;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
function transferFrom(
|
| 128 |
+
address _from,
|
| 129 |
+
address _to,
|
| 130 |
+
uint256 _value
|
| 131 |
+
)
|
| 132 |
+
public
|
| 133 |
+
returns (bool)
|
| 134 |
+
{
|
| 135 |
+
require(_value <= balances[_from]);
|
| 136 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 137 |
+
require(_to != address(0));
|
| 138 |
+
|
| 139 |
+
balances[_from] = balances[_from].sub(_value);
|
| 140 |
+
balances[_to] = balances[_to].add(_value);
|
| 141 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 142 |
+
emit Transfer(_from, _to, _value);
|
| 143 |
+
return true;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
function increaseApproval(
|
| 148 |
+
address _spender,
|
| 149 |
+
uint256 _addedValue
|
| 150 |
+
)
|
| 151 |
+
public
|
| 152 |
+
returns (bool)
|
| 153 |
+
{
|
| 154 |
+
allowed[msg.sender][_spender] = (
|
| 155 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 156 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 157 |
+
return true;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
function decreaseApproval(
|
| 162 |
+
address _spender,
|
| 163 |
+
uint256 _subtractedValue
|
| 164 |
+
)
|
| 165 |
+
public
|
| 166 |
+
returns (bool)
|
| 167 |
+
{
|
| 168 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 169 |
+
if (_subtractedValue >= oldValue) {
|
| 170 |
+
allowed[msg.sender][_spender] = 0;
|
| 171 |
+
} else {
|
| 172 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 173 |
+
}
|
| 174 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 175 |
+
return true;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
contract Pausable is Ownable {
|
| 184 |
+
event Pause();
|
| 185 |
+
event Unpause();
|
| 186 |
+
|
| 187 |
+
bool public paused = false;
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
modifier whenNotPaused() {
|
| 192 |
+
require(!paused);
|
| 193 |
+
_;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
modifier whenPaused() {
|
| 198 |
+
require(paused);
|
| 199 |
+
_;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
function pause() public onlyOwner whenNotPaused {
|
| 204 |
+
paused = true;
|
| 205 |
+
emit Pause();
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
function unpause() public onlyOwner whenPaused {
|
| 210 |
+
paused = false;
|
| 211 |
+
emit Unpause();
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
contract BurnableToken is StandardToken {
|
| 219 |
+
|
| 220 |
+
event Burn(address indexed burner, uint256 value);
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
function burn(uint256 _value) public {
|
| 224 |
+
_burn(msg.sender, _value);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
function burnFrom(address _from, uint256 _value) public {
|
| 229 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 233 |
+
_burn(_from, _value);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
function _burn(address _who, uint256 _value) internal {
|
| 237 |
+
require(_value <= balances[_who]);
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
balances[_who] = balances[_who].sub(_value);
|
| 242 |
+
totalSupply_ = totalSupply_.sub(_value);
|
| 243 |
+
emit Burn(_who, _value);
|
| 244 |
+
emit Transfer(_who, address(0), _value);
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
contract MintableToken is StandardToken, Ownable {
|
| 251 |
+
event Mint(address indexed to, uint256 amount);
|
| 252 |
+
event MintFinished();
|
| 253 |
+
|
| 254 |
+
bool public mintingFinished = false;
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
modifier canMint() {
|
| 258 |
+
require(!mintingFinished);
|
| 259 |
+
_;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
modifier hasMintPermission() {
|
| 263 |
+
require(msg.sender == owner);
|
| 264 |
+
_;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
function mint(
|
| 269 |
+
address _to,
|
| 270 |
+
uint256 _amount
|
| 271 |
+
)
|
| 272 |
+
public
|
| 273 |
+
hasMintPermission
|
| 274 |
+
canMint
|
| 275 |
+
returns (bool)
|
| 276 |
+
{
|
| 277 |
+
totalSupply_ = totalSupply_.add(_amount);
|
| 278 |
+
balances[_to] = balances[_to].add(_amount);
|
| 279 |
+
emit Mint(_to, _amount);
|
| 280 |
+
emit Transfer(address(0), _to, _amount);
|
| 281 |
+
return true;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
function finishMinting() public onlyOwner canMint returns (bool) {
|
| 286 |
+
mintingFinished = true;
|
| 287 |
+
emit MintFinished();
|
| 288 |
+
return true;
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
library SafeMath {
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
if (_a == 0) {
|
| 303 |
+
return 0;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
c = _a * _b;
|
| 307 |
+
assert(c / _a == _b);
|
| 308 |
+
return c;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
return _a / _b;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 321 |
+
assert(_b <= _a);
|
| 322 |
+
return _a - _b;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 327 |
+
c = _a + _b;
|
| 328 |
+
assert(c >= _a);
|
| 329 |
+
return c;
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
contract PausableToken is StandardToken, Pausable {
|
| 335 |
+
|
| 336 |
+
function transfer(
|
| 337 |
+
address _to,
|
| 338 |
+
uint256 _value
|
| 339 |
+
)
|
| 340 |
+
public
|
| 341 |
+
whenNotPaused
|
| 342 |
+
returns (bool)
|
| 343 |
+
{
|
| 344 |
+
return super.transfer(_to, _value);
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
function transferFrom(
|
| 348 |
+
address _from,
|
| 349 |
+
address _to,
|
| 350 |
+
uint256 _value
|
| 351 |
+
)
|
| 352 |
+
public
|
| 353 |
+
whenNotPaused
|
| 354 |
+
returns (bool)
|
| 355 |
+
{
|
| 356 |
+
return super.transferFrom(_from, _to, _value);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
function approve(
|
| 360 |
+
address _spender,
|
| 361 |
+
uint256 _value
|
| 362 |
+
)
|
| 363 |
+
public
|
| 364 |
+
whenNotPaused
|
| 365 |
+
returns (bool)
|
| 366 |
+
{
|
| 367 |
+
return super.approve(_spender, _value);
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
function increaseApproval(
|
| 371 |
+
address _spender,
|
| 372 |
+
uint _addedValue
|
| 373 |
+
)
|
| 374 |
+
public
|
| 375 |
+
whenNotPaused
|
| 376 |
+
returns (bool success)
|
| 377 |
+
{
|
| 378 |
+
return super.increaseApproval(_spender, _addedValue);
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
function decreaseApproval(
|
| 382 |
+
address _spender,
|
| 383 |
+
uint _subtractedValue
|
| 384 |
+
)
|
| 385 |
+
public
|
| 386 |
+
whenNotPaused
|
| 387 |
+
returns (bool success)
|
| 388 |
+
{
|
| 389 |
+
return super.decreaseApproval(_spender, _subtractedValue);
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
contract SCAVOToken is StandardToken, MintableToken, PausableToken, BurnableToken {
|
| 397 |
+
|
| 398 |
+
string public constant name = "SCAVO Token";
|
| 399 |
+
string public constant symbol = "SCAVO";
|
| 400 |
+
string public constant version = "1.1";
|
| 401 |
+
uint8 public constant decimals = 18;
|
| 402 |
+
|
| 403 |
+
uint256 public constant INITIAL_SUPPLY = 200000000 * (10 ** uint256(decimals));
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
constructor() public {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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.18;
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
// --
|
| 5 |
+
// --
|
| 6 |
+
// --
|
| 7 |
+
// ___ ___ ___ ___ ___
|
| 8 |
+
// /\ \ /\__\ /\ \ /\__\ /\ \
|
| 9 |
+
// /::\ \ /:/ _/_ /::\ \ /::L_L_ \:\ \
|
| 10 |
+
// /\:\:\__\ /:/_/\__\ /::\:\__\ /:/L:\__\ /::\__\
|
| 11 |
+
// \:\:\/__/ \:\/:/ / \/\::/ / \/_/:/ / /:/\/__/
|
| 12 |
+
// \::/ / \::/ / \/__/ /:/ / \/__/
|
| 13 |
+
// \/__/ \/__/ \/__/
|
| 14 |
+
// --
|
| 15 |
+
// --
|
| 16 |
+
// --
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
// Contract must have an owner
|
| 20 |
+
contract Owned {
|
| 21 |
+
address public owner;
|
| 22 |
+
|
| 23 |
+
constructor() public {
|
| 24 |
+
owner = msg.sender;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
modifier onlyOwner() {
|
| 28 |
+
require(msg.sender == owner);
|
| 29 |
+
_;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function setOwner(address _owner) onlyOwner public {
|
| 33 |
+
owner = _owner;
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
// SafeMath methods
|
| 38 |
+
contract SafeMath {
|
| 39 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 40 |
+
uint256 c = _a + _b;
|
| 41 |
+
assert(c >= _a);
|
| 42 |
+
return c;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 46 |
+
assert(_a >= _b);
|
| 47 |
+
return _a - _b;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 51 |
+
uint256 c = _a * _b;
|
| 52 |
+
assert(_a == 0 || c / _a == _b);
|
| 53 |
+
return c;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// for safety methods
|
| 58 |
+
interface ERC20Token {
|
| 59 |
+
function transfer(address _to, uint256 _value) external returns (bool);
|
| 60 |
+
function balanceOf(address _addr) external view returns (uint256);
|
| 61 |
+
function decimals() external view returns (uint8);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// the main ERC20-compliant contract
|
| 65 |
+
contract Token is SafeMath, Owned {
|
| 66 |
+
uint256 constant DAY_IN_SECONDS = 86400;
|
| 67 |
+
string public constant standard = "0.66";
|
| 68 |
+
string public name = "";
|
| 69 |
+
string public symbol = "";
|
| 70 |
+
uint8 public decimals = 0;
|
| 71 |
+
uint256 public totalSupply = 0;
|
| 72 |
+
mapping (address => uint256) public balanceP;
|
| 73 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 74 |
+
|
| 75 |
+
mapping (address => uint256[]) public lockTime;
|
| 76 |
+
mapping (address => uint256[]) public lockValue;
|
| 77 |
+
mapping (address => uint256) public lockNum;
|
| 78 |
+
mapping (address => bool) public locker;
|
| 79 |
+
uint256 public later = 0;
|
| 80 |
+
uint256 public earlier = 0;
|
| 81 |
+
|
| 82 |
+
// standard ERC20 events
|
| 83 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 84 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 85 |
+
|
| 86 |
+
// timelock-related events
|
| 87 |
+
event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value);
|
| 88 |
+
event TokenUnlocked(address indexed _address, uint256 _value);
|
| 89 |
+
|
| 90 |
+
// safety method-related events
|
| 91 |
+
event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount);
|
| 92 |
+
event WrongEtherEmptied(address indexed _addr, uint256 _amount);
|
| 93 |
+
|
| 94 |
+
// constructor for the ERC20 Token
|
| 95 |
+
constructor(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public {
|
| 96 |
+
require(bytes(_name).length > 0 && bytes(_symbol).length > 0);
|
| 97 |
+
|
| 98 |
+
name = _name;
|
| 99 |
+
symbol = _symbol;
|
| 100 |
+
decimals = _decimals;
|
| 101 |
+
totalSupply = _totalSupply;
|
| 102 |
+
|
| 103 |
+
balanceP[msg.sender] = _totalSupply;
|
| 104 |
+
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
modifier validAddress(address _address) {
|
| 108 |
+
require(_address != 0x0);
|
| 109 |
+
_;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
// owner may add or remove a locker address for the contract
|
| 113 |
+
function addLocker(address _address) public validAddress(_address) onlyOwner {
|
| 114 |
+
locker[_address] = true;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
function removeLocker(address _address) public validAddress(_address) onlyOwner {
|
| 118 |
+
locker[_address] = false;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// fast-forward the timelocks for all accounts
|
| 122 |
+
function setUnlockEarlier(uint256 _earlier) public onlyOwner {
|
| 123 |
+
earlier = add(earlier, _earlier);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// delay the timelocks for all accounts
|
| 127 |
+
function setUnlockLater(uint256 _later) public onlyOwner {
|
| 128 |
+
later = add(later, _later);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// show unlocked balance of an account
|
| 132 |
+
function balanceUnlocked(address _address) public view returns (uint256 _balance) {
|
| 133 |
+
_balance = balanceP[_address];
|
| 134 |
+
uint256 i = 0;
|
| 135 |
+
while (i < lockNum[_address]) {
|
| 136 |
+
if (add(now, earlier) > add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
|
| 137 |
+
i++;
|
| 138 |
+
}
|
| 139 |
+
return _balance;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// show timelocked balance of an account
|
| 143 |
+
function balanceLocked(address _address) public view returns (uint256 _balance) {
|
| 144 |
+
_balance = 0;
|
| 145 |
+
uint256 i = 0;
|
| 146 |
+
while (i < lockNum[_address]) {
|
| 147 |
+
if (add(now, earlier) < add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
|
| 148 |
+
i++;
|
| 149 |
+
}
|
| 150 |
+
return _balance;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
// standard ERC20 balanceOf with timelock added
|
| 154 |
+
function balanceOf(address _address) public view returns (uint256 _balance) {
|
| 155 |
+
_balance = balanceP[_address];
|
| 156 |
+
uint256 i = 0;
|
| 157 |
+
while (i < lockNum[_address]) {
|
| 158 |
+
_balance = add(_balance, lockValue[_address][i]);
|
| 159 |
+
i++;
|
| 160 |
+
}
|
| 161 |
+
return _balance;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
// show timelocks in an account
|
| 165 |
+
function showTime(address _address) public view validAddress(_address) returns (uint256[] _time) {
|
| 166 |
+
uint i = 0;
|
| 167 |
+
uint256[] memory tempLockTime = new uint256[](lockNum[_address]);
|
| 168 |
+
while (i < lockNum[_address]) {
|
| 169 |
+
tempLockTime[i] = sub(add(lockTime[_address][i], later), earlier);
|
| 170 |
+
i++;
|
| 171 |
+
}
|
| 172 |
+
return tempLockTime;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
// show values locked in an account's timelocks
|
| 176 |
+
function showValue(address _address) public view validAddress(_address) returns (uint256[] _value) {
|
| 177 |
+
return lockValue[_address];
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
// Calculate and process the timelock states of an account
|
| 181 |
+
function calcUnlock(address _address) private {
|
| 182 |
+
uint256 i = 0;
|
| 183 |
+
uint256 j = 0;
|
| 184 |
+
uint256[] memory currentLockTime;
|
| 185 |
+
uint256[] memory currentLockValue;
|
| 186 |
+
uint256[] memory newLockTime = new uint256[](lockNum[_address]);
|
| 187 |
+
uint256[] memory newLockValue = new uint256[](lockNum[_address]);
|
| 188 |
+
currentLockTime = lockTime[_address];
|
| 189 |
+
currentLockValue = lockValue[_address];
|
| 190 |
+
while (i < lockNum[_address]) {
|
| 191 |
+
if (add(now, earlier) > add(currentLockTime[i], later)) {
|
| 192 |
+
balanceP[_address] = add(balanceP[_address], currentLockValue[i]);
|
| 193 |
+
emit TokenUnlocked(_address, currentLockValue[i]);
|
| 194 |
+
} else {
|
| 195 |
+
newLockTime[j] = currentLockTime[i];
|
| 196 |
+
newLockValue[j] = currentLockValue[i];
|
| 197 |
+
j++;
|
| 198 |
+
}
|
| 199 |
+
i++;
|
| 200 |
+
}
|
| 201 |
+
uint256[] memory trimLockTime = new uint256[](j);
|
| 202 |
+
uint256[] memory trimLockValue = new uint256[](j);
|
| 203 |
+
i = 0;
|
| 204 |
+
while (i < j) {
|
| 205 |
+
trimLockTime[i] = newLockTime[i];
|
| 206 |
+
trimLockValue[i] = newLockValue[i];
|
| 207 |
+
i++;
|
| 208 |
+
}
|
| 209 |
+
lockTime[_address] = trimLockTime;
|
| 210 |
+
lockValue[_address] = trimLockValue;
|
| 211 |
+
lockNum[_address] = j;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
// standard ERC20 transfer
|
| 215 |
+
function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) {
|
| 216 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 217 |
+
if (balanceP[msg.sender] >= _value && _value > 0) {
|
| 218 |
+
balanceP[msg.sender] = sub(balanceP[msg.sender], _value);
|
| 219 |
+
balanceP[_to] = add(balanceP[_to], _value);
|
| 220 |
+
emit Transfer(msg.sender, _to, _value);
|
| 221 |
+
return true;
|
| 222 |
+
}
|
| 223 |
+
else {
|
| 224 |
+
return false;
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// transfer Token with timelocks
|
| 229 |
+
function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool success) {
|
| 230 |
+
require(_value.length == _time.length);
|
| 231 |
+
|
| 232 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 233 |
+
uint256 i = 0;
|
| 234 |
+
uint256 totalValue = 0;
|
| 235 |
+
while (i < _value.length) {
|
| 236 |
+
totalValue = add(totalValue, _value[i]);
|
| 237 |
+
i++;
|
| 238 |
+
}
|
| 239 |
+
if (balanceP[msg.sender] >= totalValue && totalValue > 0) {
|
| 240 |
+
i = 0;
|
| 241 |
+
while (i < _time.length) {
|
| 242 |
+
balanceP[msg.sender] = sub(balanceP[msg.sender], _value[i]);
|
| 243 |
+
lockTime[_to].length = lockNum[_to]+1;
|
| 244 |
+
lockValue[_to].length = lockNum[_to]+1;
|
| 245 |
+
lockTime[_to][lockNum[_to]] = add(now, _time[i]);
|
| 246 |
+
lockValue[_to][lockNum[_to]] = _value[i];
|
| 247 |
+
|
| 248 |
+
// emit custom TransferLocked event
|
| 249 |
+
emit TransferLocked(msg.sender, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);
|
| 250 |
+
|
| 251 |
+
// emit standard Transfer event for wallets
|
| 252 |
+
emit Transfer(msg.sender, _to, lockValue[_to][lockNum[_to]]);
|
| 253 |
+
lockNum[_to]++;
|
| 254 |
+
i++;
|
| 255 |
+
}
|
| 256 |
+
return true;
|
| 257 |
+
}
|
| 258 |
+
else {
|
| 259 |
+
return false;
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// lockers set by owners may transfer Token with timelocks
|
| 264 |
+
function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public
|
| 265 |
+
validAddress(_from) validAddress(_to) returns (bool success) {
|
| 266 |
+
require(locker[msg.sender]);
|
| 267 |
+
require(_value.length == _time.length);
|
| 268 |
+
|
| 269 |
+
if (lockNum[_from] > 0) calcUnlock(_from);
|
| 270 |
+
uint256 i = 0;
|
| 271 |
+
uint256 totalValue = 0;
|
| 272 |
+
while (i < _value.length) {
|
| 273 |
+
totalValue = add(totalValue, _value[i]);
|
| 274 |
+
i++;
|
| 275 |
+
}
|
| 276 |
+
if (balanceP[_from] >= totalValue && totalValue > 0 && allowance[_from][msg.sender] >= totalValue) {
|
| 277 |
+
i = 0;
|
| 278 |
+
while (i < _time.length) {
|
| 279 |
+
balanceP[_from] = sub(balanceP[_from], _value[i]);
|
| 280 |
+
allowance[_from][msg.sender] = sub(allowance[_from][msg.sender], _value[i]);
|
| 281 |
+
lockTime[_to].length = lockNum[_to]+1;
|
| 282 |
+
lockValue[_to].length = lockNum[_to]+1;
|
| 283 |
+
lockTime[_to][lockNum[_to]] = add(now, _time[i]);
|
| 284 |
+
lockValue[_to][lockNum[_to]] = _value[i];
|
| 285 |
+
|
| 286 |
+
// emit custom TransferLocked event
|
| 287 |
+
emit TransferLocked(_from, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);
|
| 288 |
+
|
| 289 |
+
// emit standard Transfer event for wallets
|
| 290 |
+
emit Transfer(_from, _to, lockValue[_to][lockNum[_to]]);
|
| 291 |
+
lockNum[_to]++;
|
| 292 |
+
i++;
|
| 293 |
+
}
|
| 294 |
+
return true;
|
| 295 |
+
}
|
| 296 |
+
else {
|
| 297 |
+
return false;
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
// standard ERC20 transferFrom
|
| 302 |
+
function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) {
|
| 303 |
+
if (lockNum[_from] > 0) calcUnlock(_from);
|
| 304 |
+
if (balanceP[_from] >= _value && _value > 0 && allowance[_from][msg.sender] >= _value) {
|
| 305 |
+
allowance[_from][msg.sender] = sub(allowance[_from][msg.sender], _value);
|
| 306 |
+
balanceP[_from] = sub(balanceP[_from], _value);
|
| 307 |
+
balanceP[_to] = add(balanceP[_to], _value);
|
| 308 |
+
emit Transfer(_from, _to, _value);
|
| 309 |
+
return true;
|
| 310 |
+
}
|
| 311 |
+
else {
|
| 312 |
+
return false;
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
// should only be called when first setting an allowance
|
| 317 |
+
function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) {
|
| 318 |
+
require(allowance[msg.sender][_spender] == 0);
|
| 319 |
+
|
| 320 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 321 |
+
allowance[msg.sender][_spender] = _value;
|
| 322 |
+
emit Approval(msg.sender, _spender, _value);
|
| 323 |
+
return true;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// increase or decrease allowance
|
| 327 |
+
function increaseApproval(address _spender, uint _value) public returns (bool) {
|
| 328 |
+
allowance[msg.sender][_spender] = add(allowance[msg.sender][_spender], _value);
|
| 329 |
+
emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
| 330 |
+
return true;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
function decreaseApproval(address _spender, uint _value) public returns (bool) {
|
| 334 |
+
if(_value > allowance[msg.sender][_spender]) {
|
| 335 |
+
allowance[msg.sender][_spender] = 0;
|
| 336 |
+
} else {
|
| 337 |
+
allowance[msg.sender][_spender] = sub(allowance[msg.sender][_spender], _value);
|
| 338 |
+
}
|
| 339 |
+
emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
| 340 |
+
return true;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
// safety methods
|
| 344 |
+
function () public payable {
|
| 345 |
+
revert();
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
function emptyWrongToken(address _addr) onlyOwner public {
|
| 349 |
+
ERC20Token wrongToken = ERC20Token(_addr);
|
| 350 |
+
uint256 amount = wrongToken.balanceOf(address(this));
|
| 351 |
+
require(amount > 0);
|
| 352 |
+
require(wrongToken.transfer(msg.sender, amount));
|
| 353 |
+
|
| 354 |
+
emit WrongTokenEmptied(_addr, msg.sender, amount);
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
// shouldn't happen, just in case
|
| 358 |
+
function emptyWrongEther() onlyOwner public {
|
| 359 |
+
uint256 amount = address(this).balance;
|
| 360 |
+
require(amount > 0);
|
| 361 |
+
msg.sender.transfer(amount);
|
| 362 |
+
|
| 363 |
+
emit WrongEtherEmptied(msg.sender, amount);
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
}
|
benchmark2/integer overflow/382.sol
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 9 |
+
|
| 10 |
+
function safeDiv(uint256 a, uint256 b)public pure returns (uint256) {
|
| 11 |
+
assert(b > 0);
|
| 12 |
+
uint256 c = a / b;
|
| 13 |
+
assert(a == b * c + a % b);
|
| 14 |
+
return c;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeSub(uint256 a, uint256 b)public pure returns (uint256) {
|
| 18 |
+
assert(b <= a);
|
| 19 |
+
return a - b;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function safeAdd(uint256 a, uint256 b)public pure returns (uint256) {
|
| 23 |
+
uint256 c = a + b;
|
| 24 |
+
assert(c>=a && c>=b);
|
| 25 |
+
return c;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function _assert(bool assertion)public pure {
|
| 29 |
+
assert(!assertion);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
contract ERC20Interface {
|
| 35 |
+
string public name;
|
| 36 |
+
string public symbol;
|
| 37 |
+
uint8 public decimals;
|
| 38 |
+
uint public totalSupply;
|
| 39 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 40 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 41 |
+
|
| 42 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 43 |
+
function allowance(address _owner, address _spender) view returns (uint256 remaining);
|
| 44 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 45 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
contract ERC20 is ERC20Interface,SafeMath {
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
mapping(address => uint256) public balanceOf;
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
mapping(address => mapping(address => uint256)) allowed;
|
| 55 |
+
|
| 56 |
+
constructor(string _name) public {
|
| 57 |
+
name = _name;
|
| 58 |
+
symbol = "IMTC";
|
| 59 |
+
decimals = 4;
|
| 60 |
+
totalSupply = 3600000000000;
|
| 61 |
+
balanceOf[msg.sender] = totalSupply;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function transfer(address _to, uint256 _value) returns (bool success) {
|
| 66 |
+
require(_to != address(0));
|
| 67 |
+
require(balanceOf[msg.sender] >= _value);
|
| 68 |
+
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
|
| 69 |
+
|
| 70 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
|
| 71 |
+
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
emit Transfer(msg.sender, _to, _value);
|
| 75 |
+
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
| 81 |
+
require(_to != address(0));
|
| 82 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 83 |
+
require(balanceOf[_from] >= _value);
|
| 84 |
+
require(balanceOf[_to] + _value >= balanceOf[_to]);
|
| 85 |
+
|
| 86 |
+
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
|
| 87 |
+
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
|
| 88 |
+
|
| 89 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
|
| 90 |
+
|
| 91 |
+
emit Transfer(msg.sender, _to, _value);
|
| 92 |
+
return true;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function approve(address _spender, uint256 _value) returns (bool success) {
|
| 96 |
+
allowed[msg.sender][_spender] = _value;
|
| 97 |
+
|
| 98 |
+
emit Approval(msg.sender, _spender, _value);
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function allowance(address _owner, address _spender) view returns (uint256 remaining) {
|
| 103 |
+
return allowed[_owner][_spender];
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
contract owned {
|
| 110 |
+
address public owner;
|
| 111 |
+
|
| 112 |
+
constructor () public {
|
| 113 |
+
owner = msg.sender;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
modifier onlyOwner {
|
| 117 |
+
require(msg.sender == owner);
|
| 118 |
+
_;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
function transferOwnerShip(address newOwer) public onlyOwner {
|
| 122 |
+
owner = newOwer;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
contract SelfDesctructionContract is owned {
|
| 128 |
+
|
| 129 |
+
string public someValue;
|
| 130 |
+
modifier ownerRestricted {
|
| 131 |
+
require(owner == msg.sender);
|
| 132 |
+
_;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
function SelfDesctructionContract() {
|
| 136 |
+
owner = msg.sender;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function setSomeValue(string value){
|
| 140 |
+
someValue = value;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function destroyContract() ownerRestricted {
|
| 144 |
+
selfdestruct(owner);
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
contract AdvanceToken is ERC20, owned,SelfDesctructionContract{
|
| 151 |
+
|
| 152 |
+
mapping (address => bool) public frozenAccount;
|
| 153 |
+
|
| 154 |
+
event AddSupply(uint amount);
|
| 155 |
+
event FrozenFunds(address target, bool frozen);
|
| 156 |
+
event Burn(address target, uint amount);
|
| 157 |
+
|
| 158 |
+
constructor (string _name) ERC20(_name) public {
|
| 159 |
+
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
function mine(address target, uint amount) public onlyOwner {
|
| 163 |
+
totalSupply =SafeMath.safeAdd(totalSupply,amount) ;
|
| 164 |
+
balanceOf[target] = SafeMath.safeAdd(balanceOf[target],amount);
|
| 165 |
+
|
| 166 |
+
emit AddSupply(amount);
|
| 167 |
+
emit Transfer(0, target, amount);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function freezeAccount(address target, bool freeze) public onlyOwner {
|
| 171 |
+
frozenAccount[target] = freeze;
|
| 172 |
+
emit FrozenFunds(target, freeze);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 177 |
+
success = _transfer(msg.sender, _to, _value);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 182 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 183 |
+
success = _transfer(_from, _to, _value);
|
| 184 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value) ;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function _transfer(address _from, address _to, uint256 _value) internal returns (bool) {
|
| 188 |
+
require(_to != address(0));
|
| 189 |
+
require(!frozenAccount[_from]);
|
| 190 |
+
|
| 191 |
+
require(balanceOf[_from] >= _value);
|
| 192 |
+
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
|
| 193 |
+
|
| 194 |
+
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
|
| 195 |
+
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to],_value) ;
|
| 196 |
+
|
| 197 |
+
emit Transfer(_from, _to, _value);
|
| 198 |
+
return true;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 202 |
+
require(balanceOf[msg.sender] >= _value);
|
| 203 |
+
|
| 204 |
+
totalSupply =SafeMath.safeSub(totalSupply,_value) ;
|
| 205 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
|
| 206 |
+
|
| 207 |
+
emit Burn(msg.sender, _value);
|
| 208 |
+
return true;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 212 |
+
require(balanceOf[_from] >= _value);
|
| 213 |
+
require(allowed[_from][msg.sender] >= _value);
|
| 214 |
+
|
| 215 |
+
totalSupply =SafeMath.safeSub(totalSupply,_value) ;
|
| 216 |
+
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender], _value);
|
| 217 |
+
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value);
|
| 218 |
+
|
| 219 |
+
emit Burn(msg.sender, _value);
|
| 220 |
+
return true;
|
| 221 |
+
}
|
| 222 |
+
}
|
benchmark2/integer overflow/39.sol
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.23;contract Ownable {address public owner;event OwnershipRenounced(address indexed previousOwner);event OwnershipTransferred(address indexed previousOwner,address indexed newOwner);constructor() public {owner = msg.sender;}modifier onlyOwner() {require(msg.sender == owner);_;}function transferOwnership(address newOwner) public onlyOwner {require(newOwner != address(0));emit OwnershipTransferred(owner, newOwner);owner = newOwner;}function renounceOwnership() public onlyOwner {emit OwnershipRenounced(owner);owner = address(0);}}library SafeMath {function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {if (a == 0) {return 0;}c = a * b;assert(c / a == b);return c;}function div(uint256 a, uint256 b) internal pure returns (uint256) {return a / b;}function sub(uint256 a, uint256 b) internal pure returns (uint256) {assert(b <= a);return a - b;}function add(uint256 a, uint256 b) internal pure returns (uint256 c) {c = a + b;assert(c >= a);return c;}}contract ERC20Basic {function totalSupply() public view returns (uint256);function balanceOf(address who) public view returns (uint256);function transfer(address to, uint256 value) public returns (bool);event Transfer(address indexed from, address indexed to, uint256 value);}contract ERC20 is ERC20Basic {function allowance(address owner, address spender) public view returns (uint256);function transferFrom(address from, address to, uint256 value) public returns(bool);function approve(address spender, uint256 value) public returns (bool);event Approval(address indexed owner, address indexed spender, uint256 value);}contract BasicToken is ERC20Basic {using SafeMath for uint256;mapping(address => uint256) balances;uint256 totalSupply_;function totalSupply() public view returns (uint256) {return totalSupply_;}function transfer(address _to, uint256 _value) public returns (bool) {require(_to != address(0));require(_value <= balances[msg.sender]);balances[msg.sender] = balances[msg.sender].sub(_value);balances[_to] = balances[_to].add(_value);emit Transfer(msg.sender, _to, _value);return true;}function balanceOf(address _owner) public view returns (uint256) {return balances[_owner];}}contract StandardToken is ERC20, BasicToken {mapping (address => mapping (address => uint256)) internal allowed;function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {require(_to != address(0));require(_value <= balances[_from]);require(_value <= allowed[_from][msg.sender]);balances[_from] = balances[_from].sub(_value);balances[_to] = balances[_to].add(_value);allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);emit Transfer(_from, _to, _value);return true;}function approve(address _spender, uint256 _value) public returns (bool) {require((_value == 0 ) || (allowed[msg.sender][_spender] == 0));allowed[msg.sender][_spender] = _value;emit Approval(msg.sender, _spender, _value);return true;}function allowance(address _owner, address _spender) public view returns (uint256) {return allowed[_owner][_spender];}function increaseApproval(address _spender, uint _addedValue) public returns (bool){allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);return true;}function decreaseApproval(address _spender, uint _subtractedValue) public returns(bool) {uint oldValue = allowed[msg.sender][_spender];if (_subtractedValue > oldValue) {allowed[msg.sender][_spender] = 0;} else {allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);}emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);return true;}}contract TokenContract is StandardToken{string public constant name="SDKTOKEN";string public constant symbol="SDK"; uint8 public constant decimals=18;uint256 public constant INITIAL_SUPPLY=100000000000000000000;uint256 public constant MAX_SUPPLY = 100 * 10000 * 10000 * (10 **uint256(decimals));address public constant holder=0x968c9f1e66f40e2851de40e84e37d62566aab393;constructor() TokenContract() public {totalSupply_ = INITIAL_SUPPLY;balances[holder] = INITIAL_SUPPLY;emit Transfer(0x0, holder, INITIAL_SUPPLY);}function() payable public {revert();}}
|
benchmark2/integer overflow/394.sol
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.10;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
|
| 6 |
+
uint256 z = x + y;
|
| 7 |
+
assert((z >= x) && (z >= y));
|
| 8 |
+
return z;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function safeSubtract(uint256 x, uint256 y) internal returns(uint256) {
|
| 12 |
+
assert(x >= y);
|
| 13 |
+
uint256 z = x - y;
|
| 14 |
+
return z;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeMult(uint256 x, uint256 y) internal returns(uint256) {
|
| 18 |
+
uint256 z = x * y;
|
| 19 |
+
assert((x == 0)||(z/x == y));
|
| 20 |
+
return z;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
contract Token {
|
| 26 |
+
uint256 public totalSupply;
|
| 27 |
+
function balanceOf(address _owner) constant returns (uint256 balance);
|
| 28 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 29 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 30 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 31 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
|
| 32 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 33 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract StandardToken is Token , SafeMath {
|
| 40 |
+
|
| 41 |
+
bool public status = true;
|
| 42 |
+
modifier on() {
|
| 43 |
+
require(status == true);
|
| 44 |
+
_;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function transfer(address _to, uint256 _value) on returns (bool success) {
|
| 48 |
+
if (balances[msg.sender] >= _value && _value > 0 && _to != 0X0) {
|
| 49 |
+
balances[msg.sender] -= _value;
|
| 50 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 51 |
+
Transfer(msg.sender, _to, _value);
|
| 52 |
+
return true;
|
| 53 |
+
} else {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function transferFrom(address _from, address _to, uint256 _value) on returns (bool success) {
|
| 59 |
+
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
|
| 60 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 61 |
+
balances[_from] = safeSubtract(balances[_from],_value);
|
| 62 |
+
allowed[_from][msg.sender] = safeSubtract(allowed[_from][msg.sender],_value);
|
| 63 |
+
Transfer(_from, _to, _value);
|
| 64 |
+
return true;
|
| 65 |
+
} else {
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function balanceOf(address _owner) on constant returns (uint256 balance) {
|
| 71 |
+
return balances[_owner];
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function approve(address _spender, uint256 _value) on returns (bool success) {
|
| 75 |
+
allowed[msg.sender][_spender] = _value;
|
| 76 |
+
Approval(msg.sender, _spender, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function allowance(address _owner, address _spender) on constant returns (uint256 remaining) {
|
| 81 |
+
return allowed[_owner][_spender];
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
mapping (address => uint256) balances;
|
| 85 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
contract ExShellToken is StandardToken {
|
| 92 |
+
string public name = "ExShellToken";
|
| 93 |
+
uint8 public decimals = 8;
|
| 94 |
+
string public symbol = "ET";
|
| 95 |
+
bool private init =true;
|
| 96 |
+
function turnon() controller {
|
| 97 |
+
status = true;
|
| 98 |
+
}
|
| 99 |
+
function turnoff() controller {
|
| 100 |
+
status = false;
|
| 101 |
+
}
|
| 102 |
+
function ExShellToken() {
|
| 103 |
+
require(init==true);
|
| 104 |
+
totalSupply = 2000000000;
|
| 105 |
+
balances[0xa089a405b1df71a6155705fb2bce87df2a86a9e4] = totalSupply;
|
| 106 |
+
init = false;
|
| 107 |
+
}
|
| 108 |
+
address public controller1 =0xa089a405b1df71a6155705fb2bce87df2a86a9e4;
|
| 109 |
+
address public controller2 =0x5aa64423529e43a53c7ea037a07f94abc0c3a111;
|
| 110 |
+
|
| 111 |
+
modifier controller () {
|
| 112 |
+
require(msg.sender == controller1||msg.sender == controller2);
|
| 113 |
+
_;
|
| 114 |
+
}
|
| 115 |
+
}
|
benchmark2/integer overflow/423.sol
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity 0.4.16;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
library SafeMath {
|
| 5 |
+
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 6 |
+
uint256 c = a * b;
|
| 7 |
+
assert(a == 0 || c / a == b);
|
| 8 |
+
return c;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function div(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 12 |
+
|
| 13 |
+
uint256 c = a / b;
|
| 14 |
+
|
| 15 |
+
return c;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 19 |
+
assert(b <= a);
|
| 20 |
+
return a - b;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function add(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 24 |
+
uint256 c = a + b;
|
| 25 |
+
assert(c >= a);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
contract ERC20Basic {
|
| 32 |
+
uint256 public totalSupply;
|
| 33 |
+
function balanceOf(address who) public constant returns (uint256);
|
| 34 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 35 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract BasicToken is ERC20Basic {
|
| 40 |
+
using SafeMath for uint256;
|
| 41 |
+
|
| 42 |
+
mapping(address => uint256) balances;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 46 |
+
require(_to != address(0));
|
| 47 |
+
require(_value > 0 && _value <= balances[msg.sender]);
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 51 |
+
balances[_to] = balances[_to].add(_value);
|
| 52 |
+
Transfer(msg.sender, _to, _value);
|
| 53 |
+
return true;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
function balanceOf(address _owner) public constant returns (uint256 balance) {
|
| 58 |
+
return balances[_owner];
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
contract ERC20 is ERC20Basic {
|
| 64 |
+
function allowance(address owner, address spender) public constant returns (uint256);
|
| 65 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 66 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 67 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
contract StandardToken is ERC20, BasicToken {
|
| 73 |
+
|
| 74 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
| 79 |
+
require(_to != address(0));
|
| 80 |
+
require(_value > 0 && _value <= balances[_from]);
|
| 81 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 82 |
+
|
| 83 |
+
balances[_from] = balances[_from].sub(_value);
|
| 84 |
+
balances[_to] = balances[_to].add(_value);
|
| 85 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 86 |
+
Transfer(_from, _to, _value);
|
| 87 |
+
return true;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 92 |
+
allowed[msg.sender][_spender] = _value;
|
| 93 |
+
Approval(msg.sender, _spender, _value);
|
| 94 |
+
return true;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
|
| 99 |
+
return allowed[_owner][_spender];
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
contract Ownable {
|
| 105 |
+
address public owner;
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
function Ownable() {
|
| 113 |
+
owner = msg.sender;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
modifier onlyOwner() {
|
| 119 |
+
require(msg.sender == owner);
|
| 120 |
+
_;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 126 |
+
require(newOwner != address(0));
|
| 127 |
+
OwnershipTransferred(owner, newOwner);
|
| 128 |
+
owner = newOwner;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
contract Pausable is Ownable {
|
| 135 |
+
event Pause();
|
| 136 |
+
event Unpause();
|
| 137 |
+
|
| 138 |
+
bool public paused = false;
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
modifier whenNotPaused() {
|
| 143 |
+
require(!paused);
|
| 144 |
+
_;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
modifier whenPaused() {
|
| 149 |
+
require(paused);
|
| 150 |
+
_;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
function pause() onlyOwner whenNotPaused public {
|
| 155 |
+
paused = true;
|
| 156 |
+
Pause();
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
function unpause() onlyOwner whenPaused public {
|
| 161 |
+
paused = false;
|
| 162 |
+
Unpause();
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
contract PausableToken is StandardToken, Pausable {
|
| 169 |
+
mapping (address => bool) public frozenAccount;
|
| 170 |
+
event FrozenFunds(address target, bool frozen);
|
| 171 |
+
|
| 172 |
+
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
|
| 173 |
+
require(!frozenAccount[msg.sender]);
|
| 174 |
+
return super.transfer(_to, _value);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
|
| 178 |
+
require(!frozenAccount[_from]);
|
| 179 |
+
return super.transferFrom(_from, _to, _value);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
|
| 183 |
+
|
| 184 |
+
return super.approve(_spender, _value);
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) {
|
| 188 |
+
require(!frozenAccount[msg.sender]);
|
| 189 |
+
uint cnt = _receivers.length;
|
| 190 |
+
uint256 amount = uint256(cnt).mul(_value);
|
| 191 |
+
require(cnt > 0 && cnt <= 121);
|
| 192 |
+
require(_value > 0 && balances[msg.sender] >= amount);
|
| 193 |
+
|
| 194 |
+
balances[msg.sender] = balances[msg.sender].sub(amount);
|
| 195 |
+
for (uint i = 0; i < cnt; i++) {
|
| 196 |
+
require (_receivers[i] != 0x0);
|
| 197 |
+
balances[_receivers[i]] = balances[_receivers[i]].add(_value);
|
| 198 |
+
Transfer(msg.sender, _receivers[i], _value);
|
| 199 |
+
}
|
| 200 |
+
return true;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
function freezeAccount(address target, bool freeze) onlyOwner public {
|
| 204 |
+
frozenAccount[target] = freeze;
|
| 205 |
+
FrozenFunds(target, freeze);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
function batchFreeze(address[] addresses, bool freeze) onlyOwner public {
|
| 209 |
+
for (uint i = 0; i < addresses.length; i++) {
|
| 210 |
+
frozenAccount[addresses[i]] = freeze;
|
| 211 |
+
FrozenFunds(addresses[i], freeze);
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
contract AdvancedToken is PausableToken {
|
| 218 |
+
|
| 219 |
+
string public name = "Thailand Tourism Chain";
|
| 220 |
+
string public symbol = "THTC";
|
| 221 |
+
string public version = '3.0.0';
|
| 222 |
+
uint8 public decimals = 18;
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
function AdvancedToken() {
|
| 226 |
+
totalSupply = 9 * 10000 * 10000 * (10**(uint256(decimals)));
|
| 227 |
+
balances[msg.sender] = totalSupply;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
function () external payable {
|
| 231 |
+
|
| 232 |
+
revert();
|
| 233 |
+
}
|
| 234 |
+
}
|
benchmark2/integer overflow/440.sol
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity 0.4.24;
|
| 2 |
+
|
| 3 |
+
contract ERC20 {
|
| 4 |
+
function totalSupply() constant public returns (uint256 supply);
|
| 5 |
+
function balanceOf(address _owner) constant public returns (uint256 balance);
|
| 6 |
+
function transfer(address _to, uint256 _value) public returns (bool success);
|
| 7 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
|
| 8 |
+
function approve(address _spender, uint256 _value) public returns (bool success);
|
| 9 |
+
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
|
| 10 |
+
|
| 11 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 12 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
library SafeMath {
|
| 16 |
+
function safeSub(uint a, uint b) internal pure returns (uint) {
|
| 17 |
+
assert(b <= a);
|
| 18 |
+
return a - b;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function safeAdd(uint a, uint b) internal pure returns (uint) {
|
| 22 |
+
uint c = a + b;
|
| 23 |
+
assert(c >= a);
|
| 24 |
+
return c;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
contract EmanateToken is ERC20 {
|
| 29 |
+
|
| 30 |
+
using SafeMath for uint256;
|
| 31 |
+
|
| 32 |
+
string public constant name = "Emanate (MN8) Token";
|
| 33 |
+
string public constant symbol = "MN8";
|
| 34 |
+
uint256 public constant decimals = 18;
|
| 35 |
+
uint256 public constant totalTokens = 208000000 * (10 ** decimals);
|
| 36 |
+
|
| 37 |
+
mapping (address => uint256) public balances;
|
| 38 |
+
mapping (address => mapping (address => uint256)) public allowed;
|
| 39 |
+
|
| 40 |
+
bool public locked = true;
|
| 41 |
+
bool public burningEnabled = false;
|
| 42 |
+
address public owner;
|
| 43 |
+
address public burnAddress;
|
| 44 |
+
|
| 45 |
+
modifier unlocked (address _to) {
|
| 46 |
+
require(
|
| 47 |
+
owner == msg.sender ||
|
| 48 |
+
locked == false ||
|
| 49 |
+
allowance(owner, msg.sender) > 0 ||
|
| 50 |
+
(_to == burnAddress && burningEnabled == true)
|
| 51 |
+
);
|
| 52 |
+
_;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
constructor () public {
|
| 56 |
+
balances[msg.sender] = totalTokens;
|
| 57 |
+
owner = msg.sender;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function totalSupply() public view returns (uint256) {
|
| 61 |
+
return totalTokens;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function transfer(address _to, uint _tokens) unlocked(_to) public returns (bool success) {
|
| 66 |
+
balances[msg.sender] = balances[msg.sender].safeSub(_tokens);
|
| 67 |
+
balances[_to] = balances[_to].safeAdd(_tokens);
|
| 68 |
+
emit Transfer(msg.sender, _to, _tokens);
|
| 69 |
+
return true;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
function transferFrom(address from, address _to, uint _tokens) unlocked(_to) public returns (bool success) {
|
| 73 |
+
balances[from] = balances[from].safeSub(_tokens);
|
| 74 |
+
allowed[from][msg.sender] = allowed[from][msg.sender].safeSub(_tokens);
|
| 75 |
+
balances[_to] = balances[_to].safeAdd(_tokens);
|
| 76 |
+
emit Transfer(from, _to, _tokens);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function balanceOf(address _owner) constant public returns (uint256) {
|
| 81 |
+
return balances[_owner];
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
function approve(address _spender, uint256 _value) unlocked(_spender) public returns (bool) {
|
| 86 |
+
allowed[msg.sender][_spender] = _value;
|
| 87 |
+
emit Approval(msg.sender, _spender, _value);
|
| 88 |
+
return true;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
|
| 92 |
+
return allowed[_owner][_spender];
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function setBurnAddress (address _burnAddress) public {
|
| 96 |
+
require(msg.sender == owner);
|
| 97 |
+
burningEnabled = true;
|
| 98 |
+
burnAddress = _burnAddress;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function unlock () public {
|
| 102 |
+
require(msg.sender == owner);
|
| 103 |
+
locked = false;
|
| 104 |
+
owner = 0x0000000000000000000000000000000000000001;
|
| 105 |
+
}
|
| 106 |
+
}
|
benchmark2/integer overflow/451.sol
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.10;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
|
| 6 |
+
uint256 z = x + y;
|
| 7 |
+
assert((z >= x) && (z >= y));
|
| 8 |
+
return z;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function safeSubtract(uint256 x, uint256 y) internal returns(uint256) {
|
| 12 |
+
assert(x >= y);
|
| 13 |
+
uint256 z = x - y;
|
| 14 |
+
return z;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeMult(uint256 x, uint256 y) internal returns(uint256) {
|
| 18 |
+
uint256 z = x * y;
|
| 19 |
+
assert((x == 0)||(z/x == y));
|
| 20 |
+
return z;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
contract Token {
|
| 26 |
+
uint256 public totalSupply;
|
| 27 |
+
function balanceOf(address _owner) constant returns (uint256 balance);
|
| 28 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 29 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 30 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 31 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
|
| 32 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 33 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract StandardToken is Token , SafeMath {
|
| 40 |
+
|
| 41 |
+
bool public status = true;
|
| 42 |
+
modifier on() {
|
| 43 |
+
require(status == true);
|
| 44 |
+
_;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function transfer(address _to, uint256 _value) on returns (bool success) {
|
| 48 |
+
if (balances[msg.sender] >= _value && _value > 0 && _to != 0X0) {
|
| 49 |
+
balances[msg.sender] -= _value;
|
| 50 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 51 |
+
Transfer(msg.sender, _to, _value);
|
| 52 |
+
return true;
|
| 53 |
+
} else {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function transferFrom(address _from, address _to, uint256 _value) on returns (bool success) {
|
| 59 |
+
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
|
| 60 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 61 |
+
balances[_from] = safeSubtract(balances[_from],_value);
|
| 62 |
+
allowed[_from][msg.sender] = safeSubtract(allowed[_from][msg.sender],_value);
|
| 63 |
+
Transfer(_from, _to, _value);
|
| 64 |
+
return true;
|
| 65 |
+
} else {
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function balanceOf(address _owner) on constant returns (uint256 balance) {
|
| 71 |
+
return balances[_owner];
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function approve(address _spender, uint256 _value) on returns (bool success) {
|
| 75 |
+
allowed[msg.sender][_spender] = _value;
|
| 76 |
+
Approval(msg.sender, _spender, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function allowance(address _owner, address _spender) on constant returns (uint256 remaining) {
|
| 81 |
+
return allowed[_owner][_spender];
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
mapping (address => uint256) balances;
|
| 85 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
contract HuobiPoolToken is StandardToken {
|
| 92 |
+
string public name = "HuobiPoolToken";
|
| 93 |
+
uint8 public decimals = 8;
|
| 94 |
+
string public symbol = "HPT";
|
| 95 |
+
bool private init =true;
|
| 96 |
+
function turnon() controller {
|
| 97 |
+
status = true;
|
| 98 |
+
}
|
| 99 |
+
function turnoff() controller {
|
| 100 |
+
status = false;
|
| 101 |
+
}
|
| 102 |
+
function HuobiPoolToken() {
|
| 103 |
+
require(init==true);
|
| 104 |
+
totalSupply = 100000000000;
|
| 105 |
+
balances[0x3567cafb8bf2a83bbea4e79f3591142fb4ebe86d] = totalSupply;
|
| 106 |
+
init = false;
|
| 107 |
+
}
|
| 108 |
+
address public controller1 =0x14de73a5602ee3769fb7a968daAFF23A4A6D4Bb5;
|
| 109 |
+
address public controller2 =0x3567cafb8bf2a83bbea4e79f3591142fb4ebe86d;
|
| 110 |
+
|
| 111 |
+
modifier controller () {
|
| 112 |
+
require(msg.sender == controller1||msg.sender == controller2);
|
| 113 |
+
_;
|
| 114 |
+
}
|
| 115 |
+
}
|
benchmark2/integer overflow/453.sol
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.17;
|
| 2 |
+
|
| 3 |
+
contract ERC20Basic {
|
| 4 |
+
function totalSupply() public view returns (uint256);
|
| 5 |
+
function balanceOf(address who) public view returns (uint256);
|
| 6 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 7 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
contract ERC20 is ERC20Basic {
|
| 11 |
+
function allowance(address owner, address spender) public view returns (uint256);
|
| 12 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 13 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 14 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
library SafeMath {
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 22 |
+
if (a == 0) {
|
| 23 |
+
return 0;
|
| 24 |
+
}
|
| 25 |
+
uint256 c = a * b;
|
| 26 |
+
assert(c / a == b);
|
| 27 |
+
return c;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 32 |
+
|
| 33 |
+
uint256 c = a / b;
|
| 34 |
+
|
| 35 |
+
return c;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 40 |
+
assert(b <= a);
|
| 41 |
+
return a - b;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 46 |
+
uint256 c = a + b;
|
| 47 |
+
assert(c >= a);
|
| 48 |
+
return c;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
contract BasicToken is ERC20Basic {
|
| 54 |
+
using SafeMath for uint256;
|
| 55 |
+
|
| 56 |
+
mapping(address => uint256) balances;
|
| 57 |
+
|
| 58 |
+
uint256 totalSupply_;
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
function totalSupply() public view returns (uint256) {
|
| 62 |
+
return totalSupply_;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 67 |
+
require(_to != address(0));
|
| 68 |
+
require(_value <= balances[msg.sender]);
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 72 |
+
balances[_to] = balances[_to].add(_value);
|
| 73 |
+
Transfer(msg.sender, _to, _value);
|
| 74 |
+
return true;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
function balanceOf(address _owner) public view returns (uint256 balance) {
|
| 79 |
+
return balances[_owner];
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
contract StandardToken is ERC20, BasicToken {
|
| 85 |
+
|
| 86 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
| 91 |
+
require(_to != address(0));
|
| 92 |
+
require(_value <= balances[_from]);
|
| 93 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 94 |
+
|
| 95 |
+
balances[_from] = balances[_from].sub(_value);
|
| 96 |
+
balances[_to] = balances[_to].add(_value);
|
| 97 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 98 |
+
Transfer(_from, _to, _value);
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 104 |
+
allowed[msg.sender][_spender] = _value;
|
| 105 |
+
Approval(msg.sender, _spender, _value);
|
| 106 |
+
return true;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
function allowance(address _owner, address _spender) public view returns (uint256) {
|
| 111 |
+
return allowed[_owner][_spender];
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
|
| 116 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 117 |
+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 118 |
+
return true;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
|
| 123 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 124 |
+
if (_subtractedValue > oldValue) {
|
| 125 |
+
allowed[msg.sender][_spender] = 0;
|
| 126 |
+
} else {
|
| 127 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 128 |
+
}
|
| 129 |
+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 130 |
+
return true;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
contract DAPL is StandardToken {
|
| 136 |
+
|
| 137 |
+
string public name = "DAPL";
|
| 138 |
+
|
| 139 |
+
string public symbol = "DAPL";
|
| 140 |
+
|
| 141 |
+
uint8 public decimals = 8;
|
| 142 |
+
|
| 143 |
+
uint public INITIAL_SUPPLY = 1000000000e8;
|
| 144 |
+
|
| 145 |
+
constructor() public {
|
| 146 |
+
|
| 147 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 148 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 149 |
+
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
}
|
benchmark2/integer overflow/462.sol
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
contract ERC20Basic {
|
| 7 |
+
function totalSupply() public view returns (uint256);
|
| 8 |
+
function balanceOf(address who) public view returns (uint256);
|
| 9 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 10 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
library SafeMath {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if (a == 0) {
|
| 24 |
+
return 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
c = a * b;
|
| 28 |
+
assert(c / a == b);
|
| 29 |
+
return c;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
return a / b;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 42 |
+
assert(b <= a);
|
| 43 |
+
return a - b;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 48 |
+
c = a + b;
|
| 49 |
+
assert(c >= a);
|
| 50 |
+
return c;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
contract BasicToken is ERC20Basic {
|
| 58 |
+
using SafeMath for uint256;
|
| 59 |
+
|
| 60 |
+
mapping(address => uint256) balances;
|
| 61 |
+
|
| 62 |
+
uint256 totalSupply_;
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function totalSupply() public view returns (uint256) {
|
| 66 |
+
return totalSupply_;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 71 |
+
require(_to != address(0));
|
| 72 |
+
require(_value <= balances[msg.sender]);
|
| 73 |
+
|
| 74 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 75 |
+
balances[_to] = balances[_to].add(_value);
|
| 76 |
+
emit Transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 82 |
+
return balances[_owner];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
contract ERC20 is ERC20Basic {
|
| 91 |
+
function allowance(address owner, address spender)
|
| 92 |
+
public view returns (uint256);
|
| 93 |
+
|
| 94 |
+
function transferFrom(address from, address to, uint256 value)
|
| 95 |
+
public returns (bool);
|
| 96 |
+
|
| 97 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 98 |
+
event Approval(
|
| 99 |
+
address indexed owner,
|
| 100 |
+
address indexed spender,
|
| 101 |
+
uint256 value
|
| 102 |
+
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
contract StandardToken is ERC20, BasicToken {
|
| 109 |
+
|
| 110 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function transferFrom(
|
| 115 |
+
address _from,
|
| 116 |
+
address _to,
|
| 117 |
+
uint256 _value
|
| 118 |
+
)
|
| 119 |
+
public
|
| 120 |
+
returns (bool)
|
| 121 |
+
{
|
| 122 |
+
require(_to != address(0));
|
| 123 |
+
require(_value <= balances[_from]);
|
| 124 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 125 |
+
|
| 126 |
+
balances[_from] = balances[_from].sub(_value);
|
| 127 |
+
balances[_to] = balances[_to].add(_value);
|
| 128 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 129 |
+
emit Transfer(_from, _to, _value);
|
| 130 |
+
return true;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 135 |
+
allowed[msg.sender][_spender] = _value;
|
| 136 |
+
emit Approval(msg.sender, _spender, _value);
|
| 137 |
+
return true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function allowance(
|
| 142 |
+
address _owner,
|
| 143 |
+
address _spender
|
| 144 |
+
)
|
| 145 |
+
public
|
| 146 |
+
view
|
| 147 |
+
returns (uint256)
|
| 148 |
+
{
|
| 149 |
+
return allowed[_owner][_spender];
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
function increaseApproval(
|
| 154 |
+
address _spender,
|
| 155 |
+
uint256 _addedValue
|
| 156 |
+
)
|
| 157 |
+
public
|
| 158 |
+
returns (bool)
|
| 159 |
+
{
|
| 160 |
+
allowed[msg.sender][_spender] = (
|
| 161 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 162 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function decreaseApproval(
|
| 168 |
+
address _spender,
|
| 169 |
+
uint256 _subtractedValue
|
| 170 |
+
)
|
| 171 |
+
public
|
| 172 |
+
returns (bool)
|
| 173 |
+
{
|
| 174 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 175 |
+
if (_subtractedValue > oldValue) {
|
| 176 |
+
allowed[msg.sender][_spender] = 0;
|
| 177 |
+
} else {
|
| 178 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 179 |
+
}
|
| 180 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 181 |
+
return true;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
contract Ownable {
|
| 190 |
+
address public owner;
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 194 |
+
event OwnershipTransferred(
|
| 195 |
+
address indexed previousOwner,
|
| 196 |
+
address indexed newOwner
|
| 197 |
+
);
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
constructor() public {
|
| 202 |
+
owner = msg.sender;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
modifier onlyOwner() {
|
| 207 |
+
require(msg.sender == owner);
|
| 208 |
+
_;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
function renounceOwnership() public onlyOwner {
|
| 213 |
+
emit OwnershipRenounced(owner);
|
| 214 |
+
owner = address(0);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 219 |
+
_transferOwnership(_newOwner);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
function _transferOwnership(address _newOwner) internal {
|
| 224 |
+
require(_newOwner != address(0));
|
| 225 |
+
emit OwnershipTransferred(owner, _newOwner);
|
| 226 |
+
owner = _newOwner;
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
contract MintableToken is StandardToken, Ownable {
|
| 234 |
+
event Mint(address indexed to, uint256 amount);
|
| 235 |
+
event MintFinished();
|
| 236 |
+
|
| 237 |
+
bool public mintingFinished = false;
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
modifier canMint() {
|
| 241 |
+
require(!mintingFinished);
|
| 242 |
+
_;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
modifier hasMintPermission() {
|
| 246 |
+
require(msg.sender == owner);
|
| 247 |
+
_;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
function mint(
|
| 252 |
+
address _to,
|
| 253 |
+
uint256 _amount
|
| 254 |
+
)
|
| 255 |
+
hasMintPermission
|
| 256 |
+
canMint
|
| 257 |
+
public
|
| 258 |
+
returns (bool)
|
| 259 |
+
{
|
| 260 |
+
totalSupply_ = totalSupply_.add(_amount);
|
| 261 |
+
balances[_to] = balances[_to].add(_amount);
|
| 262 |
+
emit Mint(_to, _amount);
|
| 263 |
+
emit Transfer(address(0), _to, _amount);
|
| 264 |
+
return true;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
function finishMinting() onlyOwner canMint public returns (bool) {
|
| 269 |
+
mintingFinished = true;
|
| 270 |
+
emit MintFinished();
|
| 271 |
+
return true;
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
contract Pausable is Ownable {
|
| 279 |
+
event Pause();
|
| 280 |
+
event Unpause();
|
| 281 |
+
|
| 282 |
+
bool public paused = false;
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
modifier whenNotPaused() {
|
| 287 |
+
require(!paused);
|
| 288 |
+
_;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
modifier whenPaused() {
|
| 293 |
+
require(paused);
|
| 294 |
+
_;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
function pause() onlyOwner whenNotPaused public {
|
| 299 |
+
paused = true;
|
| 300 |
+
emit Pause();
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
function unpause() onlyOwner whenPaused public {
|
| 305 |
+
paused = false;
|
| 306 |
+
emit Unpause();
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
contract ApprovalAndCallFallBack {
|
| 313 |
+
function receiveApproval(address _owner, uint256 _amount, address _token, bytes _data) public returns (bool);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
contract TransferAndCallFallBack {
|
| 319 |
+
function receiveToken(address _owner, uint256 _amount, address _token, bytes _data) public returns (bool);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
contract MuzikaCoin is MintableToken, Pausable {
|
| 325 |
+
string public name = 'Muzika';
|
| 326 |
+
string public symbol = 'MZK';
|
| 327 |
+
uint8 public decimals = 18;
|
| 328 |
+
|
| 329 |
+
event Burn(address indexed burner, uint256 value);
|
| 330 |
+
|
| 331 |
+
constructor(uint256 initialSupply) public {
|
| 332 |
+
totalSupply_ = initialSupply;
|
| 333 |
+
balances[msg.sender] = initialSupply;
|
| 334 |
+
emit Transfer(address(0), msg.sender, initialSupply);
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
function burn(uint256 _value) public onlyOwner {
|
| 339 |
+
_burn(msg.sender, _value);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
function _burn(address _who, uint256 _value) internal {
|
| 343 |
+
require(_value <= balances[_who]);
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
balances[_who] = balances[_who].sub(_value);
|
| 348 |
+
totalSupply_ = totalSupply_.sub(_value);
|
| 349 |
+
emit Burn(_who, _value);
|
| 350 |
+
emit Transfer(_who, address(0), _value);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
|
| 354 |
+
return super.transfer(_to, _value);
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
|
| 358 |
+
return super.transferFrom(_from, _to, _value);
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
function increaseApprovalAndCall(address _spender, uint _addedValue, bytes _data) public returns (bool) {
|
| 362 |
+
require(_spender != address(this));
|
| 363 |
+
|
| 364 |
+
increaseApproval(_spender, _addedValue);
|
| 365 |
+
|
| 366 |
+
require(
|
| 367 |
+
ApprovalAndCallFallBack(_spender).receiveApproval(
|
| 368 |
+
msg.sender,
|
| 369 |
+
_addedValue,
|
| 370 |
+
address(this),
|
| 371 |
+
_data
|
| 372 |
+
)
|
| 373 |
+
);
|
| 374 |
+
|
| 375 |
+
return true;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
function transferAndCall(address _to, uint _value, bytes _data) public returns (bool) {
|
| 379 |
+
require(_to != address(this));
|
| 380 |
+
|
| 381 |
+
transfer(_to, _value);
|
| 382 |
+
|
| 383 |
+
require(
|
| 384 |
+
TransferAndCallFallBack(_to).receiveToken(
|
| 385 |
+
msg.sender,
|
| 386 |
+
_value,
|
| 387 |
+
address(this),
|
| 388 |
+
_data
|
| 389 |
+
)
|
| 390 |
+
);
|
| 391 |
+
|
| 392 |
+
return true;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
function tokenDrain(ERC20 _token, uint256 _amount) public onlyOwner {
|
| 396 |
+
_token.transfer(owner, _amount);
|
| 397 |
+
}
|
| 398 |
+
}
|
benchmark2/integer overflow/465.sol
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.10;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
|
| 6 |
+
uint256 z = x + y;
|
| 7 |
+
assert((z >= x) && (z >= y));
|
| 8 |
+
return z;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function safeSubtract(uint256 x, uint256 y) internal returns(uint256) {
|
| 12 |
+
assert(x >= y);
|
| 13 |
+
uint256 z = x - y;
|
| 14 |
+
return z;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function safeMult(uint256 x, uint256 y) internal returns(uint256) {
|
| 18 |
+
uint256 z = x * y;
|
| 19 |
+
assert((x == 0)||(z/x == y));
|
| 20 |
+
return z;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
contract Token {
|
| 26 |
+
uint256 public totalSupply;
|
| 27 |
+
function balanceOf(address _owner) constant returns (uint256 balance);
|
| 28 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 29 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 30 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 31 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
|
| 32 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 33 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract StandardToken is Token , SafeMath {
|
| 40 |
+
|
| 41 |
+
bool public status = true;
|
| 42 |
+
modifier on() {
|
| 43 |
+
require(status == true);
|
| 44 |
+
_;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function transfer(address _to, uint256 _value) on returns (bool success) {
|
| 48 |
+
if (balances[msg.sender] >= _value && _value > 0 && _to != 0X0) {
|
| 49 |
+
balances[msg.sender] -= _value;
|
| 50 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 51 |
+
Transfer(msg.sender, _to, _value);
|
| 52 |
+
return true;
|
| 53 |
+
} else {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function transferFrom(address _from, address _to, uint256 _value) on returns (bool success) {
|
| 59 |
+
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
|
| 60 |
+
balances[_to] = safeAdd(balances[_to],_value);
|
| 61 |
+
balances[_from] = safeSubtract(balances[_from],_value);
|
| 62 |
+
allowed[_from][msg.sender] = safeSubtract(allowed[_from][msg.sender],_value);
|
| 63 |
+
Transfer(_from, _to, _value);
|
| 64 |
+
return true;
|
| 65 |
+
} else {
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function balanceOf(address _owner) on constant returns (uint256 balance) {
|
| 71 |
+
return balances[_owner];
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function approve(address _spender, uint256 _value) on returns (bool success) {
|
| 75 |
+
allowed[msg.sender][_spender] = _value;
|
| 76 |
+
Approval(msg.sender, _spender, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function allowance(address _owner, address _spender) on constant returns (uint256 remaining) {
|
| 81 |
+
return allowed[_owner][_spender];
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
mapping (address => uint256) balances;
|
| 85 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
contract ExShellToken is StandardToken {
|
| 92 |
+
string public name = "ExShellToken";
|
| 93 |
+
uint8 public decimals = 8;
|
| 94 |
+
string public symbol = "ET";
|
| 95 |
+
bool private init =true;
|
| 96 |
+
function turnon() controller {
|
| 97 |
+
status = true;
|
| 98 |
+
}
|
| 99 |
+
function turnoff() controller {
|
| 100 |
+
status = false;
|
| 101 |
+
}
|
| 102 |
+
function ExShellToken() {
|
| 103 |
+
require(init==true);
|
| 104 |
+
totalSupply = 2000000000;
|
| 105 |
+
balances[0xa089a405b1df71a6155705fb2bce87df2a86a9e4] = totalSupply;
|
| 106 |
+
init = false;
|
| 107 |
+
}
|
| 108 |
+
address public controller1 =0xa089a405b1df71a6155705fb2bce87df2a86a9e4;
|
| 109 |
+
address public controller2 =0x5aa64423529e43a53c7ea037a07f94abc0c3a111;
|
| 110 |
+
|
| 111 |
+
modifier controller () {
|
| 112 |
+
require(msg.sender == controller1||msg.sender == controller2);
|
| 113 |
+
_;
|
| 114 |
+
}
|
| 115 |
+
}
|
benchmark2/integer overflow/469.sol
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
if (a == 0) {
|
| 11 |
+
return 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
c = a * b;
|
| 15 |
+
assert(c / a == b);
|
| 16 |
+
return c;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 20 |
+
return a / b;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 24 |
+
assert(b <= a);
|
| 25 |
+
return a - b;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 29 |
+
c = a + b;
|
| 30 |
+
assert(c >= a);
|
| 31 |
+
return c;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
contract ERC20 {
|
| 37 |
+
function totalSupply() public view returns (uint256);
|
| 38 |
+
function balanceOf(address who) public view returns (uint256);
|
| 39 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 40 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 41 |
+
|
| 42 |
+
function allowance(address owner, address spender)
|
| 43 |
+
public view returns (uint256);
|
| 44 |
+
|
| 45 |
+
function transferFrom(address from, address to, uint256 value)
|
| 46 |
+
public returns (bool);
|
| 47 |
+
|
| 48 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 49 |
+
event Approval(
|
| 50 |
+
address indexed owner,
|
| 51 |
+
address indexed spender,
|
| 52 |
+
uint256 value
|
| 53 |
+
);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
contract BasicToken is ERC20 {
|
| 57 |
+
using SafeMath for uint256;
|
| 58 |
+
|
| 59 |
+
mapping(address => uint256) balances;
|
| 60 |
+
|
| 61 |
+
uint256 totalSupply_;
|
| 62 |
+
|
| 63 |
+
function totalSupply() public view returns (uint256) {
|
| 64 |
+
return totalSupply_;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 68 |
+
require(_to != address(0));
|
| 69 |
+
require(_value <= balances[msg.sender]);
|
| 70 |
+
|
| 71 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 72 |
+
balances[_to] = balances[_to].add(_value);
|
| 73 |
+
emit Transfer(msg.sender, _to, _value);
|
| 74 |
+
return true;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 78 |
+
return balances[_owner];
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
contract StandardToken is ERC20, BasicToken {
|
| 85 |
+
|
| 86 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 87 |
+
|
| 88 |
+
function transferFrom(
|
| 89 |
+
address _from,
|
| 90 |
+
address _to,
|
| 91 |
+
uint256 _value
|
| 92 |
+
)
|
| 93 |
+
public
|
| 94 |
+
returns (bool)
|
| 95 |
+
{
|
| 96 |
+
require(_to != address(0));
|
| 97 |
+
require(_value <= balances[_from]);
|
| 98 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 99 |
+
|
| 100 |
+
balances[_from] = balances[_from].sub(_value);
|
| 101 |
+
balances[_to] = balances[_to].add(_value);
|
| 102 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 103 |
+
emit Transfer(_from, _to, _value);
|
| 104 |
+
return true;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 108 |
+
allowed[msg.sender][_spender] = _value;
|
| 109 |
+
emit Approval(msg.sender, _spender, _value);
|
| 110 |
+
return true;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function allowance(
|
| 114 |
+
address _owner,
|
| 115 |
+
address _spender
|
| 116 |
+
)
|
| 117 |
+
public
|
| 118 |
+
view
|
| 119 |
+
returns (uint256)
|
| 120 |
+
{
|
| 121 |
+
return allowed[_owner][_spender];
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
function increaseApproval(
|
| 125 |
+
address _spender,
|
| 126 |
+
uint256 _addedValue
|
| 127 |
+
)
|
| 128 |
+
public
|
| 129 |
+
returns (bool)
|
| 130 |
+
{
|
| 131 |
+
allowed[msg.sender][_spender] = (
|
| 132 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 133 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 134 |
+
return true;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
function decreaseApproval(
|
| 138 |
+
address _spender,
|
| 139 |
+
uint256 _subtractedValue
|
| 140 |
+
)
|
| 141 |
+
public
|
| 142 |
+
returns (bool)
|
| 143 |
+
{
|
| 144 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 145 |
+
if (_subtractedValue > oldValue) {
|
| 146 |
+
allowed[msg.sender][_spender] = 0;
|
| 147 |
+
} else {
|
| 148 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 149 |
+
}
|
| 150 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 151 |
+
return true;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
contract ShopCornToken is StandardToken {
|
| 158 |
+
|
| 159 |
+
string public constant name = "ShopCornToken";
|
| 160 |
+
string public constant symbol = "SHC";
|
| 161 |
+
uint8 public constant decimals = 8;
|
| 162 |
+
|
| 163 |
+
uint256 public constant INITIAL_SUPPLY = 2000000000 * (10 ** uint256(decimals));
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
constructor() public {
|
| 167 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 168 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 169 |
+
emit Transfer(address(0), msg.sender, INITIAL_SUPPLY);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
}
|
benchmark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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.23;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract ERC20 {
|
| 5 |
+
function totalSupply() public view returns (uint256);
|
| 6 |
+
function balanceOf(address who) public view returns (uint256);
|
| 7 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 8 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 9 |
+
|
| 10 |
+
function allowance(address owner, address spender)
|
| 11 |
+
public view returns (uint256);
|
| 12 |
+
|
| 13 |
+
function transferFrom(address from, address to, uint256 value)
|
| 14 |
+
public returns (bool);
|
| 15 |
+
|
| 16 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 17 |
+
event Approval(
|
| 18 |
+
address indexed owner,
|
| 19 |
+
address indexed spender,
|
| 20 |
+
uint256 value
|
| 21 |
+
);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
library SafeMath {
|
| 26 |
+
|
| 27 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 28 |
+
if (a == 0) {
|
| 29 |
+
return 0;
|
| 30 |
+
}
|
| 31 |
+
c = a * b;
|
| 32 |
+
assert(c / a == b);
|
| 33 |
+
return c;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
return a / b;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 46 |
+
assert(b <= a);
|
| 47 |
+
return a - b;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 52 |
+
c = a + b;
|
| 53 |
+
assert(c >= a);
|
| 54 |
+
return c;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
contract MyanmarGoldToken is ERC20 {
|
| 60 |
+
using SafeMath for uint256;
|
| 61 |
+
|
| 62 |
+
mapping(address => uint256) balances;
|
| 63 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 64 |
+
|
| 65 |
+
uint256 totalSupply_;
|
| 66 |
+
string public constant name = "MyanmarGoldToken";
|
| 67 |
+
string public constant symbol = "MGC";
|
| 68 |
+
uint8 public constant decimals = 18;
|
| 69 |
+
|
| 70 |
+
event Burn(address indexed burner, uint256 value);
|
| 71 |
+
|
| 72 |
+
constructor(address _icoAddress) public {
|
| 73 |
+
totalSupply_ = 1000000000 * (10 ** uint256(decimals));
|
| 74 |
+
balances[_icoAddress] = totalSupply_;
|
| 75 |
+
emit Transfer(address(0), _icoAddress, totalSupply_);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
function totalSupply() public view returns (uint256) {
|
| 80 |
+
return totalSupply_;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 85 |
+
require(_to != address(0));
|
| 86 |
+
require(_value <= balances[msg.sender]);
|
| 87 |
+
|
| 88 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 89 |
+
balances[_to] = balances[_to].add(_value);
|
| 90 |
+
emit Transfer(msg.sender, _to, _value);
|
| 91 |
+
return true;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
function batchTransfer(address[] _tos, uint256[] _values) public returns (bool) {
|
| 96 |
+
require(_tos.length == _values.length);
|
| 97 |
+
uint256 arrayLength = _tos.length;
|
| 98 |
+
for(uint256 i = 0; i < arrayLength; i++) {
|
| 99 |
+
transfer(_tos[i], _values[i]);
|
| 100 |
+
}
|
| 101 |
+
return true;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 106 |
+
return balances[_owner];
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
function transferFrom(
|
| 111 |
+
address _from,
|
| 112 |
+
address _to,
|
| 113 |
+
uint256 _value
|
| 114 |
+
)
|
| 115 |
+
public
|
| 116 |
+
returns (bool)
|
| 117 |
+
{
|
| 118 |
+
require(_to != address(0));
|
| 119 |
+
require(_value <= balances[_from]);
|
| 120 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 121 |
+
|
| 122 |
+
balances[_from] = balances[_from].sub(_value);
|
| 123 |
+
balances[_to] = balances[_to].add(_value);
|
| 124 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 125 |
+
emit Transfer(_from, _to, _value);
|
| 126 |
+
return true;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 131 |
+
allowed[msg.sender][_spender] = _value;
|
| 132 |
+
emit Approval(msg.sender, _spender, _value);
|
| 133 |
+
return true;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
function allowance(
|
| 138 |
+
address _owner,
|
| 139 |
+
address _spender
|
| 140 |
+
)
|
| 141 |
+
public
|
| 142 |
+
view
|
| 143 |
+
returns (uint256)
|
| 144 |
+
{
|
| 145 |
+
return allowed[_owner][_spender];
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
function increaseApproval(
|
| 150 |
+
address _spender,
|
| 151 |
+
uint _addedValue
|
| 152 |
+
)
|
| 153 |
+
public
|
| 154 |
+
returns (bool)
|
| 155 |
+
{
|
| 156 |
+
allowed[msg.sender][_spender] = (
|
| 157 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 158 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 159 |
+
return true;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
function decreaseApproval(
|
| 164 |
+
address _spender,
|
| 165 |
+
uint _subtractedValue
|
| 166 |
+
)
|
| 167 |
+
public
|
| 168 |
+
returns (bool)
|
| 169 |
+
{
|
| 170 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 171 |
+
if (_subtractedValue > oldValue) {
|
| 172 |
+
allowed[msg.sender][_spender] = 0;
|
| 173 |
+
} else {
|
| 174 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 175 |
+
}
|
| 176 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 177 |
+
return true;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
function burn(uint256 _value) public {
|
| 182 |
+
_burn(msg.sender, _value);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
function _burn(address _who, uint256 _value) internal {
|
| 186 |
+
require(_value <= balances[_who]);
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
balances[_who] = balances[_who].sub(_value);
|
| 191 |
+
totalSupply_ = totalSupply_.sub(_value);
|
| 192 |
+
emit Burn(_who, _value);
|
| 193 |
+
emit Transfer(_who, address(0), _value);
|
| 194 |
+
}
|
| 195 |
+
}
|
benchmark2/integer overflow/508.sol
ADDED
|
@@ -0,0 +1,1089 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.23;
|
| 2 |
+
|
| 3 |
+
library SafeMath {
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 7 |
+
if (a == 0) {
|
| 8 |
+
return 0;
|
| 9 |
+
}
|
| 10 |
+
c = a * b;
|
| 11 |
+
require(c / a == b, "Overflow - Multiplication");
|
| 12 |
+
return c;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 17 |
+
return a / b;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 22 |
+
require(b <= a, "Underflow - Subtraction");
|
| 23 |
+
return a - b;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 28 |
+
c = a + b;
|
| 29 |
+
require(c >= a, "Overflow - Addition");
|
| 30 |
+
return c;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
library Contract {
|
| 35 |
+
|
| 36 |
+
using SafeMath for uint;
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
modifier conditions(function () pure first, function () pure last) {
|
| 42 |
+
first();
|
| 43 |
+
_;
|
| 44 |
+
last();
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
bytes32 internal constant EXEC_PERMISSIONS = keccak256('script_exec_permissions');
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
function authorize(address _script_exec) internal view {
|
| 58 |
+
|
| 59 |
+
initialize();
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
bytes32 perms = EXEC_PERMISSIONS;
|
| 63 |
+
bool authorized;
|
| 64 |
+
assembly {
|
| 65 |
+
|
| 66 |
+
mstore(0, _script_exec)
|
| 67 |
+
mstore(0x20, perms)
|
| 68 |
+
|
| 69 |
+
mstore(0, keccak256(0x0c, 0x34))
|
| 70 |
+
|
| 71 |
+
mstore(0x20, mload(0x80))
|
| 72 |
+
|
| 73 |
+
authorized := sload(keccak256(0, 0x40))
|
| 74 |
+
}
|
| 75 |
+
if (!authorized)
|
| 76 |
+
revert("Sender is not authorized as a script exec address");
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
function initialize() internal view {
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
require(freeMem() == 0x80, "Memory allocated prior to execution");
|
| 92 |
+
|
| 93 |
+
assembly {
|
| 94 |
+
mstore(0x80, sload(0))
|
| 95 |
+
mstore(0xa0, sload(1))
|
| 96 |
+
mstore(0xc0, 0)
|
| 97 |
+
mstore(0xe0, 0)
|
| 98 |
+
mstore(0x100, 0)
|
| 99 |
+
mstore(0x120, 0)
|
| 100 |
+
mstore(0x140, 0)
|
| 101 |
+
mstore(0x160, 0)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
mstore(0x40, 0x180)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
assert(execID() != bytes32(0) && sender() != address(0));
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
function checks(function () view _check) conditions(validState, validState) internal view {
|
| 113 |
+
_check();
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
function checks(function () pure _check) conditions(validState, validState) internal pure {
|
| 119 |
+
_check();
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
function commit() conditions(validState, none) internal pure {
|
| 125 |
+
|
| 126 |
+
bytes32 ptr = buffPtr();
|
| 127 |
+
require(ptr >= 0x180, "Invalid buffer pointer");
|
| 128 |
+
|
| 129 |
+
assembly {
|
| 130 |
+
|
| 131 |
+
let size := mload(add(0x20, ptr))
|
| 132 |
+
mstore(ptr, 0x20)
|
| 133 |
+
|
| 134 |
+
revert(ptr, add(0x40, size))
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function validState() private pure {
|
| 142 |
+
if (freeMem() < 0x180)
|
| 143 |
+
revert('Expected Contract.execute()');
|
| 144 |
+
|
| 145 |
+
if (buffPtr() != 0 && buffPtr() < 0x180)
|
| 146 |
+
revert('Invalid buffer pointer');
|
| 147 |
+
|
| 148 |
+
assert(execID() != bytes32(0) && sender() != address(0));
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
function buffPtr() private pure returns (bytes32 ptr) {
|
| 153 |
+
assembly { ptr := mload(0xc0) }
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
function freeMem() private pure returns (bytes32 ptr) {
|
| 158 |
+
assembly { ptr := mload(0x40) }
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
function currentAction() private pure returns (bytes4 action) {
|
| 163 |
+
if (buffPtr() == bytes32(0))
|
| 164 |
+
return bytes4(0);
|
| 165 |
+
|
| 166 |
+
assembly { action := mload(0xe0) }
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
function isStoring() private pure {
|
| 171 |
+
if (currentAction() != STORES)
|
| 172 |
+
revert('Invalid current action - expected STORES');
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
function isEmitting() private pure {
|
| 177 |
+
if (currentAction() != EMITS)
|
| 178 |
+
revert('Invalid current action - expected EMITS');
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
function isPaying() private pure {
|
| 183 |
+
if (currentAction() != PAYS)
|
| 184 |
+
revert('Invalid current action - expected PAYS');
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
function startBuffer() private pure {
|
| 189 |
+
assembly {
|
| 190 |
+
|
| 191 |
+
let ptr := msize()
|
| 192 |
+
mstore(0xc0, ptr)
|
| 193 |
+
|
| 194 |
+
mstore(ptr, 0)
|
| 195 |
+
mstore(add(0x20, ptr), 0)
|
| 196 |
+
|
| 197 |
+
mstore(0x40, add(0x40, ptr))
|
| 198 |
+
|
| 199 |
+
mstore(0x100, 1)
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
function validStoreBuff() private pure {
|
| 205 |
+
|
| 206 |
+
if (buffPtr() == bytes32(0))
|
| 207 |
+
startBuffer();
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
if (stored() != 0 || currentAction() == STORES)
|
| 212 |
+
revert('Duplicate request - stores');
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
function validEmitBuff() private pure {
|
| 217 |
+
|
| 218 |
+
if (buffPtr() == bytes32(0))
|
| 219 |
+
startBuffer();
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
if (emitted() != 0 || currentAction() == EMITS)
|
| 224 |
+
revert('Duplicate request - emits');
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
function validPayBuff() private pure {
|
| 229 |
+
|
| 230 |
+
if (buffPtr() == bytes32(0))
|
| 231 |
+
startBuffer();
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
if (paid() != 0 || currentAction() == PAYS)
|
| 236 |
+
revert('Duplicate request - pays');
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
function none() private pure { }
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
function execID() internal pure returns (bytes32 exec_id) {
|
| 246 |
+
assembly { exec_id := mload(0x80) }
|
| 247 |
+
require(exec_id != bytes32(0), "Execution id overwritten, or not read");
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
function sender() internal pure returns (address addr) {
|
| 252 |
+
assembly { addr := mload(0xa0) }
|
| 253 |
+
require(addr != address(0), "Sender address overwritten, or not read");
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
function read(bytes32 _location) internal view returns (bytes32 data) {
|
| 261 |
+
data = keccak256(_location, execID());
|
| 262 |
+
assembly { data := sload(data) }
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
bytes4 internal constant EMITS = bytes4(keccak256('Emit((bytes32[],bytes)[])'));
|
| 268 |
+
bytes4 internal constant STORES = bytes4(keccak256('Store(bytes32[])'));
|
| 269 |
+
bytes4 internal constant PAYS = bytes4(keccak256('Pay(bytes32[])'));
|
| 270 |
+
bytes4 internal constant THROWS = bytes4(keccak256('Error(string)'));
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
enum NextFunction {
|
| 274 |
+
INVALID, NONE, STORE_DEST, VAL_SET, VAL_INC, VAL_DEC, EMIT_LOG, PAY_DEST, PAY_AMT
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
function validStoreDest() private pure {
|
| 279 |
+
|
| 280 |
+
if (expected() != NextFunction.STORE_DEST)
|
| 281 |
+
revert('Unexpected function order - expected storage destination to be pushed');
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
isStoring();
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
function validStoreVal() private pure {
|
| 289 |
+
|
| 290 |
+
if (
|
| 291 |
+
expected() != NextFunction.VAL_SET &&
|
| 292 |
+
expected() != NextFunction.VAL_INC &&
|
| 293 |
+
expected() != NextFunction.VAL_DEC
|
| 294 |
+
) revert('Unexpected function order - expected storage value to be pushed');
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
isStoring();
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
function validPayDest() private pure {
|
| 302 |
+
|
| 303 |
+
if (expected() != NextFunction.PAY_DEST)
|
| 304 |
+
revert('Unexpected function order - expected payment destination to be pushed');
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
isPaying();
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
function validPayAmt() private pure {
|
| 312 |
+
|
| 313 |
+
if (expected() != NextFunction.PAY_AMT)
|
| 314 |
+
revert('Unexpected function order - expected payment amount to be pushed');
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
isPaying();
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
function validEvent() private pure {
|
| 322 |
+
|
| 323 |
+
if (expected() != NextFunction.EMIT_LOG)
|
| 324 |
+
revert('Unexpected function order - expected event to be pushed');
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
isEmitting();
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
function storing() conditions(validStoreBuff, isStoring) internal pure {
|
| 333 |
+
bytes4 action_req = STORES;
|
| 334 |
+
assembly {
|
| 335 |
+
|
| 336 |
+
let ptr := add(0x20, mload(0xc0))
|
| 337 |
+
|
| 338 |
+
mstore(add(0x20, add(ptr, mload(ptr))), action_req)
|
| 339 |
+
|
| 340 |
+
mstore(add(0x24, add(ptr, mload(ptr))), 0)
|
| 341 |
+
|
| 342 |
+
mstore(ptr, add(0x24, mload(ptr)))
|
| 343 |
+
|
| 344 |
+
mstore(0xe0, action_req)
|
| 345 |
+
|
| 346 |
+
mstore(0x100, 2)
|
| 347 |
+
|
| 348 |
+
mstore(sub(ptr, 0x20), add(ptr, mload(ptr)))
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
setFreeMem();
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
function set(bytes32 _field) conditions(validStoreDest, validStoreVal) internal pure returns (bytes32) {
|
| 356 |
+
assembly {
|
| 357 |
+
|
| 358 |
+
let ptr := add(0x20, mload(0xc0))
|
| 359 |
+
|
| 360 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _field)
|
| 361 |
+
|
| 362 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 363 |
+
|
| 364 |
+
mstore(0x100, 3)
|
| 365 |
+
|
| 366 |
+
mstore(
|
| 367 |
+
mload(sub(ptr, 0x20)),
|
| 368 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
mstore(0x120, add(1, mload(0x120)))
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
setFreeMem();
|
| 375 |
+
return _field;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
function to(bytes32, bytes32 _val) conditions(validStoreVal, validStoreDest) internal pure {
|
| 380 |
+
assembly {
|
| 381 |
+
|
| 382 |
+
let ptr := add(0x20, mload(0xc0))
|
| 383 |
+
|
| 384 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _val)
|
| 385 |
+
|
| 386 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 387 |
+
|
| 388 |
+
mstore(0x100, 2)
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
setFreeMem();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
function to(bytes32 _field, uint _val) internal pure {
|
| 396 |
+
to(_field, bytes32(_val));
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
function to(bytes32 _field, address _val) internal pure {
|
| 401 |
+
to(_field, bytes32(_val));
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
function to(bytes32 _field, bool _val) internal pure {
|
| 406 |
+
to(
|
| 407 |
+
_field,
|
| 408 |
+
_val ? bytes32(1) : bytes32(0)
|
| 409 |
+
);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
function increase(bytes32 _field) conditions(validStoreDest, validStoreVal) internal view returns (bytes32 val) {
|
| 413 |
+
|
| 414 |
+
val = keccak256(_field, execID());
|
| 415 |
+
assembly {
|
| 416 |
+
val := sload(val)
|
| 417 |
+
|
| 418 |
+
let ptr := add(0x20, mload(0xc0))
|
| 419 |
+
|
| 420 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _field)
|
| 421 |
+
|
| 422 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 423 |
+
|
| 424 |
+
mstore(0x100, 4)
|
| 425 |
+
|
| 426 |
+
mstore(
|
| 427 |
+
mload(sub(ptr, 0x20)),
|
| 428 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
mstore(0x120, add(1, mload(0x120)))
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
setFreeMem();
|
| 435 |
+
return val;
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
function decrease(bytes32 _field) conditions(validStoreDest, validStoreVal) internal view returns (bytes32 val) {
|
| 439 |
+
|
| 440 |
+
val = keccak256(_field, execID());
|
| 441 |
+
assembly {
|
| 442 |
+
val := sload(val)
|
| 443 |
+
|
| 444 |
+
let ptr := add(0x20, mload(0xc0))
|
| 445 |
+
|
| 446 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _field)
|
| 447 |
+
|
| 448 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 449 |
+
|
| 450 |
+
mstore(0x100, 5)
|
| 451 |
+
|
| 452 |
+
mstore(
|
| 453 |
+
mload(sub(ptr, 0x20)),
|
| 454 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 455 |
+
)
|
| 456 |
+
|
| 457 |
+
mstore(0x120, add(1, mload(0x120)))
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
setFreeMem();
|
| 461 |
+
return val;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
function by(bytes32 _val, uint _amt) conditions(validStoreVal, validStoreDest) internal pure {
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
if (expected() == NextFunction.VAL_INC)
|
| 468 |
+
_amt = _amt.add(uint(_val));
|
| 469 |
+
else if (expected() == NextFunction.VAL_DEC)
|
| 470 |
+
_amt = uint(_val).sub(_amt);
|
| 471 |
+
else
|
| 472 |
+
revert('Expected VAL_INC or VAL_DEC');
|
| 473 |
+
|
| 474 |
+
assembly {
|
| 475 |
+
|
| 476 |
+
let ptr := add(0x20, mload(0xc0))
|
| 477 |
+
|
| 478 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _amt)
|
| 479 |
+
|
| 480 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 481 |
+
|
| 482 |
+
mstore(0x100, 2)
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
setFreeMem();
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
function byMaximum(bytes32 _val, uint _amt) conditions(validStoreVal, validStoreDest) internal pure {
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
if (expected() == NextFunction.VAL_DEC) {
|
| 493 |
+
if (_amt >= uint(_val))
|
| 494 |
+
_amt = 0;
|
| 495 |
+
else
|
| 496 |
+
_amt = uint(_val).sub(_amt);
|
| 497 |
+
} else {
|
| 498 |
+
revert('Expected VAL_DEC');
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
assembly {
|
| 502 |
+
|
| 503 |
+
let ptr := add(0x20, mload(0xc0))
|
| 504 |
+
|
| 505 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _amt)
|
| 506 |
+
|
| 507 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 508 |
+
|
| 509 |
+
mstore(0x100, 2)
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
setFreeMem();
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
function emitting() conditions(validEmitBuff, isEmitting) internal pure {
|
| 518 |
+
bytes4 action_req = EMITS;
|
| 519 |
+
assembly {
|
| 520 |
+
|
| 521 |
+
let ptr := add(0x20, mload(0xc0))
|
| 522 |
+
|
| 523 |
+
mstore(add(0x20, add(ptr, mload(ptr))), action_req)
|
| 524 |
+
|
| 525 |
+
mstore(add(0x24, add(ptr, mload(ptr))), 0)
|
| 526 |
+
|
| 527 |
+
mstore(ptr, add(0x24, mload(ptr)))
|
| 528 |
+
|
| 529 |
+
mstore(0xe0, action_req)
|
| 530 |
+
|
| 531 |
+
mstore(0x100, 6)
|
| 532 |
+
|
| 533 |
+
mstore(sub(ptr, 0x20), add(ptr, mload(ptr)))
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
setFreeMem();
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
function log(bytes32 _data) conditions(validEvent, validEvent) internal pure {
|
| 540 |
+
assembly {
|
| 541 |
+
|
| 542 |
+
let ptr := add(0x20, mload(0xc0))
|
| 543 |
+
|
| 544 |
+
mstore(add(0x20, add(ptr, mload(ptr))), 0)
|
| 545 |
+
|
| 546 |
+
if eq(_data, 0) {
|
| 547 |
+
mstore(add(0x40, add(ptr, mload(ptr))), 0)
|
| 548 |
+
|
| 549 |
+
mstore(ptr, add(0x40, mload(ptr)))
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
if iszero(eq(_data, 0)) {
|
| 553 |
+
|
| 554 |
+
mstore(add(0x40, add(ptr, mload(ptr))), 0x20)
|
| 555 |
+
|
| 556 |
+
mstore(add(0x60, add(ptr, mload(ptr))), _data)
|
| 557 |
+
|
| 558 |
+
mstore(ptr, add(0x60, mload(ptr)))
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
mstore(
|
| 562 |
+
mload(sub(ptr, 0x20)),
|
| 563 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 564 |
+
)
|
| 565 |
+
|
| 566 |
+
mstore(0x140, add(1, mload(0x140)))
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
setFreeMem();
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
function log(bytes32[1] memory _topics, bytes32 _data) conditions(validEvent, validEvent) internal pure {
|
| 573 |
+
assembly {
|
| 574 |
+
|
| 575 |
+
let ptr := add(0x20, mload(0xc0))
|
| 576 |
+
|
| 577 |
+
mstore(add(0x20, add(ptr, mload(ptr))), 1)
|
| 578 |
+
|
| 579 |
+
mstore(add(0x40, add(ptr, mload(ptr))), mload(_topics))
|
| 580 |
+
|
| 581 |
+
if eq(_data, 0) {
|
| 582 |
+
mstore(add(0x60, add(ptr, mload(ptr))), 0)
|
| 583 |
+
|
| 584 |
+
mstore(ptr, add(0x60, mload(ptr)))
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
if iszero(eq(_data, 0)) {
|
| 588 |
+
|
| 589 |
+
mstore(add(0x60, add(ptr, mload(ptr))), 0x20)
|
| 590 |
+
|
| 591 |
+
mstore(add(0x80, add(ptr, mload(ptr))), _data)
|
| 592 |
+
|
| 593 |
+
mstore(ptr, add(0x80, mload(ptr)))
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
mstore(
|
| 597 |
+
mload(sub(ptr, 0x20)),
|
| 598 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 599 |
+
)
|
| 600 |
+
|
| 601 |
+
mstore(0x140, add(1, mload(0x140)))
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
setFreeMem();
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
function log(bytes32[2] memory _topics, bytes32 _data) conditions(validEvent, validEvent) internal pure {
|
| 608 |
+
assembly {
|
| 609 |
+
|
| 610 |
+
let ptr := add(0x20, mload(0xc0))
|
| 611 |
+
|
| 612 |
+
mstore(add(0x20, add(ptr, mload(ptr))), 2)
|
| 613 |
+
|
| 614 |
+
mstore(add(0x40, add(ptr, mload(ptr))), mload(_topics))
|
| 615 |
+
mstore(add(0x60, add(ptr, mload(ptr))), mload(add(0x20, _topics)))
|
| 616 |
+
|
| 617 |
+
if eq(_data, 0) {
|
| 618 |
+
mstore(add(0x80, add(ptr, mload(ptr))), 0)
|
| 619 |
+
|
| 620 |
+
mstore(ptr, add(0x80, mload(ptr)))
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
if iszero(eq(_data, 0)) {
|
| 624 |
+
|
| 625 |
+
mstore(add(0x80, add(ptr, mload(ptr))), 0x20)
|
| 626 |
+
|
| 627 |
+
mstore(add(0xa0, add(ptr, mload(ptr))), _data)
|
| 628 |
+
|
| 629 |
+
mstore(ptr, add(0xa0, mload(ptr)))
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
mstore(
|
| 633 |
+
mload(sub(ptr, 0x20)),
|
| 634 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 635 |
+
)
|
| 636 |
+
|
| 637 |
+
mstore(0x140, add(1, mload(0x140)))
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
setFreeMem();
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
function log(bytes32[3] memory _topics, bytes32 _data) conditions(validEvent, validEvent) internal pure {
|
| 644 |
+
assembly {
|
| 645 |
+
|
| 646 |
+
let ptr := add(0x20, mload(0xc0))
|
| 647 |
+
|
| 648 |
+
mstore(add(0x20, add(ptr, mload(ptr))), 3)
|
| 649 |
+
|
| 650 |
+
mstore(add(0x40, add(ptr, mload(ptr))), mload(_topics))
|
| 651 |
+
mstore(add(0x60, add(ptr, mload(ptr))), mload(add(0x20, _topics)))
|
| 652 |
+
mstore(add(0x80, add(ptr, mload(ptr))), mload(add(0x40, _topics)))
|
| 653 |
+
|
| 654 |
+
if eq(_data, 0) {
|
| 655 |
+
mstore(add(0xa0, add(ptr, mload(ptr))), 0)
|
| 656 |
+
|
| 657 |
+
mstore(ptr, add(0xa0, mload(ptr)))
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
if iszero(eq(_data, 0)) {
|
| 661 |
+
|
| 662 |
+
mstore(add(0xa0, add(ptr, mload(ptr))), 0x20)
|
| 663 |
+
|
| 664 |
+
mstore(add(0xc0, add(ptr, mload(ptr))), _data)
|
| 665 |
+
|
| 666 |
+
mstore(ptr, add(0xc0, mload(ptr)))
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
mstore(
|
| 670 |
+
mload(sub(ptr, 0x20)),
|
| 671 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 672 |
+
)
|
| 673 |
+
|
| 674 |
+
mstore(0x140, add(1, mload(0x140)))
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
setFreeMem();
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
function log(bytes32[4] memory _topics, bytes32 _data) conditions(validEvent, validEvent) internal pure {
|
| 681 |
+
assembly {
|
| 682 |
+
|
| 683 |
+
let ptr := add(0x20, mload(0xc0))
|
| 684 |
+
|
| 685 |
+
mstore(add(0x20, add(ptr, mload(ptr))), 4)
|
| 686 |
+
|
| 687 |
+
mstore(add(0x40, add(ptr, mload(ptr))), mload(_topics))
|
| 688 |
+
mstore(add(0x60, add(ptr, mload(ptr))), mload(add(0x20, _topics)))
|
| 689 |
+
mstore(add(0x80, add(ptr, mload(ptr))), mload(add(0x40, _topics)))
|
| 690 |
+
mstore(add(0xa0, add(ptr, mload(ptr))), mload(add(0x60, _topics)))
|
| 691 |
+
|
| 692 |
+
if eq(_data, 0) {
|
| 693 |
+
mstore(add(0xc0, add(ptr, mload(ptr))), 0)
|
| 694 |
+
|
| 695 |
+
mstore(ptr, add(0xc0, mload(ptr)))
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
if iszero(eq(_data, 0)) {
|
| 699 |
+
|
| 700 |
+
mstore(add(0xc0, add(ptr, mload(ptr))), 0x20)
|
| 701 |
+
|
| 702 |
+
mstore(add(0xe0, add(ptr, mload(ptr))), _data)
|
| 703 |
+
|
| 704 |
+
mstore(ptr, add(0xe0, mload(ptr)))
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
mstore(
|
| 708 |
+
mload(sub(ptr, 0x20)),
|
| 709 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 710 |
+
)
|
| 711 |
+
|
| 712 |
+
mstore(0x140, add(1, mload(0x140)))
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
setFreeMem();
|
| 716 |
+
}
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
|
| 720 |
+
function paying() conditions(validPayBuff, isPaying) internal pure {
|
| 721 |
+
bytes4 action_req = PAYS;
|
| 722 |
+
assembly {
|
| 723 |
+
|
| 724 |
+
let ptr := add(0x20, mload(0xc0))
|
| 725 |
+
|
| 726 |
+
mstore(add(0x20, add(ptr, mload(ptr))), action_req)
|
| 727 |
+
|
| 728 |
+
mstore(add(0x24, add(ptr, mload(ptr))), 0)
|
| 729 |
+
|
| 730 |
+
mstore(ptr, add(0x24, mload(ptr)))
|
| 731 |
+
|
| 732 |
+
mstore(0xe0, action_req)
|
| 733 |
+
|
| 734 |
+
mstore(0x100, 8)
|
| 735 |
+
|
| 736 |
+
mstore(sub(ptr, 0x20), add(ptr, mload(ptr)))
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
setFreeMem();
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
|
| 743 |
+
function pay(uint _amount) conditions(validPayAmt, validPayDest) internal pure returns (uint) {
|
| 744 |
+
assembly {
|
| 745 |
+
|
| 746 |
+
let ptr := add(0x20, mload(0xc0))
|
| 747 |
+
|
| 748 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _amount)
|
| 749 |
+
|
| 750 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 751 |
+
|
| 752 |
+
mstore(0x100, 7)
|
| 753 |
+
|
| 754 |
+
mstore(
|
| 755 |
+
mload(sub(ptr, 0x20)),
|
| 756 |
+
add(1, mload(mload(sub(ptr, 0x20))))
|
| 757 |
+
)
|
| 758 |
+
|
| 759 |
+
mstore(0x160, add(1, mload(0x160)))
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
setFreeMem();
|
| 763 |
+
return _amount;
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
|
| 767 |
+
function toAcc(uint, address _dest) conditions(validPayDest, validPayAmt) internal pure {
|
| 768 |
+
assembly {
|
| 769 |
+
|
| 770 |
+
let ptr := add(0x20, mload(0xc0))
|
| 771 |
+
|
| 772 |
+
mstore(add(0x20, add(ptr, mload(ptr))), _dest)
|
| 773 |
+
|
| 774 |
+
mstore(ptr, add(0x20, mload(ptr)))
|
| 775 |
+
|
| 776 |
+
mstore(0x100, 8)
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
setFreeMem();
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
function setFreeMem() private pure {
|
| 784 |
+
assembly { mstore(0x40, msize) }
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
|
| 788 |
+
function expected() private pure returns (NextFunction next) {
|
| 789 |
+
assembly { next := mload(0x100) }
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
|
| 793 |
+
function emitted() internal pure returns (uint num_emitted) {
|
| 794 |
+
if (buffPtr() == bytes32(0))
|
| 795 |
+
return 0;
|
| 796 |
+
|
| 797 |
+
|
| 798 |
+
assembly { num_emitted := mload(0x140) }
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
|
| 802 |
+
function stored() internal pure returns (uint num_stored) {
|
| 803 |
+
if (buffPtr() == bytes32(0))
|
| 804 |
+
return 0;
|
| 805 |
+
|
| 806 |
+
|
| 807 |
+
assembly { num_stored := mload(0x120) }
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
|
| 811 |
+
function paid() internal pure returns (uint num_paid) {
|
| 812 |
+
if (buffPtr() == bytes32(0))
|
| 813 |
+
return 0;
|
| 814 |
+
|
| 815 |
+
|
| 816 |
+
assembly { num_paid := mload(0x160) }
|
| 817 |
+
}
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
library Provider {
|
| 821 |
+
|
| 822 |
+
using Contract for *;
|
| 823 |
+
|
| 824 |
+
|
| 825 |
+
function appIndex() internal pure returns (bytes32)
|
| 826 |
+
{ return keccak256('index'); }
|
| 827 |
+
|
| 828 |
+
|
| 829 |
+
function execPermissions(address _exec) internal pure returns (bytes32)
|
| 830 |
+
{ return keccak256(_exec, keccak256('script_exec_permissions')); }
|
| 831 |
+
|
| 832 |
+
|
| 833 |
+
function appSelectors(bytes4 _selector) internal pure returns (bytes32)
|
| 834 |
+
{ return keccak256(_selector, 'implementation'); }
|
| 835 |
+
|
| 836 |
+
|
| 837 |
+
function registeredApps() internal pure returns (bytes32)
|
| 838 |
+
{ return keccak256(bytes32(Contract.sender()), 'app_list'); }
|
| 839 |
+
|
| 840 |
+
|
| 841 |
+
function appBase(bytes32 _app) internal pure returns (bytes32)
|
| 842 |
+
{ return keccak256(_app, keccak256(bytes32(Contract.sender()), 'app_base')); }
|
| 843 |
+
|
| 844 |
+
|
| 845 |
+
function appVersionList(bytes32 _app) internal pure returns (bytes32)
|
| 846 |
+
{ return keccak256('versions', appBase(_app)); }
|
| 847 |
+
|
| 848 |
+
|
| 849 |
+
function versionBase(bytes32 _app, bytes32 _version) internal pure returns (bytes32)
|
| 850 |
+
{ return keccak256(_version, 'version', appBase(_app)); }
|
| 851 |
+
|
| 852 |
+
|
| 853 |
+
function versionIndex(bytes32 _app, bytes32 _version) internal pure returns (bytes32)
|
| 854 |
+
{ return keccak256('index', versionBase(_app, _version)); }
|
| 855 |
+
|
| 856 |
+
|
| 857 |
+
function versionSelectors(bytes32 _app, bytes32 _version) internal pure returns (bytes32)
|
| 858 |
+
{ return keccak256('selectors', versionBase(_app, _version)); }
|
| 859 |
+
|
| 860 |
+
|
| 861 |
+
function versionAddresses(bytes32 _app, bytes32 _version) internal pure returns (bytes32)
|
| 862 |
+
{ return keccak256('addresses', versionBase(_app, _version)); }
|
| 863 |
+
|
| 864 |
+
|
| 865 |
+
function previousVersion(bytes32 _app, bytes32 _version) internal pure returns (bytes32)
|
| 866 |
+
{ return keccak256("previous version", versionBase(_app, _version)); }
|
| 867 |
+
|
| 868 |
+
|
| 869 |
+
function appVersionListAt(bytes32 _app, uint _index) internal pure returns (bytes32)
|
| 870 |
+
{ return bytes32((32 * _index) + uint(appVersionList(_app))); }
|
| 871 |
+
|
| 872 |
+
|
| 873 |
+
function registerApp(bytes32 _app, address _index, bytes4[] _selectors, address[] _implementations) external view {
|
| 874 |
+
|
| 875 |
+
Contract.authorize(msg.sender);
|
| 876 |
+
|
| 877 |
+
|
| 878 |
+
if (Contract.read(appBase(_app)) != bytes32(0))
|
| 879 |
+
revert("app is already registered");
|
| 880 |
+
|
| 881 |
+
if (_selectors.length != _implementations.length || _selectors.length == 0)
|
| 882 |
+
revert("invalid input arrays");
|
| 883 |
+
|
| 884 |
+
|
| 885 |
+
Contract.storing();
|
| 886 |
+
|
| 887 |
+
|
| 888 |
+
uint num_registered_apps = uint(Contract.read(registeredApps()));
|
| 889 |
+
|
| 890 |
+
Contract.increase(registeredApps()).by(uint(1));
|
| 891 |
+
|
| 892 |
+
Contract.set(
|
| 893 |
+
bytes32(32 * (num_registered_apps + 1) + uint(registeredApps()))
|
| 894 |
+
).to(_app);
|
| 895 |
+
|
| 896 |
+
|
| 897 |
+
Contract.set(appBase(_app)).to(_app);
|
| 898 |
+
|
| 899 |
+
|
| 900 |
+
Contract.set(versionBase(_app, _app)).to(_app);
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
Contract.set(appVersionList(_app)).to(uint(1));
|
| 904 |
+
|
| 905 |
+
Contract.set(
|
| 906 |
+
bytes32(32 + uint(appVersionList(_app)))
|
| 907 |
+
).to(_app);
|
| 908 |
+
|
| 909 |
+
|
| 910 |
+
Contract.set(versionIndex(_app, _app)).to(_index);
|
| 911 |
+
|
| 912 |
+
|
| 913 |
+
|
| 914 |
+
Contract.set(versionSelectors(_app, _app)).to(_selectors.length);
|
| 915 |
+
Contract.set(versionAddresses(_app, _app)).to(_implementations.length);
|
| 916 |
+
for (uint i = 0; i < _selectors.length; i++) {
|
| 917 |
+
Contract.set(bytes32(32 * (i + 1) + uint(versionSelectors(_app, _app)))).to(_selectors[i]);
|
| 918 |
+
Contract.set(bytes32(32 * (i + 1) + uint(versionAddresses(_app, _app)))).to(_implementations[i]);
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
|
| 922 |
+
Contract.set(previousVersion(_app, _app)).to(uint(0));
|
| 923 |
+
|
| 924 |
+
|
| 925 |
+
Contract.commit();
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
function registerAppVersion(bytes32 _app, bytes32 _version, address _index, bytes4[] _selectors, address[] _implementations) external view {
|
| 929 |
+
|
| 930 |
+
Contract.authorize(msg.sender);
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
|
| 934 |
+
if (Contract.read(appBase(_app)) == bytes32(0))
|
| 935 |
+
revert("App has not been registered");
|
| 936 |
+
|
| 937 |
+
if (Contract.read(versionBase(_app, _version)) != bytes32(0))
|
| 938 |
+
revert("Version already exists");
|
| 939 |
+
|
| 940 |
+
if (
|
| 941 |
+
_selectors.length != _implementations.length ||
|
| 942 |
+
_selectors.length == 0
|
| 943 |
+
) revert("Invalid input array lengths");
|
| 944 |
+
|
| 945 |
+
|
| 946 |
+
Contract.storing();
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
Contract.set(versionBase(_app, _version)).to(_version);
|
| 950 |
+
|
| 951 |
+
|
| 952 |
+
uint num_versions = uint(Contract.read(appVersionList(_app)));
|
| 953 |
+
Contract.set(appVersionListAt(_app, (num_versions + 1))).to(_version);
|
| 954 |
+
Contract.set(appVersionList(_app)).to(num_versions + 1);
|
| 955 |
+
|
| 956 |
+
|
| 957 |
+
Contract.set(versionIndex(_app, _version)).to(_index);
|
| 958 |
+
|
| 959 |
+
|
| 960 |
+
|
| 961 |
+
Contract.set(versionSelectors(_app, _version)).to(_selectors.length);
|
| 962 |
+
Contract.set(versionAddresses(_app, _version)).to(_implementations.length);
|
| 963 |
+
for (uint i = 0; i < _selectors.length; i++) {
|
| 964 |
+
Contract.set(bytes32(32 * (i + 1) + uint(versionSelectors(_app, _version)))).to(_selectors[i]);
|
| 965 |
+
Contract.set(bytes32(32 * (i + 1) + uint(versionAddresses(_app, _version)))).to(_implementations[i]);
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
|
| 969 |
+
bytes32 prev_version = Contract.read(bytes32(32 * num_versions + uint(appVersionList(_app))));
|
| 970 |
+
Contract.set(previousVersion(_app, _version)).to(prev_version);
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
Contract.commit();
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
|
| 977 |
+
function updateInstance(bytes32 _app_name, bytes32 _current_version, bytes32 _registry_id) external view {
|
| 978 |
+
|
| 979 |
+
Contract.authorize(msg.sender);
|
| 980 |
+
|
| 981 |
+
|
| 982 |
+
require(_app_name != 0 && _current_version != 0 && _registry_id != 0, 'invalid input');
|
| 983 |
+
|
| 984 |
+
|
| 985 |
+
bytes4[] memory current_selectors = getVersionSelectors(_app_name, _current_version, _registry_id);
|
| 986 |
+
require(current_selectors.length != 0, 'invalid current version');
|
| 987 |
+
|
| 988 |
+
|
| 989 |
+
bytes32 latest_version = getLatestVersion(_app_name, _registry_id);
|
| 990 |
+
require(latest_version != _current_version, 'current version is already latest');
|
| 991 |
+
require(latest_version != 0, 'invalid latest version');
|
| 992 |
+
|
| 993 |
+
|
| 994 |
+
|
| 995 |
+
address latest_idx = getVersionIndex(_app_name, latest_version, _registry_id);
|
| 996 |
+
bytes4[] memory latest_selectors = getVersionSelectors(_app_name, latest_version, _registry_id);
|
| 997 |
+
address[] memory latest_impl = getVersionImplementations(_app_name, latest_version, _registry_id);
|
| 998 |
+
require(latest_idx != 0, 'invalid version idx address');
|
| 999 |
+
require(latest_selectors.length != 0 && latest_selectors.length == latest_impl.length, 'invalid implementation specification');
|
| 1000 |
+
|
| 1001 |
+
|
| 1002 |
+
Contract.storing();
|
| 1003 |
+
|
| 1004 |
+
|
| 1005 |
+
for (uint i = 0; i < current_selectors.length; i++)
|
| 1006 |
+
Contract.set(appSelectors(current_selectors[i])).to(address(0));
|
| 1007 |
+
|
| 1008 |
+
|
| 1009 |
+
Contract.set(appIndex()).to(latest_idx);
|
| 1010 |
+
|
| 1011 |
+
|
| 1012 |
+
for (i = 0; i < latest_selectors.length; i++) {
|
| 1013 |
+
require(latest_selectors[i] != 0 && latest_impl[i] != 0, 'invalid input - expected nonzero implementation');
|
| 1014 |
+
Contract.set(appSelectors(latest_selectors[i])).to(latest_impl[i]);
|
| 1015 |
+
}
|
| 1016 |
+
|
| 1017 |
+
|
| 1018 |
+
Contract.commit();
|
| 1019 |
+
}
|
| 1020 |
+
|
| 1021 |
+
|
| 1022 |
+
function updateExec(address _new_exec_addr) external view {
|
| 1023 |
+
|
| 1024 |
+
Contract.authorize(msg.sender);
|
| 1025 |
+
|
| 1026 |
+
|
| 1027 |
+
require(_new_exec_addr != 0, 'invalid replacement');
|
| 1028 |
+
|
| 1029 |
+
|
| 1030 |
+
Contract.storing();
|
| 1031 |
+
|
| 1032 |
+
|
| 1033 |
+
Contract.set(execPermissions(msg.sender)).to(false);
|
| 1034 |
+
|
| 1035 |
+
|
| 1036 |
+
Contract.set(execPermissions(_new_exec_addr)).to(true);
|
| 1037 |
+
|
| 1038 |
+
|
| 1039 |
+
Contract.commit();
|
| 1040 |
+
}
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
|
| 1044 |
+
function registryRead(bytes32 _location, bytes32 _registry_id) internal view returns (bytes32 value) {
|
| 1045 |
+
_location = keccak256(_location, _registry_id);
|
| 1046 |
+
assembly { value := sload(_location) }
|
| 1047 |
+
}
|
| 1048 |
+
|
| 1049 |
+
|
| 1050 |
+
|
| 1051 |
+
|
| 1052 |
+
function getLatestVersion(bytes32 _app, bytes32 _registry_id) internal view returns (bytes32) {
|
| 1053 |
+
uint length = uint(registryRead(appVersionList(_app), _registry_id));
|
| 1054 |
+
|
| 1055 |
+
return registryRead(appVersionListAt(_app, length), _registry_id);
|
| 1056 |
+
}
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
function getVersionIndex(bytes32 _app, bytes32 _version, bytes32 _registry_id) internal view returns (address) {
|
| 1060 |
+
return address(registryRead(versionIndex(_app, _version), _registry_id));
|
| 1061 |
+
}
|
| 1062 |
+
|
| 1063 |
+
|
| 1064 |
+
function getVersionImplementations(bytes32 _app, bytes32 _version, bytes32 _registry_id) internal view returns (address[] memory impl) {
|
| 1065 |
+
|
| 1066 |
+
uint length = uint(registryRead(versionAddresses(_app, _version), _registry_id));
|
| 1067 |
+
|
| 1068 |
+
impl = new address[](length);
|
| 1069 |
+
|
| 1070 |
+
for (uint i = 0; i < length; i++) {
|
| 1071 |
+
bytes32 location = bytes32(32 * (i + 1) + uint(versionAddresses(_app, _version)));
|
| 1072 |
+
impl[i] = address(registryRead(location, _registry_id));
|
| 1073 |
+
}
|
| 1074 |
+
}
|
| 1075 |
+
|
| 1076 |
+
|
| 1077 |
+
function getVersionSelectors(bytes32 _app, bytes32 _version, bytes32 _registry_id) internal view returns (bytes4[] memory sels) {
|
| 1078 |
+
|
| 1079 |
+
uint length = uint(registryRead(versionSelectors(_app, _version), _registry_id));
|
| 1080 |
+
|
| 1081 |
+
sels = new bytes4[](length);
|
| 1082 |
+
|
| 1083 |
+
for (uint i = 0; i < length; i++) {
|
| 1084 |
+
bytes32 location = bytes32(32 * (i + 1) + uint(versionSelectors(_app, _version)));
|
| 1085 |
+
sels[i] = bytes4(registryRead(location, _registry_id));
|
| 1086 |
+
}
|
| 1087 |
+
}
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity 0.4.21;
|
| 2 |
+
|
| 3 |
+
contract Ownable {
|
| 4 |
+
address public owner;
|
| 5 |
+
address public newOwner;
|
| 6 |
+
|
| 7 |
+
event OwnershipTransferred(address indexed _from, address indexed _to);
|
| 8 |
+
|
| 9 |
+
function Ownable() public {
|
| 10 |
+
owner = msg.sender;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
modifier onlyOwner {
|
| 14 |
+
require(msg.sender == owner);
|
| 15 |
+
_;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 19 |
+
newOwner = _newOwner;
|
| 20 |
+
}
|
| 21 |
+
function acceptOwnership() public {
|
| 22 |
+
require(msg.sender == newOwner);
|
| 23 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 24 |
+
owner = newOwner;
|
| 25 |
+
newOwner = address(0);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
library SafeMath {
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 33 |
+
if (a == 0) {
|
| 34 |
+
return 0;
|
| 35 |
+
}
|
| 36 |
+
c = a * b;
|
| 37 |
+
assert(c / a == b);
|
| 38 |
+
return c;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
return a / b;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 51 |
+
assert(b <= a);
|
| 52 |
+
return a - b;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 57 |
+
c = a + b;
|
| 58 |
+
assert(c >= a);
|
| 59 |
+
return c;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
contract Pausable is Ownable {
|
| 64 |
+
event Pause();
|
| 65 |
+
event Unpause();
|
| 66 |
+
|
| 67 |
+
bool public paused = false;
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
modifier whenNotPaused() {
|
| 72 |
+
require(!paused);
|
| 73 |
+
_;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
modifier whenPaused {
|
| 78 |
+
require(paused);
|
| 79 |
+
_;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
function pause() onlyOwner whenNotPaused public returns (bool) {
|
| 84 |
+
paused = true;
|
| 85 |
+
emit Pause();
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function unpause() onlyOwner whenPaused public returns (bool) {
|
| 91 |
+
paused = false;
|
| 92 |
+
emit Unpause();
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
contract ERC20Interface {
|
| 104 |
+
function totalSupply() public constant returns (uint);
|
| 105 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance);
|
| 106 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
|
| 107 |
+
function transfer(address to, uint tokens) public returns (bool success);
|
| 108 |
+
function approve(address spender, uint tokens) public returns (bool success);
|
| 109 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success);
|
| 110 |
+
|
| 111 |
+
event Transfer(address indexed from, address indexed to, uint tokens);
|
| 112 |
+
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
contract ApproveAndCallFallBack {
|
| 122 |
+
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
contract ROC is ERC20Interface, Pausable {
|
| 131 |
+
using SafeMath for uint;
|
| 132 |
+
|
| 133 |
+
string public symbol;
|
| 134 |
+
string public name;
|
| 135 |
+
uint8 public decimals;
|
| 136 |
+
uint public _totalSupply;
|
| 137 |
+
|
| 138 |
+
mapping(address => uint) balances;
|
| 139 |
+
mapping(address => mapping(address => uint)) allowed;
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
function ROC() public {
|
| 146 |
+
symbol = "ROC";
|
| 147 |
+
name = "NeoWorld Rare Ore C";
|
| 148 |
+
decimals = 18;
|
| 149 |
+
_totalSupply = 10000000 * 10**uint(decimals);
|
| 150 |
+
balances[owner] = _totalSupply;
|
| 151 |
+
emit Transfer(address(0), owner, _totalSupply);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
function totalSupply() public constant returns (uint) {
|
| 158 |
+
return _totalSupply - balances[address(0)];
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance) {
|
| 165 |
+
return balances[tokenOwner];
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 175 |
+
balances[msg.sender] = balances[msg.sender].sub(tokens);
|
| 176 |
+
balances[to] = balances[to].add(tokens);
|
| 177 |
+
emit Transfer(msg.sender, to, tokens);
|
| 178 |
+
return true;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
function approve(address spender, uint tokens) public whenNotPaused returns (bool success) {
|
| 191 |
+
allowed[msg.sender][spender] = tokens;
|
| 192 |
+
emit Approval(msg.sender, spender, tokens);
|
| 193 |
+
return true;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
function increaseApproval (address _spender, uint _addedValue) public whenNotPaused
|
| 197 |
+
returns (bool success) {
|
| 198 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 199 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 200 |
+
return true;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
function decreaseApproval (address _spender, uint _subtractedValue) public whenNotPaused
|
| 204 |
+
returns (bool success) {
|
| 205 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 206 |
+
if (_subtractedValue > oldValue) {
|
| 207 |
+
allowed[msg.sender][_spender] = 0;
|
| 208 |
+
} else {
|
| 209 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 210 |
+
}
|
| 211 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 212 |
+
return true;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 225 |
+
balances[from] = balances[from].sub(tokens);
|
| 226 |
+
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
|
| 227 |
+
balances[to] = balances[to].add(tokens);
|
| 228 |
+
emit Transfer(from, to, tokens);
|
| 229 |
+
return true;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
|
| 238 |
+
return allowed[tokenOwner][spender];
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
|
| 248 |
+
allowed[msg.sender][spender] = tokens;
|
| 249 |
+
emit Approval(msg.sender, spender, tokens);
|
| 250 |
+
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
|
| 251 |
+
return true;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
function () public payable {
|
| 259 |
+
revert();
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
|
| 267 |
+
return ERC20Interface(tokenAddress).transfer(owner, tokens);
|
| 268 |
+
}
|
| 269 |
+
}
|
benchmark2/integer overflow/548.sol
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
}
|
| 15 |
+
uint256 c = a * b;
|
| 16 |
+
assert(c / a == b);
|
| 17 |
+
return c;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 21 |
+
|
| 22 |
+
uint256 c = a / b;
|
| 23 |
+
|
| 24 |
+
return c;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 28 |
+
assert(b <= a);
|
| 29 |
+
return a - b;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 33 |
+
uint256 c = a + b;
|
| 34 |
+
assert(c >= a);
|
| 35 |
+
return c;
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
contract Token {
|
| 44 |
+
|
| 45 |
+
function totalSupply() constant returns (uint256 supply);
|
| 46 |
+
function balanceOf(address _owner) constant returns (uint256 balance);
|
| 47 |
+
function transfer(address _to, uint256 _value) returns (bool success);
|
| 48 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
|
| 49 |
+
function approve(address _spender, uint256 _value) returns (bool success);
|
| 50 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
|
| 51 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 52 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
contract AbstractToken is Token, SafeMath {
|
| 59 |
+
|
| 60 |
+
function AbstractToken () {
|
| 61 |
+
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function balanceOf(address _owner) constant returns (uint256 balance) {
|
| 66 |
+
return accounts [_owner];
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function transfer(address _to, uint256 _value) returns (bool success) {
|
| 71 |
+
require(_to != address(0));
|
| 72 |
+
if (accounts [msg.sender] < _value) return false;
|
| 73 |
+
if (_value > 0 && msg.sender != _to) {
|
| 74 |
+
accounts [msg.sender] = safeSub (accounts [msg.sender], _value);
|
| 75 |
+
accounts [_to] = safeAdd (accounts [_to], _value);
|
| 76 |
+
}
|
| 77 |
+
emit Transfer (msg.sender, _to, _value);
|
| 78 |
+
return true;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 83 |
+
returns (bool success) {
|
| 84 |
+
require(_to != address(0));
|
| 85 |
+
if (allowances [_from][msg.sender] < _value) return false;
|
| 86 |
+
if (accounts [_from] < _value) return false;
|
| 87 |
+
|
| 88 |
+
if (_value > 0 && _from != _to) {
|
| 89 |
+
allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value);
|
| 90 |
+
accounts [_from] = safeSub (accounts [_from], _value);
|
| 91 |
+
accounts [_to] = safeAdd (accounts [_to], _value);
|
| 92 |
+
}
|
| 93 |
+
emit Transfer(_from, _to, _value);
|
| 94 |
+
return true;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
function approve (address _spender, uint256 _value) returns (bool success) {
|
| 99 |
+
allowances [msg.sender][_spender] = _value;
|
| 100 |
+
emit Approval (msg.sender, _spender, _value);
|
| 101 |
+
return true;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
function allowance(address _owner, address _spender) constant
|
| 106 |
+
returns (uint256 remaining) {
|
| 107 |
+
return allowances [_owner][_spender];
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
mapping (address => uint256) accounts;
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
mapping (address => mapping (address => uint256)) private allowances;
|
| 115 |
+
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
contract IDXToken is AbstractToken {
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
uint256 constant MAX_TOKEN_COUNT = 50000000 * (10**18);
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
address private owner;
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
mapping (address => bool) private frozenAccount;
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
uint256 tokenCount = 0;
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
bool frozen = false;
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function IDXToken () {
|
| 142 |
+
owner = msg.sender;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
function totalSupply() constant returns (uint256 supply) {
|
| 147 |
+
return tokenCount;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
string constant public name = "INDEX TOKEN";
|
| 151 |
+
string constant public symbol = "IDX";
|
| 152 |
+
uint8 constant public decimals = 18;
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
function transfer(address _to, uint256 _value) returns (bool success) {
|
| 156 |
+
require(!frozenAccount[msg.sender]);
|
| 157 |
+
if (frozen) return false;
|
| 158 |
+
else return AbstractToken.transfer (_to, _value);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 163 |
+
returns (bool success) {
|
| 164 |
+
require(!frozenAccount[_from]);
|
| 165 |
+
if (frozen) return false;
|
| 166 |
+
else return AbstractToken.transferFrom (_from, _to, _value);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
function approve (address _spender, uint256 _value)
|
| 171 |
+
returns (bool success) {
|
| 172 |
+
require(allowance (msg.sender, _spender) == 0 || _value == 0);
|
| 173 |
+
return AbstractToken.approve (_spender, _value);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
function createTokens(uint256 _value)
|
| 178 |
+
returns (bool success) {
|
| 179 |
+
require (msg.sender == owner);
|
| 180 |
+
|
| 181 |
+
if (_value > 0) {
|
| 182 |
+
if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
|
| 183 |
+
|
| 184 |
+
accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
|
| 185 |
+
tokenCount = safeAdd (tokenCount, _value);
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
emit Transfer(0x0, msg.sender, _value);
|
| 189 |
+
|
| 190 |
+
return true;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
return false;
|
| 194 |
+
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
function setOwner(address _newOwner) {
|
| 200 |
+
require (msg.sender == owner);
|
| 201 |
+
|
| 202 |
+
owner = _newOwner;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
function freezeTransfers () {
|
| 207 |
+
require (msg.sender == owner);
|
| 208 |
+
|
| 209 |
+
if (!frozen) {
|
| 210 |
+
frozen = true;
|
| 211 |
+
emit Freeze ();
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
function unfreezeTransfers () {
|
| 217 |
+
require (msg.sender == owner);
|
| 218 |
+
|
| 219 |
+
if (frozen) {
|
| 220 |
+
frozen = false;
|
| 221 |
+
emit Unfreeze ();
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
function refundTokens(address _token, address _refund, uint256 _value) {
|
| 229 |
+
require (msg.sender == owner);
|
| 230 |
+
require(_token != address(this));
|
| 231 |
+
AbstractToken token = AbstractToken(_token);
|
| 232 |
+
token.transfer(_refund, _value);
|
| 233 |
+
emit RefundTokens(_token, _refund, _value);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
function freezeAccount(address _target, bool freeze) {
|
| 238 |
+
require (msg.sender == owner);
|
| 239 |
+
require (msg.sender != _target);
|
| 240 |
+
frozenAccount[_target] = freeze;
|
| 241 |
+
emit FrozenFunds(_target, freeze);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
event Freeze ();
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
event Unfreeze ();
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
event FrozenFunds(address target, bool frozen);
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
event RefundTokens(address _token, address _refund, uint256 _value);
|
| 259 |
+
}
|
benchmark2/integer overflow/564.sol
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.23;contract Ownable {address public owner;event OwnershipRenounced(address indexed previousOwner);event OwnershipTransferred(address indexed previousOwner,address indexed newOwner);constructor() public {owner = msg.sender;}modifier onlyOwner() {require(msg.sender == owner);_;}function transferOwnership(address newOwner) public onlyOwner {require(newOwner != address(0));emit OwnershipTransferred(owner, newOwner);owner = newOwner;}function renounceOwnership() public onlyOwner {emit OwnershipRenounced(owner);owner = address(0);}}library SafeMath {function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {if (a == 0) {return 0;}c = a * b;assert(c / a == b);return c;}function div(uint256 a, uint256 b) internal pure returns (uint256) {return a / b;}function sub(uint256 a, uint256 b) internal pure returns (uint256) {assert(b <= a);return a - b;}function add(uint256 a, uint256 b) internal pure returns (uint256 c) {c = a + b;assert(c >= a);return c;}}contract ERC20Basic {function totalSupply() public view returns (uint256);function balanceOf(address who) public view returns (uint256);function transfer(address to, uint256 value) public returns (bool);event Transfer(address indexed from, address indexed to, uint256 value);}contract ERC20 is ERC20Basic {function allowance(address owner, address spender) public view returns (uint256);function transferFrom(address from, address to, uint256 value) public returns(bool);function approve(address spender, uint256 value) public returns (bool);event Approval(address indexed owner, address indexed spender, uint256 value);}contract BasicToken is ERC20Basic {using SafeMath for uint256;mapping(address => uint256) balances;uint256 totalSupply_;function totalSupply() public view returns (uint256) {return totalSupply_;}function transfer(address _to, uint256 _value) public returns (bool) {require(_to != address(0));require(_value <= balances[msg.sender]);balances[msg.sender] = balances[msg.sender].sub(_value);balances[_to] = balances[_to].add(_value);emit Transfer(msg.sender, _to, _value);return true;}function balanceOf(address _owner) public view returns (uint256) {return balances[_owner];}}contract StandardToken is ERC20, BasicToken {mapping (address => mapping (address => uint256)) internal allowed;function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {require(_to != address(0));require(_value <= balances[_from]);require(_value <= allowed[_from][msg.sender]);balances[_from] = balances[_from].sub(_value);balances[_to] = balances[_to].add(_value);allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);emit Transfer(_from, _to, _value);return true;}function approve(address _spender, uint256 _value) public returns (bool) {require((_value == 0 ) || (allowed[msg.sender][_spender] == 0));allowed[msg.sender][_spender] = _value;emit Approval(msg.sender, _spender, _value);return true;}function allowance(address _owner, address _spender) public view returns (uint256) {return allowed[_owner][_spender];}function increaseApproval(address _spender, uint _addedValue) public returns (bool){allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);return true;}function decreaseApproval(address _spender, uint _subtractedValue) public returns(bool) {uint oldValue = allowed[msg.sender][_spender];if (_subtractedValue > oldValue) {allowed[msg.sender][_spender] = 0;} else {allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);}emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);return true;}}contract TokenContract is StandardToken{string public constant name="bbb";string public constant symbol="BBBB"; uint8 public constant decimals=18;uint256 public constant INITIAL_SUPPLY=10000000000000000000000;uint256 public constant MAX_SUPPLY = 100 * 10000 * 10000 * (10 **uint256(decimals));constructor() TokenContract() public {totalSupply_ = INITIAL_SUPPLY;balances[msg.sender] = INITIAL_SUPPLY;emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);}function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 |
+
|
| 12 |
+
modifier onlyOwner() {
|
| 13 |
+
require(msg.sender == owner);
|
| 14 |
+
_;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function setOwner(address _owner) onlyOwner public {
|
| 18 |
+
owner = _owner;
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
contract SafeMath {
|
| 24 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 25 |
+
uint256 c = _a + _b;
|
| 26 |
+
assert(c >= _a);
|
| 27 |
+
return c;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 31 |
+
assert(_a >= _b);
|
| 32 |
+
return _a - _b;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 36 |
+
uint256 c = _a * _b;
|
| 37 |
+
assert(_a == 0 || c / _a == _b);
|
| 38 |
+
return c;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
contract Token is SafeMath, Owned {
|
| 44 |
+
uint256 constant DAY_IN_SECONDS = 86400;
|
| 45 |
+
string public constant standard = "0.777";
|
| 46 |
+
string public name = "";
|
| 47 |
+
string public symbol = "";
|
| 48 |
+
uint8 public decimals = 0;
|
| 49 |
+
uint256 public totalSupply = 0;
|
| 50 |
+
mapping (address => uint256) public balanceP;
|
| 51 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 52 |
+
|
| 53 |
+
mapping (address => uint256[]) public lockTime;
|
| 54 |
+
mapping (address => uint256[]) public lockValue;
|
| 55 |
+
mapping (address => uint256) public lockNum;
|
| 56 |
+
mapping (address => bool) public locker;
|
| 57 |
+
uint256 public later = 0;
|
| 58 |
+
uint256 public earlier = 0;
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
| 63 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
event TransferredLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value);
|
| 67 |
+
event TokenUnlocked(address indexed _address, uint256 _value);
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function Token(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public {
|
| 71 |
+
require(bytes(_name).length > 0 && bytes(_symbol).length > 0);
|
| 72 |
+
|
| 73 |
+
name = _name;
|
| 74 |
+
symbol = _symbol;
|
| 75 |
+
decimals = _decimals;
|
| 76 |
+
totalSupply = _totalSupply;
|
| 77 |
+
|
| 78 |
+
balanceP[msg.sender] = _totalSupply;
|
| 79 |
+
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
modifier validAddress(address _address) {
|
| 84 |
+
require(_address != 0x0);
|
| 85 |
+
_;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
function addLocker(address _address) public validAddress(_address) onlyOwner {
|
| 90 |
+
locker[_address] = true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function removeLocker(address _address) public validAddress(_address) onlyOwner {
|
| 94 |
+
locker[_address] = false;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
function setUnlockEarlier(uint256 _earlier) public onlyOwner {
|
| 99 |
+
earlier = add(earlier, _earlier);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function setUnlockLater(uint256 _later) public onlyOwner {
|
| 103 |
+
later = add(later, _later);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
function balanceUnlocked(address _address) public view returns (uint256 _balance) {
|
| 108 |
+
_balance = balanceP[_address];
|
| 109 |
+
uint256 i = 0;
|
| 110 |
+
while (i < lockNum[_address]) {
|
| 111 |
+
if (add(now, earlier) > add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
|
| 112 |
+
i++;
|
| 113 |
+
}
|
| 114 |
+
return _balance;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
function balanceLocked(address _address) public view returns (uint256 _balance) {
|
| 119 |
+
_balance = 0;
|
| 120 |
+
uint256 i = 0;
|
| 121 |
+
while (i < lockNum[_address]) {
|
| 122 |
+
if (add(now, earlier) < add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
|
| 123 |
+
i++;
|
| 124 |
+
}
|
| 125 |
+
return _balance;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
function balanceOf(address _address) public view returns (uint256 _balance) {
|
| 130 |
+
_balance = balanceP[_address];
|
| 131 |
+
uint256 i = 0;
|
| 132 |
+
while (i < lockNum[_address]) {
|
| 133 |
+
_balance = add(_balance, lockValue[_address][i]);
|
| 134 |
+
i++;
|
| 135 |
+
}
|
| 136 |
+
return _balance;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
function showTime(address _address) public view validAddress(_address) returns (uint256[] _time) {
|
| 141 |
+
uint i = 0;
|
| 142 |
+
uint256[] memory tempLockTime = new uint256[](lockNum[_address]);
|
| 143 |
+
while (i < lockNum[_address]) {
|
| 144 |
+
tempLockTime[i] = sub(add(lockTime[_address][i], later), earlier);
|
| 145 |
+
i++;
|
| 146 |
+
}
|
| 147 |
+
return tempLockTime;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
function showValue(address _address) public view validAddress(_address) returns (uint256[] _value) {
|
| 151 |
+
return lockValue[_address];
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
function calcUnlock(address _address) private {
|
| 156 |
+
uint256 i = 0;
|
| 157 |
+
uint256 j = 0;
|
| 158 |
+
uint256[] memory currentLockTime;
|
| 159 |
+
uint256[] memory currentLockValue;
|
| 160 |
+
uint256[] memory newLockTime = new uint256[](lockNum[_address]);
|
| 161 |
+
uint256[] memory newLockValue = new uint256[](lockNum[_address]);
|
| 162 |
+
currentLockTime = lockTime[_address];
|
| 163 |
+
currentLockValue = lockValue[_address];
|
| 164 |
+
while (i < lockNum[_address]) {
|
| 165 |
+
if (add(now, earlier) > add(currentLockTime[i], later)) {
|
| 166 |
+
balanceP[_address] = add(balanceP[_address], currentLockValue[i]);
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
emit TokenUnlocked(_address, currentLockValue[i]);
|
| 170 |
+
} else {
|
| 171 |
+
newLockTime[j] = currentLockTime[i];
|
| 172 |
+
newLockValue[j] = currentLockValue[i];
|
| 173 |
+
j++;
|
| 174 |
+
}
|
| 175 |
+
i++;
|
| 176 |
+
}
|
| 177 |
+
uint256[] memory trimLockTime = new uint256[](j);
|
| 178 |
+
uint256[] memory trimLockValue = new uint256[](j);
|
| 179 |
+
i = 0;
|
| 180 |
+
while (i < j) {
|
| 181 |
+
trimLockTime[i] = newLockTime[i];
|
| 182 |
+
trimLockValue[i] = newLockValue[i];
|
| 183 |
+
i++;
|
| 184 |
+
}
|
| 185 |
+
lockTime[_address] = trimLockTime;
|
| 186 |
+
lockValue[_address] = trimLockValue;
|
| 187 |
+
lockNum[_address] = j;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) {
|
| 192 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 193 |
+
if (balanceP[msg.sender] >= _value && _value > 0) {
|
| 194 |
+
balanceP[msg.sender] = sub(balanceP[msg.sender], _value);
|
| 195 |
+
balanceP[_to] = add(balanceP[_to], _value);
|
| 196 |
+
emit Transfer(msg.sender, _to, _value);
|
| 197 |
+
return true;
|
| 198 |
+
}
|
| 199 |
+
else {
|
| 200 |
+
return false;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool success) {
|
| 206 |
+
require(_value.length == _time.length);
|
| 207 |
+
|
| 208 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 209 |
+
uint256 i = 0;
|
| 210 |
+
uint256 totalValue = 0;
|
| 211 |
+
while (i < _value.length) {
|
| 212 |
+
totalValue = add(totalValue, _value[i]);
|
| 213 |
+
i++;
|
| 214 |
+
}
|
| 215 |
+
if (balanceP[msg.sender] >= totalValue && totalValue > 0) {
|
| 216 |
+
i = 0;
|
| 217 |
+
while (i < _time.length) {
|
| 218 |
+
balanceP[msg.sender] = sub(balanceP[msg.sender], _value[i]);
|
| 219 |
+
lockTime[_to].length = lockNum[_to]+1;
|
| 220 |
+
lockValue[_to].length = lockNum[_to]+1;
|
| 221 |
+
lockTime[_to][lockNum[_to]] = add(now, _time[i]);
|
| 222 |
+
lockValue[_to][lockNum[_to]] = _value[i];
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
emit TransferredLocked(msg.sender, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
emit Transfer(msg.sender, _to, lockValue[_to][lockNum[_to]]);
|
| 229 |
+
lockNum[_to]++;
|
| 230 |
+
i++;
|
| 231 |
+
}
|
| 232 |
+
return true;
|
| 233 |
+
}
|
| 234 |
+
else {
|
| 235 |
+
return false;
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public
|
| 241 |
+
validAddress(_from) validAddress(_to) returns (bool success) {
|
| 242 |
+
require(locker[msg.sender]);
|
| 243 |
+
require(_value.length == _time.length);
|
| 244 |
+
|
| 245 |
+
if (lockNum[_from] > 0) calcUnlock(_from);
|
| 246 |
+
uint256 i = 0;
|
| 247 |
+
uint256 totalValue = 0;
|
| 248 |
+
while (i < _value.length) {
|
| 249 |
+
totalValue = add(totalValue, _value[i]);
|
| 250 |
+
i++;
|
| 251 |
+
}
|
| 252 |
+
if (balanceP[_from] >= totalValue && totalValue > 0) {
|
| 253 |
+
i = 0;
|
| 254 |
+
while (i < _time.length) {
|
| 255 |
+
balanceP[_from] = sub(balanceP[_from], _value[i]);
|
| 256 |
+
lockTime[_to].length = lockNum[_to]+1;
|
| 257 |
+
lockValue[_to].length = lockNum[_to]+1;
|
| 258 |
+
lockTime[_to][lockNum[_to]] = add(now, _time[i]);
|
| 259 |
+
lockValue[_to][lockNum[_to]] = _value[i];
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
emit TransferredLocked(_from, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
emit Transfer(_from, _to, lockValue[_to][lockNum[_to]]);
|
| 266 |
+
lockNum[_to]++;
|
| 267 |
+
i++;
|
| 268 |
+
}
|
| 269 |
+
return true;
|
| 270 |
+
}
|
| 271 |
+
else {
|
| 272 |
+
return false;
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) {
|
| 278 |
+
if (lockNum[_from] > 0) calcUnlock(_from);
|
| 279 |
+
if (balanceP[_from] >= _value && _value > 0) {
|
| 280 |
+
allowance[_from][msg.sender] = sub(allowance[_from][msg.sender], _value);
|
| 281 |
+
balanceP[_from] = sub(balanceP[_from], _value);
|
| 282 |
+
balanceP[_to] = add(balanceP[_to], _value);
|
| 283 |
+
emit Transfer(_from, _to, _value);
|
| 284 |
+
return true;
|
| 285 |
+
}
|
| 286 |
+
else {
|
| 287 |
+
return false;
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) {
|
| 293 |
+
require(_value == 0 || allowance[msg.sender][_spender] == 0);
|
| 294 |
+
|
| 295 |
+
if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
|
| 296 |
+
allowance[msg.sender][_spender] = _value;
|
| 297 |
+
emit Approval(msg.sender, _spender, _value);
|
| 298 |
+
return true;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
function () public payable {
|
| 303 |
+
revert();
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
}
|
benchmark2/integer overflow/574.sol
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.21;
|
| 2 |
+
|
| 3 |
+
contract Ownable {
|
| 4 |
+
address public owner;
|
| 5 |
+
address public newOwner;
|
| 6 |
+
|
| 7 |
+
event OwnershipTransferred(address indexed _from, address indexed _to);
|
| 8 |
+
|
| 9 |
+
function Ownable() public {
|
| 10 |
+
owner = msg.sender;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
modifier onlyOwner {
|
| 14 |
+
require(msg.sender == owner);
|
| 15 |
+
_;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 19 |
+
newOwner = _newOwner;
|
| 20 |
+
}
|
| 21 |
+
function acceptOwnership() public {
|
| 22 |
+
require(msg.sender == newOwner);
|
| 23 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 24 |
+
owner = newOwner;
|
| 25 |
+
newOwner = address(0);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
library SafeMath {
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 33 |
+
if (a == 0) {
|
| 34 |
+
return 0;
|
| 35 |
+
}
|
| 36 |
+
c = a * b;
|
| 37 |
+
assert(c / a == b);
|
| 38 |
+
return c;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
return a / b;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 51 |
+
assert(b <= a);
|
| 52 |
+
return a - b;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 57 |
+
c = a + b;
|
| 58 |
+
assert(c >= a);
|
| 59 |
+
return c;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
contract Pausable is Ownable {
|
| 64 |
+
event Pause();
|
| 65 |
+
event Unpause();
|
| 66 |
+
|
| 67 |
+
bool public paused = false;
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
modifier whenNotPaused() {
|
| 72 |
+
require(!paused);
|
| 73 |
+
_;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
modifier whenPaused {
|
| 78 |
+
require(paused);
|
| 79 |
+
_;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
function pause() onlyOwner whenNotPaused public returns (bool) {
|
| 84 |
+
paused = true;
|
| 85 |
+
emit Pause();
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function unpause() onlyOwner whenPaused public returns (bool) {
|
| 91 |
+
paused = false;
|
| 92 |
+
emit Unpause();
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
contract ERC20Interface {
|
| 104 |
+
function totalSupply() public constant returns (uint);
|
| 105 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance);
|
| 106 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
|
| 107 |
+
function transfer(address to, uint tokens) public returns (bool success);
|
| 108 |
+
function approve(address spender, uint tokens) public returns (bool success);
|
| 109 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success);
|
| 110 |
+
|
| 111 |
+
event Transfer(address indexed from, address indexed to, uint tokens);
|
| 112 |
+
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
contract ApproveAndCallFallBack {
|
| 122 |
+
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
contract ROA is ERC20Interface, Pausable {
|
| 131 |
+
using SafeMath for uint;
|
| 132 |
+
|
| 133 |
+
string public symbol;
|
| 134 |
+
string public name;
|
| 135 |
+
uint8 public decimals;
|
| 136 |
+
uint public _totalSupply;
|
| 137 |
+
|
| 138 |
+
mapping(address => uint) balances;
|
| 139 |
+
mapping(address => mapping(address => uint)) allowed;
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
function ROA() public {
|
| 146 |
+
symbol = "ROA";
|
| 147 |
+
name = "NeoWorld Rare Ore A";
|
| 148 |
+
decimals = 18;
|
| 149 |
+
_totalSupply = 10000000 * 10**uint(decimals);
|
| 150 |
+
balances[owner] = _totalSupply;
|
| 151 |
+
emit Transfer(address(0), owner, _totalSupply);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
function totalSupply() public constant returns (uint) {
|
| 158 |
+
return _totalSupply - balances[address(0)];
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance) {
|
| 165 |
+
return balances[tokenOwner];
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 175 |
+
balances[msg.sender] = balances[msg.sender].sub(tokens);
|
| 176 |
+
balances[to] = balances[to].add(tokens);
|
| 177 |
+
emit Transfer(msg.sender, to, tokens);
|
| 178 |
+
return true;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
function approve(address spender, uint tokens) public whenNotPaused returns (bool success) {
|
| 191 |
+
allowed[msg.sender][spender] = tokens;
|
| 192 |
+
emit Approval(msg.sender, spender, tokens);
|
| 193 |
+
return true;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
function increaseApproval (address _spender, uint _addedValue) public whenNotPaused
|
| 197 |
+
returns (bool success) {
|
| 198 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 199 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 200 |
+
return true;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
function decreaseApproval (address _spender, uint _subtractedValue) public whenNotPaused
|
| 204 |
+
returns (bool success) {
|
| 205 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 206 |
+
if (_subtractedValue > oldValue) {
|
| 207 |
+
allowed[msg.sender][_spender] = 0;
|
| 208 |
+
} else {
|
| 209 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 210 |
+
}
|
| 211 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 212 |
+
return true;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 225 |
+
balances[from] = balances[from].sub(tokens);
|
| 226 |
+
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
|
| 227 |
+
balances[to] = balances[to].add(tokens);
|
| 228 |
+
emit Transfer(from, to, tokens);
|
| 229 |
+
return true;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
|
| 238 |
+
return allowed[tokenOwner][spender];
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
|
| 248 |
+
allowed[msg.sender][spender] = tokens;
|
| 249 |
+
emit Approval(msg.sender, spender, tokens);
|
| 250 |
+
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
|
| 251 |
+
return true;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
function () public payable {
|
| 259 |
+
revert();
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
|
| 267 |
+
return ERC20Interface(tokenAddress).transfer(owner, tokens);
|
| 268 |
+
}
|
| 269 |
+
}
|
benchmark2/integer overflow/575.sol
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.21;
|
| 2 |
+
|
| 3 |
+
contract Ownable {
|
| 4 |
+
address public owner;
|
| 5 |
+
address public newOwner;
|
| 6 |
+
|
| 7 |
+
event OwnershipTransferred(address indexed _from, address indexed _to);
|
| 8 |
+
|
| 9 |
+
function Ownable() public {
|
| 10 |
+
owner = msg.sender;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
modifier onlyOwner {
|
| 14 |
+
require(msg.sender == owner);
|
| 15 |
+
_;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 19 |
+
newOwner = _newOwner;
|
| 20 |
+
}
|
| 21 |
+
function acceptOwnership() public {
|
| 22 |
+
require(msg.sender == newOwner);
|
| 23 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 24 |
+
owner = newOwner;
|
| 25 |
+
newOwner = address(0);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
library SafeMath {
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 33 |
+
if (a == 0) {
|
| 34 |
+
return 0;
|
| 35 |
+
}
|
| 36 |
+
c = a * b;
|
| 37 |
+
assert(c / a == b);
|
| 38 |
+
return c;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
return a / b;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 51 |
+
assert(b <= a);
|
| 52 |
+
return a - b;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 57 |
+
c = a + b;
|
| 58 |
+
assert(c >= a);
|
| 59 |
+
return c;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
contract Pausable is Ownable {
|
| 64 |
+
event Pause();
|
| 65 |
+
event Unpause();
|
| 66 |
+
|
| 67 |
+
bool public paused = false;
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
modifier whenNotPaused() {
|
| 72 |
+
require(!paused);
|
| 73 |
+
_;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
modifier whenPaused {
|
| 78 |
+
require(paused);
|
| 79 |
+
_;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
function pause() onlyOwner whenNotPaused public returns (bool) {
|
| 84 |
+
paused = true;
|
| 85 |
+
emit Pause();
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function unpause() onlyOwner whenPaused public returns (bool) {
|
| 91 |
+
paused = false;
|
| 92 |
+
emit Unpause();
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
contract ERC20Interface {
|
| 104 |
+
function totalSupply() public constant returns (uint);
|
| 105 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance);
|
| 106 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
|
| 107 |
+
function transfer(address to, uint tokens) public returns (bool success);
|
| 108 |
+
function approve(address spender, uint tokens) public returns (bool success);
|
| 109 |
+
function transferFrom(address from, address to, uint tokens) public returns (bool success);
|
| 110 |
+
|
| 111 |
+
event Transfer(address indexed from, address indexed to, uint tokens);
|
| 112 |
+
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
contract ApproveAndCallFallBack {
|
| 122 |
+
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
contract ROB is ERC20Interface, Pausable {
|
| 131 |
+
using SafeMath for uint;
|
| 132 |
+
|
| 133 |
+
string public symbol;
|
| 134 |
+
string public name;
|
| 135 |
+
uint8 public decimals;
|
| 136 |
+
uint public _totalSupply;
|
| 137 |
+
|
| 138 |
+
mapping(address => uint) balances;
|
| 139 |
+
mapping(address => mapping(address => uint)) allowed;
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
function ROB() public {
|
| 146 |
+
symbol = "ROB";
|
| 147 |
+
name = "NeoWorld Rare Ore B";
|
| 148 |
+
decimals = 18;
|
| 149 |
+
_totalSupply = 10000000 * 10**uint(decimals);
|
| 150 |
+
balances[owner] = _totalSupply;
|
| 151 |
+
emit Transfer(address(0), owner, _totalSupply);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
function totalSupply() public constant returns (uint) {
|
| 159 |
+
return _totalSupply - balances[address(0)];
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
function balanceOf(address tokenOwner) public constant returns (uint balance) {
|
| 166 |
+
return balances[tokenOwner];
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 176 |
+
balances[msg.sender] = balances[msg.sender].sub(tokens);
|
| 177 |
+
balances[to] = balances[to].add(tokens);
|
| 178 |
+
emit Transfer(msg.sender, to, tokens);
|
| 179 |
+
return true;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
function approve(address spender, uint tokens) public whenNotPaused returns (bool success) {
|
| 192 |
+
allowed[msg.sender][spender] = tokens;
|
| 193 |
+
emit Approval(msg.sender, spender, tokens);
|
| 194 |
+
return true;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
function increaseApproval (address _spender, uint _addedValue) public whenNotPaused
|
| 198 |
+
returns (bool success) {
|
| 199 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 200 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 201 |
+
return true;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function decreaseApproval (address _spender, uint _subtractedValue) public whenNotPaused
|
| 205 |
+
returns (bool success) {
|
| 206 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 207 |
+
if (_subtractedValue > oldValue) {
|
| 208 |
+
allowed[msg.sender][_spender] = 0;
|
| 209 |
+
} else {
|
| 210 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 211 |
+
}
|
| 212 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 213 |
+
return true;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
|
| 226 |
+
balances[from] = balances[from].sub(tokens);
|
| 227 |
+
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
|
| 228 |
+
balances[to] = balances[to].add(tokens);
|
| 229 |
+
emit Transfer(from, to, tokens);
|
| 230 |
+
return true;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
|
| 239 |
+
return allowed[tokenOwner][spender];
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
|
| 249 |
+
allowed[msg.sender][spender] = tokens;
|
| 250 |
+
emit Approval(msg.sender, spender, tokens);
|
| 251 |
+
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
|
| 252 |
+
return true;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
function () public payable {
|
| 260 |
+
revert();
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
|
| 268 |
+
return ERC20Interface(tokenAddress).transfer(owner, tokens);
|
| 269 |
+
}
|
| 270 |
+
}
|
benchmark2/integer overflow/6.sol
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.18;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeMul(uint256 a, uint256 b) internal returns (uint256) {
|
| 6 |
+
uint256 c = a * b;
|
| 7 |
+
assert(a == 0 || c / a == b);
|
| 8 |
+
return c;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function safeDiv(uint256 a, uint256 b) internal returns (uint256) {
|
| 12 |
+
assert(b > 0);
|
| 13 |
+
uint256 c = a / b;
|
| 14 |
+
assert(a == b * c + a % b);
|
| 15 |
+
return c;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function safeSub(uint256 a, uint256 b) internal returns (uint256) {
|
| 19 |
+
assert(b <= a);
|
| 20 |
+
return a - b;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function safeAdd(uint256 a, uint256 b) internal returns (uint256) {
|
| 24 |
+
uint256 c = a + b;
|
| 25 |
+
assert(c>=a && c>=b);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function assert(bool assertion) internal {
|
| 30 |
+
if (!assertion) {
|
| 31 |
+
throw;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
contract REL is SafeMath{
|
| 36 |
+
string public name;
|
| 37 |
+
string public symbol;
|
| 38 |
+
uint8 public decimals;
|
| 39 |
+
uint256 public totalSupply;
|
| 40 |
+
address public owner;
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
mapping (address => uint256) public balanceOf;
|
| 44 |
+
mapping (address => uint256) public freezeOf;
|
| 45 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
event Burn(address indexed from, uint256 value);
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
event Freeze(address indexed from, uint256 value);
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
event Unfreeze(address indexed from, uint256 value);
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
function REL(
|
| 61 |
+
uint256 initialSupply,
|
| 62 |
+
string tokenName,
|
| 63 |
+
uint8 decimalUnits,
|
| 64 |
+
string tokenSymbol
|
| 65 |
+
) {
|
| 66 |
+
balanceOf[msg.sender] = initialSupply;
|
| 67 |
+
totalSupply = initialSupply;
|
| 68 |
+
name = tokenName;
|
| 69 |
+
symbol = tokenSymbol;
|
| 70 |
+
decimals = decimalUnits;
|
| 71 |
+
owner = msg.sender;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
function transfer(address _to, uint256 _value) {
|
| 76 |
+
if (_to == 0x0) throw;
|
| 77 |
+
if (_value <= 0) throw;
|
| 78 |
+
if (balanceOf[msg.sender] < _value) throw;
|
| 79 |
+
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
|
| 80 |
+
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
|
| 81 |
+
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
|
| 82 |
+
Transfer(msg.sender, _to, _value);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
function approve(address _spender, uint256 _value)
|
| 87 |
+
returns (bool success) {
|
| 88 |
+
if (_value <= 0) throw;
|
| 89 |
+
allowance[msg.sender][_spender] = _value;
|
| 90 |
+
return true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
| 96 |
+
if (_to == 0x0) throw;
|
| 97 |
+
if (_value <= 0) throw;
|
| 98 |
+
if (balanceOf[_from] < _value) throw;
|
| 99 |
+
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
|
| 100 |
+
if (_value > allowance[_from][msg.sender]) throw;
|
| 101 |
+
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
|
| 102 |
+
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
|
| 103 |
+
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
|
| 104 |
+
Transfer(_from, _to, _value);
|
| 105 |
+
return true;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function burn(uint256 _value) returns (bool success) {
|
| 109 |
+
if (balanceOf[msg.sender] < _value) throw;
|
| 110 |
+
if (_value <= 0) throw;
|
| 111 |
+
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
|
| 112 |
+
totalSupply = SafeMath.safeSub(totalSupply,_value);
|
| 113 |
+
Burn(msg.sender, _value);
|
| 114 |
+
return true;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
function freeze(uint256 _value) returns (bool success) {
|
| 118 |
+
if (balanceOf[msg.sender] < _value) throw;
|
| 119 |
+
if (_value <= 0) throw;
|
| 120 |
+
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
|
| 121 |
+
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
|
| 122 |
+
Freeze(msg.sender, _value);
|
| 123 |
+
return true;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function unfreeze(uint256 _value) returns (bool success) {
|
| 127 |
+
if (freezeOf[msg.sender] < _value) throw;
|
| 128 |
+
if (_value <= 0) throw;
|
| 129 |
+
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
|
| 130 |
+
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
|
| 131 |
+
Unfreeze(msg.sender, _value);
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
function withdrawEther(uint256 amount) {
|
| 137 |
+
if(msg.sender != owner)throw;
|
| 138 |
+
owner.transfer(amount);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
function() payable {
|
| 143 |
+
}
|
| 144 |
+
}
|
benchmark2/integer overflow/600.sol
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
library SafeMath {
|
| 5 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 6 |
+
assert(a >= b);
|
| 7 |
+
return a - b;
|
| 8 |
+
}
|
| 9 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 10 |
+
uint256 c = a + b;
|
| 11 |
+
assert(c >= a);
|
| 12 |
+
return c;
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
contract Owned {
|
| 18 |
+
address public owner;
|
| 19 |
+
|
| 20 |
+
event OwnershipTransfered(address indexed owner);
|
| 21 |
+
|
| 22 |
+
constructor() public {
|
| 23 |
+
owner = msg.sender;
|
| 24 |
+
emit OwnershipTransfered(owner);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
modifier onlyOwner {
|
| 28 |
+
require(msg.sender == owner);
|
| 29 |
+
_;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 33 |
+
owner = newOwner;
|
| 34 |
+
emit OwnershipTransfered(owner);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract ERC20Token {
|
| 40 |
+
using SafeMath for uint256;
|
| 41 |
+
|
| 42 |
+
string public constant name = "Ansforce Intelligence Token";
|
| 43 |
+
string public constant symbol = "AIT";
|
| 44 |
+
uint8 public constant decimals = 18;
|
| 45 |
+
uint256 public totalSupply = 0;
|
| 46 |
+
|
| 47 |
+
mapping (address => uint256) public balanceOf;
|
| 48 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 49 |
+
|
| 50 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 51 |
+
event Approval(address indexed from, uint256 value, address indexed to, bytes extraData);
|
| 52 |
+
|
| 53 |
+
constructor() public {
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
function _transfer(address from, address to, uint256 value) internal {
|
| 58 |
+
|
| 59 |
+
require(balanceOf[from] >= value);
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
require(balanceOf[to] + value > balanceOf[to]);
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
uint256 previousBalances = balanceOf[from].add(balanceOf[to]);
|
| 66 |
+
|
| 67 |
+
balanceOf[from] = balanceOf[from].sub(value);
|
| 68 |
+
balanceOf[to] = balanceOf[to].add(value);
|
| 69 |
+
|
| 70 |
+
emit Transfer(from, to, value);
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
assert(balanceOf[from].add(balanceOf[to]) == previousBalances);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function transfer(address to, uint256 value) public {
|
| 78 |
+
_transfer(msg.sender, to, value);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
|
| 83 |
+
require(value <= allowance[from][msg.sender]);
|
| 84 |
+
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
|
| 85 |
+
_transfer(from, to, value);
|
| 86 |
+
return true;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function approve(address spender, uint256 value, bytes extraData) public returns (bool success) {
|
| 91 |
+
allowance[msg.sender][spender] = value;
|
| 92 |
+
emit Approval(msg.sender, value, spender, extraData);
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
contract AnsforceIntelligenceToken is Owned, ERC20Token {
|
| 99 |
+
constructor() public {
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function init(uint256 _supply, address _vault) public onlyOwner {
|
| 103 |
+
require(totalSupply == 0);
|
| 104 |
+
require(_supply > 0);
|
| 105 |
+
require(_vault != address(0));
|
| 106 |
+
totalSupply = _supply;
|
| 107 |
+
balanceOf[_vault] = totalSupply;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
bool public stopped = false;
|
| 112 |
+
|
| 113 |
+
modifier isRunning {
|
| 114 |
+
require (!stopped);
|
| 115 |
+
_;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function transfer(address to, uint256 value) isRunning public {
|
| 119 |
+
ERC20Token.transfer(to, value);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function stop() public onlyOwner {
|
| 123 |
+
stopped = true;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function start() public onlyOwner {
|
| 127 |
+
stopped = false;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
mapping (address => uint256) public freezeOf;
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
event Freeze(address indexed target, uint256 value);
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
event Unfreeze(address indexed target, uint256 value);
|
| 138 |
+
|
| 139 |
+
function freeze(address target, uint256 _value) public onlyOwner returns (bool success) {
|
| 140 |
+
require( _value > 0 );
|
| 141 |
+
balanceOf[target] = SafeMath.sub(balanceOf[target], _value);
|
| 142 |
+
freezeOf[target] = SafeMath.add(freezeOf[target], _value);
|
| 143 |
+
emit Freeze(target, _value);
|
| 144 |
+
return true;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
function unfreeze(address target, uint256 _value) public onlyOwner returns (bool success) {
|
| 148 |
+
require( _value > 0 );
|
| 149 |
+
freezeOf[target] = SafeMath.sub(freezeOf[target], _value);
|
| 150 |
+
balanceOf[target] = SafeMath.add(balanceOf[target], _value);
|
| 151 |
+
emit Unfreeze(target, _value);
|
| 152 |
+
return true;
|
| 153 |
+
}
|
| 154 |
+
}
|
benchmark2/integer overflow/607.sol
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.21;
|
| 2 |
+
|
| 3 |
+
// File: contracts/ownership/Ownable.sol
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* @title Ownable
|
| 7 |
+
* @dev The Ownable contract has an owner address, and provides basic authorization control
|
| 8 |
+
* functions, this simplifies the implementation of "user permissions".
|
| 9 |
+
*/
|
| 10 |
+
contract Ownable {
|
| 11 |
+
address public owner;
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 15 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
|
| 20 |
+
* account.
|
| 21 |
+
*/
|
| 22 |
+
function Ownable() public {
|
| 23 |
+
owner = msg.sender;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @dev Throws if called by any account other than the owner.
|
| 28 |
+
*/
|
| 29 |
+
modifier onlyOwner() {
|
| 30 |
+
require(msg.sender == owner);
|
| 31 |
+
_;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* @dev Allows the current owner to transfer control of the contract to a newOwner.
|
| 36 |
+
* @param newOwner The address to transfer ownership to.
|
| 37 |
+
*/
|
| 38 |
+
function transferOwnership(address newOwner) public onlyOwner {
|
| 39 |
+
require(newOwner != address(0));
|
| 40 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 41 |
+
owner = newOwner;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* @dev Allows the current owner to relinquish control of the contract.
|
| 46 |
+
*/
|
| 47 |
+
function renounceOwnership() public onlyOwner {
|
| 48 |
+
emit OwnershipRenounced(owner);
|
| 49 |
+
owner = address(0);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// File: contracts/math/SafeMath.sol
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* @title SafeMath
|
| 57 |
+
* @dev Math operations with safety checks that throw on error
|
| 58 |
+
*/
|
| 59 |
+
library SafeMath {
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @dev Multiplies two numbers, throws on overflow.
|
| 63 |
+
*/
|
| 64 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 65 |
+
if (a == 0) {
|
| 66 |
+
return 0;
|
| 67 |
+
}
|
| 68 |
+
c = a * b;
|
| 69 |
+
assert(c / a == b);
|
| 70 |
+
return c;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* @dev Integer division of two numbers, truncating the quotient.
|
| 75 |
+
*/
|
| 76 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 77 |
+
// assert(b > 0); // Solidity automatically throws when dividing by 0
|
| 78 |
+
// uint256 c = a / b;
|
| 79 |
+
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
|
| 80 |
+
return a / b;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
|
| 85 |
+
*/
|
| 86 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 87 |
+
assert(b <= a);
|
| 88 |
+
return a - b;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* @dev Adds two numbers, throws on overflow.
|
| 93 |
+
*/
|
| 94 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 95 |
+
c = a + b;
|
| 96 |
+
assert(c >= a);
|
| 97 |
+
return c;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
// File: contracts/token/ERC20/ERC20Basic.sol
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* @title ERC20Basic
|
| 105 |
+
* @dev Simpler version of ERC20 interface
|
| 106 |
+
* @dev see https://github.com/ethereum/EIPs/issues/179
|
| 107 |
+
*/
|
| 108 |
+
contract ERC20Basic {
|
| 109 |
+
function totalSupply() public view returns (uint256);
|
| 110 |
+
function balanceOf(address who) public view returns (uint256);
|
| 111 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 112 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// File: contracts/token/ERC20/BasicToken.sol
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* @title Basic token
|
| 119 |
+
* @dev Basic version of StandardToken, with no allowances.
|
| 120 |
+
*/
|
| 121 |
+
contract BasicToken is ERC20Basic {
|
| 122 |
+
using SafeMath for uint256;
|
| 123 |
+
|
| 124 |
+
mapping(address => uint256) balances;
|
| 125 |
+
|
| 126 |
+
uint256 totalSupply_;
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* @dev total number of tokens in existence
|
| 130 |
+
*/
|
| 131 |
+
function totalSupply() public view returns (uint256) {
|
| 132 |
+
return totalSupply_;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* @dev transfer token for a specified address
|
| 137 |
+
* @param _to The address to transfer to.
|
| 138 |
+
* @param _value The amount to be transferred.
|
| 139 |
+
*/
|
| 140 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 141 |
+
require(_to != address(0));
|
| 142 |
+
require(_value <= balances[msg.sender]);
|
| 143 |
+
|
| 144 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 145 |
+
balances[_to] = balances[_to].add(_value);
|
| 146 |
+
emit Transfer(msg.sender, _to, _value);
|
| 147 |
+
return true;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* @dev Gets the balance of the specified address.
|
| 152 |
+
* @param _owner The address to query the the balance of.
|
| 153 |
+
* @return An uint256 representing the amount owned by the passed address.
|
| 154 |
+
*/
|
| 155 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 156 |
+
return balances[_owner];
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
// File: contracts/token/ERC20/ERC20.sol
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* @title ERC20 interface
|
| 167 |
+
* @dev see https://github.com/ethereum/EIPs/issues/20
|
| 168 |
+
*/
|
| 169 |
+
contract ERC20 is ERC20Basic {
|
| 170 |
+
function allowance(address owner, address spender) public view returns (uint256);
|
| 171 |
+
function transferFrom(address from, address to, uint256 value) public returns (bool);
|
| 172 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 173 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// File: contracts/token/ERC20/StandardToken.sol
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* @title Standard ERC20 token
|
| 180 |
+
*
|
| 181 |
+
* @dev Implementation of the basic standard token.
|
| 182 |
+
* @dev https://github.com/ethereum/EIPs/issues/20
|
| 183 |
+
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
|
| 184 |
+
*/
|
| 185 |
+
contract StandardToken is ERC20, BasicToken {
|
| 186 |
+
|
| 187 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* @dev Transfer tokens from one address to another
|
| 192 |
+
* @param _from address The address which you want to send tokens from
|
| 193 |
+
* @param _to address The address which you want to transfer to
|
| 194 |
+
* @param _value uint256 the amount of tokens to be transferred
|
| 195 |
+
*/
|
| 196 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
| 197 |
+
require(_to != address(0));
|
| 198 |
+
require(_value <= balances[_from]);
|
| 199 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 200 |
+
|
| 201 |
+
balances[_from] = balances[_from].sub(_value);
|
| 202 |
+
balances[_to] = balances[_to].add(_value);
|
| 203 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 204 |
+
emit Transfer(_from, _to, _value);
|
| 205 |
+
return true;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
|
| 210 |
+
*
|
| 211 |
+
* Beware that changing an allowance with this method brings the risk that someone may use both the old
|
| 212 |
+
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
|
| 213 |
+
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
|
| 214 |
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
| 215 |
+
* @param _spender The address which will spend the funds.
|
| 216 |
+
* @param _value The amount of tokens to be spent.
|
| 217 |
+
*/
|
| 218 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 219 |
+
allowed[msg.sender][_spender] = _value;
|
| 220 |
+
emit Approval(msg.sender, _spender, _value);
|
| 221 |
+
return true;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* @dev Function to check the amount of tokens that an owner allowed to a spender.
|
| 226 |
+
* @param _owner address The address which owns the funds.
|
| 227 |
+
* @param _spender address The address which will spend the funds.
|
| 228 |
+
* @return A uint256 specifying the amount of tokens still available for the spender.
|
| 229 |
+
*/
|
| 230 |
+
function allowance(address _owner, address _spender) public view returns (uint256) {
|
| 231 |
+
return allowed[_owner][_spender];
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/**
|
| 235 |
+
* @dev Increase the amount of tokens that an owner allowed to a spender.
|
| 236 |
+
*
|
| 237 |
+
* approve should be called when allowed[_spender] == 0. To increment
|
| 238 |
+
* allowed value is better to use this function to avoid 2 calls (and wait until
|
| 239 |
+
* the first transaction is mined)
|
| 240 |
+
* From MonolithDAO Token.sol
|
| 241 |
+
* @param _spender The address which will spend the funds.
|
| 242 |
+
* @param _addedValue The amount of tokens to increase the allowance by.
|
| 243 |
+
*/
|
| 244 |
+
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
|
| 245 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 246 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 247 |
+
return true;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* @dev Decrease the amount of tokens that an owner allowed to a spender.
|
| 252 |
+
*
|
| 253 |
+
* approve should be called when allowed[_spender] == 0. To decrement
|
| 254 |
+
* allowed value is better to use this function to avoid 2 calls (and wait until
|
| 255 |
+
* the first transaction is mined)
|
| 256 |
+
* From MonolithDAO Token.sol
|
| 257 |
+
* @param _spender The address which will spend the funds.
|
| 258 |
+
* @param _subtractedValue The amount of tokens to decrease the allowance by.
|
| 259 |
+
*/
|
| 260 |
+
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
|
| 261 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 262 |
+
if (_subtractedValue > oldValue) {
|
| 263 |
+
allowed[msg.sender][_spender] = 0;
|
| 264 |
+
} else {
|
| 265 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 266 |
+
}
|
| 267 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 268 |
+
return true;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
contract DubaiGreenBlockChain is StandardToken, Ownable {
|
| 274 |
+
// Constants
|
| 275 |
+
string public constant name = "Dubai Green BlockChain";
|
| 276 |
+
string public constant symbol = "DGBC";
|
| 277 |
+
uint8 public constant decimals = 4;
|
| 278 |
+
uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals));
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
mapping(address => bool) touched;
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
function DubaiGreenBlockChain() public {
|
| 285 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 290 |
+
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 294 |
+
require (balances[_from] >= _value); // Check if the sender has enough
|
| 295 |
+
require (balances[_to] + _value > balances[_to]); // Check for overflows
|
| 296 |
+
|
| 297 |
+
balances[_from] = balances[_from].sub(_value); // Subtract from the sender
|
| 298 |
+
balances[_to] = balances[_to].add(_value); // Add the same to the recipient
|
| 299 |
+
|
| 300 |
+
emit Transfer(_from, _to, _value);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
function safeWithdrawal(uint _value ) onlyOwner public {
|
| 305 |
+
if (_value == 0)
|
| 306 |
+
owner.transfer(address(this).balance);
|
| 307 |
+
else
|
| 308 |
+
owner.transfer(_value);
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
}
|
benchmark2/integer overflow/609.sol
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.13;
|
| 2 |
+
|
| 3 |
+
contract Ownable {
|
| 4 |
+
address public owner;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 8 |
+
event OwnershipTransferred(
|
| 9 |
+
address indexed previousOwner,
|
| 10 |
+
address indexed newOwner
|
| 11 |
+
);
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
constructor() public {
|
| 16 |
+
owner = msg.sender;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
modifier onlyOwner() {
|
| 21 |
+
require(msg.sender == owner);
|
| 22 |
+
_;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
function renounceOwnership() public onlyOwner {
|
| 27 |
+
emit OwnershipRenounced(owner);
|
| 28 |
+
owner = address(0);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 33 |
+
_transferOwnership(_newOwner);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
function _transferOwnership(address _newOwner) internal {
|
| 38 |
+
require(_newOwner != address(0));
|
| 39 |
+
emit OwnershipTransferred(owner, _newOwner);
|
| 40 |
+
owner = _newOwner;
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
contract ERC20Basic {
|
| 45 |
+
function totalSupply() public view returns (uint256);
|
| 46 |
+
function balanceOf(address who) public view returns (uint256);
|
| 47 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 48 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
contract ERC20 is ERC20Basic {
|
| 52 |
+
function allowance(address owner, address spender)
|
| 53 |
+
public view returns (uint256);
|
| 54 |
+
|
| 55 |
+
function transferFrom(address from, address to, uint256 value)
|
| 56 |
+
public returns (bool);
|
| 57 |
+
|
| 58 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 59 |
+
event Approval(
|
| 60 |
+
address indexed owner,
|
| 61 |
+
address indexed spender,
|
| 62 |
+
uint256 value
|
| 63 |
+
);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
library SafeMath {
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
if (a == 0) {
|
| 74 |
+
return 0;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
c = a * b;
|
| 78 |
+
assert(c / a == b);
|
| 79 |
+
return c;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
return a / b;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 92 |
+
assert(b <= a);
|
| 93 |
+
return a - b;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 98 |
+
c = a + b;
|
| 99 |
+
assert(c >= a);
|
| 100 |
+
return c;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
contract BasicToken is ERC20Basic {
|
| 105 |
+
using SafeMath for uint256;
|
| 106 |
+
|
| 107 |
+
mapping(address => uint256) balances;
|
| 108 |
+
|
| 109 |
+
uint256 totalSupply_;
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
function totalSupply() public view returns (uint256) {
|
| 113 |
+
return totalSupply_;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 118 |
+
require(_to != address(0));
|
| 119 |
+
require(_value <= balances[msg.sender]);
|
| 120 |
+
|
| 121 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 122 |
+
balances[_to] = balances[_to].add(_value);
|
| 123 |
+
emit Transfer(msg.sender, _to, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 129 |
+
return balances[_owner];
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
contract StandardToken is ERC20, BasicToken {
|
| 135 |
+
|
| 136 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
function transferFrom(
|
| 141 |
+
address _from,
|
| 142 |
+
address _to,
|
| 143 |
+
uint256 _value
|
| 144 |
+
)
|
| 145 |
+
public
|
| 146 |
+
returns (bool)
|
| 147 |
+
{
|
| 148 |
+
require(_to != address(0));
|
| 149 |
+
require(_value <= balances[_from]);
|
| 150 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 151 |
+
|
| 152 |
+
balances[_from] = balances[_from].sub(_value);
|
| 153 |
+
balances[_to] = balances[_to].add(_value);
|
| 154 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 155 |
+
emit Transfer(_from, _to, _value);
|
| 156 |
+
return true;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 161 |
+
allowed[msg.sender][_spender] = _value;
|
| 162 |
+
emit Approval(msg.sender, _spender, _value);
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function allowance(
|
| 168 |
+
address _owner,
|
| 169 |
+
address _spender
|
| 170 |
+
)
|
| 171 |
+
public
|
| 172 |
+
view
|
| 173 |
+
returns (uint256)
|
| 174 |
+
{
|
| 175 |
+
return allowed[_owner][_spender];
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
function increaseApproval(
|
| 180 |
+
address _spender,
|
| 181 |
+
uint _addedValue
|
| 182 |
+
)
|
| 183 |
+
public
|
| 184 |
+
returns (bool)
|
| 185 |
+
{
|
| 186 |
+
allowed[msg.sender][_spender] = (
|
| 187 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 188 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 189 |
+
return true;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
function decreaseApproval(
|
| 194 |
+
address _spender,
|
| 195 |
+
uint _subtractedValue
|
| 196 |
+
)
|
| 197 |
+
public
|
| 198 |
+
returns (bool)
|
| 199 |
+
{
|
| 200 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 201 |
+
if (_subtractedValue > oldValue) {
|
| 202 |
+
allowed[msg.sender][_spender] = 0;
|
| 203 |
+
} else {
|
| 204 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 205 |
+
}
|
| 206 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 207 |
+
return true;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
contract ArtBlockchainToken is StandardToken, Ownable {
|
| 213 |
+
string public name = "Art Blockchain Token";
|
| 214 |
+
string public symbol = "ARTCN";
|
| 215 |
+
uint public decimals = 18;
|
| 216 |
+
uint internal INITIAL_SUPPLY = (10 ** 9) * (10 ** decimals);
|
| 217 |
+
|
| 218 |
+
mapping(address => uint256) private userLockedTokens;
|
| 219 |
+
event Freeze(address indexed account, uint256 value);
|
| 220 |
+
event UnFreeze(address indexed account, uint256 value);
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
constructor(address _addressFounder) public {
|
| 224 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 225 |
+
balances[_addressFounder] = INITIAL_SUPPLY;
|
| 226 |
+
emit Transfer(0x0, _addressFounder, INITIAL_SUPPLY);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function balance(address _owner) internal view returns (uint256 token) {
|
| 230 |
+
return balances[_owner].sub(userLockedTokens[_owner]);
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
function lockedTokens(address _owner) public view returns (uint256 token) {
|
| 234 |
+
return userLockedTokens[_owner];
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
function freezeAccount(address _userAddress, uint256 _amount) onlyOwner public returns (bool success) {
|
| 238 |
+
require(balance(_userAddress) >= _amount);
|
| 239 |
+
userLockedTokens[_userAddress] = userLockedTokens[_userAddress].add(_amount);
|
| 240 |
+
emit Freeze(_userAddress, _amount);
|
| 241 |
+
return true;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
function unfreezeAccount(address _userAddress, uint256 _amount) onlyOwner public returns (bool success) {
|
| 245 |
+
require(userLockedTokens[_userAddress] >= _amount);
|
| 246 |
+
userLockedTokens[_userAddress] = userLockedTokens[_userAddress].sub(_amount);
|
| 247 |
+
emit UnFreeze(_userAddress, _amount);
|
| 248 |
+
return true;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 252 |
+
require(balance(msg.sender) >= _value);
|
| 253 |
+
return super.transfer(_to, _value);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 257 |
+
require(balance(_from) >= _value);
|
| 258 |
+
return super.transferFrom(_from, _to, _value);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
}
|
benchmark2/integer overflow/626.sol
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
library SafeMath {
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
if (a == 0) {
|
| 11 |
+
return 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
c = a * b;
|
| 15 |
+
assert(c / a == b);
|
| 16 |
+
return c;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
return a / b;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 29 |
+
assert(b <= a);
|
| 30 |
+
return a - b;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 35 |
+
c = a + b;
|
| 36 |
+
assert(c >= a);
|
| 37 |
+
return c;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
contract ERC20Basic {
|
| 43 |
+
function totalSupply() public view returns (uint256);
|
| 44 |
+
function balanceOf(address who) public view returns (uint256);
|
| 45 |
+
function transfer(address to, uint256 value) public returns (bool);
|
| 46 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
contract BasicToken is ERC20Basic {
|
| 51 |
+
using SafeMath for uint256;
|
| 52 |
+
|
| 53 |
+
mapping(address => uint256) balances;
|
| 54 |
+
|
| 55 |
+
uint256 totalSupply_;
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
function totalSupply() public view returns (uint256) {
|
| 59 |
+
return totalSupply_;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 64 |
+
require(_to != address(0));
|
| 65 |
+
require(_value <= balances[msg.sender]);
|
| 66 |
+
|
| 67 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 68 |
+
balances[_to] = balances[_to].add(_value);
|
| 69 |
+
emit Transfer(msg.sender, _to, _value);
|
| 70 |
+
return true;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 75 |
+
return balances[_owner];
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
contract ERC20 is ERC20Basic {
|
| 82 |
+
function allowance(address owner, address spender)
|
| 83 |
+
public view returns (uint256);
|
| 84 |
+
|
| 85 |
+
function transferFrom(address from, address to, uint256 value)
|
| 86 |
+
public returns (bool);
|
| 87 |
+
|
| 88 |
+
function approve(address spender, uint256 value) public returns (bool);
|
| 89 |
+
event Approval(
|
| 90 |
+
address indexed owner,
|
| 91 |
+
address indexed spender,
|
| 92 |
+
uint256 value
|
| 93 |
+
);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
contract StandardToken is ERC20, BasicToken {
|
| 98 |
+
|
| 99 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
function transferFrom(
|
| 104 |
+
address _from,
|
| 105 |
+
address _to,
|
| 106 |
+
uint256 _value
|
| 107 |
+
)
|
| 108 |
+
public
|
| 109 |
+
returns (bool)
|
| 110 |
+
{
|
| 111 |
+
require(_to != address(0));
|
| 112 |
+
require(_value <= balances[_from]);
|
| 113 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 114 |
+
|
| 115 |
+
balances[_from] = balances[_from].sub(_value);
|
| 116 |
+
balances[_to] = balances[_to].add(_value);
|
| 117 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 118 |
+
emit Transfer(_from, _to, _value);
|
| 119 |
+
return true;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 124 |
+
allowed[msg.sender][_spender] = _value;
|
| 125 |
+
emit Approval(msg.sender, _spender, _value);
|
| 126 |
+
return true;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
function allowance(
|
| 131 |
+
address _owner,
|
| 132 |
+
address _spender
|
| 133 |
+
)
|
| 134 |
+
public
|
| 135 |
+
view
|
| 136 |
+
returns (uint256)
|
| 137 |
+
{
|
| 138 |
+
return allowed[_owner][_spender];
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
function increaseApproval(
|
| 143 |
+
address _spender,
|
| 144 |
+
uint256 _addedValue
|
| 145 |
+
)
|
| 146 |
+
public
|
| 147 |
+
returns (bool)
|
| 148 |
+
{
|
| 149 |
+
allowed[msg.sender][_spender] = (
|
| 150 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 151 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 152 |
+
return true;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
function decreaseApproval(
|
| 157 |
+
address _spender,
|
| 158 |
+
uint256 _subtractedValue
|
| 159 |
+
)
|
| 160 |
+
public
|
| 161 |
+
returns (bool)
|
| 162 |
+
{
|
| 163 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 164 |
+
if (_subtractedValue > oldValue) {
|
| 165 |
+
allowed[msg.sender][_spender] = 0;
|
| 166 |
+
} else {
|
| 167 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 168 |
+
}
|
| 169 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 170 |
+
return true;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
contract VerityToken is StandardToken {
|
| 176 |
+
string public name = "VerityToken";
|
| 177 |
+
string public symbol = "VTY";
|
| 178 |
+
uint8 public decimals = 18;
|
| 179 |
+
uint public INITIAL_SUPPLY = 500000000 * 10 ** uint(decimals);
|
| 180 |
+
|
| 181 |
+
function VerityToken() public {
|
| 182 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 183 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 184 |
+
}
|
| 185 |
+
}
|
benchmark2/integer overflow/634.sol
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.16;
|
| 2 |
+
|
| 3 |
+
contract owned {
|
| 4 |
+
address public owner;
|
| 5 |
+
|
| 6 |
+
function owned() public {
|
| 7 |
+
owner = msg.sender;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
modifier onlyOwner {
|
| 11 |
+
require(msg.sender == owner);
|
| 12 |
+
_;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 16 |
+
owner = newOwner;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
|
| 21 |
+
|
| 22 |
+
contract TokenERC20 {
|
| 23 |
+
|
| 24 |
+
string public name;
|
| 25 |
+
string public symbol;
|
| 26 |
+
uint8 public decimals = 18;
|
| 27 |
+
|
| 28 |
+
uint256 public totalSupply;
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
mapping (address => uint256) public balanceOf;
|
| 32 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
event Burn(address indexed from, uint256 value);
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
function TokenERC20(
|
| 45 |
+
uint256 initialSupply,
|
| 46 |
+
string tokenName,
|
| 47 |
+
string tokenSymbol
|
| 48 |
+
) public {
|
| 49 |
+
totalSupply = initialSupply * 10 ** uint256(decimals);
|
| 50 |
+
balanceOf[msg.sender] = totalSupply;
|
| 51 |
+
name = tokenName;
|
| 52 |
+
symbol = tokenSymbol;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 57 |
+
|
| 58 |
+
require(_to != 0x0);
|
| 59 |
+
|
| 60 |
+
require(balanceOf[_from] >= _value);
|
| 61 |
+
|
| 62 |
+
require(balanceOf[_to] + _value > balanceOf[_to]);
|
| 63 |
+
|
| 64 |
+
uint previousBalances = balanceOf[_from] + balanceOf[_to];
|
| 65 |
+
|
| 66 |
+
balanceOf[_from] -= _value;
|
| 67 |
+
|
| 68 |
+
balanceOf[_to] += _value;
|
| 69 |
+
emit Transfer(_from, _to, _value);
|
| 70 |
+
|
| 71 |
+
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 76 |
+
_transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 82 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 83 |
+
allowance[_from][msg.sender] -= _value;
|
| 84 |
+
_transfer(_from, _to, _value);
|
| 85 |
+
return true;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
function approve(address _spender, uint256 _value) public
|
| 90 |
+
returns (bool success) {
|
| 91 |
+
allowance[msg.sender][_spender] = _value;
|
| 92 |
+
emit Approval(msg.sender, _spender, _value);
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
|
| 98 |
+
public
|
| 99 |
+
returns (bool success) {
|
| 100 |
+
tokenRecipient spender = tokenRecipient(_spender);
|
| 101 |
+
if (approve(_spender, _value)) {
|
| 102 |
+
spender.receiveApproval(msg.sender, _value, this, _extraData);
|
| 103 |
+
return true;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 109 |
+
require(balanceOf[msg.sender] >= _value);
|
| 110 |
+
balanceOf[msg.sender] -= _value;
|
| 111 |
+
totalSupply -= _value;
|
| 112 |
+
emit Burn(msg.sender, _value);
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 118 |
+
require(balanceOf[_from] >= _value);
|
| 119 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 120 |
+
balanceOf[_from] -= _value;
|
| 121 |
+
allowance[_from][msg.sender] -= _value;
|
| 122 |
+
totalSupply -= _value;
|
| 123 |
+
emit Burn(_from, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
contract INCRYPTHEDGE is owned, TokenERC20 {
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
mapping (address => bool) public frozenAccount;
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
event FrozenFunds(address target, bool frozen);
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
function INCRYPTHEDGE(
|
| 143 |
+
uint256 initialSupply,
|
| 144 |
+
string tokenName,
|
| 145 |
+
string tokenSymbol
|
| 146 |
+
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 150 |
+
require (_to != 0x0);
|
| 151 |
+
require (balanceOf[_from] >= _value);
|
| 152 |
+
require (balanceOf[_to] + _value >= balanceOf[_to]);
|
| 153 |
+
require(!frozenAccount[_from]);
|
| 154 |
+
require(!frozenAccount[_to]);
|
| 155 |
+
balanceOf[_from] -= _value;
|
| 156 |
+
balanceOf[_to] += _value;
|
| 157 |
+
emit Transfer(_from, _to, _value);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
|
| 164 |
+
balanceOf[target] += mintedAmount;
|
| 165 |
+
totalSupply += mintedAmount;
|
| 166 |
+
emit Transfer(0, this, mintedAmount);
|
| 167 |
+
emit Transfer(this, target, mintedAmount);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
function freezeAccount(address target, bool freeze) onlyOwner public {
|
| 174 |
+
frozenAccount[target] = freeze;
|
| 175 |
+
emit FrozenFunds(target, freeze);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
}
|
benchmark2/integer overflow/635.sol
ADDED
|
@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.16;
|
| 2 |
+
|
| 3 |
+
contract owned {
|
| 4 |
+
address public owner;
|
| 5 |
+
|
| 6 |
+
function owned() public {
|
| 7 |
+
owner = msg.sender;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
modifier onlyOwner {
|
| 11 |
+
require(msg.sender == owner);
|
| 12 |
+
_;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 16 |
+
owner = newOwner;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
|
| 21 |
+
|
| 22 |
+
contract TokenERC20 {
|
| 23 |
+
|
| 24 |
+
string public name;
|
| 25 |
+
string public symbol;
|
| 26 |
+
uint8 public decimals = 18;
|
| 27 |
+
|
| 28 |
+
uint256 public totalSupply;
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
mapping (address => uint256) public balanceOf;
|
| 32 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
event Burn(address indexed from, uint256 value);
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
function TokenERC20(
|
| 45 |
+
uint256 initialSupply,
|
| 46 |
+
string tokenName,
|
| 47 |
+
string tokenSymbol
|
| 48 |
+
) public {
|
| 49 |
+
totalSupply = initialSupply * 10 ** uint256(decimals);
|
| 50 |
+
balanceOf[msg.sender] = totalSupply;
|
| 51 |
+
name = tokenName;
|
| 52 |
+
symbol = tokenSymbol;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 57 |
+
|
| 58 |
+
require(_to != 0x0);
|
| 59 |
+
|
| 60 |
+
require(balanceOf[_from] >= _value);
|
| 61 |
+
|
| 62 |
+
require(balanceOf[_to] + _value > balanceOf[_to]);
|
| 63 |
+
|
| 64 |
+
uint previousBalances = balanceOf[_from] + balanceOf[_to];
|
| 65 |
+
|
| 66 |
+
balanceOf[_from] -= _value;
|
| 67 |
+
|
| 68 |
+
balanceOf[_to] += _value;
|
| 69 |
+
emit Transfer(_from, _to, _value);
|
| 70 |
+
|
| 71 |
+
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 76 |
+
_transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 82 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 83 |
+
allowance[_from][msg.sender] -= _value;
|
| 84 |
+
_transfer(_from, _to, _value);
|
| 85 |
+
return true;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
function approve(address _spender, uint256 _value) public
|
| 90 |
+
returns (bool success) {
|
| 91 |
+
allowance[msg.sender][_spender] = _value;
|
| 92 |
+
emit Approval(msg.sender, _spender, _value);
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
|
| 98 |
+
public
|
| 99 |
+
returns (bool success) {
|
| 100 |
+
tokenRecipient spender = tokenRecipient(_spender);
|
| 101 |
+
if (approve(_spender, _value)) {
|
| 102 |
+
spender.receiveApproval(msg.sender, _value, this, _extraData);
|
| 103 |
+
return true;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 109 |
+
require(balanceOf[msg.sender] >= _value);
|
| 110 |
+
balanceOf[msg.sender] -= _value;
|
| 111 |
+
totalSupply -= _value;
|
| 112 |
+
emit Burn(msg.sender, _value);
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 118 |
+
require(balanceOf[_from] >= _value);
|
| 119 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 120 |
+
balanceOf[_from] -= _value;
|
| 121 |
+
allowance[_from][msg.sender] -= _value;
|
| 122 |
+
totalSupply -= _value;
|
| 123 |
+
emit Burn(_from, _value);
|
| 124 |
+
return true;
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
contract INCRYPT is owned, TokenERC20 {
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
mapping (address => bool) public frozenAccount;
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
event FrozenFunds(address target, bool frozen);
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
function INCRYPT(
|
| 143 |
+
uint256 initialSupply,
|
| 144 |
+
string tokenName,
|
| 145 |
+
string tokenSymbol
|
| 146 |
+
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 150 |
+
require (_to != 0x0);
|
| 151 |
+
require (balanceOf[_from] >= _value);
|
| 152 |
+
require (balanceOf[_to] + _value >= balanceOf[_to]);
|
| 153 |
+
require(!frozenAccount[_from]);
|
| 154 |
+
require(!frozenAccount[_to]);
|
| 155 |
+
balanceOf[_from] -= _value;
|
| 156 |
+
balanceOf[_to] += _value;
|
| 157 |
+
emit Transfer(_from, _to, _value);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
|
| 164 |
+
balanceOf[target] += mintedAmount;
|
| 165 |
+
totalSupply += mintedAmount;
|
| 166 |
+
emit Transfer(0, this, mintedAmount);
|
| 167 |
+
emit Transfer(this, target, mintedAmount);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
function freezeAccount(address target, bool freeze) onlyOwner public {
|
| 174 |
+
frozenAccount[target] = freeze;
|
| 175 |
+
emit FrozenFunds(target, freeze);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
}
|
benchmark2/integer overflow/638.sol
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
contract SafeMath {
|
| 5 |
+
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 6 |
+
if (a == 0) {
|
| 7 |
+
return 0;
|
| 8 |
+
}
|
| 9 |
+
uint256 c = a * b;
|
| 10 |
+
assert(c / a == b);
|
| 11 |
+
return c;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 15 |
+
assert(b > 0);
|
| 16 |
+
uint256 c = a / b;
|
| 17 |
+
assert(a == b * c + a % b);
|
| 18 |
+
return c;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 22 |
+
assert(b <= a);
|
| 23 |
+
return a - b;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 27 |
+
uint256 c = a + b;
|
| 28 |
+
assert(c>=a && c>=b);
|
| 29 |
+
return c;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
contract AMeiToken is SafeMath {
|
| 35 |
+
address public owner;
|
| 36 |
+
string public name;
|
| 37 |
+
string public symbol;
|
| 38 |
+
uint public decimals;
|
| 39 |
+
uint256 public totalSupply;
|
| 40 |
+
|
| 41 |
+
mapping (address => uint256) public balanceOf;
|
| 42 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 43 |
+
|
| 44 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 45 |
+
event Burn(address indexed from, uint256 value);
|
| 46 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 47 |
+
|
| 48 |
+
mapping (address => bool) public frozenAccount;
|
| 49 |
+
event FrozenFunds(address target, bool frozen);
|
| 50 |
+
|
| 51 |
+
bool lock = false;
|
| 52 |
+
|
| 53 |
+
constructor(
|
| 54 |
+
uint256 initialSupply,
|
| 55 |
+
string tokenName,
|
| 56 |
+
string tokenSymbol,
|
| 57 |
+
uint decimalUnits
|
| 58 |
+
) public {
|
| 59 |
+
owner = msg.sender;
|
| 60 |
+
name = tokenName;
|
| 61 |
+
symbol = tokenSymbol;
|
| 62 |
+
decimals = decimalUnits;
|
| 63 |
+
totalSupply = initialSupply * 10 ** uint256(decimals);
|
| 64 |
+
balanceOf[msg.sender] = totalSupply;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
modifier onlyOwner {
|
| 68 |
+
require(msg.sender == owner);
|
| 69 |
+
_;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
modifier isLock {
|
| 73 |
+
require(!lock);
|
| 74 |
+
_;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
function setLock(bool _lock) onlyOwner public{
|
| 78 |
+
lock = _lock;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 82 |
+
if (newOwner != address(0)) {
|
| 83 |
+
owner = newOwner;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
function _transfer(address _from, address _to, uint _value) isLock internal {
|
| 89 |
+
require (_to != 0x0);
|
| 90 |
+
require (balanceOf[_from] >= _value);
|
| 91 |
+
require (balanceOf[_to] + _value > balanceOf[_to]);
|
| 92 |
+
require(!frozenAccount[_from]);
|
| 93 |
+
require(!frozenAccount[_to]);
|
| 94 |
+
balanceOf[_from] -= _value;
|
| 95 |
+
balanceOf[_to] += _value;
|
| 96 |
+
emit Transfer(_from, _to, _value);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
function transfer(address _to, uint256 _value) public returns (bool success) {
|
| 100 |
+
_transfer(msg.sender, _to, _value);
|
| 101 |
+
return true;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 105 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 106 |
+
allowance[_from][msg.sender] -= _value;
|
| 107 |
+
_transfer(_from, _to, _value);
|
| 108 |
+
return true;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function approve(address _spender, uint256 _value) public returns (bool success) {
|
| 112 |
+
allowance[msg.sender][_spender] = _value;
|
| 113 |
+
emit Approval(msg.sender, _spender, _value);
|
| 114 |
+
return true;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
function burn(uint256 _value) onlyOwner public returns (bool success) {
|
| 118 |
+
require(balanceOf[msg.sender] >= _value);
|
| 119 |
+
balanceOf[msg.sender] -= _value;
|
| 120 |
+
totalSupply -= _value;
|
| 121 |
+
emit Burn(msg.sender, _value);
|
| 122 |
+
return true;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
|
| 126 |
+
require(balanceOf[_from] >= _value);
|
| 127 |
+
require(_value <= allowance[_from][msg.sender]);
|
| 128 |
+
balanceOf[_from] -= _value;
|
| 129 |
+
allowance[_from][msg.sender] -= _value;
|
| 130 |
+
totalSupply -= _value;
|
| 131 |
+
emit Burn(_from, _value);
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
|
| 136 |
+
uint256 _amount = mintedAmount * 10 ** uint256(decimals);
|
| 137 |
+
balanceOf[target] += _amount;
|
| 138 |
+
totalSupply += _amount;
|
| 139 |
+
emit Transfer(this, target, _amount);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
function freezeAccount(address target, bool freeze) onlyOwner public {
|
| 143 |
+
frozenAccount[target] = freeze;
|
| 144 |
+
emit FrozenFunds(target, freeze);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
function transferBatch(address[] _to, uint256 _value) public returns (bool success) {
|
| 148 |
+
for (uint i=0; i<_to.length; i++) {
|
| 149 |
+
_transfer(msg.sender, _to[i], _value);
|
| 150 |
+
}
|
| 151 |
+
return true;
|
| 152 |
+
}
|
| 153 |
+
}
|
benchmark2/integer overflow/640.sol
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.16;
|
| 2 |
+
/* å建ä¸ä¸ªç¶ç±»ï¼ è´¦æ·ç®¡çå */
|
| 3 |
+
contract owned {
|
| 4 |
+
|
| 5 |
+
address public owner;
|
| 6 |
+
|
| 7 |
+
function owned() public {
|
| 8 |
+
owner = msg.sender;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
/* modifieræ¯ä¿®æ¹æ å¿ */
|
| 12 |
+
modifier onlyOwner {
|
| 13 |
+
require(msg.sender == owner);
|
| 14 |
+
_;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/* ä¿®æ¹ç®¡çåè´¦æ·ï¼ onlyOwner代表åªè½æ¯ç¨æ·ç®¡çåæ¥ä¿®æ¹ */
|
| 18 |
+
function transferOwnership(address newOwner) onlyOwner public {
|
| 19 |
+
owner = newOwner;
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* receiveApprovalæå¡å约æç¤ºä»£å¸å约å°ä»£å¸ä»åéè
çè´¦æ·è½¬ç§»å°æå¡å约çè´¦æ·ï¼éè¿è°ç¨æå¡å约ç */
|
| 24 |
+
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
|
| 25 |
+
|
| 26 |
+
contract TokenERC20 {
|
| 27 |
+
// 代å¸ï¼tokenï¼çå
Œ
±åé
|
| 28 |
+
string public name; //代å¸åå
|
| 29 |
+
string public symbol; //代å¸ç¬¦å·
|
| 30 |
+
uint8 public decimals = 18; //代å¸å°æ°ç¹ä½æ°ï¼ 18æ¯é»è®¤ï¼ å°½éä¸è¦æ´æ¹
|
| 31 |
+
|
| 32 |
+
uint256 public totalSupply; //代叿»é
|
| 33 |
+
|
| 34 |
+
// è®°å½å个账æ·ç代叿°ç®
|
| 35 |
+
mapping (address => uint256) public balanceOf;
|
| 36 |
+
|
| 37 |
+
// Aè´¦æ·åå¨Bè´¦æ·èµé
|
| 38 |
+
mapping (address => mapping (address => uint256)) public allowance;
|
| 39 |
+
|
| 40 |
+
// 转账éç¥äºä»¶
|
| 41 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 42 |
+
|
| 43 |
+
// 鿝éé¢éç¥äºä»¶
|
| 44 |
+
event Burn(address indexed from, uint256 value);
|
| 45 |
+
|
| 46 |
+
/* æé 彿° */
|
| 47 |
+
function TokenERC20(
|
| 48 |
+
uint256 initialSupply,
|
| 49 |
+
string tokenName,
|
| 50 |
+
string tokenSymbol
|
| 51 |
+
) public {
|
| 52 |
+
totalSupply = initialSupply * 10 ** uint256(decimals); // æ ¹æ®decimals计ç®ä»£å¸çæ°é
|
| 53 |
+
balanceOf[msg.sender] = totalSupply; // ç»çæè
ææç代叿°é
|
| 54 |
+
name = tokenName; // 设置代å¸çåå
|
| 55 |
+
symbol = tokenSymbol; // 设置代å¸ç符å·
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* ç§æç交æå½æ° */
|
| 59 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 60 |
+
// 鲿¢è½¬ç§»å°0x0ï¼ ç¨burn代æ¿è¿ä¸ªåè½
|
| 61 |
+
require(_to != 0x0);
|
| 62 |
+
// æ£æµåéè
æ¯å¦æè¶³å¤çèµé
|
| 63 |
+
require(balanceOf[_from] >= _value);
|
| 64 |
+
// æ£æ¥æ¯å¦æº¢åºï¼æ°æ®ç±»åçæº¢åºï¼
|
| 65 |
+
require(balanceOf[_to] + _value > balanceOf[_to]);
|
| 66 |
+
// å°æ¤ä¿åä¸ºå°æ¥çæè¨ï¼ 彿°æå伿ä¸ä¸ªæ£éª
|
| 67 |
+
uint previousBalances = balanceOf[_from] + balanceOf[_to];
|
| 68 |
+
// åå°åéè
èµäº§
|
| 69 |
+
balanceOf[_from] -= _value;
|
| 70 |
+
// å¢å æ¥æ¶è
çèµäº§
|
| 71 |
+
balanceOf[_to] += _value;
|
| 72 |
+
Transfer(_from, _to, _value);
|
| 73 |
+
// æè¨æ£æµï¼ ä¸åºè¯¥ä¸ºé
|
| 74 |
+
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/* ä¼ étokens */
|
| 78 |
+
function transfer(address _to, uint256 _value) public {
|
| 79 |
+
_transfer(msg.sender, _to, _value);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* ä»å
¶ä»è´¦æ·è½¬ç§»èµäº§ */
|
| 83 |
+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
|
| 84 |
+
require(_value <= allowance[_from][msg.sender]); // Check allowance
|
| 85 |
+
allowance[_from][msg.sender] -= _value;
|
| 86 |
+
_transfer(_from, _to, _value);
|
| 87 |
+
return true;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/* ææç¬¬ä¸æ¹ä»åéè
è´¦æ·è½¬ç§»ä»£å¸ï¼ç¶åéè¿transferFrom()彿°æ¥æ§è¡ç¬¬ä¸æ¹ç转移æä½ */
|
| 91 |
+
function approve(address _spender, uint256 _value) public
|
| 92 |
+
returns (bool success) {
|
| 93 |
+
allowance[msg.sender][_spender] = _value;
|
| 94 |
+
return true;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/*
|
| 98 |
+
为å
¶ä»å°åè®¾ç½®æ´¥è´´ï¼ å¹¶éç¥
|
| 99 |
+
åéè
éç¥ä»£å¸å约, 代å¸å约éç¥æå¡å约receiveApproval, æå¡å约æç¤ºä»£å¸å约å°ä»£å¸ä»åéè
çè´¦æ·è½¬ç§»å°æå¡å约çè´¦æ·ï¼éè¿è°ç¨æå¡å约çtransferFrom)
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
|
| 103 |
+
public
|
| 104 |
+
returns (bool success) {
|
| 105 |
+
tokenRecipient spender = tokenRecipient(_spender);
|
| 106 |
+
if (approve(_spender, _value)) {
|
| 107 |
+
spender.receiveApproval(msg.sender, _value, this, _extraData);
|
| 108 |
+
return true;
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* 鿝代å¸
|
| 114 |
+
*/
|
| 115 |
+
function burn(uint256 _value) public returns (bool success) {
|
| 116 |
+
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
|
| 117 |
+
balanceOf[msg.sender] -= _value; // Subtract from the sender
|
| 118 |
+
totalSupply -= _value; // Updates totalSupply
|
| 119 |
+
Burn(msg.sender, _value);
|
| 120 |
+
return true;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* ä»å
¶ä»è´¦æ·éæ¯ä»£å¸
|
| 125 |
+
*/
|
| 126 |
+
function burnFrom(address _from, uint256 _value) public returns (bool success) {
|
| 127 |
+
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
|
| 128 |
+
require(_value <= allowance[_from][msg.sender]); // Check allowance
|
| 129 |
+
balanceOf[_from] -= _value; // Subtract from the targeted balance
|
| 130 |
+
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
|
| 131 |
+
totalSupply -= _value; // Update totalSupply
|
| 132 |
+
Burn(_from, _value);
|
| 133 |
+
return true;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/******************************************/
|
| 138 |
+
/* ADVANCED TOKEN STARTS HERE */
|
| 139 |
+
/******************************************/
|
| 140 |
+
|
| 141 |
+
contract ROSCtoken is owned, TokenERC20 {
|
| 142 |
+
|
| 143 |
+
uint256 public sellPrice;
|
| 144 |
+
uint256 public buyPrice;
|
| 145 |
+
|
| 146 |
+
/* å»ç»è´¦æ· */
|
| 147 |
+
mapping (address => bool) public frozenAccount;
|
| 148 |
+
|
| 149 |
+
/* This generates a public event on the blockchain that will notify clients */
|
| 150 |
+
event FrozenFunds(address target, bool frozen);
|
| 151 |
+
|
| 152 |
+
/* æé 彿° */
|
| 153 |
+
function ROSCtoken(
|
| 154 |
+
uint256 initialSupply,
|
| 155 |
+
string tokenName,
|
| 156 |
+
string tokenSymbol
|
| 157 |
+
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
|
| 158 |
+
|
| 159 |
+
/* è½¬è´¦ï¼ æ¯ç¶ç±»å å
¥äºè´¦æ·å»ç» */
|
| 160 |
+
function _transfer(address _from, address _to, uint _value) internal {
|
| 161 |
+
require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead
|
| 162 |
+
require (balanceOf[_from] >= _value); // Check if the sender has enough
|
| 163 |
+
require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows
|
| 164 |
+
require(!frozenAccount[_from]); // Check if sender is frozen
|
| 165 |
+
require(!frozenAccount[_to]); // Check if recipient is frozen
|
| 166 |
+
balanceOf[_from] -= _value; // Subtract from the sender
|
| 167 |
+
balanceOf[_to] += _value; // Add the same to the recipient
|
| 168 |
+
Transfer(_from, _to, _value);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/// åæå®è´¦æ·å¢åèµé
|
| 172 |
+
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
|
| 173 |
+
balanceOf[target] += mintedAmount;
|
| 174 |
+
totalSupply += mintedAmount;
|
| 175 |
+
Transfer(0, this, mintedAmount);
|
| 176 |
+
Transfer(this, target, mintedAmount);
|
| 177 |
+
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
/// å»ç» or è§£å»è´¦æ·
|
| 182 |
+
function freezeAccount(address target, bool freeze) onlyOwner public {
|
| 183 |
+
frozenAccount[target] = freeze;
|
| 184 |
+
FrozenFunds(target, freeze);
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
|
| 188 |
+
sellPrice = newSellPrice;
|
| 189 |
+
buyPrice = newBuyPrice;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/// @notice Buy tokens from contract by sending ether
|
| 193 |
+
function buy() payable public {
|
| 194 |
+
uint amount = msg.value / buyPrice; // calculates the amount
|
| 195 |
+
_transfer(this, msg.sender, amount); // makes the transfers
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function sell(uint256 amount) public {
|
| 199 |
+
require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
|
| 200 |
+
_transfer(msg.sender, this, amount); // makes the transfers
|
| 201 |
+
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
|
| 202 |
+
}
|
| 203 |
+
}
|
benchmark2/integer overflow/651.sol
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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returns (uint256);
|
| 8 |
+
function balanceOf(address _who) public view returns (uint256);
|
| 9 |
+
function transfer(address _to, uint256 _value) public returns (bool);
|
| 10 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
library SafeMath {
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if (_a == 0) {
|
| 24 |
+
return 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
c = _a * _b;
|
| 28 |
+
assert(c / _a == _b);
|
| 29 |
+
return c;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
return _a / _b;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
|
| 42 |
+
assert(_b <= _a);
|
| 43 |
+
return _a - _b;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
|
| 48 |
+
c = _a + _b;
|
| 49 |
+
assert(c >= _a);
|
| 50 |
+
return c;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
contract BasicToken is ERC20Basic {
|
| 58 |
+
using SafeMath for uint256;
|
| 59 |
+
|
| 60 |
+
mapping(address => uint256) internal balances;
|
| 61 |
+
|
| 62 |
+
uint256 internal totalSupply_;
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
function totalSupply() public view returns (uint256) {
|
| 66 |
+
return totalSupply_;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
function transfer(address _to, uint256 _value) public returns (bool) {
|
| 71 |
+
require(_value <= balances[msg.sender]);
|
| 72 |
+
require(_to != address(0));
|
| 73 |
+
|
| 74 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 75 |
+
balances[_to] = balances[_to].add(_value);
|
| 76 |
+
emit Transfer(msg.sender, _to, _value);
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
function balanceOf(address _owner) public view returns (uint256) {
|
| 82 |
+
return balances[_owner];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
contract ERC20 is ERC20Basic {
|
| 91 |
+
function allowance(address _owner, address _spender)
|
| 92 |
+
public view returns (uint256);
|
| 93 |
+
|
| 94 |
+
function transferFrom(address _from, address _to, uint256 _value)
|
| 95 |
+
public returns (bool);
|
| 96 |
+
|
| 97 |
+
function approve(address _spender, uint256 _value) public returns (bool);
|
| 98 |
+
event Approval(
|
| 99 |
+
address indexed owner,
|
| 100 |
+
address indexed spender,
|
| 101 |
+
uint256 value
|
| 102 |
+
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
contract StandardToken is ERC20, BasicToken {
|
| 109 |
+
|
| 110 |
+
mapping (address => mapping (address => uint256)) internal allowed;
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function transferFrom(
|
| 115 |
+
address _from,
|
| 116 |
+
address _to,
|
| 117 |
+
uint256 _value
|
| 118 |
+
)
|
| 119 |
+
public
|
| 120 |
+
returns (bool)
|
| 121 |
+
{
|
| 122 |
+
require(_value <= balances[_from]);
|
| 123 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 124 |
+
require(_to != address(0));
|
| 125 |
+
|
| 126 |
+
balances[_from] = balances[_from].sub(_value);
|
| 127 |
+
balances[_to] = balances[_to].add(_value);
|
| 128 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 129 |
+
emit Transfer(_from, _to, _value);
|
| 130 |
+
return true;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
function approve(address _spender, uint256 _value) public returns (bool) {
|
| 135 |
+
allowed[msg.sender][_spender] = _value;
|
| 136 |
+
emit Approval(msg.sender, _spender, _value);
|
| 137 |
+
return true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
function allowance(
|
| 142 |
+
address _owner,
|
| 143 |
+
address _spender
|
| 144 |
+
)
|
| 145 |
+
public
|
| 146 |
+
view
|
| 147 |
+
returns (uint256)
|
| 148 |
+
{
|
| 149 |
+
return allowed[_owner][_spender];
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
function increaseApproval(
|
| 154 |
+
address _spender,
|
| 155 |
+
uint256 _addedValue
|
| 156 |
+
)
|
| 157 |
+
public
|
| 158 |
+
returns (bool)
|
| 159 |
+
{
|
| 160 |
+
allowed[msg.sender][_spender] = (
|
| 161 |
+
allowed[msg.sender][_spender].add(_addedValue));
|
| 162 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
function decreaseApproval(
|
| 168 |
+
address _spender,
|
| 169 |
+
uint256 _subtractedValue
|
| 170 |
+
)
|
| 171 |
+
public
|
| 172 |
+
returns (bool)
|
| 173 |
+
{
|
| 174 |
+
uint256 oldValue = allowed[msg.sender][_spender];
|
| 175 |
+
if (_subtractedValue >= oldValue) {
|
| 176 |
+
allowed[msg.sender][_spender] = 0;
|
| 177 |
+
} else {
|
| 178 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 179 |
+
}
|
| 180 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 181 |
+
return true;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
contract Ownable {
|
| 190 |
+
address public owner;
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 194 |
+
event OwnershipTransferred(
|
| 195 |
+
address indexed previousOwner,
|
| 196 |
+
address indexed newOwner
|
| 197 |
+
);
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
constructor() public {
|
| 202 |
+
owner = msg.sender;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
modifier onlyOwner() {
|
| 207 |
+
require(msg.sender == owner);
|
| 208 |
+
_;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
function renounceOwnership() public onlyOwner {
|
| 213 |
+
emit OwnershipRenounced(owner);
|
| 214 |
+
owner = address(0);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
function transferOwnership(address _newOwner) public onlyOwner {
|
| 219 |
+
_transferOwnership(_newOwner);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
function _transferOwnership(address _newOwner) internal {
|
| 224 |
+
require(_newOwner != address(0));
|
| 225 |
+
emit OwnershipTransferred(owner, _newOwner);
|
| 226 |
+
owner = _newOwner;
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
contract Pausable is Ownable {
|
| 234 |
+
event Pause();
|
| 235 |
+
event Unpause();
|
| 236 |
+
|
| 237 |
+
bool public paused = false;
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
modifier whenNotPaused() {
|
| 242 |
+
require(!paused);
|
| 243 |
+
_;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
modifier whenPaused() {
|
| 248 |
+
require(paused);
|
| 249 |
+
_;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
function pause() public onlyOwner whenNotPaused {
|
| 254 |
+
paused = true;
|
| 255 |
+
emit Pause();
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
function unpause() public onlyOwner whenPaused {
|
| 260 |
+
paused = false;
|
| 261 |
+
emit Unpause();
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
contract PausableToken is StandardToken, Pausable {
|
| 269 |
+
|
| 270 |
+
function transfer(
|
| 271 |
+
address _to,
|
| 272 |
+
uint256 _value
|
| 273 |
+
)
|
| 274 |
+
public
|
| 275 |
+
whenNotPaused
|
| 276 |
+
returns (bool)
|
| 277 |
+
{
|
| 278 |
+
return super.transfer(_to, _value);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function transferFrom(
|
| 282 |
+
address _from,
|
| 283 |
+
address _to,
|
| 284 |
+
uint256 _value
|
| 285 |
+
)
|
| 286 |
+
public
|
| 287 |
+
whenNotPaused
|
| 288 |
+
returns (bool)
|
| 289 |
+
{
|
| 290 |
+
return super.transferFrom(_from, _to, _value);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
function approve(
|
| 294 |
+
address _spender,
|
| 295 |
+
uint256 _value
|
| 296 |
+
)
|
| 297 |
+
public
|
| 298 |
+
whenNotPaused
|
| 299 |
+
returns (bool)
|
| 300 |
+
{
|
| 301 |
+
return super.approve(_spender, _value);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
function increaseApproval(
|
| 305 |
+
address _spender,
|
| 306 |
+
uint _addedValue
|
| 307 |
+
)
|
| 308 |
+
public
|
| 309 |
+
whenNotPaused
|
| 310 |
+
returns (bool success)
|
| 311 |
+
{
|
| 312 |
+
return super.increaseApproval(_spender, _addedValue);
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
function decreaseApproval(
|
| 316 |
+
address _spender,
|
| 317 |
+
uint _subtractedValue
|
| 318 |
+
)
|
| 319 |
+
public
|
| 320 |
+
whenNotPaused
|
| 321 |
+
returns (bool success)
|
| 322 |
+
{
|
| 323 |
+
return super.decreaseApproval(_spender, _subtractedValue);
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
contract TangguoTaoToken is PausableToken{
|
| 330 |
+
string public name = "TangguoTao Token";
|
| 331 |
+
string public symbol = "TCA";
|
| 332 |
+
uint8 public decimals = 18;
|
| 333 |
+
uint public INITIAL_SUPPLY = 60000000000000000000000000000;
|
| 334 |
+
|
| 335 |
+
constructor() public {
|
| 336 |
+
totalSupply_ = INITIAL_SUPPLY;
|
| 337 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 338 |
+
}
|
| 339 |
+
}
|
benchmark2/integer overflow/655.sol
ADDED
|
@@ -0,0 +1,1134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity ^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
library SafeMath {
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 10 |
+
if (a == 0) {
|
| 11 |
+
return 0;
|
| 12 |
+
}
|
| 13 |
+
c = a * b;
|
| 14 |
+
assert(c / a == b);
|
| 15 |
+
return c;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
return a / b;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
| 28 |
+
assert(b <= a);
|
| 29 |
+
return a - b;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 34 |
+
c = a + b;
|
| 35 |
+
assert(c >= a);
|
| 36 |
+
return c;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
contract Ownable {
|
| 44 |
+
address public owner;
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
event OwnershipRenounced(address indexed previousOwner);
|
| 48 |
+
event OwnershipTransferred(
|
| 49 |
+
address indexed previousOwner,
|
| 50 |
+
address indexed newOwner
|
| 51 |
+
);
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
constructor() public {
|
| 56 |
+
owner = msg.sender;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
modifier onlyOwner() {
|
| 61 |
+
require(msg.sender == owner);
|
| 62 |
+
_;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
function transferOwnership(address newOwner) public onlyOwner {
|
| 67 |
+
require(newOwner != address(0));
|
| 68 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 69 |
+
owner = newOwner;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
function renounceOwnership() public onlyOwner {
|
| 74 |
+
emit OwnershipRenounced(owner);
|
| 75 |
+
owner = address(0);
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
contract Pausable is Ownable {
|
| 83 |
+
event Pause();
|
| 84 |
+
event Unpause();
|
| 85 |
+
|
| 86 |
+
bool public paused = false;
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
modifier whenNotPaused() {
|
| 91 |
+
require(!paused);
|
| 92 |
+
_;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
modifier whenPaused() {
|
| 97 |
+
require(paused);
|
| 98 |
+
_;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
function pause() onlyOwner whenNotPaused public {
|
| 103 |
+
paused = true;
|
| 104 |
+
emit Pause();
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
function unpause() onlyOwner whenPaused public {
|
| 109 |
+
paused = false;
|
| 110 |
+
emit Unpause();
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
contract ERC721Basic {
|
| 118 |
+
function balanceOf(address _owner) public view returns (uint256 _balance);
|
| 119 |
+
function ownerOf(uint256 _tokenId) public view returns (address _owner);
|
| 120 |
+
function exists(uint256 _tokenId) public view returns (bool _exists);
|
| 121 |
+
|
| 122 |
+
function approve(address _to, uint256 _tokenId) public;
|
| 123 |
+
function getApproved(uint256 _tokenId) public view returns (address _operator);
|
| 124 |
+
|
| 125 |
+
function transferFrom(address _from, address _to, uint256 _tokenId) public;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
contract HorseyExchange is Pausable {
|
| 130 |
+
|
| 131 |
+
using SafeMath for uint256;
|
| 132 |
+
|
| 133 |
+
event HorseyDeposit(uint256 tokenId, uint256 price);
|
| 134 |
+
event SaleCanceled(uint256 tokenId);
|
| 135 |
+
event HorseyPurchased(uint256 tokenId, address newOwner, uint256 totalToPay);
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
uint256 public marketMakerFee = 3;
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
uint256 collectedFees = 0;
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
ERC721Basic public token;
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
struct SaleData {
|
| 148 |
+
uint256 price;
|
| 149 |
+
address owner;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
mapping (uint256 => SaleData) market;
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
mapping (address => uint256[]) userBarn;
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
constructor() Pausable() public {
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
function setStables(address _token) external
|
| 164 |
+
onlyOwner()
|
| 165 |
+
{
|
| 166 |
+
require(address(_token) != 0,"Address of token is zero");
|
| 167 |
+
token = ERC721Basic(_token);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
function setMarketFees(uint256 fees) external
|
| 172 |
+
onlyOwner()
|
| 173 |
+
{
|
| 174 |
+
marketMakerFee = fees;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
function getTokensOnSale(address user) external view returns(uint256[]) {
|
| 179 |
+
return userBarn[user];
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
function getTokenPrice(uint256 tokenId) public view
|
| 184 |
+
isOnMarket(tokenId) returns (uint256) {
|
| 185 |
+
return market[tokenId].price + (market[tokenId].price.div(100).mul(marketMakerFee));
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
function depositToExchange(uint256 tokenId, uint256 price) external
|
| 190 |
+
whenNotPaused()
|
| 191 |
+
isTokenOwner(tokenId)
|
| 192 |
+
nonZeroPrice(price)
|
| 193 |
+
tokenAvailable() {
|
| 194 |
+
require(token.getApproved(tokenId) == address(this),"Exchange is not allowed to transfer");
|
| 195 |
+
|
| 196 |
+
token.transferFrom(msg.sender, address(this), tokenId);
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
market[tokenId] = SaleData(price,msg.sender);
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
userBarn[msg.sender].push(tokenId);
|
| 203 |
+
|
| 204 |
+
emit HorseyDeposit(tokenId, price);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
function cancelSale(uint256 tokenId) external
|
| 209 |
+
whenNotPaused()
|
| 210 |
+
originalOwnerOf(tokenId)
|
| 211 |
+
tokenAvailable() returns (bool) {
|
| 212 |
+
|
| 213 |
+
token.transferFrom(address(this),msg.sender,tokenId);
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
delete market[tokenId];
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
_removeTokenFromBarn(tokenId, msg.sender);
|
| 220 |
+
|
| 221 |
+
emit SaleCanceled(tokenId);
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
return userBarn[msg.sender].length > 0;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
function purchaseToken(uint256 tokenId) external payable
|
| 230 |
+
whenNotPaused()
|
| 231 |
+
isOnMarket(tokenId)
|
| 232 |
+
tokenAvailable()
|
| 233 |
+
notOriginalOwnerOf(tokenId)
|
| 234 |
+
{
|
| 235 |
+
|
| 236 |
+
uint256 totalToPay = getTokenPrice(tokenId);
|
| 237 |
+
require(msg.value >= totalToPay, "Not paying enough");
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
SaleData memory sale = market[tokenId];
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
collectedFees += totalToPay - sale.price;
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
sale.owner.transfer(sale.price);
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
_removeTokenFromBarn(tokenId, sale.owner);
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
delete market[tokenId];
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
token.transferFrom(address(this), msg.sender, tokenId);
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
if(msg.value > totalToPay)
|
| 260 |
+
{
|
| 261 |
+
msg.sender.transfer(msg.value.sub(totalToPay));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
emit HorseyPurchased(tokenId, msg.sender, totalToPay);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
function withdraw() external
|
| 269 |
+
onlyOwner()
|
| 270 |
+
{
|
| 271 |
+
assert(collectedFees <= address(this).balance);
|
| 272 |
+
owner.transfer(collectedFees);
|
| 273 |
+
collectedFees = 0;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
function _removeTokenFromBarn(uint tokenId, address barnAddress) internal {
|
| 278 |
+
uint256[] storage barnArray = userBarn[barnAddress];
|
| 279 |
+
require(barnArray.length > 0,"No tokens to remove");
|
| 280 |
+
int index = _indexOf(tokenId, barnArray);
|
| 281 |
+
require(index >= 0, "Token not found in barn");
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
for (uint256 i = uint256(index); i<barnArray.length-1; i++){
|
| 285 |
+
barnArray[i] = barnArray[i+1];
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
barnArray.length--;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
function _indexOf(uint item, uint256[] memory array) internal pure returns (int256){
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
for(uint256 i = 0; i < array.length; i++){
|
| 298 |
+
if(array[i] == item){
|
| 299 |
+
return int256(i);
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
return -1;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
modifier isOnMarket(uint256 tokenId) {
|
| 309 |
+
require(token.ownerOf(tokenId) == address(this),"Token not on market");
|
| 310 |
+
_;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
modifier isTokenOwner(uint256 tokenId) {
|
| 315 |
+
require(token.ownerOf(tokenId) == msg.sender,"Not tokens owner");
|
| 316 |
+
_;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
modifier originalOwnerOf(uint256 tokenId) {
|
| 321 |
+
require(market[tokenId].owner == msg.sender,"Not the original owner of");
|
| 322 |
+
_;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
modifier notOriginalOwnerOf(uint256 tokenId) {
|
| 327 |
+
require(market[tokenId].owner != msg.sender,"Is the original owner");
|
| 328 |
+
_;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
modifier nonZeroPrice(uint256 price){
|
| 333 |
+
require(price > 0,"Price is zero");
|
| 334 |
+
_;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
modifier tokenAvailable(){
|
| 339 |
+
require(address(token) != 0,"Token address not set");
|
| 340 |
+
_;
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
contract BettingControllerInterface {
|
| 347 |
+
address public owner;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
contract EthorseRace {
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
struct chronus_info {
|
| 354 |
+
bool betting_open;
|
| 355 |
+
bool race_start;
|
| 356 |
+
bool race_end;
|
| 357 |
+
bool voided_bet;
|
| 358 |
+
uint32 starting_time;
|
| 359 |
+
uint32 betting_duration;
|
| 360 |
+
uint32 race_duration;
|
| 361 |
+
uint32 voided_timestamp;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
address public owner;
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
chronus_info public chronus;
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
mapping (bytes32 => bool) public winner_horse;
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
function getCoinIndex(bytes32 index, address candidate) external constant returns (uint, uint, uint, bool, uint);
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
contract EthorseHelpers {
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
bytes32[] public all_horses = [bytes32("BTC"),bytes32("ETH"),bytes32("LTC")];
|
| 381 |
+
mapping(address => bool) private _legitOwners;
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
function _addHorse(bytes32 newHorse) internal {
|
| 385 |
+
all_horses.push(newHorse);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
function _addLegitOwner(address newOwner) internal
|
| 389 |
+
{
|
| 390 |
+
_legitOwners[newOwner] = true;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
function getall_horsesCount() public view returns(uint) {
|
| 394 |
+
return all_horses.length;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
function _isWinnerOf(address raceAddress, address eth_address) internal view returns (bool,bytes32)
|
| 399 |
+
{
|
| 400 |
+
|
| 401 |
+
EthorseRace race = EthorseRace(raceAddress);
|
| 402 |
+
|
| 403 |
+
BettingControllerInterface bc = BettingControllerInterface(race.owner());
|
| 404 |
+
|
| 405 |
+
require(_legitOwners[bc.owner()]);
|
| 406 |
+
|
| 407 |
+
bool voided_bet;
|
| 408 |
+
bool race_end;
|
| 409 |
+
(,,race_end,voided_bet,,,,) = race.chronus();
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
if(voided_bet || !race_end)
|
| 413 |
+
return (false,bytes32(0));
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
bytes32 horse;
|
| 417 |
+
bool found = false;
|
| 418 |
+
uint256 arrayLength = all_horses.length;
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
for(uint256 i = 0; i < arrayLength; i++)
|
| 422 |
+
{
|
| 423 |
+
if(race.winner_horse(all_horses[i])) {
|
| 424 |
+
horse = all_horses[i];
|
| 425 |
+
found = true;
|
| 426 |
+
break;
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
if(!found)
|
| 431 |
+
return (false,bytes32(0));
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
uint256 bet_amount = 0;
|
| 435 |
+
if(eth_address != address(0)) {
|
| 436 |
+
(,,,, bet_amount) = race.getCoinIndex(horse, eth_address);
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
return (bet_amount > 0, horse);
|
| 441 |
+
}
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
contract RoyalStablesInterface {
|
| 447 |
+
|
| 448 |
+
struct Horsey {
|
| 449 |
+
address race;
|
| 450 |
+
bytes32 dna;
|
| 451 |
+
uint8 feedingCounter;
|
| 452 |
+
uint8 tier;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
mapping(uint256 => Horsey) public horseys;
|
| 456 |
+
mapping(address => uint32) public carrot_credits;
|
| 457 |
+
mapping(uint256 => string) public names;
|
| 458 |
+
address public master;
|
| 459 |
+
|
| 460 |
+
function getOwnedTokens(address eth_address) public view returns (uint256[]);
|
| 461 |
+
function storeName(uint256 tokenId, string newName) public;
|
| 462 |
+
function storeCarrotsCredit(address client, uint32 amount) public;
|
| 463 |
+
function storeHorsey(address client, uint256 tokenId, address race, bytes32 dna, uint8 feedingCounter, uint8 tier) public;
|
| 464 |
+
function modifyHorsey(uint256 tokenId, address race, bytes32 dna, uint8 feedingCounter, uint8 tier) public;
|
| 465 |
+
function modifyHorseyDna(uint256 tokenId, bytes32 dna) public;
|
| 466 |
+
function modifyHorseyFeedingCounter(uint256 tokenId, uint8 feedingCounter) public;
|
| 467 |
+
function modifyHorseyTier(uint256 tokenId, uint8 tier) public;
|
| 468 |
+
function unstoreHorsey(uint256 tokenId) public;
|
| 469 |
+
function ownerOf(uint256 tokenId) public returns (address);
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
contract HorseyToken is EthorseHelpers,Pausable {
|
| 474 |
+
using SafeMath for uint256;
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
event Claimed(address raceAddress, address eth_address, uint256 tokenId);
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
event Feeding(uint256 tokenId);
|
| 481 |
+
|
| 482 |
+
|
| 483 |
+
event ReceivedCarrot(uint256 tokenId, bytes32 newDna);
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
event FeedingFailed(uint256 tokenId);
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
event HorseyRenamed(uint256 tokenId, string newName);
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
event HorseyFreed(uint256 tokenId);
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
RoyalStablesInterface public stables;
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
uint8 public carrotsMultiplier = 1;
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
uint8 public rarityMultiplier = 1;
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
uint256 public claimingFee = 0.008 ether;
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
struct FeedingData {
|
| 508 |
+
uint256 blockNumber;
|
| 509 |
+
uint256 horsey;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
mapping(address => FeedingData) public pendingFeedings;
|
| 514 |
+
|
| 515 |
+
|
| 516 |
+
uint256 public renamingCostsPerChar = 0.001 ether;
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
constructor(address stablesAddress)
|
| 520 |
+
EthorseHelpers()
|
| 521 |
+
Pausable() public {
|
| 522 |
+
stables = RoyalStablesInterface(stablesAddress);
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
function setRarityMultiplier(uint8 newRarityMultiplier) external
|
| 527 |
+
onlyOwner() {
|
| 528 |
+
rarityMultiplier = newRarityMultiplier;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
function setCarrotsMultiplier(uint8 newCarrotsMultiplier) external
|
| 533 |
+
onlyOwner() {
|
| 534 |
+
carrotsMultiplier = newCarrotsMultiplier;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
function setRenamingCosts(uint256 newRenamingCost) external
|
| 539 |
+
onlyOwner() {
|
| 540 |
+
renamingCostsPerChar = newRenamingCost;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
function setClaimingCosts(uint256 newClaimingFee) external
|
| 545 |
+
onlyOwner() {
|
| 546 |
+
claimingFee = newClaimingFee;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
function addLegitDevAddress(address newAddress) external
|
| 551 |
+
onlyOwner() {
|
| 552 |
+
_addLegitOwner(newAddress);
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
|
| 556 |
+
function withdraw() external
|
| 557 |
+
onlyOwner() {
|
| 558 |
+
owner.transfer(address(this).balance);
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
function addHorseIndex(bytes32 newHorse) external
|
| 564 |
+
onlyOwner() {
|
| 565 |
+
_addHorse(newHorse);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
function getOwnedTokens(address eth_address) public view returns (uint256[]) {
|
| 570 |
+
return stables.getOwnedTokens(eth_address);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
function can_claim(address raceAddress, address eth_address) public view returns (bool) {
|
| 575 |
+
bool res;
|
| 576 |
+
(res,) = _isWinnerOf(raceAddress, eth_address);
|
| 577 |
+
return res;
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
function claim(address raceAddress) external payable
|
| 582 |
+
costs(claimingFee)
|
| 583 |
+
whenNotPaused()
|
| 584 |
+
{
|
| 585 |
+
|
| 586 |
+
bytes32 winner;
|
| 587 |
+
(,winner) = _isWinnerOf(raceAddress, address(0));
|
| 588 |
+
require(winner != bytes32(0),"Winner is zero");
|
| 589 |
+
require(can_claim(raceAddress, msg.sender),"can_claim return false");
|
| 590 |
+
|
| 591 |
+
uint256 id = _generate_special_horsey(raceAddress, msg.sender, winner);
|
| 592 |
+
emit Claimed(raceAddress, msg.sender, id);
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
function renameHorsey(uint256 tokenId, string newName) external
|
| 597 |
+
whenNotPaused()
|
| 598 |
+
onlyOwnerOf(tokenId)
|
| 599 |
+
costs(renamingCostsPerChar * bytes(newName).length)
|
| 600 |
+
payable {
|
| 601 |
+
uint256 renamingFee = renamingCostsPerChar * bytes(newName).length;
|
| 602 |
+
|
| 603 |
+
if(msg.value > renamingFee)
|
| 604 |
+
{
|
| 605 |
+
msg.sender.transfer(msg.value.sub(renamingFee));
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
stables.storeName(tokenId,newName);
|
| 609 |
+
emit HorseyRenamed(tokenId,newName);
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
|
| 613 |
+
function freeForCarrots(uint256 tokenId) external
|
| 614 |
+
whenNotPaused()
|
| 615 |
+
onlyOwnerOf(tokenId) {
|
| 616 |
+
require(pendingFeedings[msg.sender].horsey != tokenId,"");
|
| 617 |
+
|
| 618 |
+
uint8 feedingCounter;
|
| 619 |
+
(,,feedingCounter,) = stables.horseys(tokenId);
|
| 620 |
+
stables.storeCarrotsCredit(msg.sender,stables.carrot_credits(msg.sender) + uint32(feedingCounter * carrotsMultiplier));
|
| 621 |
+
stables.unstoreHorsey(tokenId);
|
| 622 |
+
emit HorseyFreed(tokenId);
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
function getCarrotCredits() external view returns (uint32) {
|
| 627 |
+
return stables.carrot_credits(msg.sender);
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
function getHorsey(uint256 tokenId) public view returns (address, bytes32, uint8, string) {
|
| 632 |
+
RoyalStablesInterface.Horsey memory temp;
|
| 633 |
+
(temp.race,temp.dna,temp.feedingCounter,temp.tier) = stables.horseys(tokenId);
|
| 634 |
+
return (temp.race,temp.dna,temp.feedingCounter,stables.names(tokenId));
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
function feed(uint256 tokenId) external
|
| 639 |
+
whenNotPaused()
|
| 640 |
+
onlyOwnerOf(tokenId)
|
| 641 |
+
carrotsMeetLevel(tokenId)
|
| 642 |
+
noFeedingInProgress()
|
| 643 |
+
{
|
| 644 |
+
pendingFeedings[msg.sender] = FeedingData(block.number,tokenId);
|
| 645 |
+
uint8 feedingCounter;
|
| 646 |
+
(,,feedingCounter,) = stables.horseys(tokenId);
|
| 647 |
+
stables.storeCarrotsCredit(msg.sender,stables.carrot_credits(msg.sender) - uint32(feedingCounter));
|
| 648 |
+
emit Feeding(tokenId);
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
function stopFeeding() external
|
| 653 |
+
feedingInProgress() returns (bool) {
|
| 654 |
+
uint256 blockNumber = pendingFeedings[msg.sender].blockNumber;
|
| 655 |
+
uint256 tokenId = pendingFeedings[msg.sender].horsey;
|
| 656 |
+
|
| 657 |
+
require(block.number - blockNumber >= 1,"feeding and stop feeding are in same block");
|
| 658 |
+
|
| 659 |
+
delete pendingFeedings[msg.sender];
|
| 660 |
+
|
| 661 |
+
|
| 662 |
+
|
| 663 |
+
if(block.number - blockNumber > 255) {
|
| 664 |
+
|
| 665 |
+
|
| 666 |
+
emit FeedingFailed(tokenId);
|
| 667 |
+
return false;
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
if(stables.ownerOf(tokenId) != msg.sender) {
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
emit FeedingFailed(tokenId);
|
| 675 |
+
return false;
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
_feed(tokenId, blockhash(blockNumber));
|
| 680 |
+
bytes32 dna;
|
| 681 |
+
(,dna,,) = stables.horseys(tokenId);
|
| 682 |
+
emit ReceivedCarrot(tokenId, dna);
|
| 683 |
+
return true;
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
function() external payable {
|
| 688 |
+
revert("Not accepting donations");
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
|
| 692 |
+
function _feed(uint256 tokenId, bytes32 blockHash) internal {
|
| 693 |
+
|
| 694 |
+
uint8 tier;
|
| 695 |
+
uint8 feedingCounter;
|
| 696 |
+
(,,feedingCounter,tier) = stables.horseys(tokenId);
|
| 697 |
+
uint256 probabilityByRarity = 10 ** (uint256(tier).add(1));
|
| 698 |
+
uint256 randNum = uint256(keccak256(abi.encodePacked(tokenId, blockHash))) % probabilityByRarity;
|
| 699 |
+
|
| 700 |
+
|
| 701 |
+
if(randNum <= (feedingCounter * rarityMultiplier)){
|
| 702 |
+
_increaseRarity(tokenId, blockHash);
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
|
| 707 |
+
if(feedingCounter < 255) {
|
| 708 |
+
stables.modifyHorseyFeedingCounter(tokenId,feedingCounter+1);
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
|
| 713 |
+
function _makeSpecialId(address race, address sender, bytes32 coinIndex) internal pure returns (uint256) {
|
| 714 |
+
return uint256(keccak256(abi.encodePacked(race, sender, coinIndex)));
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
function _generate_special_horsey(address race, address eth_address, bytes32 coinIndex) internal returns (uint256) {
|
| 719 |
+
uint256 id = _makeSpecialId(race, eth_address, coinIndex);
|
| 720 |
+
|
| 721 |
+
bytes32 dna = _shiftRight(keccak256(abi.encodePacked(race, coinIndex)),16);
|
| 722 |
+
|
| 723 |
+
stables.storeHorsey(eth_address,id,race,dna,1,0);
|
| 724 |
+
return id;
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
|
| 728 |
+
function _increaseRarity(uint256 tokenId, bytes32 blockHash) private {
|
| 729 |
+
uint8 tier;
|
| 730 |
+
bytes32 dna;
|
| 731 |
+
(,dna,,tier) = stables.horseys(tokenId);
|
| 732 |
+
if(tier < 255)
|
| 733 |
+
stables.modifyHorseyTier(tokenId,tier+1);
|
| 734 |
+
uint256 random = uint256(keccak256(abi.encodePacked(tokenId, blockHash)));
|
| 735 |
+
|
| 736 |
+
bytes32 rarityMask = _shiftLeft(bytes32(1), (random % 16 + 240));
|
| 737 |
+
bytes32 newdna = dna | rarityMask;
|
| 738 |
+
stables.modifyHorseyDna(tokenId,newdna);
|
| 739 |
+
}
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
function _shiftLeft(bytes32 data, uint n) internal pure returns (bytes32) {
|
| 743 |
+
return bytes32(uint256(data)*(2 ** n));
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
function _shiftRight(bytes32 data, uint n) internal pure returns (bytes32) {
|
| 748 |
+
return bytes32(uint256(data)/(2 ** n));
|
| 749 |
+
}
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
modifier carrotsMeetLevel(uint256 tokenId){
|
| 753 |
+
uint256 feedingCounter;
|
| 754 |
+
(,,feedingCounter,) = stables.horseys(tokenId);
|
| 755 |
+
require(feedingCounter <= stables.carrot_credits(msg.sender),"Not enough carrots");
|
| 756 |
+
_;
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
|
| 760 |
+
modifier costs(uint256 amount) {
|
| 761 |
+
require(msg.value >= amount,"Not enough funds");
|
| 762 |
+
_;
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
modifier validAddress(address addr) {
|
| 767 |
+
require(addr != address(0),"Address is zero");
|
| 768 |
+
_;
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
|
| 772 |
+
modifier noFeedingInProgress() {
|
| 773 |
+
|
| 774 |
+
require(pendingFeedings[msg.sender].blockNumber == 0,"Already feeding");
|
| 775 |
+
_;
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
modifier feedingInProgress() {
|
| 780 |
+
|
| 781 |
+
require(pendingFeedings[msg.sender].blockNumber != 0,"No pending feeding");
|
| 782 |
+
_;
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
|
| 786 |
+
modifier onlyOwnerOf(uint256 tokenId) {
|
| 787 |
+
require(stables.ownerOf(tokenId) == msg.sender, "Caller is not owner of this token");
|
| 788 |
+
_;
|
| 789 |
+
}
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
|
| 793 |
+
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
contract HorseyPilot {
|
| 797 |
+
|
| 798 |
+
using SafeMath for uint256;
|
| 799 |
+
|
| 800 |
+
|
| 801 |
+
event NewProposal(uint8 methodId, uint parameter, address proposer);
|
| 802 |
+
|
| 803 |
+
|
| 804 |
+
event ProposalPassed(uint8 methodId, uint parameter, address proposer);
|
| 805 |
+
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
uint8 constant votingThreshold = 2;
|
| 809 |
+
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
uint256 constant proposalLife = 7 days;
|
| 813 |
+
|
| 814 |
+
|
| 815 |
+
|
| 816 |
+
uint256 constant proposalCooldown = 1 days;
|
| 817 |
+
|
| 818 |
+
|
| 819 |
+
uint256 cooldownStart;
|
| 820 |
+
|
| 821 |
+
|
| 822 |
+
address public jokerAddress;
|
| 823 |
+
address public knightAddress;
|
| 824 |
+
address public paladinAddress;
|
| 825 |
+
|
| 826 |
+
|
| 827 |
+
address[3] public voters;
|
| 828 |
+
|
| 829 |
+
|
| 830 |
+
uint8 constant public knightEquity = 40;
|
| 831 |
+
uint8 constant public paladinEquity = 10;
|
| 832 |
+
|
| 833 |
+
|
| 834 |
+
address public exchangeAddress;
|
| 835 |
+
address public tokenAddress;
|
| 836 |
+
|
| 837 |
+
|
| 838 |
+
mapping(address => uint) internal _cBalance;
|
| 839 |
+
|
| 840 |
+
|
| 841 |
+
struct Proposal{
|
| 842 |
+
address proposer;
|
| 843 |
+
uint256 timestamp;
|
| 844 |
+
uint256 parameter;
|
| 845 |
+
uint8 methodId;
|
| 846 |
+
address[] yay;
|
| 847 |
+
address[] nay;
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
|
| 851 |
+
Proposal public currentProposal;
|
| 852 |
+
|
| 853 |
+
|
| 854 |
+
bool public proposalInProgress = false;
|
| 855 |
+
|
| 856 |
+
|
| 857 |
+
uint256 public toBeDistributed;
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
bool deployed = false;
|
| 861 |
+
|
| 862 |
+
|
| 863 |
+
constructor(
|
| 864 |
+
address _jokerAddress,
|
| 865 |
+
address _knightAddress,
|
| 866 |
+
address _paladinAddress,
|
| 867 |
+
address[3] _voters
|
| 868 |
+
) public {
|
| 869 |
+
jokerAddress = _jokerAddress;
|
| 870 |
+
knightAddress = _knightAddress;
|
| 871 |
+
paladinAddress = _paladinAddress;
|
| 872 |
+
|
| 873 |
+
for(uint i = 0; i < 3; i++) {
|
| 874 |
+
voters[i] = _voters[i];
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
|
| 878 |
+
cooldownStart = block.timestamp - proposalCooldown;
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
|
| 882 |
+
function deployChildren(address stablesAddress) external {
|
| 883 |
+
require(!deployed,"already deployed");
|
| 884 |
+
|
| 885 |
+
exchangeAddress = new HorseyExchange();
|
| 886 |
+
tokenAddress = new HorseyToken(stablesAddress);
|
| 887 |
+
|
| 888 |
+
|
| 889 |
+
HorseyExchange(exchangeAddress).setStables(stablesAddress);
|
| 890 |
+
|
| 891 |
+
deployed = true;
|
| 892 |
+
}
|
| 893 |
+
|
| 894 |
+
|
| 895 |
+
function transferJokerOwnership(address newJoker) external
|
| 896 |
+
validAddress(newJoker) {
|
| 897 |
+
require(jokerAddress == msg.sender,"Not right role");
|
| 898 |
+
_moveBalance(newJoker);
|
| 899 |
+
jokerAddress = newJoker;
|
| 900 |
+
}
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
function transferKnightOwnership(address newKnight) external
|
| 904 |
+
validAddress(newKnight) {
|
| 905 |
+
require(knightAddress == msg.sender,"Not right role");
|
| 906 |
+
_moveBalance(newKnight);
|
| 907 |
+
knightAddress = newKnight;
|
| 908 |
+
}
|
| 909 |
+
|
| 910 |
+
|
| 911 |
+
function transferPaladinOwnership(address newPaladin) external
|
| 912 |
+
validAddress(newPaladin) {
|
| 913 |
+
require(paladinAddress == msg.sender,"Not right role");
|
| 914 |
+
_moveBalance(newPaladin);
|
| 915 |
+
paladinAddress = newPaladin;
|
| 916 |
+
}
|
| 917 |
+
|
| 918 |
+
|
| 919 |
+
function withdrawCeo(address destination) external
|
| 920 |
+
onlyCLevelAccess()
|
| 921 |
+
validAddress(destination) {
|
| 922 |
+
|
| 923 |
+
|
| 924 |
+
if(toBeDistributed > 0){
|
| 925 |
+
_updateDistribution();
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
|
| 929 |
+
uint256 balance = _cBalance[msg.sender];
|
| 930 |
+
|
| 931 |
+
|
| 932 |
+
if(balance > 0 && (address(this).balance >= balance)) {
|
| 933 |
+
destination.transfer(balance);
|
| 934 |
+
_cBalance[msg.sender] = 0;
|
| 935 |
+
}
|
| 936 |
+
}
|
| 937 |
+
|
| 938 |
+
|
| 939 |
+
function syncFunds() external {
|
| 940 |
+
uint256 prevBalance = address(this).balance;
|
| 941 |
+
HorseyToken(tokenAddress).withdraw();
|
| 942 |
+
HorseyExchange(exchangeAddress).withdraw();
|
| 943 |
+
uint256 newBalance = address(this).balance;
|
| 944 |
+
|
| 945 |
+
toBeDistributed = toBeDistributed.add(newBalance - prevBalance);
|
| 946 |
+
}
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
function getNobleBalance() external view
|
| 950 |
+
onlyCLevelAccess() returns (uint256) {
|
| 951 |
+
return _cBalance[msg.sender];
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
|
| 955 |
+
function makeProposal( uint8 methodId, uint256 parameter ) external
|
| 956 |
+
onlyCLevelAccess()
|
| 957 |
+
proposalAvailable()
|
| 958 |
+
cooledDown()
|
| 959 |
+
{
|
| 960 |
+
currentProposal.timestamp = block.timestamp;
|
| 961 |
+
currentProposal.parameter = parameter;
|
| 962 |
+
currentProposal.methodId = methodId;
|
| 963 |
+
currentProposal.proposer = msg.sender;
|
| 964 |
+
delete currentProposal.yay;
|
| 965 |
+
delete currentProposal.nay;
|
| 966 |
+
proposalInProgress = true;
|
| 967 |
+
|
| 968 |
+
emit NewProposal(methodId,parameter,msg.sender);
|
| 969 |
+
}
|
| 970 |
+
|
| 971 |
+
|
| 972 |
+
function voteOnProposal(bool voteFor) external
|
| 973 |
+
proposalPending()
|
| 974 |
+
onlyVoters()
|
| 975 |
+
notVoted() {
|
| 976 |
+
|
| 977 |
+
require((block.timestamp - currentProposal.timestamp) <= proposalLife);
|
| 978 |
+
if(voteFor)
|
| 979 |
+
{
|
| 980 |
+
currentProposal.yay.push(msg.sender);
|
| 981 |
+
|
| 982 |
+
if( currentProposal.yay.length >= votingThreshold )
|
| 983 |
+
{
|
| 984 |
+
_doProposal();
|
| 985 |
+
proposalInProgress = false;
|
| 986 |
+
|
| 987 |
+
return;
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
} else {
|
| 991 |
+
currentProposal.nay.push(msg.sender);
|
| 992 |
+
|
| 993 |
+
if( currentProposal.nay.length >= votingThreshold )
|
| 994 |
+
{
|
| 995 |
+
proposalInProgress = false;
|
| 996 |
+
cooldownStart = block.timestamp;
|
| 997 |
+
return;
|
| 998 |
+
}
|
| 999 |
+
}
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
+
|
| 1003 |
+
function _moveBalance(address newAddress) internal
|
| 1004 |
+
validAddress(newAddress) {
|
| 1005 |
+
require(newAddress != msg.sender);
|
| 1006 |
+
_cBalance[newAddress] = _cBalance[msg.sender];
|
| 1007 |
+
_cBalance[msg.sender] = 0;
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
|
| 1011 |
+
function _updateDistribution() internal {
|
| 1012 |
+
require(toBeDistributed != 0,"nothing to distribute");
|
| 1013 |
+
uint256 knightPayday = toBeDistributed.div(100).mul(knightEquity);
|
| 1014 |
+
uint256 paladinPayday = toBeDistributed.div(100).mul(paladinEquity);
|
| 1015 |
+
|
| 1016 |
+
|
| 1017 |
+
uint256 jokerPayday = toBeDistributed.sub(knightPayday).sub(paladinPayday);
|
| 1018 |
+
|
| 1019 |
+
_cBalance[jokerAddress] = _cBalance[jokerAddress].add(jokerPayday);
|
| 1020 |
+
_cBalance[knightAddress] = _cBalance[knightAddress].add(knightPayday);
|
| 1021 |
+
_cBalance[paladinAddress] = _cBalance[paladinAddress].add(paladinPayday);
|
| 1022 |
+
|
| 1023 |
+
toBeDistributed = 0;
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
|
| 1027 |
+
function _doProposal() internal {
|
| 1028 |
+
|
| 1029 |
+
if( currentProposal.methodId == 0 ) HorseyToken(tokenAddress).setRenamingCosts(currentProposal.parameter);
|
| 1030 |
+
|
| 1031 |
+
|
| 1032 |
+
if( currentProposal.methodId == 1 ) HorseyExchange(exchangeAddress).setMarketFees(currentProposal.parameter);
|
| 1033 |
+
|
| 1034 |
+
|
| 1035 |
+
if( currentProposal.methodId == 2 ) HorseyToken(tokenAddress).addLegitDevAddress(address(currentProposal.parameter));
|
| 1036 |
+
|
| 1037 |
+
|
| 1038 |
+
if( currentProposal.methodId == 3 ) HorseyToken(tokenAddress).addHorseIndex(bytes32(currentProposal.parameter));
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
if( currentProposal.methodId == 4 ) {
|
| 1042 |
+
if(currentProposal.parameter == 0) {
|
| 1043 |
+
HorseyExchange(exchangeAddress).unpause();
|
| 1044 |
+
HorseyToken(tokenAddress).unpause();
|
| 1045 |
+
} else {
|
| 1046 |
+
HorseyExchange(exchangeAddress).pause();
|
| 1047 |
+
HorseyToken(tokenAddress).pause();
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
|
| 1052 |
+
if( currentProposal.methodId == 5 ) HorseyToken(tokenAddress).setClaimingCosts(currentProposal.parameter);
|
| 1053 |
+
|
| 1054 |
+
|
| 1055 |
+
if( currentProposal.methodId == 8 ){
|
| 1056 |
+
HorseyToken(tokenAddress).setCarrotsMultiplier(uint8(currentProposal.parameter));
|
| 1057 |
+
}
|
| 1058 |
+
|
| 1059 |
+
|
| 1060 |
+
if( currentProposal.methodId == 9 ){
|
| 1061 |
+
HorseyToken(tokenAddress).setRarityMultiplier(uint8(currentProposal.parameter));
|
| 1062 |
+
}
|
| 1063 |
+
|
| 1064 |
+
emit ProposalPassed(currentProposal.methodId,currentProposal.parameter,currentProposal.proposer);
|
| 1065 |
+
}
|
| 1066 |
+
|
| 1067 |
+
|
| 1068 |
+
modifier validAddress(address addr) {
|
| 1069 |
+
require(addr != address(0),"Address is zero");
|
| 1070 |
+
_;
|
| 1071 |
+
}
|
| 1072 |
+
|
| 1073 |
+
|
| 1074 |
+
modifier onlyCLevelAccess() {
|
| 1075 |
+
require((jokerAddress == msg.sender) || (knightAddress == msg.sender) || (paladinAddress == msg.sender),"not c level");
|
| 1076 |
+
_;
|
| 1077 |
+
}
|
| 1078 |
+
|
| 1079 |
+
|
| 1080 |
+
|
| 1081 |
+
modifier proposalAvailable(){
|
| 1082 |
+
require(((!proposalInProgress) || ((block.timestamp - currentProposal.timestamp) > proposalLife)),"proposal already pending");
|
| 1083 |
+
_;
|
| 1084 |
+
}
|
| 1085 |
+
|
| 1086 |
+
|
| 1087 |
+
|
| 1088 |
+
modifier cooledDown( ){
|
| 1089 |
+
if(msg.sender == currentProposal.proposer && (block.timestamp - cooldownStart < 1 days)){
|
| 1090 |
+
revert("Cool down period not passed yet");
|
| 1091 |
+
}
|
| 1092 |
+
_;
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
|
| 1096 |
+
modifier proposalPending() {
|
| 1097 |
+
require(proposalInProgress,"no proposal pending");
|
| 1098 |
+
_;
|
| 1099 |
+
}
|
| 1100 |
+
|
| 1101 |
+
|
| 1102 |
+
modifier notVoted() {
|
| 1103 |
+
uint256 length = currentProposal.yay.length;
|
| 1104 |
+
for(uint i = 0; i < length; i++) {
|
| 1105 |
+
if(currentProposal.yay[i] == msg.sender) {
|
| 1106 |
+
revert("Already voted");
|
| 1107 |
+
}
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
+
length = currentProposal.nay.length;
|
| 1111 |
+
for(i = 0; i < length; i++) {
|
| 1112 |
+
if(currentProposal.nay[i] == msg.sender) {
|
| 1113 |
+
revert("Already voted");
|
| 1114 |
+
}
|
| 1115 |
+
}
|
| 1116 |
+
_;
|
| 1117 |
+
}
|
| 1118 |
+
|
| 1119 |
+
|
| 1120 |
+
modifier onlyVoters() {
|
| 1121 |
+
bool found = false;
|
| 1122 |
+
uint256 length = voters.length;
|
| 1123 |
+
for(uint i = 0; i < length; i++) {
|
| 1124 |
+
if(voters[i] == msg.sender) {
|
| 1125 |
+
found = true;
|
| 1126 |
+
break;
|
| 1127 |
+
}
|
| 1128 |
+
}
|
| 1129 |
+
if(!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^0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
library SafeMath {
|
| 5 |
+
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 6 |
+
uint256 c = a * b;
|
| 7 |
+
assert(a == 0 || c / a == b);
|
| 8 |
+
return c;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function div(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 12 |
+
|
| 13 |
+
uint256 c = a / b;
|
| 14 |
+
|
| 15 |
+
return c;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 19 |
+
assert(b <= a);
|
| 20 |
+
return a - b;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function add(uint256 a, uint256 b) internal constant returns (uint256) {
|
| 24 |
+
uint256 c = a + b;
|
| 25 |
+
assert(c >= a);
|
| 26 |
+
return c;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
contract ERC20Basic {
|
| 32 |
+
uint256 public totalSupply;
|
| 33 |
+
function balanceOf(address who) constant returns (uint256);
|
| 34 |
+
function transfer(address to, uint256 value) returns (bool);
|
| 35 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
contract BasicToken is ERC20Basic {
|
| 40 |
+
using SafeMath for uint256;
|
| 41 |
+
|
| 42 |
+
mapping(address => uint256) balances;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
function transfer(address _to, uint256 _value) returns (bool) {
|
| 46 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 47 |
+
balances[_to] = balances[_to].add(_value);
|
| 48 |
+
Transfer(msg.sender, _to, _value);
|
| 49 |
+
return true;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
function balanceOf(address _owner) constant returns (uint256 balance) {
|
| 54 |
+
return balances[_owner];
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
contract ERC20 is ERC20Basic {
|
| 61 |
+
function allowance(address owner, address spender) constant returns (uint256);
|
| 62 |
+
function transferFrom(address from, address to, uint256 value) returns (bool);
|
| 63 |
+
function approve(address spender, uint256 value) returns (bool);
|
| 64 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
contract StandardToken is ERC20, BasicToken {
|
| 69 |
+
|
| 70 |
+
mapping (address => mapping (address => uint256)) allowed;
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
|
| 75 |
+
var _allowance = allowed[_from][msg.sender];
|
| 76 |
+
balances[_to] = balances[_to].add(_value);
|
| 77 |
+
balances[_from] = balances[_from].sub(_value);
|
| 78 |
+
allowed[_from][msg.sender] = _allowance.sub(_value);
|
| 79 |
+
Transfer(_from, _to, _value);
|
| 80 |
+
return true;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
function approve(address _spender, uint256 _value) returns (bool) {
|
| 85 |
+
|
| 86 |
+
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
|
| 87 |
+
|
| 88 |
+
allowed[msg.sender][_spender] = _value;
|
| 89 |
+
Approval(msg.sender, _spender, _value);
|
| 90 |
+
return true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
|
| 94 |
+
return allowed[_owner][_spender];
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
contract Ownable {
|
| 100 |
+
address public owner;
|
| 101 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
modifier onlyOwner() {
|
| 107 |
+
require(msg.sender == owner);
|
| 108 |
+
_;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function transferOwnership(address newOwner) public onlyOwner {
|
| 112 |
+
require(newOwner != address(0));
|
| 113 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 114 |
+
owner = newOwner;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
contract IPM is StandardToken ,Ownable {
|
| 124 |
+
|
| 125 |
+
string public constant name = "IPMCOIN";
|
| 126 |
+
string public constant symbol = "IPM";
|
| 127 |
+
uint256 public constant decimals = 18;
|
| 128 |
+
|
| 129 |
+
uint256 public constant INITIAL_SUPPLY = 3000000000 * 10 ** uint256(decimals);
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
function IPM() {
|
| 133 |
+
totalSupply = INITIAL_SUPPLY;
|
| 134 |
+
balances[msg.sender] = INITIAL_SUPPLY;
|
| 135 |
+
owner=msg.sender;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
function Airdrop(ERC20 token, address[] _addresses, uint256 amount) public {
|
| 140 |
+
for (uint256 i = 0; i < _addresses.length; i++) {
|
| 141 |
+
token.transfer(_addresses[i], amount);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
}
|
benchmark2/integer overflow/683.sol
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ershipTransferred(address indexed previousOwner, address indexed newOwner);
|
| 7 |
+
|
| 8 |
+
constructor() public {
|
| 9 |
+
owner = msg.sender;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
modifier onlyOwner() {
|
| 13 |
+
require(msg.sender == owner);
|
| 14 |
+
_;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function transferOwnership(address newOwner) public onlyOwner {
|
| 18 |
+
require(newOwner != address(0));
|
| 19 |
+
emit OwnershipTransferred(owner, newOwner);
|
| 20 |
+
owner = newOwner;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
contract Pausable is Ownable {
|
| 26 |
+
event Pause();
|
| 27 |
+
event Unpause();
|
| 28 |
+
|
| 29 |
+
bool public paused = false;
|
| 30 |
+
|
| 31 |
+
modifier whenNotPaused() {
|
| 32 |
+
if (msg.sender != owner) {
|
| 33 |
+
require(!paused);
|
| 34 |
+
}
|
| 35 |
+
_;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
modifier whenPaused() {
|
| 39 |
+
if (msg.sender != owner) {
|
| 40 |
+
require(paused);
|
| 41 |
+
}
|
| 42 |
+
_;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function pause() onlyOwner public {
|
| 46 |
+
paused = true;
|
| 47 |
+
emit Pause();
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function unpause() onlyOwner public {
|
| 51 |
+
paused = false;
|
| 52 |
+
emit Unpause();
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
library SafeMath {
|
| 57 |
+
function mul(uint a, uint b) internal pure returns (uint) {
|
| 58 |
+
if (a == 0) {
|
| 59 |
+
return 0;
|
| 60 |
+
}
|
| 61 |
+
uint c = a * b;
|
| 62 |
+
assert(c / a == b);
|
| 63 |
+
return c;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function div(uint a, uint b) internal pure returns (uint) {
|
| 67 |
+
|
| 68 |
+
uint c = a / b;
|
| 69 |
+
|
| 70 |
+
return c;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
function sub(uint a, uint b) internal pure returns (uint) {
|
| 74 |
+
assert(b <= a);
|
| 75 |
+
return a - b;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function add(uint a, uint b) internal pure returns (uint) {
|
| 79 |
+
uint c = a + b;
|
| 80 |
+
assert(c >= a);
|
| 81 |
+
return c;
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
contract ERC20 {
|
| 86 |
+
string public name;
|
| 87 |
+
string public symbol;
|
| 88 |
+
uint8 public decimals;
|
| 89 |
+
uint public totalSupply;
|
| 90 |
+
constructor(string _name, string _symbol, uint8 _decimals) public {
|
| 91 |
+
name = _name;
|
| 92 |
+
symbol = _symbol;
|
| 93 |
+
decimals = _decimals;
|
| 94 |
+
}
|
| 95 |
+
function balanceOf(address who) public view returns (uint);
|
| 96 |
+
function transfer(address to, uint value) public returns (bool);
|
| 97 |
+
function allowance(address owner, address spender) public view returns (uint);
|
| 98 |
+
function transferFrom(address from, address to, uint value) public returns (bool);
|
| 99 |
+
function approve(address spender, uint value) public returns (bool);
|
| 100 |
+
event Transfer(address indexed from, address indexed to, uint value);
|
| 101 |
+
event Approval(address indexed owner, address indexed spender, uint value);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
contract Token is Pausable, ERC20 {
|
| 105 |
+
using SafeMath for uint;
|
| 106 |
+
event Burn(address indexed burner, uint256 value);
|
| 107 |
+
|
| 108 |
+
mapping(address => uint) balances;
|
| 109 |
+
mapping (address => mapping (address => uint)) internal allowed;
|
| 110 |
+
mapping(address => uint) public balanceOfLocked;
|
| 111 |
+
mapping(address => bool) public addressLocked;
|
| 112 |
+
|
| 113 |
+
constructor() ERC20("OCP", "OCP", 18) public {
|
| 114 |
+
totalSupply = 10000000000 * 10 ** uint(decimals);
|
| 115 |
+
balances[msg.sender] = totalSupply;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
modifier lockCheck(address from, uint value) {
|
| 119 |
+
require(addressLocked[from] == false);
|
| 120 |
+
require(balances[from] >= balanceOfLocked[from]);
|
| 121 |
+
require(value <= balances[from] - balanceOfLocked[from]);
|
| 122 |
+
_;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function burn(uint _value) onlyOwner public {
|
| 126 |
+
balances[owner] = balances[owner].sub(_value);
|
| 127 |
+
totalSupply = totalSupply.sub(_value);
|
| 128 |
+
emit Burn(msg.sender, _value);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
function lockAddressValue(address _addr, uint _value) onlyOwner public {
|
| 132 |
+
balanceOfLocked[_addr] = _value;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
function lockAddress(address addr) onlyOwner public {
|
| 136 |
+
addressLocked[addr] = true;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function unlockAddress(address addr) onlyOwner public {
|
| 140 |
+
addressLocked[addr] = false;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function transfer(address _to, uint _value) lockCheck(msg.sender, _value) whenNotPaused public returns (bool) {
|
| 144 |
+
require(_to != address(0));
|
| 145 |
+
require(_value <= balances[msg.sender]);
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
balances[msg.sender] = balances[msg.sender].sub(_value);
|
| 149 |
+
balances[_to] = balances[_to].add(_value);
|
| 150 |
+
emit Transfer(msg.sender, _to, _value);
|
| 151 |
+
return true;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
function balanceOf(address _owner) public view returns (uint balance) {
|
| 155 |
+
return balances[_owner];
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
function transferFrom(address _from, address _to, uint _value) public lockCheck(_from, _value) whenNotPaused returns (bool) {
|
| 159 |
+
require(_to != address(0));
|
| 160 |
+
require(_value <= balances[_from]);
|
| 161 |
+
require(_value <= allowed[_from][msg.sender]);
|
| 162 |
+
|
| 163 |
+
balances[_from] = balances[_from].sub(_value);
|
| 164 |
+
balances[_to] = balances[_to].add(_value);
|
| 165 |
+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
|
| 166 |
+
emit Transfer(_from, _to, _value);
|
| 167 |
+
return true;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function approve(address _spender, uint _value) public whenNotPaused returns (bool) {
|
| 171 |
+
allowed[msg.sender][_spender] = _value;
|
| 172 |
+
emit Approval(msg.sender, _spender, _value);
|
| 173 |
+
return true;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
function allowance(address _owner, address _spender) public view returns (uint) {
|
| 177 |
+
return allowed[_owner][_spender];
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool) {
|
| 181 |
+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
|
| 182 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 183 |
+
return true;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool) {
|
| 187 |
+
uint oldValue = allowed[msg.sender][_spender];
|
| 188 |
+
if (_subtractedValue > oldValue) {
|
| 189 |
+
allowed[msg.sender][_spender] = 0;
|
| 190 |
+
} else {
|
| 191 |
+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
|
| 192 |
+
}
|
| 193 |
+
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
|
| 194 |
+
return true;
|
| 195 |
+
}
|
| 196 |
+
}
|
benchmark2/integer overflow/727.sol
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pragma solidity 0.4.24;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
library SafeMath {
|
| 8 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 9 |
+
c = a + b; assert(c >= a); return c; }
|
| 10 |
+
|
| 11 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
|
| 12 |
+
|
| 13 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
| 14 |
+
if (a == 0){return 0;} c = a * b; assert(c / a == b); return c; }
|
| 15 |
+
|
| 16 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; }
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
contract ERC20Token {
|
| 22 |
+
function totalSupply() public view returns (uint256);
|
| 23 |
+
function balanceOf(address _targetAddress) public view returns (uint256);
|
| 24 |
+
function transfer(address _targetAddress, uint256 _value) public returns (bool);
|
| 25 |
+
event Transfer(address indexed _originAddress, address indexed _targetAddress, uint256 _value);
|
| 26 |
+
|
| 27 |
+
function allowance(address _originAddress, address _targetAddress) public view returns (uint256);
|
| 28 |
+
function approve(address _originAddress, uint256 _value) public returns (bool);
|
| 29 |
+
function transferFrom(address _originAddress, address _targetAddress, uint256 _value) public returns (bool);
|
| 30 |
+
event Approval(address indexed _originAddress, address indexed _targetAddress, uint256 _value);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
contract Ownership {
|
| 36 |
+
address public owner;
|
| 37 |
+
|
| 38 |
+
modifier onlyOwner() { require(msg.sender == owner); _; }
|
| 39 |
+
modifier validDestination(address _targetAddress) { require(_targetAddress != address(0x0)); _; }
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
contract MAJz is ERC20Token, Ownership {
|
| 45 |
+
using SafeMath for uint256;
|
| 46 |
+
|
| 47 |
+
string public symbol;
|
| 48 |
+
string public name;
|
| 49 |
+
uint256 public decimals;
|
| 50 |
+
uint256 public totalSupply;
|
| 51 |
+
|
| 52 |
+
mapping(address => uint256) public balances;
|
| 53 |
+
mapping(address => mapping(address => uint256)) allowed;
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
constructor() public{
|
| 57 |
+
symbol = "MAZ";
|
| 58 |
+
name = "MAJz";
|
| 59 |
+
decimals = 18;
|
| 60 |
+
totalSupply = 560000000000000000000000000;
|
| 61 |
+
balances[msg.sender] = totalSupply;
|
| 62 |
+
owner = msg.sender;
|
| 63 |
+
emit Transfer(address(0), msg.sender, totalSupply);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
function totalSupply() public view returns (uint256) {
|
| 70 |
+
return totalSupply;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
function balanceOf(address _targetAddress) public view returns (uint256) {
|
| 74 |
+
return balances[_targetAddress];
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
function transfer(address _targetAddress, uint256 _value) validDestination(_targetAddress) public returns (bool) {
|
| 79 |
+
balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
|
| 80 |
+
balances[_targetAddress] = SafeMath.add(balances[_targetAddress], _value);
|
| 81 |
+
emit Transfer(msg.sender, _targetAddress, _value);
|
| 82 |
+
return true;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
function allowance(address _originAddress, address _targetAddress) public view returns (uint256){
|
| 87 |
+
return allowed[_originAddress][_targetAddress];
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
function approve(address _targetAddress, uint256 _value) public returns (bool) {
|
| 91 |
+
allowed[msg.sender][_targetAddress] = _value;
|
| 92 |
+
emit Approval(msg.sender, _targetAddress, _value);
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
function transferFrom(address _originAddress, address _targetAddress, uint256 _value) public returns (bool) {
|
| 97 |
+
balances[_originAddress] = SafeMath.sub(balances[_originAddress], _value);
|
| 98 |
+
allowed[_originAddress][msg.sender] = SafeMath.sub(allowed[_originAddress][msg.sender], _value);
|
| 99 |
+
balances[_targetAddress] = SafeMath.add(balances[_targetAddress], _value);
|
| 100 |
+
emit Transfer(_originAddress, _targetAddress, _value);
|
| 101 |
+
return true;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function () public payable {
|
| 105 |
+
revert();
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
function burnTokens(uint256 _value) public onlyOwner returns (bool){
|
| 112 |
+
balances[owner] = SafeMath.sub(balances[owner], _value);
|
| 113 |
+
totalSupply = SafeMath.sub(totalSupply, _value);
|
| 114 |
+
emit BurnTokens(_value);
|
| 115 |
+
return true;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
function emitTokens(uint256 _value) public onlyOwner returns (bool){
|
| 120 |
+
balances[owner] = SafeMath.add(balances[owner], _value);
|
| 121 |
+
totalSupply = SafeMath.add(totalSupply, _value);
|
| 122 |
+
emit EmitTokens(_value);
|
| 123 |
+
return true;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
function revertTransfer(address _targetAddress, uint256 _value) public onlyOwner returns (bool) {
|
| 128 |
+
balances[_targetAddress] = SafeMath.sub(balances[_targetAddress], _value);
|
| 129 |
+
balances[owner] = SafeMath.add(balances[owner], _value);
|
| 130 |
+
emit RevertTransfer(_targetAddress, _value);
|
| 131 |
+
return true;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
event RevertTransfer(address _targetAddress, uint256 _value);
|
| 135 |
+
event BurnTokens(uint256 _value);
|
| 136 |
+
event EmitTokens(uint256 _value);
|
| 137 |
+
}
|