Transaction Hash:
Block:
8313915 at Aug-09-2019 03:09:39 AM +UTC
Transaction Fee:
0.000385215 ETH
$0.78
Gas Used:
77,043 Gas / 5 Gwei
Emitted Events:
| 90 |
IBNEST.Transfer( from=[Sender] 0x358a2ef0b615590fc7b6be0a566652fff6a37592, to=NESTSave, value=6000000000000000000000 )
|
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
| 0x04abEdA2...c74ddC74C | |||||
| 0x358A2Ef0...FF6A37592 |
0.0104955080000003 Eth
Nonce: 3
|
0.0101102930000003 Eth
Nonce: 4
| 0.000385215 | ||
| 0x561d0d6c...223fFaeBF | (NEST Protocol: Token Earnings Verification) | ||||
|
0x5A0b54D5...D3E029c4c
Miner
| (Spark Pool) | 4,686.340027774474094453 Eth | 4,686.340412989474094453 Eth | 0.000385215 |
Execution Trace
NESTAbonus.depositIn( amount=6000000000000000000000 )
NESTSave.depositIn( num=6000000000000000000000 )-
IBMapping.checkAddress( name=nestAbonus ) => ( contractAddress=0xDEeaA1726cc544486eeA4d0E114AEbD04A5016bd )
IBNEST.balanceOf( _owner=0x358A2Ef0b615590FC7b6bE0A566652fFF6A37592 ) => ( 6000000000000000000000 )
-
IterableMapping.4c5e1cae( )
-
-
IBNEST.allowance( _owner=0x358A2Ef0b615590FC7b6bE0A566652fFF6A37592, _spender=0x561d0d6c498a379574eAaA4a5F2532b223fFaeBF ) => ( 5000000000000000000000000 )
IBNEST.transferFrom( _from=0x358A2Ef0b615590FC7b6bE0A566652fFF6A37592, _to=0x561d0d6c498a379574eAaA4a5F2532b223fFaeBF, _value=6000000000000000000000 ) => ( True )
-
IterableMapping.4c5e1cae( ) -
IterableMapping.4c5e1cae( ) -
IterableMapping.ab517b4f( ) -
IterableMapping.4c5e1cae( ) -
IterableMapping.ab517b4f( )
-
-
depositIn[NESTAbonus (ln:126)]
File 1 of 5: NESTAbonus
File 2 of 5: NESTSave
File 3 of 5: IBNEST
File 4 of 5: IBMapping
File 5 of 5: IterableMapping
pragma solidity ^0.5.8;
contract IBNEST {
function totalSupply() public view returns (uint supply);
function balanceOf( address who ) public view returns (uint value);
function allowance( address owner, address spender ) public view returns (uint _allowance);
function transfer( address to, uint256 value) external;
function transferFrom( address from, address to, uint value) public returns (bool ok);
function approve( address spender, uint value ) public returns (bool ok);
event Transfer( address indexed from, address indexed to, uint value);
event Approval( address indexed owner, address indexed spender, uint value);
function balancesStart() public view returns(uint256);
function balancesGetBool(uint256 num) public view returns(bool);
function balancesGetNext(uint256 num) public view returns(uint256);
function balancesGetValue(uint256 num) public view returns(address, uint256);
}
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b > 0); // Solidity automatically throws when dividing by 0
uint256 c = _a / _b;
assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
}
// 映射合约
contract IBMapping {
// 查询地址
function checkAddress(string memory name) public view returns (address contractAddress);
// 查看是否管理员
function checkOwners(address man) public view returns (bool);
}
library address_make_payable {
function make_payable(address x) internal pure returns (address payable) {
return address(uint160(x));
}
}
contract NESTSave {
function takeOut(uint256 num) public;
function depositIn(uint256 num) public;
function takeOutPrivate() public;
function checkAmount(address sender) public view returns(uint256);
}
contract Abonus {
function getETH(uint256 num) public;
function getETHNum() public view returns (uint256);
}
contract NESTAbonus {
using address_make_payable for address;
using SafeMath for uint256;
IBNEST nestContract;
IBMapping mappingContract;
NESTSave baseMapping;
Abonus abonusContract;
uint256 timeLimit = 168 hours;
uint256 nextTime = 1562299200;
uint256 getAbonusTimeLimit = 60 hours;
uint256 ethNum = 0;
uint256 nestAllValue = 0;
uint256 times = 0;
mapping(uint256 => mapping(address => bool)) getMapping;
constructor (address map) public {
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
baseMapping = NESTSave(address(mappingContract.checkAddress("nestSave")));
address payable addr = address(mappingContract.checkAddress("abonus")).make_payable();
abonusContract = Abonus(addr);
}
function changeMapping(address map) public {
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
baseMapping = NESTSave(address(mappingContract.checkAddress("nestSave")));
address payable addr = address(mappingContract.checkAddress("abonus")).make_payable();
abonusContract = Abonus(addr);
}
function depositIn(uint256 amount) public {
require(isContract(address(msg.sender)) == false);
uint256 nowTime = now;
if (nowTime < nextTime) {
require(!(nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit)));
} else {
require(!(nowTime >= nextTime && nowTime <= nextTime.add(getAbonusTimeLimit)));
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
uint256 startTime = nextTime.add((time).mul(timeLimit));
uint256 endTime = startTime.add(getAbonusTimeLimit);
require(!(nowTime >= startTime && nowTime <= endTime));
}
baseMapping.depositIn(amount);
}
function takeOut(uint256 amount) public {
require(isContract(address(msg.sender)) == false);
require(amount != 0);
require(amount <= baseMapping.checkAmount(address(msg.sender)));
baseMapping.takeOut(amount);
}
function getETH() public {
require(isContract(address(msg.sender)) == false);
reloadTimeAndMapping ();
uint256 nowTime = now;
require(nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit));
require(getMapping[times.sub(1)][address(msg.sender)] != true);
uint256 nestAmount = baseMapping.checkAmount(address(msg.sender));
require(nestAmount > 0);
require(nestAllValue > 0);
uint256 selfEth = nestAmount.mul(ethNum).div(nestAllValue);
require(selfEth > 0);
getMapping[times.sub(1)][address(msg.sender)] = true;
abonusContract.getETH(selfEth);
}
function reloadTimeAndMapping () private {
require(isContract(address(msg.sender)) == false);
uint256 nowTime = now;
if (nowTime >= nextTime) {
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
uint256 startTime = nextTime.add((time).mul(timeLimit));
uint256 endTime = startTime.add(getAbonusTimeLimit);
if (nowTime >= startTime && nowTime <= endTime) {
nextTime = getNextTime();
times = times.add(1);
ethNum = abonusContract.getETHNum();
nestAllValue = allValue();
}
}
}
function getInfo() public view returns (uint256 _nextTime, uint256 _getAbonusTime, uint256 _ethNum, uint256 _nestValue, uint256 _myJoinNest, uint256 _getEth, uint256 _allowNum, uint256 _leftNum, bool allowAbonus) {
uint256 nowTime = now;
if (nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit)) {
allowAbonus = getMapping[times.sub(1)][address(msg.sender)];
_ethNum = ethNum;
_nestValue = nestAllValue;
} else {
_ethNum = abonusContract.getETHNum();
_nestValue = allValue();
allowAbonus = getMapping[times][address(msg.sender)];
}
_myJoinNest = baseMapping.checkAmount(address(msg.sender));
if (allowAbonus == true) {
_getEth = 0;
} else {
_getEth = _myJoinNest.mul(_ethNum).div(_nestValue);
}
_nextTime = getNextTime();
_getAbonusTime = _nextTime.sub(timeLimit).add(getAbonusTimeLimit);
_allowNum = nestContract.allowance(address(msg.sender), address(baseMapping));
_leftNum = nestContract.balanceOf(address(msg.sender));
}
function getNextTime() public view returns (uint256) {
uint256 nowTime = now;
if (nextTime >= nowTime) {
return nextTime;
} else {
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
return nextTime.add(timeLimit.mul(time.add(1)));
}
}
function allValue() public view returns (uint256) {
uint256 all = 10000000000 ether;
uint256 leftNum = all.sub(nestContract.balanceOf(address(mappingContract.checkAddress("miningSave"))));
return leftNum;
}
function changeTimeLimit(uint256 hour) public onlyOwner {
require(hour > 0);
timeLimit = hour.mul(1 hours);
}
function changeGetAbonusTimeLimit(uint256 hour) public onlyOwner {
require(hour > 0);
getAbonusTimeLimit = hour;
}
modifier onlyOwner(){
require(mappingContract.checkOwners(msg.sender) == true);
_;
}
function isContract(address addr) public view returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}File 2 of 5: NESTSave
pragma solidity ^0.5.8;
contract IBNEST {
function totalSupply() public view returns (uint supply);
function balanceOf( address who ) public view returns (uint value);
function allowance( address owner, address spender ) public view returns (uint _allowance);
function transfer( address to, uint256 value) external;
function transferFrom( address from, address to, uint value) public returns (bool ok);
function approve( address spender, uint value ) public returns (bool ok);
event Transfer( address indexed from, address indexed to, uint value);
event Approval( address indexed owner, address indexed spender, uint value);
function balancesStart() public view returns(uint256);
function balancesGetBool(uint256 num) public view returns(bool);
function balancesGetNext(uint256 num) public view returns(uint256);
function balancesGetValue(uint256 num) public view returns(address, uint256);
}
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b > 0); // Solidity automatically throws when dividing by 0
uint256 c = _a / _b;
assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
}
contract IBMapping {
function checkAddress(string memory name) public view returns (address contractAddress);
function checkOwners(address man) public view returns (bool);
}
library address_make_payable {
function make_payable(address x) internal pure returns (address payable) {
return address(uint160(x));
}
}
/**
* @title Nest storage contract
*/
contract NESTSave {
using SafeMath for uint256;
mapping (address => uint256) baseMapping; // General ledger
IBNEST nestContract; // Nest contract
IBMapping mappingContract; // Mapping contract
/**
* @dev Initialization method
* @param map Mapping contract address
*/
constructor(address map) public {
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
}
/**
* @dev Change mapping contract
* @param map Mapping contract address
*/
function changeMapping(address map) public onlyOwner{
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
}
/**
* @dev Take out nest
* @param num Quantity taken out
*/
function takeOut(uint256 num) public onlyContract {
require(isContract(address(tx.origin)) == false);
require(num <= baseMapping[tx.origin]);
baseMapping[address(tx.origin)] = baseMapping[address(tx.origin)].sub(num);
nestContract.transfer(address(tx.origin), num);
}
/**
* @dev Deposit in nest
* @param num Deposit quantity
*/
function depositIn(uint256 num) public onlyContract {
require(isContract(address(tx.origin)) == false);
require(nestContract.balanceOf(address(tx.origin)) >= num);
require(nestContract.allowance(address(tx.origin), address(this)) >= num);
require(nestContract.transferFrom(address(tx.origin),address(this),num));
baseMapping[address(tx.origin)] = baseMapping[address(tx.origin)].add(num);
}
/**
* @dev Take out all
*/
function takeOutPrivate() public {
require(isContract(address(msg.sender)) == false);
require(baseMapping[msg.sender] > 0);
nestContract.transfer(address(msg.sender), baseMapping[msg.sender]);
baseMapping[address(msg.sender)] = 0;
}
function checkAmount(address sender) public view returns(uint256) {
return baseMapping[address(sender)];
}
modifier onlyOwner(){
require(mappingContract.checkOwners(msg.sender) == true);
_;
}
modifier onlyContract(){
require(mappingContract.checkAddress("nestAbonus") == msg.sender);
_;
}
function isContract(address addr) public view returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}
/**
* @title Dividend pool contract
*/
contract Abonus {
using address_make_payable for address;
IBMapping mappingContract; // Mapping contract
/**
* @dev Initialization method
* @param map Mapping contract address
*/
constructor(address map) public {
mappingContract = IBMapping(map);
}
/**
* @dev Change mapping contract
* @param map Mapping contract address
*/
function changeMapping(address map) public onlyOwner{
mappingContract = IBMapping(map);
}
/**
* @dev Draw ETH
* @param num Draw amount
* @param target Transfer target
*/
function getETH(uint256 num, address target) public onlyContract {
require(num <= getETHNum());
address payable addr = target.make_payable();
addr.transfer(num);
}
function getETHNum() public view returns (uint256) {
return address(this).balance;
}
modifier onlyContract(){
require(mappingContract.checkAddress("nestAbonus") == msg.sender);
_;
}
modifier onlyOwner(){
require(mappingContract.checkOwners(msg.sender) == true);
_;
}
function () external payable {
}
}
/**
* @title Leveling contract
*/
contract NESTLeveling {
using address_make_payable for address;
IBMapping mappingContract; // Mapping contract
/**
* @dev Initialization method
* @param map Mapping contract address
*/
constructor (address map) public {
mappingContract = IBMapping(map);
}
/**
* @dev Change mapping contract
* @param map Mapping contract address
*/
function changeMapping(address map) public onlyOwner {
mappingContract = IBMapping(map);
}
/**
* @dev Transfer ETH
* @param amount Transfer quantity
* @param target Transfer target
*/
function tranEth(uint256 amount, address target) public {
require(address(msg.sender) == address(mappingContract.checkAddress("nestAbonus")));
uint256 tranAmount = amount;
if (amount > address(this).balance) {
tranAmount = address(this).balance;
}
address payable addr = target.make_payable();
addr.transfer(tranAmount);
}
function () external payable {
}
modifier onlyOwner(){
require(mappingContract.checkOwners(msg.sender) == true);
_;
}
}
/**
* @title Dividend logical contract
*/
contract NESTAbonus {
using address_make_payable for address;
using SafeMath for uint256;
IBNEST nestContract;
IBMapping mappingContract;
NESTSave baseMapping;
Abonus abonusContract;
NESTLeveling nestLeveling;
uint256 timeLimit = 168 hours; // Dividend period
uint256 nextTime = 1587700800; // Next dividend time
uint256 getAbonusTimeLimit = 60 hours; // Trigger calculation settlement time
uint256 ethNum = 0; // ETH amount
uint256 nestAllValue = 0; // Nest circulation
uint256 times = 0; // Dividend book
uint256 expectedIncrement = 3; // Expected dividend increment proportion
uint256 expectedMinimum = 100 ether; // Expected minimum dividend
uint256 levelingProportion = 10; // Proportion of dividends deducted
mapping(uint256 => mapping(address => bool)) getMapping; // Dividend collection record
/**
* @dev Initialization method
* @param map Mapping contract address
*/
constructor (address map) public {
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
baseMapping = NESTSave(address(mappingContract.checkAddress("nestSave")));
address payable addr = address(mappingContract.checkAddress("abonus")).make_payable();
abonusContract = Abonus(addr);
address payable levelingAddr = address(mappingContract.checkAddress("nestLeveling")).make_payable();
nestLeveling = NESTLeveling(levelingAddr);
}
/**
* @dev Change mapping contract
* @param map Mapping contract address
*/
function changeMapping(address map) public onlyOwner {
mappingContract = IBMapping(map);
nestContract = IBNEST(address(mappingContract.checkAddress("nest")));
baseMapping = NESTSave(address(mappingContract.checkAddress("nestSave")));
address payable addr = address(mappingContract.checkAddress("abonus")).make_payable();
abonusContract = Abonus(addr);
address payable levelingAddr = address(mappingContract.checkAddress("nestLeveling")).make_payable();
nestLeveling = NESTLeveling(levelingAddr);
}
/**
* @dev Deposit in nest
* @param amount Deposit quantity
*/
function depositIn(uint256 amount) public {
require(address(tx.origin) == address(msg.sender));
uint256 nowTime = now;
if (nowTime < nextTime) {
require(!(nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit)));
} else {
require(!(nowTime >= nextTime && nowTime <= nextTime.add(getAbonusTimeLimit)));
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
uint256 startTime = nextTime.add((time).mul(timeLimit));
uint256 endTime = startTime.add(getAbonusTimeLimit);
require(!(nowTime >= startTime && nowTime <= endTime));
}
baseMapping.depositIn(amount);
}
/**
* @dev Take out nest
* @param amount Quantity taken out
*/
function takeOut(uint256 amount) public {
require(address(tx.origin) == address(msg.sender));
require(amount != 0);
require(amount <= baseMapping.checkAmount(address(msg.sender)));
baseMapping.takeOut(amount);
}
/**
* @dev Receive dividend
*/
function getETH() public {
require(address(tx.origin) == address(msg.sender));
reloadTimeAndMapping ();
uint256 nowTime = now;
require(nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit));
require(getMapping[times.sub(1)][address(msg.sender)] != true);
uint256 nestAmount = baseMapping.checkAmount(address(msg.sender));
require(nestAmount > 0);
require(nestAllValue > 0);
uint256 selfEth = nestAmount.mul(ethNum).div(nestAllValue);
require(selfEth > 0);
getMapping[times.sub(1)][address(msg.sender)] = true;
abonusContract.getETH(selfEth, address(msg.sender));
}
function levelingResult() private {
abonusContract.getETH(abonusContract.getETHNum().mul(levelingProportion).div(100), address(nestLeveling));
uint256 miningAmount = allValue().div(100000000 ether);
uint256 minimumAbonus = expectedMinimum;
for (uint256 i = 0; i < miningAmount; i++) {
minimumAbonus = minimumAbonus.add(minimumAbonus.mul(expectedIncrement).div(100));
}
uint256 nowEth = abonusContract.getETHNum();
if (nowEth < minimumAbonus) {
nestLeveling.tranEth(minimumAbonus.sub(nowEth), address(abonusContract));
}
}
function reloadTimeAndMapping() private {
uint256 nowTime = now;
if (nowTime >= nextTime) {
levelingResult();
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
uint256 startTime = nextTime.add((time).mul(timeLimit));
uint256 endTime = startTime.add(getAbonusTimeLimit);
if (nowTime >= startTime && nowTime <= endTime) {
nextTime = getNextTime();
times = times.add(1);
ethNum = abonusContract.getETHNum();
nestAllValue = allValue();
}
}
}
function getInfo() public view returns (uint256 _nextTime, uint256 _getAbonusTime, uint256 _ethNum, uint256 _nestValue, uint256 _myJoinNest, uint256 _getEth, uint256 _allowNum, uint256 _leftNum, bool allowAbonus) {
uint256 nowTime = now;
if (nowTime >= nextTime.sub(timeLimit) && nowTime <= nextTime.sub(timeLimit).add(getAbonusTimeLimit)) {
allowAbonus = getMapping[times.sub(1)][address(msg.sender)];
_ethNum = ethNum;
_nestValue = nestAllValue;
} else {
_ethNum = abonusContract.getETHNum();
_nestValue = allValue();
allowAbonus = getMapping[times][address(msg.sender)];
}
_myJoinNest = baseMapping.checkAmount(address(msg.sender));
if (allowAbonus == true) {
_getEth = 0;
} else {
_getEth = _myJoinNest.mul(_ethNum).div(_nestValue);
}
_nextTime = getNextTime();
_getAbonusTime = _nextTime.sub(timeLimit).add(getAbonusTimeLimit);
_allowNum = nestContract.allowance(address(msg.sender), address(baseMapping));
_leftNum = nestContract.balanceOf(address(msg.sender));
}
function getNextTime() public view returns (uint256) {
uint256 nowTime = now;
if (nextTime > nowTime) {
return nextTime;
} else {
uint256 time = (nowTime.sub(nextTime)).div(timeLimit);
return nextTime.add(timeLimit.mul(time.add(1)));
}
}
function allValue() public view returns (uint256) {
uint256 all = 10000000000 ether;
uint256 leftNum = all.sub(nestContract.balanceOf(address(mappingContract.checkAddress("miningSave"))));
return leftNum;
}
function checkTimeLimit() public view returns(uint256) {
return timeLimit;
}
function checkGetAbonusTimeLimit() public view returns(uint256) {
return getAbonusTimeLimit;
}
function checkMinimumAbonus() public view returns(uint256) {
uint256 miningAmount = allValue().div(100000000 ether);
uint256 minimumAbonus = expectedMinimum;
for (uint256 i = 0; i < miningAmount; i++) {
minimumAbonus = minimumAbonus.add(minimumAbonus.mul(expectedIncrement).div(100));
}
return minimumAbonus;
}
function changeTimeLimit(uint256 hour) public onlyOwner {
require(hour > 0);
timeLimit = hour.mul(1 hours);
}
function changeGetAbonusTimeLimit(uint256 hour) public onlyOwner {
require(hour > 0);
getAbonusTimeLimit = hour;
}
function changeExpectedIncrement(uint256 num) public onlyOwner {
require(num > 0);
expectedIncrement = num;
}
function changeExpectedMinimum(uint256 num) public onlyOwner {
require(num > 0);
expectedMinimum = num;
}
function changeLevelingProportion(uint256 num) public onlyOwner {
require(num > 0);
levelingProportion = num;
}
modifier onlyOwner(){
require(mappingContract.checkOwners(msg.sender) == true);
_;
}
}File 3 of 5: IBNEST
pragma solidity ^0.5.1;
library IterableMapping {
struct itmap
{
mapping(address => IndexValue) data;
KeyFlag[] keys;
uint size;
}
struct IndexValue { uint keyIndex; uint value; }
struct KeyFlag { address key; bool deleted; }
function insert(itmap storage self, address key, uint value) public returns (bool replaced)
{
uint keyIndex = self.data[key].keyIndex;
self.data[key].value = value;
if (keyIndex > 0)
return true;
else
{
keyIndex = self.keys.length++;
self.data[key].keyIndex = keyIndex + 1;
self.keys[keyIndex].key = key;
self.size++;
return false;
}
}
function remove(itmap storage self, address key) public returns (bool success)
{
uint keyIndex = self.data[key].keyIndex;
if (keyIndex == 0)
return false;
delete self.data[key];
self.keys[keyIndex - 1].deleted = true;
self.size --;
}
function contains(itmap storage self, address key) public view returns (bool)
{
return self.data[key].keyIndex > 0;
}
function iterate_start(itmap storage self) public view returns (uint keyIndex)
{
return iterate_next(self, uint(-1));
}
function iterate_valid(itmap storage self, uint keyIndex) public view returns (bool)
{
return keyIndex < self.keys.length;
}
function iterate_next(itmap storage self, uint keyIndex) public view returns (uint r_keyIndex)
{
keyIndex++;
while (keyIndex < self.keys.length && self.keys[keyIndex].deleted)
keyIndex++;
return keyIndex;
}
function iterate_get(itmap storage self, uint keyIndex) public view returns (address key, uint value)
{
key = self.keys[keyIndex].key;
value = self.data[key].value;
}
function iterate_getValue(itmap storage self, address key) public view returns (uint value) {
return self.data[key].value;
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b > 0); // Solidity automatically throws when dividing by 0
uint256 c = _a / _b;
assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* See https://github.com/ethereum/EIPs/issues/179
*/
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);
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
IterableMapping.itmap balances;
uint256 internal totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= IterableMapping.iterate_getValue(balances, msg.sender));
require(_to != address(0));
IterableMapping.insert(balances, msg.sender, IterableMapping.iterate_getValue(balances, msg.sender).sub(_value));
IterableMapping.insert(balances, _to, IterableMapping.iterate_getValue(balances, _to).add(_value));
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return IterableMapping.iterate_getValue(balances, _owner);
}
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
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
);
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= IterableMapping.iterate_getValue(balances, _from));
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
IterableMapping.insert(balances, _from, IterableMapping.iterate_getValue(balances, _from).sub(_value));
IterableMapping.insert(balances, _to, IterableMapping.iterate_getValue(balances, _to).add(_value));
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _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;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 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 IBNEST is StandardToken {
string public name = "NEST";
string public symbol = "NEST";
uint8 public decimals = 18;
uint256 public INITIAL_SUPPLY = 10000000000 ether;
constructor () public {
totalSupply_ = INITIAL_SUPPLY;
IterableMapping.insert(balances, tx.origin, INITIAL_SUPPLY);
}
function balancesStart() public view returns(uint256) {
return IterableMapping.iterate_start(balances);
}
function balancesGetBool(uint256 num) public view returns(bool){
return IterableMapping.iterate_valid(balances, num);
}
function balancesGetNext(uint256 num) public view returns(uint256) {
return IterableMapping.iterate_next(balances, num);
}
function balancesGetValue(uint256 num) public view returns(address, uint256) {
address key;
uint256 value;
(key, value) = IterableMapping.iterate_get(balances, num);
return (key, value);
}
}File 4 of 5: IBMapping
pragma solidity ^0.5.1;
/**
* @title Mapping contract
* @dev Add and delete business contract
*/
contract IBMapping {
mapping(string => address) private ContractAddress; // Business contract address
mapping (address => bool) owners; // Superman address
/**
* @dev Initialization method
*/
constructor () public {
owners[msg.sender] = true;
}
/**
* @dev Inquiry address
* @param name String ID
* @return contractAddress Contract address
*/
function checkAddress(string memory name) public view returns (address contractAddress) {
return ContractAddress[name];
}
/**
* @dev Add address
* @param name String ID
* @param contractAddress Contract address
*/
function addContractAddress(string memory name, address contractAddress) public {
require(checkOwners(msg.sender) == true);
ContractAddress[name] = contractAddress;
}
/**
* @dev Add superman
* @param superMan Superman address
*/
function addSuperMan(address superMan) public {
require(checkOwners(msg.sender) == true);
owners[superMan] = true;
}
/**
* @dev Delete superman
* @param superMan Superman address
*/
function deleteSuperMan(address superMan) public {
require(checkOwners(msg.sender) == true);
owners[superMan] = false;
}
/**
* @dev Check superman
* @param man Superman address
* @return Permission or not
*/
function checkOwners(address man) public view returns (bool){
return owners[man];
}
}File 5 of 5: IterableMapping
library IterableMapping {
struct itmap
{
mapping(address => IndexValue) data;
KeyFlag[] keys;
uint size;
}
struct IndexValue { uint keyIndex; uint value; }
struct KeyFlag { address key; bool deleted; }
function insert(itmap storage self, address key, uint value) public returns (bool replaced)
{
uint keyIndex = self.data[key].keyIndex;
self.data[key].value = value;
if (keyIndex > 0)
return true;
else
{
keyIndex = self.keys.length++;
self.data[key].keyIndex = keyIndex + 1;
self.keys[keyIndex].key = key;
self.size++;
return false;
}
}
function remove(itmap storage self, address key) public returns (bool success)
{
uint keyIndex = self.data[key].keyIndex;
if (keyIndex == 0)
return false;
delete self.data[key];
self.keys[keyIndex - 1].deleted = true;
self.size --;
}
function contains(itmap storage self, address key) public view returns (bool)
{
return self.data[key].keyIndex > 0;
}
function iterate_start(itmap storage self) public view returns (uint keyIndex)
{
return iterate_next(self, uint(-1));
}
function iterate_valid(itmap storage self, uint keyIndex) public view returns (bool)
{
return keyIndex < self.keys.length;
}
function iterate_next(itmap storage self, uint keyIndex) public view returns (uint r_keyIndex)
{
keyIndex++;
while (keyIndex < self.keys.length && self.keys[keyIndex].deleted)
keyIndex++;
return keyIndex;
}
function iterate_get(itmap storage self, uint keyIndex) public view returns (address key, uint value)
{
key = self.keys[keyIndex].key;
value = self.data[key].value;
}
function iterate_getValue(itmap storage self, address key) public view returns (uint value) {
return self.data[key].value;
}
}