This is a smart contract which was written to distribute the winners rewards based on the betting games like rock,paper and scissors or a cup game which is played by the users in the front-end.
It was created using OpenZeppline by inheriting Ownable contract.
The main working of the smart contract lies that the user would bet some amount when he creates a bet with the another user . Once the second user joins the room in the front-end the room would be locked and both users would pay the betting amount which was created by the first user to the escort smart contract . As soon as the game completed the backend team would send the winners address to the escort smart contract . The contract verifies the winner and would validates the address between both users and cut 2% service fee from the final bet amount. The final amount after the service fee deduction would be sent to the winner of the game.
- Deposit the funds in order to play the game .
- Withdraw the funds in case the second user got disconnected .
- Claim the rewards if you win the game .
- Can set the service fee percentage as per his convineance .
- Could directly with draw the funds from the escort smart contract.
- Can check the current balance in the escort smart contract.
Polygon Mumbai deployment :
- Java script
- Hardhat configuration.
- A free Infura Project Id key for Polygon mumbai testnet.
- Polygonscan of mumbai net url
- A private key of the meta mask account
Clone the repo:
git clone https://github.com/mohindar99/Money_Betting.git
cd Money_Betting
- We are compiling the smart contract to get the ABI in order to interact with the smart contract after deployment.
- Run the command
npx hardhat compile
- The polygon mumbai test net is not a default network which is present by default.
- We need to add it manually to the meta mask in order to deploy in it .
- Follow the steps as per this LINK in order to configure the network to the metamask
- The tests might succeed or fail based on the smart contract functionalities.
- To run the tests locally we might need mocha and chai frame works in the Hardhat.
- Once the test script is done . Run the command :
npx hardhat test
-
Add a
.env
file with the same contents of.env.example
,but replaced with your variables. -
Run the command :
npx hardhat run scripts/deploy.js --network mumbai
The script will :
- It would deploy the smart contract of the game with a default service fee of 2% in the polygon mumbai test net.
- We need to verify the contract in the polygonscan.mumbai
- In order to verify we need to go to the polygonscan.mumbai .
- The smart contract need to be flattened in order to match with the bytecode which was generated while deploying with the present one.
- The compiler version need to be matched so that the final verification is done and to display the smart contract in the polygonscan.
- With this we can directly interact with the smart contract from the polygonscan if we are a valid user.
- The smart contract is deployed in the polygonscan.mumbai with the address of
0x798c6D8df7ef7d50f2402e00F84a166fdd95faf8
- As it is verified you can directly interact with the contract for better understanding .
If it was helpful please consider donating:
0x0997650B553D83B9433c3bEe8669Ff413Be03196