Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 3 txns
 Latest 3 txns

TxHash Age From To Value [TxFee]
0x4ee56d673c8ba0b65f74c0bf6aed90f83ac1d6bd0b6564c2d6d0673d8cad2eef209 days 6 hrs ago0x985a7cc0c6d90948b50bb89dbb29a695936e6d56  IN   0x1ff8922bbc5a8c72413a9d6daebf5a3ce86fe8270 Ether0.00071866
0xe1eb8c6b83f3a7005e5b1a4cb0eaf4ec6c8b580515818de32542c52f40175b2f267 days 6 hrs ago0x6199c48d37819eecc7c31db8002ed7f4c98486db  IN   0x1ff8922bbc5a8c72413a9d6daebf5a3ce86fe8270.026 Ether0.000124039
0x831a4742981de410b6812f32045b53534ad61927b7ce46b128a0ef417fe88d06269 days 7 hrs ago0x985a7cc0c6d90948b50bb89dbb29a695936e6d56  IN    Contract Creation0 Ether0.004618356
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 1 Internal Transaction

ParentTxHash Block Age From To Value
0x4ee56d673c8ba0b65f74c0bf6aed90f83ac1d6bd0b6564c2d6d0673d8cad2eef5319332209 days 6 hrs ago0x1ff8922bbc5a8c72413a9d6daebf5a3ce86fe8270x6199c48d37819eecc7c31db8002ed7f4c98486db0.026 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity), NestedArrayFunctionCallDecoder (medium-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Similar Match)
Note: Displaying Similar Match Verified Source Code At Contract 0x927a4e90c3728f04cc373cd4c445daafa9e54df7(Excluding Constructor Arguments if_any)
Contract Name: Dextera
Compiler Text: v0.4.19+commit.c4cbbb05
Optimization Enabled: No
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity 0.4.19;

