The Lottery Smart Contract is a decentralized application (DApp) built on the PChain blockchain. It allows participants to purchase lottery tickets and have a chance to win the total prize. The contract randomly selects a winner when the number of participants reaches the targeted number.
- Participants can enter the lottery by purchasing a ticket.
- The contract ensures that participants have sent the correct ticket price.
- The total prize increases with each ticket purchase.
- When the number of participants reaches the targeted number, the contract conducts the lottery and selects a random winner.
- The winner receives the total prize amount.
- The contract resets for the next lottery round.
To deploy and interact with the Lottery Smart Contract, follow these steps:
- Install the required dependencies and set up the development environment.
- Deploy the smart contract on the PChain blockchain.
- Interact with the deployed contract by calling the
execute
method.
-
Initialize the contract by calling the
new
method:- Set the ticket price (in XPLL).
- Set the targeted number of participants.
-
Participants can enter the lottery by calling the
execute
method:- Ensure the ticket price is sent along with the transaction.
- The participant's address will be automatically recorded.
- The total prize will increase by the ticket price.
-
Once the number of participants reaches the targeted number:
- The contract will conduct the lottery and select a random winner.
- The total prize amount will be transferred to the winner's address.
- The contract will reset for the next lottery round.
To contribute to the Lottery Smart Contract development, follow these steps:
- Clone the repository and navigate to the project directory.
- Install the required dependencies.
- Make changes and add new features.
- Run tests to ensure the contract functions correctly.
- Submit a pull request with your changes.
The smart contract includes unit tests to verify its functionality. To run the tests:
- Set up the development environment and install dependencies.
- Run the test suite using the provided testing framework.
- Check the test results to ensure all tests pass successfully.
The Lottery Smart Contract is open-source and distributed under the MIT License.
For any questions or inquiries, please contact [email protected].