ETH Price: $3,198.64 (+4.84%)

Contract

0xD87A0DF90BffdF0c4A168744a1a3F9292B500433
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Send Crypto Vers...70888562019-01-18 20:00:442122 days ago1547841644IN
0xD87A0DF9...92B500433
0 ETH0.000161367.5
Send Reward70888552019-01-18 20:00:432122 days ago1547841643IN
0xD87A0DF9...92B500433
0 ETH0.000113084.5
Send Reward70888542019-01-18 20:00:392122 days ago1547841639IN
0xD87A0DF9...92B500433
0 ETH0.000128864.5
Check End Of Cha...70888502019-01-18 19:58:402122 days ago1547841520IN
0xD87A0DF9...92B500433
0 ETH0.000382214.5
Vote For Candida...70874832019-01-18 14:05:382122 days ago1547820338IN
0xD87A0DF9...92B500433
0.006 ETH0.000572775.4
Vote For Candida...70874782019-01-18 14:04:302122 days ago1547820270IN
0xD87A0DF9...92B500433
0.005 ETH0.000572425.4
Start Challenge70874692019-01-18 14:01:592122 days ago1547820119IN
0xD87A0DF9...92B500433
0 ETH0.000265145.4
0x6080604070874672019-01-18 14:01:192122 days ago1547820079IN
 Contract Creation
0 ETH0.005601014.5

Latest 3 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
70888562019-01-18 20:00:442122 days ago1547841644
0xD87A0DF9...92B500433
0.000265 ETH
70888542019-01-18 20:00:392122 days ago1547841639
0xD87A0DF9...92B500433
0.01065 ETH
70888502019-01-18 19:58:402122 days ago1547841520
0xD87A0DF9...92B500433
0.000085 ETH
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x48f7e7C9...39A8d8d3E
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
VotingChallenge

Compiler Version
v0.5.2+commit.1df8f40c

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
/**
 *Submitted for verification at Etherscan.io on 2019-01-08
*/

pragma solidity ^0.5.1;

