Sponsored Link:   SHIFT.cash - smart-contract based car title lending platform, 30 billion market, 35+ employees. Join NOW.
Contract Overview | HelloGoldToken
ETH Balance: 0 Ether
ETH USD Value: $0
No Of Transactions: 8375 txns
Token Tracker 0xba2184520a1cc49a6159c57e61e1844e085615b6
  Latest 25 txns from a total Of 8375 transactions View All

TxHash Age From To Value [TxFee]
0xa6311c151e65f7671ec96c6f083708246016f54aaf4d041080e9e1fc39e401284 mins agoCoss.io  IN   HelloGoldToken0 Ether0.00624618
0x15849be22feb42afec6410d78bf084908f5887949c23898b23ce2c9397084f2a4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.00402423
0x1e4941ccedfd7e2aee64362d0cfbddcbc2b66a9c7fa75eac9cd282d5570b2a7f1 hr 9 mins ago0x4491d85f9bc521d6a9c8e0ac9737783881dd4c8b  IN   HelloGoldToken0 Ether0.000096072
0x5fc503fdb62fac8f9daa7a51ef26a648a1ced261698de2adfcff2e1576cd3c021 hr 9 mins ago0x4491d85f9bc521d6a9c8e0ac9737783881dd4c8b  IN   HelloGoldToken0 Ether0.000184644
0x131254531329fe4e97f4a88da29d2e56f6d9405b59fb0d4965c3f14af2c56c3a1 hr 10 mins ago0x4491d85f9bc521d6a9c8e0ac9737783881dd4c8b  IN   HelloGoldToken0 Ether0.000184644
0xea02333d724c6934cc5ac3952a1a6541817e0e394e1ea0771417f1019729ece43 hrs 47 mins ago0xc93e131c415b6bfe8f05d61fc012859aa51e8752  IN   HelloGoldToken0 Ether0.00023128
0x855d9843ddd548890ec025db7a1bdbf60741ccd011bceee28974768d223aed1b3 hrs 56 mins ago0xc93e131c415b6bfe8f05d61fc012859aa51e8752  IN   HelloGoldToken0 Ether0.00201705
0xc1503cb3a329d62742a3fc9be993c28a4977143ca6cbff28be74f849a9a65cfe4 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.0038301
0xe6927d3dd51348bb123b6d2330bd46f0088cbfbb57f1e4973ca618e865911fb05 hrs 6 mins ago0xc7881f90792feeb9398fbb47a220ac72f94b9741  IN   HelloGoldToken0 Ether0.00062481
0xa4378f4cb7f22d4afb742a6b0da9f36fa26d97f97f2208e7a6b10ec6dcfdb1155 hrs 19 mins ago0xe3611676d9ba6ae68e8e838044d62ee29a85ecd7  IN   HelloGoldToken0 Ether0.000184644
0x617e109c3cc7378ac8e7e4609caea3af1435b0f9dd2d3bd7e51f96b955c6ed1a5 hrs 24 mins ago0x03acd18bcf0bdbbe7a23a72c0f88b61a622ebe44  IN   HelloGoldToken0 Ether0.000729984
0xe60c00e91a7da4545382b1bbcfec38153432e4b8b5d17f142af06692c0d4d2995 hrs 25 mins ago0xdedada0478bb459b447eeca7f846b2fcee1e9c71  IN   HelloGoldToken0 Ether0.00303933
0x14cb9c3d44a642389cb0ce5d99058fe1f3c042f29fcbed558649b6514c4031095 hrs 30 mins ago0xdedada0478bb459b447eeca7f846b2fcee1e9c71  IN   HelloGoldToken0 Ether0.009494657
0x1f4d50d338ec6c45fe4614e5d0b75f06d98418b9d80abcd754e39d312ee4908c6 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.00624618
0x3a4104229ed87b04c473afd6cc7da4c3c19389293b64cb1fce2ba1edd3c1e1867 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.00386424
0xea97829bdadc1f0fdec00979bae1e88279c83e868e35583fce2ce11c853e98bd7 hrs 14 mins ago0xc7881f90792feeb9398fbb47a220ac72f94b9741  IN   HelloGoldToken0 Ether0.000415449
0x1cf14bbb1cea5c41337b44986e7ef18aa5276be18e13bc8725a813344ac4cb008 hrs 2 mins ago0x61afa575fcb7964b0efcc2533b83b24790b766cd  IN   HelloGoldToken0 Ether0.00150536
0x9528793da603c6cf27c8c1471d88d23dedc18b91dd58c3b3877d27ed97cbbf228 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.0062481
0xdbdb057dd7cc7dd8fb9e01a10f3829225e5034ae658e95db8542e2bdb6acabc98 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.0031239
0x545c8dac2e89e93c930f9803440b5254caa991b45e8796e652967e152a9331849 hrs 3 mins ago0xac3cc401bd598a8f1ab0aaeb9867aa2fb2779ded  IN   HelloGoldToken0 Ether0.000150874
0xee8dc04bf4f8f4884247dc55a00cbfafe67849dd4f1c104171664065fb4199c59 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.0031239
0xb7c223d0073aca08fddf9e4033a45c7c4c55a253d1356b386b20376dd78703d89 hrs 13 mins ago0xc2ff0b1a7f8a2013153c5d097706e056dd135295  IN   HelloGoldToken0 Ether0.000236418
0xc3c8ef2ff1a46a17965e623c895e25d211997445a55537e40ad98140776ab19212 hrs 4 mins agoCoss.io  IN   HelloGoldToken0 Ether0.00624618
0xe9db2dd4f3a3818805d0f6be1fdb6d72798008b2936877c1453706bef30dd88f12 hrs 56 mins ago0x786f59828a02466a641410563e71d1280490ca34  IN   HelloGoldToken0 Ether0.009435289
0x51d289abd70b802599360ea341da695ccc1877f968697847e05e2f4068ca48d313 hrs 10 mins ago0x8c91782cfde01e5fb7147de365598baa55423265  IN   HelloGoldToken0 Ether0.00354435
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
View All
ParentTxHash Block Age From To Value
Warning: The compiled contract might be susceptible to ZeroFunctionSelector (very low-severity) Solidity compiler bugs.

