false
false
0

Contract Address Details

0x6840e9A4a29dFE5603D5C0512c6a2bEd704ab201

Contract Name
Lottery
Creator
0xc0a1ac–7fae10 at 0x0306cb–b951fc
Balance
0 3C
Tokens
Fetching tokens...
Transactions
1 Transactions
Transfers
0 Transfers
Gas Used
34,086
Last Balance Update
4741340
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Lottery




Optimization enabled
false
Compiler version
v0.8.20+commit.a1b79de6




EVM Version
paris




Verified at
2025-05-31T14:11:45.547662Z

Lottery.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
 
contract Lottery {
 
    // Define the event that will be emitted when winners are drawn
    event WinnersDrawn(address indexed sender, uint256[] winners);
 
    function drawWinners(uint256 from, uint256 to, uint256 count) external returns (uint256[] memory) {
        // Validate input ranges
        require(to > from, "Invalid range: 'to' must be greater than 'from'");
        require(count > 0 && count <= (to - from + 1), "Invalid count: 'count' must be positive and less than or equal to the range size");
 
        uint256[] memory numbers = new uint256[](to - from + 1);
        for (uint256 i = 0; i < numbers.length; i++) {
            numbers[i] = from + i;
        }
 
        // Shuffle using Fisher-Yates Algorithm
        for (uint256 i = 0; i < count; i++) {
            uint256 rand = uint256(keccak256(
                abi.encodePacked(
                    block.timestamp,
                    block.prevrandao, // <-- used instead of block.difficulty
                    msg.sender,
                    i
                )
            )) % (numbers.length - i);
 
            uint256 n = i + rand;
            (numbers[i], numbers[n]) = (numbers[n], numbers[i]);
        }
 
        uint256[] memory winners = new uint256[](count);
        for (uint256 i = 0; i < count; i++) {
            winners[i] = numbers[i];
        }
 
        // Emit the event with the winners
        emit WinnersDrawn(msg.sender, winners);
 
        return winners;
    }
}
        

Compiler Settings

