Decentralized Lottery.
DecentralizedLottery Deployed on Linea MainNet -> 0x3bb15e57aad0ba82c471e3d42ae51bf5f24b6d55 WinnerAnnouncer Deployed on Polygon MainNet (POS) -> 0x854b1cb04296594427db0f7e96bccbc35a05638b
-
On Linea Mainnet. Start the session: startSession Arguments:
entranceFee– Entrance Fee is the initial amount users need to set. It's in the Wei format.interval– seconds duration of the lottery. https://lineascan.build/address/0x3bb15e57aad0ba82c471e3d42ae51bf5f24b6d55#writeContract#F5 -
On Linea Mainnet. For users enterLottery
-
On Linea Mainnet. After interval end. Perform Upkeep that will close the lottery. performUpkeep
As the argument set:
0x00 -
On Polygon Mainnet. Now, we need to request the random winner from Chainlink:
requestRandomWinner (0x522a1f0b)
The argument requires attached native tokens. They will be used as a fee for the Oracles that will transfer the random number to the lottery contract on Linea Mainnet. You can see the protocol fees here: Docs.Debridge.Finance/fees and supported networks.
Use the fee for the Polygon. During the deployment of the smartcontracts, the protocol fee was 0.5 MATIC. Therefore, pass
0.5as the argument. -
Chainlink VRF, we need to get the transaction id that fulfilled the random number:
-
Debridge, finally we need to claim the execution on the bridge.
https://app.debridge.finance/transaction?chainId=137&tx= tx id copied from chainlink

Login and connect your wallet. Switch to the Linea Mainnet. On the page, wait until the block is finalized. For polygon you need to wait 256 blocks. After blocks were finalized, and if you passed the protocol fee, then under the
Lineayou will see the Claim button. Click on that. And it will execute the transaction and announce the winner. -
Check If you claimed the transaction, you will see the transaction ID on the same page. Click on that.
will redirect to the blockchain explorer. You will see 2 token transfers.
First is the winners tokens (50% of the pool), and second is the burning amount (20% of the pool)

After transferring the tokens, you can call the startSession again to start new lottery.
1. cd frontend
2. npm install
3. npm run dev
1. cd Smart-Contract
2. npm install
3. setup env
4. npx hardhat test
5. npx hardhat deploy --network localhost
- Next.js
- Tailwind CSS (For styling)
- ts-particles (for background animations)
- Moralis (For web3 integration)
- Web3uikit (For wallet connect button and notifications)
- Ethers (For converting value into ethers)
- Fleek IPFS (For deploying frontend)
- Solidity (To develop Smart Contract)
- Javascript (For deploying scripts)
- Chai (For testing Smart Contract)
- Chain-Link (For getting random number and choosing winner after specific time)
- Rinkeby (Test network)
- Hardhat
- ethers