Contract Source Code Verified
Contract Name: HelloGoldToken
Compiler Version: v0.4.15+commit.bbb8e64f
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts
pragma solidity ^0.4.11;


contract DoNotDeployThisGetTheRightOneCosParityPutsThisOnTop {
    uint256 nothing;

    function DoNotDeployThisGetTheRightOneCosParityPutsThisOnTop() {
        nothing = 27;
    }
}


//*************** Ownable

contract Ownable {
  address public owner;

  function Ownable() {
    owner = msg.sender;
  }

  modifier onlyOwner() {
    require(msg.sender == owner);
    
    _;
  }

  function transferOwnership(address newOwner) onlyOwner {
    if (newOwner != address(0)) {
      owner = newOwner;
    }
  }

}

//***********Pausible

contract Pausable is Ownable {
  event Pause();
  event Unpause();

  bool public paused = false;

  /**
   * @dev modifier to allow actions only when the contract IS paused
   */
  modifier whenNotPaused() {
    require (!paused);
    _;
  }

  /**
   * @dev modifier to allow actions only when the contract IS NOT paused
   */
  modifier whenPaused {
    require (paused) ;
    _;
  }

  /**
   * @dev called by the owner to pause, triggers stopped state
   */
  function pause() onlyOwner whenNotPaused returns (bool) {
    paused = true;
    Pause();
    return true;
  }

  /**
   * @dev called by the owner to unpause, returns to normal state
   */
  function unpause() onlyOwner whenPaused returns (bool) {
    paused = false;
    Unpause();
    return true;
  }
}

//*************ERC20

contract ERC20 {
  uint public totalSupply;
  function balanceOf(address who) constant returns (uint);
  function allowance(address owner, address spender) constant returns (uint);

  function transfer(address to, uint value) returns (bool ok);
  function transferFrom(address from, address to, uint value) returns (bool ok);
  function approve(address spender, uint value) returns (bool ok);
  event Transfer(address indexed from, address indexed to, uint value);
  event Approval(address indexed owner, address indexed spender, uint value);
}

//*************** SafeMath

contract SafeMath {
  function safeMul(uint a, uint b) internal returns (uint) {
    uint c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

  function safeDiv(uint a, uint b) internal returns (uint) {
    assert(b > 0);
    uint c = a / b;
    assert(a == b * c + a % b);
    return c;
  }

  function safeSub(uint a, uint b) internal returns (uint) {
    assert(b <= a);
    return a - b;
  }

  function safeAdd(uint a, uint b) internal returns (uint) {
    uint c = a + b;
    assert(c>=a && c>=b);
    return c;
  }

  function max64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a >= b ? a : b;
  }

  function min64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a < b ? a : b;
  }

  function max256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a >= b ? a : b;
  }

  function min256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a < b ? a : b;
  }

}

//**************** StandardToken

contract StandardToken is ERC20, SafeMath {

  /**
   * @dev Fix for the ERC20 short address attack.
   */
  modifier onlyPayloadSize(uint size) {
     require(msg.data.length >= size + 4);
     _;
  }

  mapping(address => uint) balances;
  mapping (address => mapping (address => uint)) allowed;

  function transfer(address _to, uint _value) onlyPayloadSize(2 * 32)  returns (bool success){
    balances[msg.sender] = safeSub(balances[msg.sender], _value);
    balances[_to] = safeAdd(balances[_to], _value);
    Transfer(msg.sender, _to, _value);
    return true;
  }

  function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) returns (bool success) {
    var _allowance = allowed[_from][msg.sender];

    // Check is not needed because safeSub(_allowance, _value) will already throw if this condition is not met
    // if (_value > _allowance) throw;

    balances[_to] = safeAdd(balances[_to], _value);
    balances[_from] = safeSub(balances[_from], _value);
    allowed[_from][msg.sender] = safeSub(_allowance, _value);
    Transfer(_from, _to, _value);
    return true;
  }

  function balanceOf(address _owner) constant returns (uint balance) {
    return balances[_owner];
  }

  function approve(address _spender, uint _value) returns (bool success) {
    require((_value == 0) || (allowed[msg.sender][_spender] == 0));
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
  }

  function allowance(address _owner, address _spender) constant returns (uint remaining) {
    return allowed[_owner][_spender];
  }

}

