ShakeOnIt is a decentralized application (dApp) that facilitates the creation and management of bets between users. Create a friendly bet between friends, or accept any bets that are still open on the platform.
The project is divided into several smart contracts, each responsible for a specific aspect of the system. Below is a detailed explanation of each contract and its purpose.
The DataCenter contract acts as the central information hub for the ShakeOnIt system. Use it to get the current User and Bet Management contracts.
Key Functions:
getMultiSig(): Returns the multi-signature wallet address. (lol stop watching my pockets, yo)getUserStorage: Returns the address of a user'sUserStoragecontract.getUserManagement(): Returns the address of theUserManagementcontract.getBetManagement(): Returns the address of theBetManagementcontract.
The UserManagement contract handles the registration and management of users within the ShakeOnIt system. It ensures that each user has a corresponding UserStorage contract to store their bets.
Key Functions:
register(string username, address betManagement): Registers a new user and creates aUserStoragecontract for them.getUserStorage(address _user): Returns the address of the user'sUserStoragecontract.getUsers(): Returns a list of all registered users.
The BetManagement contract handles the creation and management of bets. It stores the details of each bet and ensures that all bets are properly tracked and managed.
Key Functions:
deployBet(address _token, UserDetails memory _initiator, UserDetails memory _arbiter, uint256 _stake,uint256 _arbiterFee, uint256 _platformFee, uint256 _payout, string memory _condition): Creates a newBetand stores it in the user'sUserStoragecontract.
The UserStorage contract is deployed for each user and stores the details of all bets they are involved in. It ensures that users can easily track their betting history.
Key Functions:
addBet(address _bet): Adds a new bet to the user's storage.getBets(): Returns a list of all bets stored in the contract.grantApproval(address _token, address _spender, uint256 _amount): Grants the_spenderthe ability to spend_amountfrom yourUserStoragecontract. You will need to call this to grant theBetManagementin order to create a bet.
The Bet.sol contract is created by calling the deployBet() function in the bet management contract. This contract is in charge of all bet functionality.
Key Functions
acceptBet()
stateDiagram-v2
[*] --> INITIATED: deployBet()
INITIATED --> FUNDED: acceptBet()
FUNDED --> WON: declareWinner()
WON --> SETTLED: withdrawEarnings()
INITIATED --> CANCELLED: cancelBet()
- User Management Contract:
0x7f68AAE9C9cB52E4689763F9Ef2c859778578230 - Bet Management contract:
0x021b140B5F931237eD6934B539dE57c111584754 - Data Center contract:
0x934726B886D24fdD98701aF57BedcBCd137870FF - Vbux contract:
0x9D2A5b0B86a630333eBC02E3cd080Dc60Fe583F9
graph TD
subgraph Bet Creation
A((Initiator)) -->|1. Deposit| B[UserStorage]
A -->|2. Approve| C[BetManagement]
B -->|3. Transfer| C
C -->|4. Deploy| D[New Bet]
D -->|5. Store| E[DataCenter]
end
subgraph Bet Acceptance
F((Acceptor)) -->|6. Deposit| G[UserStorage]
F -->|7. Approve| C
G -->|8. Transfer| D
D -->|9. Update| E
end
subgraph Resolution
H((Arbiter)) -->|10. Declare| D
D -->|11. Transfer| Winner
D -->|12. Fee| H
D -->|13. Platform Fee| MultiSig
end
style A fill:#98FB98,stroke:#333,stroke-width:2px
style F fill:#98FB98,stroke:#333,stroke-width:2px
style H fill:#FFA500,stroke:#333,stroke-width:2px
style B,G fill:#87CEEB,stroke:#333,stroke-width:2px
style C fill:#87CEEB,stroke:#333,stroke-width:2px
style D fill:#DDA0DD,stroke:#333,stroke-width:2px
style E fill:#FFB6C1,stroke:#333,stroke-width:2px