Installation
tilttek/raffleRequirements
- PHP 8.5 or later, with
ext-sodium. phil/url0.1, which checks the addresses of the relays.psr/clockandpsr/event-dispatcher: the clock and the dispatcher ofRaffleDrawn, both optional.symfony/http-client-contracts, and an HTTP client such assymfony/http-clientfor the drand adapter.
Installing
composer require tilttek/raffle symfony/http-client
Wiring the library
use Tilttek\Raffle\Drand\{DrandBeacon, DrandChains};
use Tilttek\Raffle\Raffles;
$raffles = new Raffles(
$store, // Contract\RaffleStore: the raffles and their entrants
$beacon, // Contract\RandomnessBeacon: needed for a raffle with a prize; null without one
$dispatcher, // a PSR-14 dispatcher, told of each draw; null to dispatch nothing
$clock, // a PSR-20 clock; the system's by default
$randomizer, // the source of the organisers' seeds; the system's secure source by default
margin: 30, // the seconds between the closing of the entries and the beacon round
);
$beacon = new DrandBeacon($httpClient, DrandChains::quicknet(), DrandChains::RELAYS);
Without a beacon, Raffles runs raffles without a stake only. Raffles, RaffleVerifier and DrandBeacon keep
nothing between two calls, so one instance serves every request of a worker; InMemoryRaffleStore keeps everything in
the process, for tests and scripts.