Chainlink Integration
At Leet Lotto, we're all about embracing decentralization and ensuring the utmost security for our valued users.
Leet Lotto relies on Chainlink services for tamper-proof randomness and autonomous upkeep.
Verifiable Randomness
// ⚠️ Simplified example
function drawWinner(uint256 lottoId) external onlyUpkeep {
bytes32 requestId = VRFCoordinator.requestRandomWords(
keyHash,
subscriptionId,
3, // confirmations
200000, // gasLimit
1 // words
);
vrfRequests[requestId] = lottoId;
}
Chainlink VRF returns a random value used to pick the winning ticket index.
Anyone can verify the randomness on-chain.
Automation / Upkeep
// ⚠️ Simplified example
function checkUpkeep(bytes calldata) external view returns (bool, bytes memory) {
bool isReady = block.timestamp >= closingTime && !winnerSelected;
return (isReady, bytes(""));
}
function performUpkeep(bytes calldata) external {
require(block.timestamp >= closingTime, "Lottery still open");
_startVRFRequest();
}
Draws trigger automatically when a lotto’s closing time hits.
Removes human intervention and schedule risk.
Last updated