POL Price: $0.218734 (+7.79%)
Gas: 30 GWei
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Draw Winner661542472024-12-31 21:00:06112 days ago1735678806IN
0xEf50F956...7c5D28944
0 POL0.0049828161.75722087

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RisyRaffle

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 999999 runs

Other Settings:
paris EvmVersion
File 1 of 1 : RisyRaffle.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

interface IERC721 {
    function ownerOf(uint256 tokenId) external view returns (address);
    function totalSupply() external view returns (uint256);
}

contract RisyRaffle {
    address public immutable nftContract;
    uint256 public winningTicketId;
    address public winner;
    bool public isDrawComplete;
    address public owner;

    event WinnerSelected(uint256 indexed ticketId, address indexed winner);

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can call this function");
        _;
    }

    constructor(address _nftContract) {
        nftContract = _nftContract;
        owner = msg.sender;
    }

    function drawWinner() external onlyOwner {
        require(!isDrawComplete, "Draw already completed");
        
        uint256 totalTickets = IERC721(nftContract).totalSupply();
        require(totalTickets > 0, "No tickets minted");

        // Using block variables for randomness
        // Note: This is not cryptographically secure, but simple enough for this use case
        uint256 randomNumber = uint256(
            keccak256(
                abi.encodePacked(
                    block.timestamp,
                    block.prevrandao,
                    block.number
                )
            )
        );

        // Select winning ticket (1-based index since NFT IDs typically start at 1)
        winningTicketId = (randomNumber % totalTickets) + 1;
        
        // Get the winner's address
        winner = IERC721(nftContract).ownerOf(winningTicketId);
        
        isDrawComplete = true;
        
        emit WinnerSelected(winningTicketId, winner);
    }

    // Allow owner to transfer ownership
    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "New owner cannot be zero address");
        owner = newOwner;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 999999
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ticketId","type":"uint256"},{"indexed":true,"internalType":"address","name":"winner","type":"address"}],"name":"WinnerSelected","type":"event"},{"inputs":[],"name":"drawWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isDrawComplete","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"winner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"winningTicketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b5060405161089f38038061089f83398101604081905261002f91610052565b6001600160a01b0316608052600280546001600160a01b03191633179055610082565b60006020828403121561006457600080fd5b81516001600160a01b038116811461007b57600080fd5b9392505050565b6080516107f46100ab60003960008181610127015281816102b1015261044a01526107f46000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b2185bb11161005b578063b2185bb114610118578063d56d229d14610122578063dfbf53ae14610149578063f2fde38b1461016957600080fd5b8063482a5665146100825780638da5cb5b146100bc578063a7380ec214610101575b600080fd5b6001546100a79074010000000000000000000000000000000000000000900460ff1681565b60405190151581526020015b60405180910390f35b6002546100dc9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b3565b61010a60005481565b6040519081526020016100b3565b61012061017c565b005b6100dc7f000000000000000000000000000000000000000000000000000000000000000081565b6001546100dc9073ffffffffffffffffffffffffffffffffffffffff1681565b6101206101773660046106e9565b610559565b60025473ffffffffffffffffffffffffffffffffffffffff163314610228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60015474010000000000000000000000000000000000000000900460ff16156102ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4472617720616c726561647920636f6d706c6574656400000000000000000000604482015260640161021f565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561031a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033e919061070d565b9050600081116103aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4e6f207469636b657473206d696e746564000000000000000000000000000000604482015260640161021f565b604080514260208201524491810191909152436060820152600090608001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528051602090910120905061040a8282610726565b610415906001610761565b60008190556040517f6352211e00000000000000000000000000000000000000000000000000000000815260048101919091527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690636352211e90602401602060405180830381865afa1580156104a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ca91906107a1565b600180547fffffffffffffffffffffff0000000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92831617740100000000000000000000000000000000000000001790819055600080546040519290931692917f03fb57eb449654e24e1b240d3d06702cf79362a065d5c0323aee642d4702fa4b9190a35050565b60025473ffffffffffffffffffffffffffffffffffffffff163314610600576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60448201527f6e00000000000000000000000000000000000000000000000000000000000000606482015260840161021f565b73ffffffffffffffffffffffffffffffffffffffff811661067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e6577206f776e65722063616e6e6f74206265207a65726f2061646472657373604482015260640161021f565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b73ffffffffffffffffffffffffffffffffffffffff811681146106e657600080fd5b50565b6000602082840312156106fb57600080fd5b8135610706816106c4565b9392505050565b60006020828403121561071f57600080fd5b5051919050565b60008261075c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8082018082111561079b577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b6000602082840312156107b357600080fd5b8151610706816106c456fea2646970667358221220fc0b92ad0184d7f12865811820f46b6618a47c53be7ee32818740e8de558d19e64736f6c634300081400330000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b2185bb11161005b578063b2185bb114610118578063d56d229d14610122578063dfbf53ae14610149578063f2fde38b1461016957600080fd5b8063482a5665146100825780638da5cb5b146100bc578063a7380ec214610101575b600080fd5b6001546100a79074010000000000000000000000000000000000000000900460ff1681565b60405190151581526020015b60405180910390f35b6002546100dc9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b3565b61010a60005481565b6040519081526020016100b3565b61012061017c565b005b6100dc7f0000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae81565b6001546100dc9073ffffffffffffffffffffffffffffffffffffffff1681565b6101206101773660046106e9565b610559565b60025473ffffffffffffffffffffffffffffffffffffffff163314610228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60015474010000000000000000000000000000000000000000900460ff16156102ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4472617720616c726561647920636f6d706c6574656400000000000000000000604482015260640161021f565b60007f0000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561031a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033e919061070d565b9050600081116103aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4e6f207469636b657473206d696e746564000000000000000000000000000000604482015260640161021f565b604080514260208201524491810191909152436060820152600090608001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528051602090910120905061040a8282610726565b610415906001610761565b60008190556040517f6352211e00000000000000000000000000000000000000000000000000000000815260048101919091527f0000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae73ffffffffffffffffffffffffffffffffffffffff1690636352211e90602401602060405180830381865afa1580156104a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ca91906107a1565b600180547fffffffffffffffffffffff0000000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92831617740100000000000000000000000000000000000000001790819055600080546040519290931692917f03fb57eb449654e24e1b240d3d06702cf79362a065d5c0323aee642d4702fa4b9190a35050565b60025473ffffffffffffffffffffffffffffffffffffffff163314610600576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60448201527f6e00000000000000000000000000000000000000000000000000000000000000606482015260840161021f565b73ffffffffffffffffffffffffffffffffffffffff811661067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e6577206f776e65722063616e6e6f74206265207a65726f2061646472657373604482015260640161021f565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b73ffffffffffffffffffffffffffffffffffffffff811681146106e657600080fd5b50565b6000602082840312156106fb57600080fd5b8135610706816106c4565b9392505050565b60006020828403121561071f57600080fd5b5051919050565b60008261075c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8082018082111561079b577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b6000602082840312156107b357600080fd5b8151610706816106c456fea2646970667358221220fc0b92ad0184d7f12865811820f46b6618a47c53be7ee32818740e8de558d19e64736f6c63430008140033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae

-----Decoded View---------------
Arg [0] : _nftContract (address): 0x7615ff3DD6762f54494F3d0Aa22Ec5DD0a0b15Ae

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000007615ff3dd6762f54494f3d0aa22ec5dd0a0b15ae


Block Transaction 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
[ 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.