contract VotingChallenge {
    struct Team {
        uint fullVotes;
        uint weightedVotes;
    }

    struct Voter {
        uint[2] fullVotes;
        uint[2] weightedVotes;
        address payable[2] referrers;
    }

    VotingChallengeForwarder forwarder;

    uint public challengeDuration;
    uint public challengeStarted;
    address payable public creator;
    uint16 public creatorFee = 17;       // measured in in tenths of a percent
    address payable public cryptoVersusWallet = 0xa0bedE75cfeEF0266f8A31b47074F5f9fBE1df80;
    uint16 public cryptoVersusFee = 53;  // measured in in tenths of a percent
    uint public cryptoVersusPrize;
    uint public challengePrize;
    uint public winner;
    bool public isVotingPeriod = false;
    bool public beforeVoting = true;
    Team[2] public teams;
    mapping( address => Voter ) private voters;

    modifier inVotingPeriod() {
        require(isVotingPeriod);
        _;
    }

    modifier afterVotingPeriod() {
        require(!isVotingPeriod);
        _;
    }

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

    event ChallengeBegins(address _creator, uint _challengeDuration);
    event NewVotesFor(address _participant, uint _candidate, uint _votes, uint _coefficient);
    event TransferVotes(address _from, address _to, uint _candidateIndex, uint _votes);
    event EndOfChallenge(uint _winner, uint _winnerVotes, uint _challengePrize);
    event RewardWasPaid(address _participant, uint _amount);
    event ReferrerRewardWasPaid(address _via, address _to, uint amount);
    event CreatorRewardWasPaid(address _creator, uint _amount);
    event CryptoVersusRewardWasPaid(address _cryptoVersusWallet, uint _amount);

    constructor(uint _challengeDuration, address _forwarder) public {
        forwarder = VotingChallengeForwarder(_forwarder);
        challengeDuration = _challengeDuration;
        creator = msg.sender;
    }

    function getAllVotes() public view returns (uint[2] memory) {
        return [ teams[0].fullVotes, teams[1].fullVotes ];
    }

    function currentCoefficient() public view returns (uint) {  // in 1/1000000
        return 1000000 - 900000 * (now - challengeStarted) / challengeDuration;
    }

    function timeOver() public view returns (bool) {
        return challengeStarted + challengeDuration <= now;
    }

    function startChallenge() public onlyCreator {
        require(beforeVoting);
        isVotingPeriod = true;
        beforeVoting = false;
        challengeStarted = now;

        emit ChallengeBegins(creator, challengeDuration);
    }

    function voteForCandidate(uint candidate) public payable inVotingPeriod {
        require(0 <= candidate && candidate < 2);
        require(msg.value > 0);
        require(!timeOver());

        uint coefficient = currentCoefficient();
        uint weightedVotes = msg.value * coefficient / 1000000;
        teams[candidate].fullVotes += msg.value;
        teams[candidate].weightedVotes += weightedVotes;
        voters[msg.sender].fullVotes[candidate] += msg.value;
        voters[msg.sender].weightedVotes[candidate] += weightedVotes;

        emit NewVotesFor(msg.sender, candidate, msg.value, coefficient);
    }

    function voteForCandidate(uint candidate, address payable referrer1) public payable inVotingPeriod {
        voters[msg.sender].referrers[0] = referrer1;
        voteForCandidate(candidate);
    }

    function voteForCandidate(uint candidate, address payable referrer1, address payable referrer2) public payable inVotingPeriod {
        voters[msg.sender].referrers[1] = referrer2;
        voteForCandidate(candidate, referrer1);
    }

    function checkEndOfChallenge() public inVotingPeriod returns (bool) {
        if (!timeOver())
            return false;

        if (teams[0].fullVotes > teams[1].fullVotes)
            winner = 0;
        else
            winner = 1;

        uint loser = 1 - winner;
        creator.transfer((teams[loser].fullVotes * creatorFee) / 1000);
        cryptoVersusPrize = (teams[loser].fullVotes * cryptoVersusFee) / 1000;
        challengePrize = teams[loser].fullVotes * (1000 - creatorFee - cryptoVersusFee) / 1000;
        isVotingPeriod = false;

        emit EndOfChallenge(winner, teams[winner].fullVotes, challengePrize);
        return true;
    }

    function sendReward(address payable to) public afterVotingPeriod {
        uint winnerVotes = voters[to].weightedVotes[winner];
        uint loserVotes = voters[to].fullVotes[1-winner];
        address payable referrer1 = voters[to].referrers[0];
        address payable referrer2 = voters[to].referrers[1];
        uint sum;

        if (winnerVotes > 0) {
            uint reward = challengePrize * winnerVotes / teams[winner].weightedVotes;
            to.transfer(reward + voters[to].fullVotes[winner]);
            if (referrer1 != address(0)) {
                sum = reward / 100 * 2;  // 2%
                forwarder.forward.value(sum)(referrer1, to);
                cryptoVersusPrize -= sum;
                emit ReferrerRewardWasPaid(to, referrer1, sum);
            }
            if (referrer2 != address(0)) {
                sum = reward / 1000 * 2;  // 0.2%
                forwarder.forward.value(sum)(referrer2, to);
                cryptoVersusPrize -= sum;
                emit ReferrerRewardWasPaid(to, referrer2, sum);
            }
            voters[to].fullVotes[winner] = 0;
            voters[to].weightedVotes[winner] = 0;
            emit RewardWasPaid(to, reward);
        }
        if (loserVotes > 0) {
            if (referrer1 != address(0)) {
                sum = loserVotes / 100 * 1;  // 1%
                forwarder.forward.value(sum)(referrer1, to);
                cryptoVersusPrize -= sum;
                emit ReferrerRewardWasPaid(to, referrer1, sum);
            }
            if (referrer2 != address(0)) {
                sum = loserVotes / 1000 * 1;  // 0.1%
                forwarder.forward.value(sum)(referrer2, to);
                cryptoVersusPrize -= sum;
                emit ReferrerRewardWasPaid(to, referrer2, sum);
            }
            voters[to].fullVotes[1-winner] = 0;
            voters[to].weightedVotes[1-winner] = 0;
        }
    }

    function sendCryptoVersusReward() public afterVotingPeriod {
        if (cryptoVersusPrize > 0) {
            uint cryptoVersusReward = cryptoVersusPrize;
            cryptoVersusPrize = 0;
            cryptoVersusWallet.transfer(cryptoVersusReward);

            emit CryptoVersusRewardWasPaid(cryptoVersusWallet, cryptoVersusReward);
        }
    }
}