contract GBT {
  function parentChange(address,uint);
  function parentFees(address);
  function setHGT(address _hgt);
}

//************ HELLOGOLDTOKEN

contract HelloGoldToken is ERC20, SafeMath, Pausable, StandardToken {

  string public name;
  string public symbol;
  uint8  public decimals;

  GBT  goldtoken;
  

  function setGBT(address gbt_) onlyOwner {
    goldtoken = GBT(gbt_);
  }

  function GBTAddress() constant returns (address) {
    return address(goldtoken);
  }

  function HelloGoldToken(address _reserve) {
    name = "HelloGold Token";
    symbol = "HGT";
    decimals = 8;
 
    totalSupply = 1 * 10 ** 9 * 10 ** uint256(decimals);
    balances[_reserve] = totalSupply;
  }


  function parentChange(address _to) internal {
    require(address(goldtoken) != 0x0);
    goldtoken.parentChange(_to,balances[_to]);
  }
  function parentFees(address _to) internal {
    require(address(goldtoken) != 0x0);
    goldtoken.parentFees(_to);
  }

  function transferFrom(address _from, address _to, uint256 _value) returns (bool success){
    parentFees(_from);
    parentFees(_to);
    success = super.transferFrom(_from,_to,_value);
    parentChange(_from);
    parentChange(_to);
    return;
  }

  function transfer(address _to, uint _value) whenNotPaused returns (bool success)  {
    parentFees(msg.sender);
    parentFees(_to);
    success = super.transfer(_to,_value);
    parentChange(msg.sender);
    parentChange(_to);
    return;
  }

  function approve(address _spender, uint _value) whenNotPaused returns (bool success)  {
    return super.approve(_spender,_value);
  }
}

//********* GOLDFEES ************************

contract GoldFees is SafeMath,Ownable {
    // e.g. if rate = 0.0054
    //uint rateN = 9999452055;
    uint rateN = 9999452054794520548;
    uint rateD = 19;
    uint public maxDays;
    uint public maxRate;

    
    function GoldFees() {
        calcMax();
    }

    function calcMax() {
        maxDays = 1;
        maxRate = rateN;
        
        
        uint pow = 2;
        do {
            uint newN = rateN ** pow;
            if (newN / maxRate != maxRate) {
                maxDays = pow / 2;
                break;
            }
            maxRate = newN;
            pow *= 2;
        } while (pow < 2000);
        
    }

    function updateRate(uint256 _n, uint256 _d) onlyOwner{
        rateN = _n;
        rateD = _d;
        calcMax();
    }
    
    function rateForDays(uint256 numDays) constant returns (uint256 rate) {
        if (numDays <= maxDays) {
            uint r = rateN ** numDays;
            uint d = rateD * numDays;
            if (d > 18) {
                uint div =  10 ** (d-18);
                rate = r / div;
            } else {
                div = 10 ** (18 - d);
                rate = r * div;
            }
        } else {
            uint256 md1 = numDays / 2;
            uint256 md2 = numDays - md1;
             uint256 r2;

            uint256 r1 = rateForDays(md1);
            if (md1 == md2) {
                r2 = r1;
            } else {
                r2 = rateForDays(md2);
            }
           

            //uint256 r1 = rateForDays(maxDays);
            //uint256 r2 = rateForDays(numDays-maxDays);
            rate  = safeMul( r1 , r2)  / 10 ** 18;
        }
        return; 
        
    }

    uint256 constant public UTC2MYT = 1483200000;

    function wotDay(uint256 time) returns (uint256) {
        return (time - UTC2MYT) / (1 days);
    }

    // minimum fee is 1 unless same day
    function calcFees(uint256 start, uint256 end, uint256 startAmount) constant returns (uint256 amount, uint256 fee) {
        if (startAmount == 0) return;
        uint256 numberOfDays = wotDay(end) - wotDay(start);
        if (numberOfDays == 0) {
            amount = startAmount;
            return;
        }
        amount = (rateForDays(numberOfDays) * startAmount) / (1 ether);
        if ((fee == 0) && (amount !=  0)) amount--;
        fee = safeSub(startAmount,amount);
    }
}

//******************** GoldBackedToken

