From what I understand, each wallet would pay for a "ticket" and the raffle program would create a PDA for each wallet, tracking the wallet and number of raffle tickets.
However, I'm not sure where/how best to handle the actual raffle logic (selecting a random winner, timing...). Would this be implemented off-chain on a server, with some cronjob running an action when the raffle is over, which would then trigger another instruction within the raffle program to transfer the tokens?
Or could it also be done on the blockchain? I'd prefer to do it on-chain for transparency but I'm not sure about the potential limitations and how to go about structuring the accounts so that normal users can't call certain instructions and break/disrupt the raffle.
I'm looking for a simple implementation that could serve as a foundation, while still fitting as much as makes sense onto the blockchain.