contract VotingChallengeForwarder {
    mapping ( address => address[] ) public sendersHash;
    mapping ( address => uint[] ) public sumsHash;

    function forward(address payable to, address sender) public payable {
        to.transfer(msg.value);
        sendersHash[to].push(sender);
        sumsHash[to].push(msg.value);
    }

    function getSendersHash(address user) public view returns (address[] memory) {
        return sendersHash[user];
    }

    function getSumsHash(address user) public view returns (uint[] memory) {
        return sumsHash[user];
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[],"name":"creator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"candidate","type":"uint256"},{"name":"referrer1","type":"address"}],"name":"voteForCandidate","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"challengeStarted","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentCoefficient","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"challengeDuration","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"candidate","type":"uint256"}],"name":"voteForCandidate","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"cryptoVersusPrize","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"teams","outputs":[{"name":"fullVotes","type":"uint256"},{"name":"weightedVotes","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"timeOver","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"checkEndOfChallenge","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"cryptoVersusWallet","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beforeVoting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllVotes","outputs":[{"name":"","type":"uint256[2]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cryptoVersusFee","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"challengePrize","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"sendReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"sendCryptoVersusReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winner","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startChallenge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isVotingPeriod","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"creatorFee","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"candidate","type":"uint256"},{"name":"referrer1","type":"address"},{"name":"referrer2","type":"address"}],"name":"voteForCandidate","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[{"name":"_challengeDuration","type":"uint256"},{"name":"_forwarder","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_creator","type":"address"},{"indexed":false,"name":"_challengeDuration","type":"uint256"}],"name":"ChallengeBegins","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_participant","type":"address"},{"indexed":false,"name":"_candidate","type":"uint256"},{"indexed":false,"name":"_votes","type":"uint256"},{"indexed":false,"name":"_coefficient","type":"uint256"}],"name":"NewVotesFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_from","type":"address"},{"indexed":false,"name":"_to","type":"address"},{"indexed":false,"name":"_candidateIndex","type":"uint256"},{"indexed":false,"name":"_votes","type":"uint256"}],"name":"TransferVotes","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_winner","type":"uint256"},{"indexed":false,"name":"_winnerVotes","type":"uint256"},{"indexed":false,"name":"_challengePrize","type":"uint256"}],"name":"EndOfChallenge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_participant","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"RewardWasPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_via","type":"address"},{"indexed":false,"name":"_to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ReferrerRewardWasPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_creator","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"CreatorRewardWasPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_cryptoVersusWallet","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"CryptoVersusRewardWasPaid","type":"event"}]

Deployed Bytecode

