Sponsored:   INLOCK - Put Your BTC, Get Your Cash! Crypto Backed Loans, 3.2M Raised Already. Join NOW!
Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 1 txn
 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), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: Serpent
Compiler Text: v0.4.24-nightly.2018.5.16+commit.7f965c86
Optimization Enabled: No
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.21;

/**
 * @title Serpentio Contract <http://serpentio.com> - April 2018
 * @Author Alber Erre <[email protected]> <http://albererre.com>
 * Technical details here: https://medium.com/@alber_erre/serpentio-a-snake-on-the-ethereum-blockchain-non-linear-distribution-scheme-b116bfa187d8
 */

/**
 * The Serpent contract distributes its acummulated balance between investors using a non-linear scheme, inside a period of time.
 * As such, every new investor help to fund previous investors, under the promise that future new investors will fund itself.
 * Result: Early investors receive more funds than last investors.
 */

/**
 * Based on Open Zeppelin - https://github.com/OpenZeppelin/zeppelin-solidity
 * 
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */

library SafeMath {
  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    if (a == 0) {
      return 0;
    }
    uint256 c = a * b;
    assert(c / a == b);
    return c;
  }

  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 c;
  }

  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    assert(c >= a);
    return c;
  }
}

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;

  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() public {
    owner = msg.sender;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    emit OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }
}

contract Serpent is Ownable {
	using SafeMath for uint256;

	// everyone should check this measure to find out how much they have earned.
	mapping (address => uint256) public investorReturn;

	uint256 public SerpenSegmentCount;
	uint256 public SerpentCountDown;
	address public SerpentHead;
	address[] investormapping;

	struct investorDetails {
	    address investorAddress;
	    uint256 amountInvested;
	    uint256 SegmentNumber;
	    uint256 time;
	    string  quote;
	}

	investorDetails[] public investorsList;

	function Serpent () {
		// Constructor: init public variables and add creator as SerpentHead
		SerpentHead = owner;
		SerpenSegmentCount = 0;
		SerpentCountDown = uint256(block.timestamp);
	}

	function Play (string _quote) payable public {

		require (msg.value > 0);
        require (msg.sender != address(0)); // just in case
        require (uint256(block.timestamp) < SerpentCountDown); // nobody can play once countdown is finished

        address thisAddress = msg.sender;
		uint256 thisAmmount = msg.value;

        AddReturnsMapping(thisAmmount);
	    // AddReturnsMapping MUST be before AddNewSegment, to avoid counting the new segment while calculating returns

	    SerpenSegmentCount = SerpenSegmentCount.add(1);
		AddNewSegment(thisAddress, thisAmmount, SerpenSegmentCount, uint256(block.timestamp), _quote);
	    // Adding new segment - the same address can send more than once.
        // Although, distribution is based on chronological amounts, not addresses.
	}

	// Callback function
	function () payable public {
		require(msg.value > 0);

		Play("Callback, No quote");
	}

	function NewSerpent (uint256 _SerpentCountDown) public onlyOwner {

		// this is to avoid deleting current serpent game until the previous game has finished
		require (uint256(block.timestamp) > SerpentCountDown);
		
		SerpenSegmentCount = 0;
		SerpentCountDown = _SerpentCountDown;

		//Collect prime-number reminders from previous game calculations
		uint256 nonPrimeReminders = 0;
		for (uint256 p = 0; p < investormapping.length; p++) {
			nonPrimeReminders.add(investorReturn[investormapping[p]]);
		}
		uint256 PrimeReminder = uint256(address(this).balance) - nonPrimeReminders;
		SerpentHead.transfer(PrimeReminder);

		//Delete current investormapping array elements, to init new-serpent investormapping
		while (investormapping.length != 0) {
			delete investormapping[investormapping.length-1]; //delete last element
			investormapping.length--;
		}

		// Start first serpent segment
	    SerpenSegmentCount = SerpenSegmentCount.add(1);
	    investormapping.push(SerpentHead);
	    AddNewSegment(SerpentHead, 1 ether, SerpenSegmentCount, uint256(block.timestamp), "Everything started with Salazar Slytherin");
	}
	
	
	function AddNewSegment (address _address, uint256 _amount, uint256 _segmentNumber, uint256 _time, string _quote) internal {
	    require (_amount > 0); // just in case

		// in case this is a new address, add it to mappings, if not, just do nothing
		uint256 inList = 0;
		for (uint256 n = 0; n < investormapping.length; n++) {
			if (investormapping[n] == _address) {
				inList = 1;
			}
		}
		if (inList == 0) {
			investorReturn[_address] = 0;
			investormapping.push(_address); //add only once per address
		}

		// add to struct list, but after inList check
		investorsList.push(investorDetails(_address, _amount, _segmentNumber, _time, _quote));
	}

	function AddReturnsMapping (uint256 _amount) internal {

		uint256 individualAmount = _amount.div(investormapping.length);

		for (uint256 a = 0; a < investormapping.length; a++) {
			investorReturn[investormapping[a]] = investorReturn[investormapping[a]].add(individualAmount); 
		}
	}
	
	function CollectReturns () external {

		uint256 currentTime = uint256(block.timestamp);
		uint256 amountToCollect = getReturns(msg.sender);
		require (currentTime > SerpentCountDown); // collect if serpent has finished
		require(address(this).balance >= amountToCollect);

		address(msg.sender).transfer(amountToCollect);
		investorReturn[msg.sender] = 0;
	}

	function getBalance () public view returns(uint256) {
		return uint256(address(this).balance);
	}

	function getParticipants () public view returns(uint256) {
		return uint256(investormapping.length);
	}

	function getCountdownDate () public view returns(uint256) {
		return uint256(SerpentCountDown);
	}

	function getReturns (address _address) public view returns(uint256) {
		return uint256(investorReturn[_address]);
	}
	
	function SerpentIsRunning () public view returns(bool) {
		return bool(uint256(block.timestamp) < SerpentCountDown);
	}

  // End of contract
}

    Contract ABI  