contract GoldBackedToken is Ownable, SafeMath, ERC20, Pausable {

  event Transfer(address indexed from, address indexed to, uint value);
  event Approval(address indexed owner, address indexed spender, uint value);
  event DeductFees(address indexed owner,uint256 amount);

  event TokenMinted(address destination, uint256 amount);
  event TokenBurned(address source, uint256 amount);
  
	string public name = "HelloGold Gold Backed Token";
	string public symbol = "GBT";
	uint256 constant public  decimals = 18;  // same as ETH
	uint256 constant public  hgtDecimals = 8;
		
	uint256 constant public allocationPool = 1 *  10**9 * 10**hgtDecimals;      // total HGT holdings
	uint256	constant public	maxAllocation  = 38 * 10**5 * 10**decimals;			// max GBT that can ever ever be given out
	uint256	         public	totAllocation;			// amount of GBT so far
	
	address			 public feeCalculator;
	address		     public HGT;					// HGT contract address



	function setFeeCalculator(address newFC) onlyOwner {
		feeCalculator = newFC;
	}


	function calcFees(uint256 from, uint256 to, uint256 amount) returns (uint256 val, uint256 fee) {
		return GoldFees(feeCalculator).calcFees(from,to,amount);
	}

	function GoldBackedToken(address feeCalc) {
		feeCalculator = feeCalc;
	}

    struct allocation { 
        uint256     amount;
        uint256     date;
    }
	
	allocation[]   public allocationsOverTime;
	allocation[]   public currentAllocations;

	function currentAllocationLength() constant returns (uint256) {
		return currentAllocations.length;
	}

	function aotLength() constant returns (uint256) {
		return allocationsOverTime.length;
	}

	
    struct Balance {
        uint256 amount;                 // amount through update or transfer
        uint256 lastUpdated;            // DATE last updated
        uint256 nextAllocationIndex;    // which allocationsOverTime record contains next update
        uint256 allocationShare;        // the share of allocationPool that this holder gets (means they hold HGT)
    }

	/*Creates an array with all balances*/
	mapping (address => Balance) public balances;
	mapping (address => mapping (address => uint)) allowed;
	
	function update(address where) internal {
        uint256 pos;
		uint256 fees;
		uint256 val;
        (val,fees,pos) = updatedBalance(where);
	    balances[where].nextAllocationIndex = pos;
	    balances[where].amount = val;
        balances[where].lastUpdated = now;
	}
	
	function updatedBalance(address where) constant public returns (uint val, uint fees, uint pos) {
		uint256 c_val;
		uint256 c_fees;
		uint256 c_amount;

		(val, fees) = calcFees(balances[where].lastUpdated,now,balances[where].amount);

	    pos = balances[where].nextAllocationIndex;
		if ((pos < currentAllocations.length) &&  (balances[where].allocationShare != 0)) {

			c_amount = currentAllocations[balances[where].nextAllocationIndex].amount * balances[where].allocationShare / allocationPool;

			(c_val,c_fees)   = calcFees(currentAllocations[balances[where].nextAllocationIndex].date,now,c_amount);

		} 

	    val  += c_val;
		fees += c_fees;
		pos   = currentAllocations.length;
	}

    function balanceOf(address where) constant returns (uint256 val) {
        uint256 fees;
		uint256 pos;
        (val,fees,pos) = updatedBalance(where);
        return ;
    }

	event Allocation(uint256 amount, uint256 date);
	event FeeOnAllocation(uint256 fees, uint256 date);

	event PartComplete();
	event StillToGo(uint numLeft);
	uint256 public partPos;
	uint256 public partFees;
	uint256 partL;
	allocation[]   public partAllocations;

	function partAllocationLength() constant returns (uint) {
		return partAllocations.length;
	}

	function addAllocationPartOne(uint newAllocation,uint numSteps) onlyOwner{
		uint256 thisAllocation = newAllocation;

		require(totAllocation < maxAllocation);		// cannot allocate more than this;

		if (currentAllocations.length > partAllocations.length) {
			partAllocations = currentAllocations;
		}

		if (totAllocation + thisAllocation > maxAllocation) {
			thisAllocation = maxAllocation - totAllocation;
			log0("max alloc reached");
		}
		totAllocation += thisAllocation;

		Allocation(thisAllocation,now);

        allocation memory newDiv;
        newDiv.amount = thisAllocation;
        newDiv.date = now;
		// store into history
	    allocationsOverTime.push(newDiv);
		// add this record to the end of currentAllocations
		partL = partAllocations.push(newDiv);
		// update all other records with calcs from last record
		if (partAllocations.length < 2) { // no fees to consider
			PartComplete();
			currentAllocations = partAllocations;
			FeeOnAllocation(0,now);
			return;
		}
		//
		// The only fees that need to be collected are the fees on location zero.
		// Since they are the last calculated = they come out with the break
		//
		for (partPos = partAllocations.length - 2; partPos >= 0; partPos-- ){
			(partAllocations[partPos].amount,partFees) = calcFees(partAllocations[partPos].date,now,partAllocations[partPos].amount);

			partAllocations[partPos].amount += partAllocations[partL - 1].amount;
			partAllocations[partPos].date    = now;
			if ((partPos == 0) || (partPos == partAllocations.length-numSteps)){
				break; 
			}
		}
		if (partPos != 0) {
			StillToGo(partPos);
			return; // not done yet
		}
		PartComplete();
		FeeOnAllocation(partFees,now);
		currentAllocations = partAllocations;
	}

	function addAllocationPartTwo(uint numSteps) onlyOwner {
		require(numSteps > 0);
		require(partPos > 0);
		for (uint i = 0; i < numSteps; i++ ){
			partPos--;
			(partAllocations[partPos].amount,partFees) = calcFees(partAllocations[partPos].date,now,partAllocations[partPos].amount);

			partAllocations[partPos].amount += partAllocations[partL - 1].amount;
			partAllocations[partPos].date    = now;
			if (partPos == 0) {
				break; 
			}
		}
		if (partPos != 0) {
			StillToGo(partPos);
			return; // not done yet
		}
		PartComplete();
		FeeOnAllocation(partFees,now);
		currentAllocations = partAllocations;
	}


	function setHGT(address _hgt) onlyOwner {
		HGT = _hgt;
	}

	function parentFees(address where) whenNotPaused {
		require(msg.sender == HGT);
	    update(where);		
	}
	
	function parentChange(address where, uint newValue) whenNotPaused { // called when HGT balance changes
		require(msg.sender == HGT);
	    balances[where].allocationShare = newValue;
	}
	
	/* send GBT */
	function transfer(address _to, uint256 _value) whenNotPaused returns (bool ok) {
	    update(msg.sender);              // Do this to ensure sender has enough funds.
		update(_to); 

        balances[msg.sender].amount = safeSub(balances[msg.sender].amount, _value);
        balances[_to].amount = safeAdd(balances[_to].amount, _value);

		Transfer(msg.sender, _to, _value); //Notify anyone listening that this transfer took place
        return true;
	}

	function transferFrom(address _from, address _to, uint _value) whenNotPaused returns (bool success) {
		var _allowance = allowed[_from][msg.sender];

	    update(_from);              // Do this to ensure sender has enough funds.
		update(_to); 

		balances[_to].amount = safeAdd(balances[_to].amount, _value);
		balances[_from].amount = safeSub(balances[_from].amount, _value);
		allowed[_from][msg.sender] = safeSub(_allowance, _value);
		Transfer(_from, _to, _value);
		return true;
	}

  	function approve(address _spender, uint _value) whenNotPaused returns (bool success) {
		require((_value == 0) || (allowed[msg.sender][_spender] == 0));
    	allowed[msg.sender][_spender] = _value;
    	Approval(msg.sender, _spender, _value);
    	return true;
  	}

  	function allowance(address _owner, address _spender) constant returns (uint remaining) {
    	return allowed[_owner][_spender];
  	}

	// Minting Functions 
	address public authorisedMinter;

	function setMinter(address minter) onlyOwner {
		authorisedMinter = minter;
	}
	
	function mintTokens(address destination, uint256 amount) {
		require(msg.sender == authorisedMinter);
		update(destination);
		balances[destination].amount = safeAdd(balances[destination].amount, amount);
		balances[destination].lastUpdated = now;
		balances[destination].nextAllocationIndex = currentAllocations.length;
		TokenMinted(destination,amount);
	}

	function burnTokens(address source, uint256 amount) {
		require(msg.sender == authorisedMinter);
		update(source);
		balances[source].amount = safeSub(balances[source].amount,amount);
		balances[source].lastUpdated = now;
		balances[source].nextAllocationIndex = currentAllocations.length;
		TokenBurned(source,amount);
	}
}