0x608060405260043610610152576000357c01000000000000000000000000000000000000000000000000000000009004806358644191116100c85780639ded18171161008c5780639ded1817146103a8578063dfbf53ae146103bd578063e0a7b2c3146103d2578063e16fd62e146103e7578063e88958dc146103fc578063f69e739e1461041157610152565b806358644191146102cf578063851b6ef2146102e4578063969177b21461033457806396affb25146103605780639dabff251461037557610152565b806336c8c5ee1161011a57806336c8c5ee146102075780633cd86984146102245780633ed2b77a1461023957806346057b701461027c5780634d85b8d0146102a557806356e33cf5146102ba57610152565b806302d05d3f146101575780630b9675841461018857806312fefa28146101b657806324a1cd1e146101dd578063292f2e0e146101f2575b600080fd5b34801561016357600080fd5b5061016c610445565b60408051600160a060020a039092168252519081900360200190f35b6101b46004803603604081101561019e57600080fd5b5080359060200135600160a060020a0316610454565b005b3480156101c257600080fd5b506101cb6104aa565b60408051918252519081900360200190f35b3480156101e957600080fd5b506101cb6104b0565b3480156101fe57600080fd5b506101cb6104d4565b6101b46004803603602081101561021d57600080fd5b50356104da565b34801561023057600080fd5b506101cb610618565b34801561024557600080fd5b506102636004803603602081101561025c57600080fd5b503561061e565b6040805192835260208301919091528051918290030190f35b34801561028857600080fd5b5061029161063d565b604080519115158252519081900360200190f35b3480156102b157600080fd5b5061029161064b565b3480156102c657600080fd5b5061016c6107e2565b3480156102db57600080fd5b506102916107f1565b3480156102f057600080fd5b506102f96107ff565b6040518082600260200280838360005b83811015610321578181015183820152602001610309565b5050505090500191505060405180910390f35b34801561034057600080fd5b50610349610822565b6040805161ffff9092168252519081900360200190f35b34801561036c57600080fd5b506101cb610833565b34801561038157600080fd5b506101b46004803603602081101561039857600080fd5b5035600160a060020a0316610839565b3480156103b457600080fd5b506101b4610d95565b3480156103c957600080fd5b506101cb610e41565b3480156103de57600080fd5b506101b4610e47565b3480156103f357600080fd5b50610291610eda565b34801561040857600080fd5b50610349610ee3565b6101b46004803603606081101561042757600080fd5b50803590600160a060020a0360208201358116916040013516610ef4565b600354600160a060020a031681565b60085460ff16151561046557600080fd5b336000908152600d60205260409020600401805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790556104a6826104da565b5050565b60025481565b60006001546002544203620dbba0028115156104c857fe5b04620f42400390505b90565b60015481565b60085460ff1615156104eb57600080fd5b806000111580156104fc5750600281105b151561050757600080fd5b6000341161051457600080fd5b61051c61063d565b1561052657600080fd5b60006105306104b0565b90506000620f4240348302049050346009846002811061054c57fe5b600290810291909101805490920190915581906009908590811061056c57fe5b600290810291909101600101805492909201909155336000908152600d6020526040902034918590811061059c57fe5b0180549091019055336000908152600d602052604090208190600290810190859081106105c557fe5b0180549091019055604080513381526020810185905234818301526060810184905290517f93c3873974f2b228ddc4e04463f9397e8f33e3b1bc24b8d87f443e1a759293359181900360800190a1505050565b60055481565b6009816002811061062b57fe5b60020201805460019091015490915082565b600154600254429101111590565b60085460009060ff16151561065f57600080fd5b61066761063d565b1515610675575060006104d1565b600b54600954111561068b576000600755610691565b60016007555b60075460035460019190910390600160a060020a038116906108fc906103e89060a060020a900461ffff16600985600281106106c957fe5b6002020154028115156106d857fe5b049081150290604051600060405180830381858888f19350505050158015610704573d6000803e3d6000fd5b506004546103e89060a060020a900461ffff166009836002811061072457fe5b60020201540281151561073357fe5b046005556004546003546103e89161ffff60a060020a918290048116919092048216830303166009836002811061076657fe5b60020201540281151561077557fe5b046006556008805460ff191690556007547f2227f144280fca39880d0277ffc8a63f76ea2385b3a5f034a2c61bd7de984bd290600981600281106107b557fe5b600202015460065460408051938452602084019290925282820152519081900360600190a1600191505090565b600454600160a060020a031681565b600854610100900460ff1681565b610807610f4c565b50604080518082019091526009548152600b54602082015290565b60045460a060020a900461ffff1681565b60065481565b60085460ff161561084957600080fd5b600160a060020a0381166000908152600d60205260408120600754600291820191811061087257fe5b0154600160a060020a0383166000908152600d602052604081206007549293509091600103600281106108a157fe5b0154600160a060020a038481166000908152600d6020526040812060048101546005909101549394508216929091169080851115610b9457600060096007546002811015156108ec57fe5b6002020160010154866006540281151561090257fe5b600160a060020a0389166000818152600d60205260409020600754939092049350916108fc91906002811061093357fe5b015483019081150290604051600060405180830381858888f19350505050158015610962573d6000803e3d6000fd5b50600160a060020a03841615610a2f57600080546040805160e060020a6395ccf8bf028152600160a060020a0388811660048301528b81166024830152915160026064870402965091909216926395ccf8bf9286926044808301939282900301818588803b1580156109d357600080fd5b505af11580156109e7573d6000803e3d6000fd5b5050600580548690039055505060408051600160a060020a03808b168252871660208201528082018590529051600080516020610f6883398151915292509081900360600190a15b600160a060020a03831615610afc57600080546040805160e060020a6395ccf8bf028152600160a060020a0387811660048301528b81166024830152915160026103e8870402965091909216926395ccf8bf9286926044808301939282900301818588803b158015610aa057600080fd5b505af1158015610ab4573d6000803e3d6000fd5b5050600580548690039055505060408051600160a060020a03808b168252861660208201528082018590529051600080516020610f6883398151915292509081900360600190a15b600160a060020a0387166000908152600d6020526040812060075460028110610b2157fe5b0155600160a060020a0387166000908152600d602052604081206007546002918201918110610b4c57fe5b015560408051600160a060020a03891681526020810183905281517f122e846b03a4c60f6cf271fe02a35753b67faca82f36cc27eb87aa7278496eb2929181900390910190a1505b6000841115610d8d57600160a060020a03831615610c665750600080546040805160e060020a6395ccf8bf028152600160a060020a03868116600483015289811660248301529151606488049492909316926395ccf8bf9285926044808201939182900301818588803b158015610c0a57600080fd5b505af1158015610c1e573d6000803e3d6000fd5b5050600580548590039055505060408051600160a060020a03808a168252861660208201528082018490529051600080516020610f6883398151915292509081900360600190a15b600160a060020a03821615610d305750600080546040805160e060020a6395ccf8bf028152600160a060020a038581166004830152898116602483015291516103e888049492909316926395ccf8bf9285926044808201939182900301818588803b158015610cd457600080fd5b505af1158015610ce8573d6000803e3d6000fd5b5050600580548590039055505060408051600160a060020a03808a168252851660208201528082018490529051600080516020610f6883398151915292509081900360600190a15b600160a060020a0386166000908152600d6020526040812060075460010360028110610d5857fe5b0155600160a060020a0386166000908152600d60205260408120600754600291820191600191909103908110610d8a57fe5b01555b505050505050565b60085460ff1615610da557600080fd5b60006005541115610e3f57600580546000918290556004546040519192600160a060020a039091169183156108fc0291849190818181858888f19350505050158015610df5573d6000803e3d6000fd5b5060045460408051600160a060020a0390921682526020820183905280517f0589ab4d2b794888cc8aca31418dbedd8240147e9acb641e4dbbb0eba4c2b00d9281900390910190a1505b565b60075481565b600354600160a060020a03163314610e5e57600080fd5b600854610100900460ff161515610e7457600080fd5b60088054600160ff19909116811761ff00191690915542600255600354905460408051600160a060020a039093168352602083019190915280517f889ebfc3811c0501f2f04a863b1c8e99851ce7716b8f706ac7073289eb7906ab9281900390910190a1565b60085460ff1681565b60035460a060020a900461ffff1681565b60085460ff161515610f0557600080fd5b336000908152600d60205260409020600501805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038316179055610f478383610454565b505050565b6040805180820182529060029082908038833950919291505056fea1a0fbce42e81c82d03f0beec88277407740c607bd36f4218d387577e78851b1a165627a7a72305820f72b3a4e2d24a6c1124880230dff17e95f742b05d3b7e804b4c9b9fe3326f9810029

Swarm Source

bzzr://f72b3a4e2d24a6c1124880230dff17e95f742b05d3b7e804b4c9b9fe3326f981

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.