[{"constant":false,"inputs":[],"name":"CollectReturns","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SerpenSegmentCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"investorsList","outputs":[{"name":"investorAddress","type":"address"},{"name":"amountInvested","type":"uint256"},{"name":"SegmentNumber","type":"uint256"},{"name":"time","type":"uint256"},{"name":"quote","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SerpentCountDown","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_SerpentCountDown","type":"uint256"}],"name":"NewSerpent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getParticipants","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCountdownDate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_quote","type":"string"}],"name":"Play","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"_address","type":"address"}],"name":"getReturns","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SerpentIsRunning","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SerpentHead","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"investorReturn","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

  Contract Creation Code Switch To Opcodes View
608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600060028190555042600381905550611251806100d16000396000f3006080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806309a7dbb41461012a57806312065fe0146101415780632185072f1461016c5780632ccc87271461019757806334d55cd914610285578063434df07e146102b05780635aa68ac0146102dd57806361186e2314610308578063648f0bde1461033357806364b065f71461038f5780636e8a3d4b146103e657806388f2b12e146104155780638da5cb5b1461046c578063f2fde38b146104c3578063f978372a14610506575b6000341115156100ea57600080fd5b6101286040805190810160405280601281526020017f43616c6c6261636b2c204e6f2071756f7465000000000000000000000000000081525061055d565b005b34801561013657600080fd5b5061013f6105fa565b005b34801561014d57600080fd5b506101566106d1565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b506101816106f0565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101c2600480360381019080803590602001909291905050506106f6565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561024657808201518184015260208101905061022b565b50505050905090810190601f1680156102735780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561029157600080fd5b5061029a6107f3565b6040518082815260200191505060405180910390f35b3480156102bc57600080fd5b506102db600480360381019080803590602001909291905050506107f9565b005b3480156102e957600080fd5b506102f2610b5a565b6040518082815260200191505060405180910390f35b34801561031457600080fd5b5061031d610b67565b6040518082815260200191505060405180910390f35b61038d600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061055d565b005b34801561039b57600080fd5b506103d0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b71565b6040518082815260200191505060405180910390f35b3480156103f257600080fd5b506103fb610bba565b604051808215151515815260200191505060405180910390f35b34801561042157600080fd5b5061042a610bc6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047857600080fd5b50610481610bec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104cf57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c11565b005b34801561051257600080fd5b50610547600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d66565b6040518082815260200191505060405180910390f35b60008060003411151561056f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515156105ab57600080fd5b600354421015156105bb57600080fd5b3391503490506105ca81610d7e565b6105e06001600254610ec690919063ffffffff16565b6002819055506105f582826002544287610ee4565b505050565b60008042915061060933610b71565b90506003548211151561061b57600080fd5b803073ffffffffffffffffffffffffffffffffffffffff16311015151561064157600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610687573d6000803e3d6000fd5b506000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b60025481565b60068181548110151561070557fe5b90600052602060002090600502016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690806001015490806002015490806003015490806004018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e95780601f106107be576101008083540402835291602001916107e9565b820191906000526020600020905b8154815290600101906020018083116107cc57829003601f168201915b5050505050905085565b60035481565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561085957600080fd5b6003544211151561086957600080fd5b60006002819055508360038190555060009250600091505b60058054905082101561092757610919600160006005858154811015156108a457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610ec690919063ffffffff16565b508180600101925050610881565b823073ffffffffffffffffffffffffffffffffffffffff1631039050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156109ab573d6000803e3d6000fd5b505b6000600580549050141515610a1b5760056001600580549050038154811015156109d357fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556005805480919060019003610a159190611154565b506109ad565b610a316001600254610ec690919063ffffffff16565b6002819055506005600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610b54600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a764000060025442606060405190810160405280602981526020017f45766572797468696e67207374617274656420776974682053616c617a61722081526020017f536c7974686572696e0000000000000000000000000000000000000000000000815250610ee4565b50505050565b6000600580549050905090565b6000600354905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006003544210905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c6c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610ca857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60016020528060005260406000206000915090505481565b600080610d996005805490508461113990919063ffffffff16565b9150600090505b600580549050811015610ec157610e388260016000600585815481101515610dc457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ec690919063ffffffff16565b60016000600584815481101515610e4b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508080600101915050610da0565b505050565b6000808284019050838110151515610eda57fe5b8091505092915050565b600080600086111515610ef657600080fd5b60009150600090505b600580549050811015610f8b578673ffffffffffffffffffffffffffffffffffffffff16600582815481101515610f3257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610f7e57600191505b8080600101915050610eff565b6000821415611040576000600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060058790806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b600660a0604051908101604052808973ffffffffffffffffffffffffffffffffffffffff168152602001888152602001878152602001868152602001858152509080600181540180825580915050906001820390600052602060002090600502016000909192909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030155608082015181600401908051906020019061112c929190611180565b5050505050505050505050565b600080828481151561114757fe5b0490508091505092915050565b81548183558181111561117b5781836000526020600020918201910161117a9190611200565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106111c157805160ff19168380011785556111ef565b828001600101855582156111ef579182015b828111156111ee5782518255916020019190600101906111d3565b5b5090506111fc9190611200565b5090565b61122291905b8082111561121e576000816000905550600101611206565b5090565b905600a165627a7a72305820d10b34c697e693e60c97bef39719513f4a6c134e99aa4aecad2a63e27a15171f0029

   Swarm Source:
bzzr://d10b34c697e693e60c97bef39719513f4a6c134e99aa4aecad2a63e27a15171f

 

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.