{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":false},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"paris"}
              

Contract ABI

[{"type":"event","name":"WinnersDrawn","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":true},{"type":"uint256[]","name":"winners","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"drawWinners","inputs":[{"type":"uint256","name":"from","internalType":"uint256"},{"type":"uint256","name":"to","internalType":"uint256"},{"type":"uint256","name":"count","internalType":"uint256"}]}]
              

Contract Creation Code

Verify & Publish
0x608060405234801561001057600080fd5b5061092e806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a18f9b1114610030575b600080fd5b61004a600480360381019061004591906103e4565b610060565b60405161005791906104f5565b60405180910390f35b60608383116100a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161009b9061059a565b60405180910390fd5b6000821180156100cb5750600184846100bd91906105e9565b6100c7919061061d565b8211155b61010a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610101906106e9565b60405180910390fd5b60006001858561011a91906105e9565b610124919061061d565b67ffffffffffffffff81111561013d5761013c610709565b5b60405190808252806020026020018201604052801561016b5781602001602082028036833780820191505090505b50905060005b81518110156101b8578086610186919061061d565b82828151811061019957610198610738565b5b60200260200101818152505080806101b090610767565b915050610171565b5060005b838110156102a85760008183516101d391906105e9565b424433856040516020016101ea949392919061084a565b6040516020818303038152906040528051906020012060001c61020d91906108c7565b90506000818361021d919061061d565b905083818151811061023257610231610738565b5b602002602001015184848151811061024d5761024c610738565b5b602002602001015185858151811061026857610267610738565b5b6020026020010186848151811061028257610281610738565b5b6020026020010182815250828152505050505080806102a090610767565b9150506101bc565b5060008367ffffffffffffffff8111156102c5576102c4610709565b5b6040519080825280602002602001820160405280156102f35781602001602082028036833780820191505090505b50905060005b8481101561034e5782818151811061031457610313610738565b5b602002602001015182828151811061032f5761032e610738565b5b602002602001018181525050808061034690610767565b9150506102f9565b503373ffffffffffffffffffffffffffffffffffffffff167ff628e245f2d0eac0d008204bacf1370c6adacc3877228223f08d4caf732533ea8260405161039591906104f5565b60405180910390a280925050509392505050565b600080fd5b6000819050919050565b6103c1816103ae565b81146103cc57600080fd5b50565b6000813590506103de816103b8565b92915050565b6000806000606084860312156103fd576103fc6103a9565b5b600061040b868287016103cf565b935050602061041c868287016103cf565b925050604061042d868287016103cf565b9150509250925092565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61046c816103ae565b82525050565b600061047e8383610463565b60208301905092915050565b6000602082019050919050565b60006104a282610437565b6104ac8185610442565b93506104b783610453565b8060005b838110156104e85781516104cf8882610472565b97506104da8361048a565b9250506001810190506104bb565b5085935050505092915050565b6000602082019050818103600083015261050f8184610497565b905092915050565b600082825260208201905092915050565b7f496e76616c69642072616e67653a2027746f27206d757374206265206772656160008201527f746572207468616e202766726f6d270000000000000000000000000000000000602082015250565b6000610584602f83610517565b915061058f82610528565b604082019050919050565b600060208201905081810360008301526105b381610577565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006105f4826103ae565b91506105ff836103ae565b9250828203905081811115610617576106166105ba565b5b92915050565b6000610628826103ae565b9150610633836103ae565b925082820190508082111561064b5761064a6105ba565b5b92915050565b7f496e76616c696420636f756e743a2027636f756e7427206d757374206265207060008201527f6f73697469766520616e64206c657373207468616e206f7220657175616c207460208201527f6f207468652072616e67652073697a6500000000000000000000000000000000604082015250565b60006106d3605083610517565b91506106de82610651565b606082019050919050565b60006020820190508181036000830152610702816106c6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000610772826103ae565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036107a4576107a36105ba565b5b600182019050919050565b6000819050919050565b6107ca6107c5826103ae565b6107af565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107fb826107d0565b9050919050565b60008160601b9050919050565b600061081a82610802565b9050919050565b600061082c8261080f565b9050919050565b61084461083f826107f0565b610821565b82525050565b600061085682876107b9565b60208201915061086682866107b9565b6020820191506108768285610833565b60148201915061088682846107b9565b60208201915081905095945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006108d2826103ae565b91506108dd836103ae565b9250826108ed576108ec610898565b5b82820690509291505056fea2646970667358221220b4047b94333e41ef166dceb35b5e0eec63ad3df5f4c880c4bd0f59c9dccc8c3564736f6c63430008140033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a18f9b1114610030575b600080fd5b61004a600480360381019061004591906103e4565b610060565b60405161005791906104f5565b60405180910390f35b60608383116100a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161009b9061059a565b60405180910390fd5b6000821180156100cb5750600184846100bd91906105e9565b6100c7919061061d565b8211155b61010a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610101906106e9565b60405180910390fd5b60006001858561011a91906105e9565b610124919061061d565b67ffffffffffffffff81111561013d5761013c610709565b5b60405190808252806020026020018201604052801561016b5781602001602082028036833780820191505090505b50905060005b81518110156101b8578086610186919061061d565b82828151811061019957610198610738565b5b60200260200101818152505080806101b090610767565b915050610171565b5060005b838110156102a85760008183516101d391906105e9565b424433856040516020016101ea949392919061084a565b6040516020818303038152906040528051906020012060001c61020d91906108c7565b90506000818361021d919061061d565b905083818151811061023257610231610738565b5b602002602001015184848151811061024d5761024c610738565b5b602002602001015185858151811061026857610267610738565b5b6020026020010186848151811061028257610281610738565b5b6020026020010182815250828152505050505080806102a090610767565b9150506101bc565b5060008367ffffffffffffffff8111156102c5576102c4610709565b5b6040519080825280602002602001820160405280156102f35781602001602082028036833780820191505090505b50905060005b8481101561034e5782818151811061031457610313610738565b5b602002602001015182828151811061032f5761032e610738565b5b602002602001018181525050808061034690610767565b9150506102f9565b503373ffffffffffffffffffffffffffffffffffffffff167ff628e245f2d0eac0d008204bacf1370c6adacc3877228223f08d4caf732533ea8260405161039591906104f5565b60405180910390a280925050509392505050565b600080fd5b6000819050919050565b6103c1816103ae565b81146103cc57600080fd5b50565b6000813590506103de816103b8565b92915050565b6000806000606084860312156103fd576103fc6103a9565b5b600061040b868287016103cf565b935050602061041c868287016103cf565b925050604061042d868287016103cf565b9150509250925092565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61046c816103ae565b82525050565b600061047e8383610463565b60208301905092915050565b6000602082019050919050565b60006104a282610437565b6104ac8185610442565b93506104b783610453565b8060005b838110156104e85781516104cf8882610472565b97506104da8361048a565b9250506001810190506104bb565b5085935050505092915050565b6000602082019050818103600083015261050f8184610497565b905092915050565b600082825260208201905092915050565b7f496e76616c69642072616e67653a2027746f27206d757374206265206772656160008201527f746572207468616e202766726f6d270000000000000000000000000000000000602082015250565b6000610584602f83610517565b915061058f82610528565b604082019050919050565b600060208201905081810360008301526105b381610577565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006105f4826103ae565b91506105ff836103ae565b9250828203905081811115610617576106166105ba565b5b92915050565b6000610628826103ae565b9150610633836103ae565b925082820190508082111561064b5761064a6105ba565b5b92915050565b7f496e76616c696420636f756e743a2027636f756e7427206d757374206265207060008201527f6f73697469766520616e64206c657373207468616e206f7220657175616c207460208201527f6f207468652072616e67652073697a6500000000000000000000000000000000604082015250565b60006106d3605083610517565b91506106de82610651565b606082019050919050565b60006020820190508181036000830152610702816106c6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000610772826103ae565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036107a4576107a36105ba565b5b600182019050919050565b6000819050919050565b6107ca6107c5826103ae565b6107af565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107fb826107d0565b9050919050565b60008160601b9050919050565b600061081a82610802565b9050919050565b600061082c8261080f565b9050919050565b61084461083f826107f0565b610821565b82525050565b600061085682876107b9565b60208201915061086682866107b9565b6020820191506108768285610833565b60148201915061088682846107b9565b60208201915081905095945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006108d2826103ae565b91506108dd836103ae565b9250826108ed576108ec610898565b5b82820690509291505056fea2646970667358221220b4047b94333e41ef166dceb35b5e0eec63ad3df5f4c880c4bd0f59c9dccc8c3564736f6c63430008140033
<script src="{@file}"> </script>