Sponsored:   Ubex.com - World roadshow: Seoul Sep 17-19, Singapore Sep 19-20, Dubai 18-23. Meet us!.
 Latest 25 txns From a total of 21720 Transactions

TxHash Age From To Value [TxFee]
0x9ad44cd6995c642f81f84d1b229325abd394c5cf78a3d0d1e783cb9aba86942e5 hrs 18 mins agoCoss.io  IN   HelloGold0 Ether0.00241714
0xb558801b6dff208dc63013d9525e112dcd044bf58e27711f6bdf12974566f97f6 hrs 4 mins ago0xa72725b050d3aa6959a25672680de116c751a8a2  IN   HelloGold0 Ether0.000681282
0x8ac6ba0158b66d8e9b1ba5a814aa14e42b616912c87091cc33c53e80d417b0e28 hrs 7 mins ago0x783e04aef9a8c19b7776ec63e1ea3f88e0c6bedf  IN   HelloGold0 Ether0.009435289
0xb8cfa6e80fce490769c3525fb7bd638087ed2e1e1d30bd37d38712a0f6e323e615 hrs 32 mins ago0x09d63f5c29d08a41a3466fb18f3e1336288828d9  IN   HelloGold0 Ether0.002592708
0x73aaae40bc6145102412c63001482e1a116f10e7ac21299043238c783b67a41f18 hrs 44 mins ago0xcfc1e1a4fc683dcea7dc63d59c3f96c76eabc866  IN   HelloGold0 Ether0.00067851
0xb583c272648ad05a96bd7989ff53bbb1c73d1849c2974a27316ecabeaa65fb761 day 9 hrs agoCoss.io  IN   HelloGold0 Ether0.00161898
0x08ae624b3d84d91fc27167cd8ecd15f9fee3ff3976f042e4fa68c39b7228a2661 day 12 hrs agoCoss.io  IN   HelloGold0 Ether0.00256602
0x84fbb06f644496f6e374d629b57fcf368c1a79475095fd2c4f5e17f8e8c92e321 day 12 hrs agoHitBTC_2  IN   HelloGold0 Ether0.00118139
0xc87b2f85f8944cff59501e67517c4621e8787c0d5e05c6a4f9f978130d5edcf91 day 15 hrs ago0x91eb6d8ae94e6c8a16acce49f8c2e07d6d690d19  IN   HelloGold0 Ether0.00047953
0x57d74f054212d1c254ddfcc09c0681fcd791f252fc3a66568d7a8f1d3026ce0f1 day 19 hrs ago0x288bed17390be01c8dc8fce505f6f81396adae9c  IN   HelloGold0 Ether0.000576204
0x08098d546694d73651cd079344d82f0f2329f3b3caa744e945c84b6477e89b702 days 11 hrs ago0x113fb53ad7c0de23c45847aed76b0e148119600e  IN   HelloGold0 Ether0.0011232
0xb77384ca2bc1caab23e6aa5d97914c02c95ab7eaf233353a4d9d2e3339f01bdf2 days 15 hrs ago0x089ffdde1f37b0f377b29be06f4dc9f8c75d75d6  IN   HelloGold0 Ether0.00288687
0x377c459029189eb7151c63ad2cbb6fa235216326559540878b720a585c994bb63 days 7 hrs ago0x21ad201f725eefb21bb0abda8002dd8bbe59541b  IN   HelloGold0 Ether0.000323127
0x55107778c7cb49bb7ebd456b264621d6f192b6d687bede447e8f4d3948631eb23 days 8 hrs ago0x9d2921854787966defc46c27527a21d8ebf6d44f  IN   HelloGold0 Ether0.00203333
0x7da166fe49b3a4118dd1cd89f442d352f3a3e4173d51cbdeaedeec32a1ec67963 days 11 hrs agoCoss.io  IN   HelloGold0 Ether0.00418688
0x665c577e2a260d1e2f2ffce58c2e867ff91c03b2d1ee82d5f25256a93eb36a173 days 19 hrs ago0x29a3ca0b01fda815e135952dc36df63768dd06b1  IN   HelloGold0 Ether0.00452688
0x8c16927a2b1ef059ab1ac41aa05a1a9ede6edc4a41d853d67ef440897fa15c9b4 days 3 hrs ago0xde81ddd1dd7ae32c649ae99738d1a95d251a3362  IN   HelloGold0 Ether0.0011118968
0xb12c6ee0954aaebeddc7dffc6ee2fb5fbb667996a8e6e3cd90f9c896a3cc90334 days 4 hrs ago0xde81ddd1dd7ae32c649ae99738d1a95d251a3362  IN   HelloGold0 Ether0.000467454
0x2fe7f70ddef661d14026d78db85fabe26af396377c6d65de17a72b30f2b17d584 days 10 hrs ago0x26554809c4c63ee939a78edb189d5c4508f8d4b1  IN   HelloGold0 Ether0.017832126
0xa2f7be6029f1de114de70a50ccf8663447e315cf0f727550089b078b2b79ba2d4 days 14 hrs ago0x774270df6df960b0582b35dcd44f34c804dd192f  IN   HelloGold0 Ether0.001390319
0xc27e7c46dc2bac49758ae012ba7c1a467ddb44b8b07a35905804217242f17a1b4 days 14 hrs ago0x774270df6df960b0582b35dcd44f34c804dd192f  IN   HelloGold0 Ether0.000416472
0xaaa4b9563f0dd28b35dbd35de9e63129c3a4bebf00cb7b017b5b25dc3ce1f8bc4 days 22 hrs ago0x85061f96c5db7db5ec3db5f6af0b2d553eb4f383  IN   HelloGold0 Ether0.00129912258
0x963c23d2b72dcda24839ce21fee861a7f28257f7abeb8cc83472972f1f73d0d24 days 22 hrs ago0x4a2b6a735d825f16cf0054b013c472d11408cec9  IN   HelloGold0 Ether0.000951864
0x042de6c7d3b927bb56003d863b16119231ed4fe2df0a877fa8af82866ace9a074 days 22 hrs ago0x4a2b6a735d825f16cf0054b013c472d11408cec9  IN   HelloGold0 Ether0.000479364
0x0b55f3d878aec2181d295cd008780d2f3bcb5ca1d190122ceb0a255b374c0ffb4 days 22 hrs ago0x4a2b6a735d825f16cf0054b013c472d11408cec9  IN   HelloGold0 Ether0.000597486
[ 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 ExpExponentCleanup (medium/high-severity), NestedArrayFunctionCallDecoder (medium-severity), ZeroFunctionSelector (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: HelloGoldToken
Compiler Text: 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

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c03281af336e2c25b41ff893a0e6ce1a932b23af


   Swarm Source:
bzzr://30e9b8ba2700c1618c855aa1f995bd948086b561fd83600668a189da268856fa

 

View All
Block Age transaction Difficulty Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.