//**************** HelloGoldSale

contract HelloGoldSale is Pausable, SafeMath {

  uint256 public decimals = 8;

  uint256 public startDate = 1503892800;      // Monday, August 28, 2017 12:00:00 PM GMT+08:00
  uint256 public endDate   = 1504497600;      // Monday, September 4, 2017 12:00:00 PM GMT+08:00

  uint256 tranchePeriod = 1 weeks;

  // address of HGT Token. HGT must Approve this contract to disburse 300M tokens
  HelloGoldToken          token;

  uint256 constant MaxCoinsR1      = 180 * 10**6 * 10**8;   // 180M HGT
  uint256 public coinsRemaining    = 180 * 10**6 * 10**8; 
  uint256 coinsPerTier             =  20 * 10**6 * 10**8;   // 20M HGT
  uint256 public coinsLeftInTier   =  20 * 10**6 * 10**8;

  uint256 public minimumCap        =  0;   // 40M HGT

  uint256 numTiers                  = 5;
  uint16  public tierNo;
  uint256 public preallocCoins;   // used for testing against cap (inc placement)
  uint256 public purchasedCoins;  // used for testing against tier pricing
  uint256 public ethRaised;
  uint256 public personalMax        = 10 * 1 ether;     // max ether per person during public sale
  uint256 public contributors;

  address public cs;
  address public multiSig;
  address public HGT_Reserve;
  
  struct csAction  {
      bool        passedKYC;
      bool        blocked;
  }

  /* This creates an array with all balances */
  mapping (address => csAction) public permissions;
  mapping (address => uint256)  public deposits;

  modifier MustBeEnabled(address x) {
      require (!permissions[x].blocked) ;
      require (permissions[x].passedKYC) ;
      
      _;
  }

  function HelloGoldSale(address _cs, address _hgt, address _multiSig, address _reserve) {
    cs          = _cs;
    token       = HelloGoldToken(_hgt);
    multiSig    = _multiSig;
    HGT_Reserve = _reserve;
  }

  // We only expect to use this to set/reset the start of the contract under exceptional circumstances
  function setStart(uint256 when_) onlyOwner {
      startDate = when_;
      endDate = when_ + tranchePeriod;
  }

  modifier MustBeCs() {
      require (msg.sender == cs) ;
      
      _;
  }


  // 1 ether = N HGT tokens 
  uint256[5] public hgtRates = [1248900000000,1196900000000,1144800000000,1092800000000,1040700000000];
                      

    /* Approve the account for operation */
    function approve(address user) MustBeCs {
        permissions[user].passedKYC = true;
    }
    
    function block(address user) MustBeCs {
        permissions[user].blocked = true;
    }

    function unblock(address user) MustBeCs {
         permissions[user].blocked = false;
    }

    function newCs(address newCs) onlyOwner {
        cs = newCs;
    }

    function setPeriod(uint256 period_) onlyOwner {
        require (!funding()) ;
        tranchePeriod = period_;
        endDate = startDate + tranchePeriod;
        if (endDate < now + tranchePeriod) {
            endDate = now + tranchePeriod;
        }
    }

    function when()  constant returns (uint256) {
        return now;
    }

  function funding() constant returns (bool) {     
    if (paused) return false;               // frozen
    if (now < startDate) return false;      // too early
    if (now > endDate) return false;        // too late
    if (coinsRemaining == 0) return false;  // no more coins
    if (tierNo >= numTiers ) return false;  // passed end of top tier. Tiers start at zero
    return true;
  }

  function success() constant returns (bool succeeded) {
    if (coinsRemaining == 0) return true;
    bool complete = (now > endDate) ;
    bool didOK = (coinsRemaining <= (MaxCoinsR1 - minimumCap)); // not even 40M Gone?? Aargh.
    succeeded = (complete && didOK)  ;  // (out of steam but enough sold) 
    return ;
  }

  function failed() constant returns (bool didNotSucceed) {
    bool complete = (now > endDate  );
    bool didBad = (coinsRemaining > (MaxCoinsR1 - minimumCap));
    didNotSucceed = (complete && didBad);
    return;
  }

  
  function () payable MustBeEnabled(msg.sender) whenNotPaused {    
    createTokens(msg.sender,msg.value);
  }

  function linkCoin(address coin) onlyOwner {
    token = HelloGoldToken(coin);
  }

  function coinAddress() constant returns (address) {
      return address(token);
  }

  // hgtRates in whole tokens per ETH
  // max individual contribution in whole ETH
  function setHgtRates(uint256 p0,uint256 p1,uint256 p2,uint256 p3,uint256 p4, uint256 _max ) onlyOwner {
              require (now < startDate) ;
              hgtRates[0]   = p0 * 10**8;
              hgtRates[1]   = p1 * 10**8;
              hgtRates[2]   = p2 * 10**8;
              hgtRates[3]   = p3 * 10**8;
              hgtRates[4]   = p4 * 10**8;
              personalMax = _max * 1 ether;           // max ETH per person
  }

  
  event Purchase(address indexed buyer, uint256 level,uint256 value, uint256 tokens);
  event Reduction(string msg, address indexed buyer, uint256 wanted, uint256 allocated);
  
  function createTokens(address recipient, uint256 value) private {
    uint256 totalTokens;
    uint256 hgtRate;
    require (funding()) ;
    require (value > 1 finney) ;
    require (deposits[recipient] < personalMax);

    uint256 maxRefund = 0;
    if ((deposits[msg.sender] + value) > personalMax) {
        maxRefund = deposits[msg.sender] + value - personalMax;
        value -= maxRefund;
        log0("maximum funds exceeded");
    }  

    uint256 val = value;

    ethRaised = safeAdd(ethRaised,value);
    if (deposits[recipient] == 0) contributors++;
    
    
    do {
      hgtRate = hgtRates[tierNo];                 // hgtRate must include the 10^8
      uint tokens = safeMul(val, hgtRate);      // (val in eth * 10^18) * #tokens per eth
      tokens = safeDiv(tokens, 1 ether);      // val is in ether, msg.value is in wei
   
      if (tokens <= coinsLeftInTier) {
        uint256 actualTokens = tokens;
        uint refund = 0;
        if (tokens > coinsRemaining) { //can't sell desired # tokens
            Reduction("in tier",recipient,tokens,coinsRemaining);
            actualTokens = coinsRemaining;
            refund = safeSub(tokens, coinsRemaining ); // refund amount in tokens
            refund = safeDiv(refund*1 ether,hgtRate );  // refund amount in ETH
            // need a refund mechanism here too
            coinsRemaining = 0;
            val = safeSub( val,refund);
        } else {
            coinsRemaining  = safeSub(coinsRemaining,  actualTokens);
        }
        purchasedCoins  = safeAdd(purchasedCoins, actualTokens);

        totalTokens = safeAdd(totalTokens,actualTokens);

        require (token.transferFrom(HGT_Reserve, recipient,totalTokens)) ;

        Purchase(recipient,tierNo,val,actualTokens); // event

        deposits[recipient] = safeAdd(deposits[recipient],val); // in case of refund - could pull off etherscan
        refund += maxRefund;
        if (refund > 0) {
            ethRaised = safeSub(ethRaised,refund);
            recipient.transfer(refund);
        }
        if (coinsRemaining <= (MaxCoinsR1 - minimumCap)){ // has passed success criteria
            if (!multiSig.send(this.balance)) {                // send funds to HGF
                log0("cannot forward funds to owner");
            }
        }
        coinsLeftInTier = safeSub(coinsLeftInTier,actualTokens);
        if ((coinsLeftInTier == 0) && (coinsRemaining != 0)) { // exact sell out of non final tier
            coinsLeftInTier = coinsPerTier;
            tierNo++;
            endDate = now + tranchePeriod;
        }
        return;
      }
      // check that coinsLeftInTier >= coinsRemaining

      uint256 coins2buy = min256(coinsLeftInTier , coinsRemaining); 

      endDate = safeAdd( now, tranchePeriod);
      // Have bumped levels - need to modify end date here
      purchasedCoins = safeAdd(purchasedCoins, coins2buy);  // give all coins remaining in this tier
      totalTokens    = safeAdd(totalTokens,coins2buy);
      coinsRemaining = safeSub(coinsRemaining,coins2buy);

      uint weiCoinsLeftInThisTier = safeMul(coins2buy,1 ether);
      uint costOfTheseCoins = safeDiv(weiCoinsLeftInThisTier, hgtRate);  // how much did that cost?

      Purchase(recipient, tierNo,costOfTheseCoins,coins2buy); // event

      deposits[recipient] = safeAdd(deposits[recipient],costOfTheseCoins);
      val    = safeSub(val,costOfTheseCoins);
      tierNo = tierNo + 1;
      coinsLeftInTier = coinsPerTier;
    } while ((val > 0) && funding());

    // escaped because we passed the end of the universe.....
    // so give them their tokens
    require (token.transferFrom(HGT_Reserve, recipient,totalTokens)) ;

    if ((val > 0) || (maxRefund > 0)){
        Reduction("finished crowdsale, returning ",recipient,value,totalTokens);
        // return the remainder !
        recipient.transfer(val+maxRefund); // if you can't return the balance, abort whole process
    }
    if (!multiSig.send(this.balance)) {
        ethRaised = safeSub(ethRaised,this.balance);
        log0("cannot send at tier jump");
    }
  }
  
  function allocatedTokens(address grantee, uint256 numTokens) onlyOwner {
    require (now < startDate) ;
    if (numTokens < coinsRemaining) {
        coinsRemaining = safeSub(coinsRemaining, numTokens);
       
    } else {
        numTokens = coinsRemaining;
        coinsRemaining = 0;
    }
    preallocCoins = safeAdd(preallocCoins,numTokens);
    require (token.transferFrom(HGT_Reserve,grantee,numTokens));
  }

  function withdraw() { // it failed. Come and get your ether.
      if (failed()) {
          if (deposits[msg.sender] > 0) {
              uint256 val = deposits[msg.sender];
              deposits[msg.sender] = 0;
              msg.sender.transfer(val);
          }
      }
  }

  function complete() onlyOwner {  // this should not have to be called. Extreme measures.
      if (success()) {
          uint256 val = this.balance;
          if (val > 0) {
            if (!multiSig.send(val)) {
                log0("cannot withdraw");
            } else {
                log0("funds withdrawn");
            }
          } else {
              log0("nothing to withdraw");
          }
      }
  }

}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"GBTAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"gbt_","type":"address"}],"name":"setGBT","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_reserve","type":"address"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]

  Contract Creation Code Switch To Opcodes View
