The aim of this project is to provide a simple example of Smart Contract application.
- This Project is written in Solidity. Find out more about Solidity on Solidity Docs v0.8.15.
- We use Truffle to test and deploy solidity Smart Contract to BSC Testnet. See tutorial.
- Someone bet on Even or Odd
- Roll the dice then give result & pay winners
- Repeat...
- deposit() : Deposit some fund to Smart Contract. The Jackpot shouldn't be empty right? :)
- putInEven() : Bet on Even. You will send 0.01 test BNB to contract to play
- putInOdd() : Bet on Odd. You will send 0.01 test BNB to contract to play
- endBet() : Roll the dice then pay the winners (DOUBLE amount of their bets)
- Others... See the contract
- Please note that this contract is not for gamling purpose (Study purpose only).
- The problem is in the rollTheDice() function.
- The Pseudorandom number generator from this function is NOT safe for gambling.
- Chainlink VRF is the best solution for now. Check out
We made a truffle-project with mostly everything setup. 0. Clone this Project
- Put in your mnemonic phrase into a file named .secret
- Your above wallet must have some BNB to trigger the smart contract deployment. Get some testnet BNB Here
- Install @truffle/hdwallet-provider via:
npm install @truffle/hdwallet-provider
- Run command and wait for magic:
truffle migrate --network bscTestnet
- Get Contract address then move to Web3.js to interact with it.
This is the deployed smart contract from BSC Testnet. Feel free to send it some funds. It's free anyway :P 0x498B0384D00bB9ba49f4eD2C88bc257B110670bc