pragma solidity ^0.4.10;
contract Attractor {
string public name = "Attractor";
string public symbol = "ETHA1";
string public standard = "ERC20 Attract Token v0.0 (1 percent)";
uint256 public totalSupply;
mapping(uint256 => uint256) public totalSupplyDeep;
mapping(uint256 => uint256) public reserveDeep;
address owner;
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
event TransferDeep(
address indexed _from,
address indexed _to,
uint256 _value,
uint256 _deep
);
event ApprovalDeep(
address indexed _owner,
address indexed _spender,
uint256 _value,
uint256 _deep
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => mapping(uint256 => uint256)) public balanceOfDeep;
mapping(address => mapping(address => mapping(uint256 => uint256))) public allowanceDeep;
mapping(address => uint256) supportOf;
constructor (uint256 _initialSupply) public {
balanceOf[msg.sender] = _initialSupply;
totalSupply = _initialSupply;
owner = msg.sender;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
balanceOfDeep[msg.sender][0] = balanceOf[msg.sender];
balanceOfDeep[_to][0] = balanceOf[_to];
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferDeep(address _to, uint256 _value, uint256 _deep) public returns (bool success) {
require(balanceOfDeep[msg.sender][_deep] >= _value);
balanceOfDeep[msg.sender][_deep] -= _value;
balanceOfDeep[_to][_deep] += _value;
if(_deep == 0)
{
balanceOf[msg.sender] = balanceOfDeep[msg.sender][0];
balanceOf[_to] = balanceOfDeep[_to][0];
emit Transfer(msg.sender, _to, _value);
}
emit TransferDeep(msg.sender, _to, _value, _deep);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
allowanceDeep[msg.sender][_spender][0] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function approveDeep(address _spender, uint256 _value, uint256 _deep) public returns (bool success) {
allowanceDeep[msg.sender][_spender][_deep] = _value;
if(_deep == 0)
{
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
emit ApprovalDeep(msg.sender, _spender, _value, _deep);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
balanceOfDeep[_from][0] = balanceOf[_from];
balanceOfDeep[_to][0] = balanceOf[_to];
allowanceDeep[_from][msg.sender][0] = allowance[_from][msg.sender];
emit Transfer(_from, _to, _value);
return true;
}
function transferFromDeep(address _from, address _to, uint256 _value, uint256 _deep) public returns (bool success) {
require(_value <= balanceOfDeep[_from][_deep]);
require(_value <= allowanceDeep[_from][msg.sender][_deep]);
balanceOfDeep[_from][_deep] -= _value;
balanceOfDeep[_to][_deep] += _value;
allowanceDeep[_from][msg.sender][_deep] -= _value;