contract Dextera {
	/*
		Statics
	*/

	// Creator account
	address public creator = msg.sender;

	// Sellers account
	address public seller;

	// One ticket price in wei
	uint256 public ticketPrice;

	// Minimum number of tickets for successful completion
	uint256 public minimumTickets;

	// Creator fee percent
	uint256 public creatorFeePercent;

	// Datetime of contract end
	uint256 public saleEndTime;

	/*
		Mutables
	*/

	// Datetime of successful processing
	uint256 public successfulTime;

	// Buyers
	struct Buyer {
		address ethAddress;
		uint256 atTicket;
		uint256 amountPaid;
	}
	mapping(uint256 => Buyer) public buyers;

	// Total buyers counter
	uint256 public totalBuyers = 0;

	// Total tickets counter
	uint256 public totalTickets = 0;

	// Buyer index for funds return
	uint256 public returnLastBuyerIndex = 0;

	// Winner, buyers mapping key (statring from 0)
	uint256 public winnerKey = 0;

	// Winner ticket number (starting from 1)
	uint256 public winnerTicket = 0;

	// Sale states
	enum States { Started, NoEntry, Failed, Succeeded }
	States public saleState = States.Started;

	/*
		Constructor
	*/

	// Saving the contract statics
	function Dextera(address _seller, uint256 _ticketPrice, uint256 _minimumTickets, uint256 _creatorFeePercent, uint256 _saleDays) public {
		// Saving the sellers address
		seller = _seller;

		// Set the 1 ticket price
		ticketPrice = _ticketPrice;

		// Set minimum tickets for a successful sale
		minimumTickets = _minimumTickets;

		// Set the creator fee
		creatorFeePercent = _creatorFeePercent;

		// Set the sale end datetime
 		saleEndTime = now + _saleDays * 1 days;
  }

	/*
		Modifiers
	*/

	// Only creator
	modifier onlyCreator() {
		require(msg.sender == creator);
		_;
	}

	// State checker
	modifier inState(States _state) {
		require(saleState == _state);
		_;
	}

	/*
		Participation
	*/

	// Fallback function (simple funds transfer)
	function() public payable {
		// Buy a ticket, only if the sell is running
		if (saleState == States.Started) {
			// Is the amount enough?
			require(msg.value >= ticketPrice);

			// How many tickets we can buy?
			uint256 _ticketsBought = 1;
			if (msg.value > ticketPrice) {
				_ticketsBought = msg.value / ticketPrice;
			}

			// Do we have enough tickets for this sale?
			require(minimumTickets - totalTickets >= _ticketsBought);

			// Increment the quantity of tickets sold
			totalTickets = totalTickets + _ticketsBought;

			// Save the buyer
			buyers[totalBuyers] = Buyer(msg.sender, totalTickets, msg.value);

			// Save the new buyers counter
			totalBuyers = totalBuyers + 1;

			// We sold all the tickets?
			if (totalTickets >= minimumTickets) {
				finalSuccess();
			}

		// Protection, unblock funds by the winner, only after sell was closed
		} else if (saleState == States.NoEntry) {
			// Only winner
			require(msg.sender == buyers[winnerKey].ethAddress);

			// Check if there is enough balance
			require(this.balance > 0);

			// Amount should be zero
			require(msg.value == 0);

			// Setting the state of the sale
			saleState = States.Succeeded;

			// Send fee percent amount to us
			uint256 _creatorFee = (this.balance * creatorFeePercent / 100);
			creator.send(_creatorFee);

			// Another amount to the seller
			seller.send(this.balance);

		// Not allowed to send call
		} else {
			require(false);
		}
	}

	/*
		Completion
	*/

	// Not enough tickets sold within timeframe, the sale failed
	function saleFinalize() public inState(States.Started) {
		// Is it the time?
		require(now >= saleEndTime);

		// Set new sale state
		saleState = States.Failed;

		// Return all the funds to the buyers
		returnToBuyers();
	}

	// Complete, success
	function finalSuccess() private {
		// Set the datetime of a successful processing
		successfulTime = now;

		// Set new sale state
		saleState = States.NoEntry;

		// Select the winning ticket number
		winnerTicket = getRand(totalTickets) + 1;

		// Get the winner address
		winnerKey = getWinnerKey();
	}

	/*
		Sale protection
	*/

	// Protection, return funds after the timeout if the winner did not unblocked the funds
	function revertFunds() public inState(States.NoEntry) {
		// Is it the time?
		require(now >= successfulTime + 30 * 1 days);

		// Setting the state of the sale
		saleState = States.Failed;

		// Return all the funds to the buyers
		returnToBuyers();
	}

	// Continue to return funds in case the process was interrupted
	function returnToBuyersContinue() public inState(States.Failed) {
		// We didn't finished the refund yet
		require(returnLastBuyerIndex < totalBuyers);

		// Start the return process
		returnToBuyers();
	}

	/*
		System
	*/

	// In case of emergeny, pull the lever
	function pullTheLever() public onlyCreator {
		// Destruct the contract
		selfdestruct(creator);
	}

	// Pseudo random function, from 0 to _max (exclusive)
	function getRand(uint256 _max) private view returns(uint256) {
		return (uint256(keccak256(block.difficulty, block.coinbase, now, block.blockhash(block.number - 1))) % _max);
	}

	// Get winner account
	function getWinnerAccount() public view returns(address) {
		// There should be a winner ticket selected
		require(winnerTicket > 0);

		// Return the winners address
		return buyers[winnerKey].ethAddress;
	}

	// Return all the funds to the buyers
	function returnToBuyers() private {
		// Check if there is enough balance
		if (this.balance > 0) {
			// Sending funds back (with a gas limiter check)
			uint256 _i = returnLastBuyerIndex;

			while (_i < totalBuyers && msg.gas > 200000) {
				buyers[_i].ethAddress.send(buyers[_i].amountPaid);
				_i++;
			}
			returnLastBuyerIndex = _i;
		}
	}

	// Get the winner key for a winner ticket
	function getWinnerKey() private view returns(uint256) {
		// Reset the variables
		uint256 _i = 0;
		uint256 _j = totalBuyers - 1;
		uint256 _n = 0;

		// Let's search who bought this ticket
		do {
			// Buyer found in a lower limiter
			if (buyers[_i].atTicket >= winnerTicket) {
				return _i;

			// Buyer found in a higher limiter
			} else if (buyers[_j].atTicket <= winnerTicket) {
				return _j;

			// Only two elements left, get the biggest
			} else if ((_j - _i + 1) == 2) {
				return _j;
			}

			// Split the mapping into halves
			_n = ((_j - _i) / 2) + _i;

			// The ticket is in the right part
			if (buyers[_n].atTicket <= winnerTicket) {
				_i = _n;

			// The ticket is in the left part
			} else {
				_j = _n;
			}

		} while(true);
	}
}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"creator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"seller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ticketPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pullTheLever","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalBuyers","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minimumTickets","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getWinnerAccount","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"creatorFeePercent","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"saleState","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"saleFinalize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"returnLastBuyerIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"returnToBuyersContinue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winnerTicket","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"revertFunds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winnerKey","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalTickets","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"saleEndTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"buyers","outputs":[{"name":"ethAddress","type":"address"},{"name":"atTicket","type":"uint256"},{"name":"amountPaid","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"successfulTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_seller","type":"address"},{"name":"_ticketPrice","type":"uint256"},{"name":"_minimumTickets","type":"uint256"},{"name":"_creatorFeePercent","type":"uint256"},{"name":"_saleDays","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

  Contract Creation Code Switch To Opcodes View
6060604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600060085560006009556000600a556000600b556000600c556000600d60006101000a81548160ff0219169083600381111561007c57fe5b0217905550341561008c57600080fd5b60405160a080610eed8339810160405280805190602001909190805190602001909190805190602001909190805190602001909190805190602001909190505084600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600281905550826003819055508160048190555062015180810242016005819055505050505050610da9806101446000396000f300606060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806302d05d3f1461045757806308551a53146104ac5780631209b1f614610501578063384b93f21461052a5780633abd01361461053f5780634e4afa1b14610568578063509515b51461059157806353613dd3146105e6578063603f4d521461060f57806370212761146106465780639c1f332f1461065b578063ae90e9f814610684578063b16d2fd114610699578063bb3f5330146106c2578063d476620b146106d7578063dd11247e14610700578063ed338ff114610729578063f2aa821814610752578063fcfdaa52146107c3575b6000806000600381111561011757fe5b600d60009054906101000a900460ff16600381111561013257fe5b141561025657600254341015151561014957600080fd5b60019150600254341115610168576002543481151561016457fe5b0491505b81600954600354031015151561017d57600080fd5b81600954016009819055506060604051908101604052803373ffffffffffffffffffffffffffffffffffffffff16815260200160095481526020013481525060076000600854815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155905050600160085401600881905550600354600954101515610251576102506107ec565b5b610453565b6001600381111561026357fe5b600d60009054906101000a900460ff16600381111561027e57fe5b14156104445760076000600b54815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156102f657600080fd5b60003073ffffffffffffffffffffffffffffffffffffffff163111151561031c57600080fd5b60003414151561032b57600080fd5b6003600d60006101000a81548160ff0219169083600381111561034a57fe5b021790555060646004543073ffffffffffffffffffffffffffffffffffffffff16310281151561037657fe5b0490506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505050610452565b6000151561045157600080fd5b5b5b5050005b341561046257600080fd5b61046a61083b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104b757600080fd5b6104bf610860565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561050c57600080fd5b610514610886565b6040518082815260200191505060405180910390f35b341561053557600080fd5b61053d61088c565b005b341561054a57600080fd5b610552610921565b6040518082815260200191505060405180910390f35b341561057357600080fd5b61057b610927565b6040518082815260200191505060405180910390f35b341561059c57600080fd5b6105a461092d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156105f157600080fd5b6105f961097d565b6040518082815260200191505060405180910390f35b341561061a57600080fd5b610622610983565b6040518082600381111561063257fe5b60ff16815260200191505060405180910390f35b341561065157600080fd5b610659610996565b005b341561066657600080fd5b61066e610a0b565b6040518082815260200191505060405180910390f35b341561068f57600080fd5b610697610a11565b005b34156106a457600080fd5b6106ac610a63565b6040518082815260200191505060405180910390f35b34156106cd57600080fd5b6106d5610a69565b005b34156106e257600080fd5b6106ea610ae3565b6040518082815260200191505060405180910390f35b341561070b57600080fd5b610713610ae9565b6040518082815260200191505060405180910390f35b341561073457600080fd5b61073c610aef565b6040518082815260200191505060405180910390f35b341561075d57600080fd5b6107736004808035906020019091905050610af5565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34156107ce57600080fd5b6107d6610b3f565b6040518082815260200191505060405180910390f35b426006819055506001600d60006101000a81548160ff0219169083600381111561081257fe5b02179055506001610824600954610b45565b01600c81905550610833610bd2565b600b81905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e757600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b60085481565b60035481565b600080600c5411151561093f57600080fd5b60076000600b54815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b600d60009054906101000a900460ff1681565b60008060038111156109a457fe5b600d60009054906101000a900460ff1660038111156109bf57fe5b1415156109cb57600080fd5b60055442101515156109dc57600080fd5b6002600d60006101000a81548160ff021916908360038111156109fb57fe5b0217905550610a08610ca4565b50565b600a5481565b6002806003811115610a1f57fe5b600d60009054906101000a900460ff166003811115610a3a57fe5b141515610a4657600080fd5b600854600a54101515610a5857600080fd5b610a60610ca4565b50565b600c5481565b6001806003811115610a7757fe5b600d60009054906101000a900460ff166003811115610a9257fe5b141515610a9e57600080fd5b62278d00600654014210151515610ab457600080fd5b6002600d60006101000a81548160ff02191690836003811115610ad357fe5b0217905550610ae0610ca4565b50565b600b5481565b60095481565b60055481565b60076020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b60065481565b6000814441426001430340604051808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018381526020018260001916600019168152602001945050505050604051809103902060019004811515610bca57fe5b069050919050565b600080600080600092506001600854039150600090505b600c546007600085815260200190815260200160002060010154101515610c1257829350610c9e565b600c546007600084815260200190815260200160002060010154111515610c3b57819350610c9e565b60026001848403011415610c5157819350610c9e565b826002848403811515610c6057fe5b04019050600c546007600083815260200190815260200160002060010154111515610c8d57809250610c91565b8091505b600115610c9d57610be9565b5b50505090565b6000803073ffffffffffffffffffffffffffffffffffffffff16311115610d7a57600a5490505b60085481108015610cde575062030d405a115b15610d72576007600082815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60076000848152602001908152602001600020600201549081150290604051600060405180830381858888f19350505050508080600101915050610ccb565b80600a819055505b505600a165627a7a72305820b3066a54c11914b0280ee699a266faa3985ec5663d585342f66d364dc782cc4f00290000000000000000000000000028296cc4c90af33f694492ba0e20dd4cefff6700000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002

   Swarm Source:
bzzr://b3066a54c11914b0280ee699a266faa3985ec5663d585342f66d364dc782cc4f

 

View All
Block Age transaction Difficulty GasUsed 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.