Inspiration

Some years back I was in a Casino with my cousin, and that's when I came across this game, can't remember the name but basically, you have to guess about 6 numbers ranging from 1 to 60, and it runs every 10mins, it kinda stuck with me for a while, so around the middle of the year, I wanted to build something similar using Chainlink VRF, but time wasn't on my side so I had to wait, I saw the blockchain as being decentralized and fair as no one entity could manipulate the system to get unfair advantage over the gamblers, everything is given to chance and they always win with La Chance.

What it does

La Chance is a zero-loss decentralized betting platform powered by smart contracts and Chainlink VRF, La Chance is one of a kind because not only is it risk-free, but it pays losing bets, so how does La Chance work, a user makes a bet with five numbers, ranging from 1 - 100, La Chance record the bet and invest the funds in a lending protocol (Currently our lending protocol only does flash loans), the interest from this activity is split into Seven vaults, after about 24 hours the smart contract will receive Five random numbers from Chainlink, these random numbers are the results if a bet wins the staker gets to withdraw his/her rewards including their stake immediately, but if the bet loses, the stake will stay in the protocol for three months after that the funds can be withdrawn with earnings from the community pot.

These are the vaults and their function

  • Vault 1: When a bet gets at least one number right they get their earnings from Vault1.
  • Vault 2: When a bet gets at least two numbers right they get their earnings from Vault2.
  • Vault 3: When a bet gets at least three numbers right they get their earnings from Vault3.
  • Vault 4: When a bet gets at least four numbers right they get their earnings from Vault4.
  • Vault 5: When a bet gets at least five numbers right they get their earnings from Vault5.
  • DAOVault: This is used to primarily run the DAO, our platform pays users to make and vote on proposals, and it also aids in the purchase of Link tokens (does not require voting).
  • Community Vault: Every Staker withdraws from this vault whether they win or lose.

NB: All earnings are shared amongst winners.

Finally La Chance also comes with a DAO, that pays you for voting.

How the DAO works

The DAO is the owner of all our smart contracts, when a player buys a ticket, they get issued an ERC20 Governance Token, Called LGT, which is equal to the amount spent on the tickets.

  • Member creates a proposal, He and others support this proposal with LGT tokens, if the proposal doesn't get the required support, it won't qualify for voting. (The support tokens, act as collateral if the proposal is Rejected, by the community, it gets burnt by the percentage of people that reject the proposal, Let's 70% were against the proposal, so 70% of the supporting tokens would be burnt), but if the proposal passes, they get to take a certain amount of funds from the DAOVault.

  • After the proposal has gained the required support, it is open for voting, and the current quorum is set at 10%, so 10% of tokens are needed to be involved for a proposal to pass,

  • Once the voting period is over, the proposal needs to be executed, execution here does not mean the proposal must make changes to the protocol, only winning proposals can make changes to the protocol, but all proposals need to be executed to source funds from the DAO Vault.

  • After the proposal is executed, each voter can now claim their voting tokens and their pay.

How we built it

This project consists of several smart contracts that perform various functions.

  • Jackpot.sol : This is the main smart contract and it is the entry point to the system, This contract calls the other contracts within the system.

  • JackpotCore.sol: This contract manages the state of the game, it stores user tickets, game results and game rounds.

  • Chainlink.sol: This contract interacts with Chainlink VRF and Delivers random numbers from Chainlink to the Jackpot, upkeeps are also sent to this contract.

  • LendingProtocol.sol : All the funds generated from buying tickets is sent to this contract, the contract facilitates Flashloans and the interest are recorded as the individual vaults contract according to the sharing formula.

  • Vault.sol: The vault contract is the only contract that can withdraw funds from the LendingProtocol, the vault doesn't store funds, it creates a new pot contract, that stores all the funds, this action resets the interest accrued by the Vault to zero, and stores real funds in on the pot, this contract does this only when a pot is won.

  • DAOVault.sol: This is an extension of the Vault contract, it is meant to interact with the DAO, so it doesn't create a pot. It just sends funds to the Governor Vault whenever a proposal is executed.

  • Governance.sol: This is the governance contract that handles proposal and voting.

  • GovernanceToken.sol: This is a simple ERC20 token that is used for voting on our platform.

  • GovernorVault.sol: This vault is created for each proposal and it stores all the funds associated with that proposal.

Challenges we ran into

The first challenge was how to successfully mock test Chainlink VRF, My contract was unable to receive random words for a few days until I set the right amount of Callback gas.

Accomplishments that we're proud of

Being able to put up this project in a short while, is something that I am really proud of.

What we learned

  • Learnt how to use Chainlink VRF and Mock test it locally.
  • Learnt how to make self automated contracts.
  • Learnt more about onchain governance.

What's next for La Chance

I want to take this project to production so the next phase are as followed.

  • Make the contracts upgradeable
  • Optimize the contract to cost less Gas
  • Work with lending protocols like Aave, so we don't have to implement ours.
  • Go for Auditing
  • Deploy to production.

I am looking forward to teaming up with the best minds, to take this project Live after this Hackathon

Addresses on Fuji Testnet

VITE_JACKPOT="0x12d470884133d0b6846f60daae60affdfee2c1d1" VITE_JACKPOT_CORE="0xfc3a72a1a271ee9d60a366b970bb234e07d73914" VITE_LENDING_PROTOCOL="0xebb1d7a9d9807d4a61a6cfab1dc9884fec76defa" VITE_TEST_USDC="0xeb52d74c78e50e1b1d30f93b57ae7e66376b8bf6" VITE_CHAINLINK="0x3b12c041ff5fc2c6d0274a040f8cfc45dcce978e" VITE_GOVERNANCE="0x6237f14c122710860b8719fc971201167236e0e9" VITE_GOVERNANCE_TOKEN="0xc6d4cb0228cadcdf79bf6d4fafbeb3dbf76dc72e"

Built With

Share this project:

Updates