60606040526002805460ff19169055341561001957600080fd5b604051602080610e39833981016040528080519150505b5b60008054600160a060020a03191633600160a060020a03161790555b60408051908101604052600f81527f48656c6c6f476f6c6420546f6b656e00000000000000000000000000000000006020820152600590805161009492916020019061011f565b5060408051908101604052600381527f4847540000000000000000000000000000000000000000000000000000000000602082015260069080516100dc92916020019061011f565b5060078054600860ff19909116179081905560ff16600a0a633b9aca00026001819055600160a060020a0382166000908152600360205260409020555b506101bf565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061016057805160ff191683800117855561018d565b8280016001018555821561018d579182015b8281111561018d578251825591602001919060010190610172565b5b5061019a92915061019e565b5090565b6101bc91905b8082111561019a57600081556001016101a4565b5090565b90565b610c6b806101ce6000396000f300606060405236156100ca5763ffffffff60e060020a60003504166306fdde0381146100cf578063095ea7b31461015a57806318160ddd1461019057806323b872dd146101b5578063313ce567146101f15780633f4ba83a1461021a5780635c975abb146102415780636ad03feb1461026857806370a08231146102975780638456cb59146102c85780638da5cb5b146102ef57806395d89b411461031e578063a3dd3aa7146103a9578063a9059cbb146103ca578063dd62ed3e14610400578063f2fde38b14610437575b600080fd5b34156100da57600080fd5b6100e2610458565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561011f5780820151818401525b602001610106565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016557600080fd5b61017c600160a060020a03600435166024356104f6565b604051901515815260200160405180910390f35b341561019b57600080fd5b6101a361051d565b60405190815260200160405180910390f35b34156101c057600080fd5b61017c600160a060020a0360043581169060243516604435610523565b604051901515815260200160405180910390f35b34156101fc57600080fd5b61020461055e565b60405160ff909116815260200160405180910390f35b341561022557600080fd5b61017c610567565b604051901515815260200160405180910390f35b341561024c57600080fd5b61017c6105d3565b604051901515815260200160405180910390f35b341561027357600080fd5b61027b6105dc565b604051600160a060020a03909116815260200160405180910390f35b34156102a257600080fd5b6101a3600160a060020a03600435166105f1565b60405190815260200160405180910390f35b34156102d357600080fd5b61017c610610565b604051901515815260200160405180910390f35b34156102fa57600080fd5b61027b61067e565b604051600160a060020a03909116815260200160405180910390f35b341561032957600080fd5b6100e261068d565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561011f5780820151818401525b602001610106565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103b457600080fd5b6103c8600160a060020a036004351661072b565b005b34156103d557600080fd5b61017c600160a060020a0360043516602435610778565b604051901515815260200160405180910390f35b341561040b57600080fd5b6101a3600160a060020a03600435811690602435166107c3565b60405190815260200160405180910390f35b341561044257600080fd5b6103c8600160a060020a03600435166107f0565b005b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ee5780601f106104c3576101008083540402835291602001916104ee565b820191906000526020600020905b8154815290600101906020018083116104d157829003601f168201915b505050505081565b60025460009060ff161561050957600080fd5b6105138383610848565b90505b5b92915050565b60015481565b600061052e846108ef565b610537836108ef565b610542848484610978565b905061054d84610a90565b61055683610a90565b5b9392505050565b60075460ff1681565b6000805433600160a060020a0390811691161461058357600080fd5b60025460ff16151561059457600080fd5b6002805460ff191690557f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a15060015b5b5b90565b60025460ff1681565b6007546101009004600160a060020a03165b90565b600160a060020a0381166000908152600360205260409020545b919050565b6000805433600160a060020a0390811691161461062c57600080fd5b60025460ff161561063c57600080fd5b6002805460ff191660011790557f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a15060015b5b5b90565b600054600160a060020a031681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ee5780601f106104c3576101008083540402835291602001916104ee565b820191906000526020600020905b8154815290600101906020018083116104d157829003601f168201915b505050505081565b60005433600160a060020a0390811691161461074657600080fd5b6007805474ffffffffffffffffffffffffffffffffffffffff001916610100600160a060020a038416021790555b5b50565b60025460009060ff161561078b57600080fd5b610794336108ef565b61079d836108ef565b6107a78383610b37565b90506107b233610a90565b61051683610a90565b5b5b92915050565b600160a060020a038083166000908152600460209081526040808320938516835292905220545b92915050565b60005433600160a060020a0390811691161461080b57600080fd5b600160a060020a03811615610774576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b5b50565b600081158061087a5750600160a060020a03338116600090815260046020908152604080832093871683529290522054155b151561088557600080fd5b600160a060020a03338116600081815260046020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6007546101009004600160a060020a0316151561090b57600080fd5b6007546101009004600160a060020a03166336b693678260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561096057600080fd5b6102c65a03f1151561097157600080fd5b5050505b50565b6000806060606436101561098b57600080fd5b600160a060020a0380871660009081526004602090815260408083203385168452825280832054938916835260039091529020549092506109cc9085610c00565b600160a060020a0380871660009081526003602052604080822093909355908816815220546109fb9085610c28565b600160a060020a038716600090815260036020526040902055610a1e8285610c28565b600160a060020a03808816600081815260046020908152604080832033861684529091529081902093909355908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9087905190815260200160405180910390a3600192505b5b50509392505050565b6007546101009004600160a060020a03161515610aac57600080fd5b600754600160a060020a0382811660009081526003602052604090819020546101009093049091169163e5a7b51f918491905160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561096057600080fd5b6102c65a03f1151561097157600080fd5b5050505b50565b600060406044361015610b4957600080fd5b600160a060020a033316600090815260036020526040902054610b6c9084610c28565b600160a060020a033381166000908152600360205260408082209390935590861681522054610b9b9084610c00565b600160a060020a0380861660008181526003602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a3600191505b5b5092915050565b6000828201838110801590610c155750828110155b1515610c1d57fe5b8091505b5092915050565b600082821115610c3457fe5b508082035b929150505600a165627a7a7230582030e9b8ba2700c1618c855aa1f995bd948086b561fd83600668a189da268856fa0029000000000000000000000000c03281af336e2c25b41ff893a0e6ce1a932b23af

    Constructor Arguments (ABI-encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c03281af336e2c25b41ff893a0e6ce1a932b23af

-----Decoded View---------------
Found 1 constructor arguments :
Arg [0] : 000000000000000000000000c03281af336e2c25b41ff893a0e6ce1a932b23af


   Swarm Source:
bzzr://30e9b8ba2700c1618c855aa1f995bd948086b561fd83600668a189da268856fa

 

View All
Block Age txn Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "downvote" button for any spammy posts, and the "upvote" for interesting conversations.