Address Details
contract

0x589E16a7D36190a844aB5c5E15014242c051eecB

Contract Name
Game
Creator
0x93a8ba–4feaee at 0x6587b2–dc9f89
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
6404151
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Game




Optimization enabled
false
Compiler version
v0.5.16+commit.9c3226ce




EVM Version
istanbul




Verified at
2022-09-30T10:25:54.171971Z

/Users/vaibhavchopra/code/david/contracts/Game.sol

pragma solidity >=0.4.22 <0.9.0;

// Importing OpenZeppelin's SafeMath Implementation
// import "@openzeppelin/contracts/utils/math/SafeMath.sol";


contract Game{
    function _pickResult(string memory _pickerName) internal  view  returns(uint){
        uint rand = uint (keccak256(abi.encodePacked(_pickerName,block.timestamp,block.difficulty)));
        return rand;
    }

    function _getResultsArray(uint16 _pairNumber,string memory _pickerName ) internal view returns(uint16[] memory,uint16){
        uint result = _pickResult(_pickerName);
        uint16[] memory finalResult = new uint16[](_pairNumber); 
        uint16 winIndex;
        uint16 temp;
        for (uint16 i=0;i<=_pairNumber-1;i++){
            finalResult[i]=uint16(result % 1000);
            if (i == 0){
                temp = finalResult[i];
                winIndex=0;
            }
            if (finalResult[i]>temp){
                temp=finalResult[i];
                winIndex=i;
            }
            result =uint(( result - (result % 1000))/1000);

        }
        return (finalResult,winIndex);
    }


    function pickWinner(string memory _pickerName) public view  returns(uint16[] memory){
        uint16[] memory fresult;
        uint16 windex;
        (fresult,windex) = _getResultsArray(uint16(2),_pickerName);
        return fresult;
    }


}
        

Contract ABI

[{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint16[]","name":"","internalType":"uint16[]"}],"name":"pickWinner","inputs":[{"type":"string","name":"_pickerName","internalType":"string"}],"constant":true}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50610368806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806327e2506914610030575b600080fd5b6100e96004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610140565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561012c578082015181840152602081019050610111565b505050509050019250505060405180910390f35b6060806000610150600285610162565b80925081935050508192505050919050565b6060600080610170846102a0565b905060608561ffff166040519080825280602002602001820160405280156101a75781602001602082028038833980820191505090505b50905060008060008090505b6001890361ffff168161ffff161161028e576103e885816101d057fe5b06848261ffff16815181106101e157fe5b602002602001019061ffff16908161ffff168152505060008161ffff16141561022357838161ffff168151811061021457fe5b60200260200101519150600092505b8161ffff16848261ffff168151811061023857fe5b602002602001015161ffff16111561026857838161ffff168151811061025a57fe5b602002602001015191508092505b6103e880868161027457fe5b0686038161027e57fe5b04945080806001019150506101b3565b50828295509550505050509250929050565b6000808242446040516020018084805190602001908083835b602083106102dc57805182526020820191506020810190506020830392506102b9565b6001836020036101000a03801982511681845116808217855250505050505090500183815260200182815260200193505050506040516020818303038152906040528051906020012060001c90508091505091905056fea265627a7a7231582006bef067f12e7299718dc58bd9ddec71de2c4a3e8d1d0f91ccab4e725938010564736f6c63430005100032

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806327e2506914610030575b600080fd5b6100e96004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610140565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561012c578082015181840152602081019050610111565b505050509050019250505060405180910390f35b6060806000610150600285610162565b80925081935050508192505050919050565b6060600080610170846102a0565b905060608561ffff166040519080825280602002602001820160405280156101a75781602001602082028038833980820191505090505b50905060008060008090505b6001890361ffff168161ffff161161028e576103e885816101d057fe5b06848261ffff16815181106101e157fe5b602002602001019061ffff16908161ffff168152505060008161ffff16141561022357838161ffff168151811061021457fe5b60200260200101519150600092505b8161ffff16848261ffff168151811061023857fe5b602002602001015161ffff16111561026857838161ffff168151811061025a57fe5b602002602001015191508092505b6103e880868161027457fe5b0686038161027e57fe5b04945080806001019150506101b3565b50828295509550505050509250929050565b6000808242446040516020018084805190602001908083835b602083106102dc57805182526020820191506020810190506020830392506102b9565b6001836020036101000a03801982511681845116808217855250505050505090500183815260200182815260200193505050506040516020818303038152906040528051906020012060001c90508091505091905056fea265627a7a7231582006bef067f12e7299718dc58bd9ddec71de2c4a3e8d1d0f91ccab4e725938010564736f6c63430005100032