Skip to content

divyat2605/Smart-Wallet-Connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lottery Smart Contract

This is a simple lottery smart contract written in Solidity. It allows users to participate in a lottery by sending Ether, and the manager can pick a random winner from the participants.

Features

  • Users can participate in the lottery by sending exactly 1 Ether.
  • The manager can pick a winner from the participants.
  • The winner receives the entire balance of the contract.
  • The list of participants is reset after each lottery round.
  • Emits an event when a winner is picked for transparency.

Installation

To deploy and interact with this contract, you need to have the following tools installed:

  1. Node.js: Download and install Node.js from nodejs.org.
  2. Truffle: Install Truffle globally using npm:
    npm install -g truffle
  3. Ganache: Download Ganache from trufflesuite.com/ganache for local blockchain development.

Usage

  1. Clone this repository:

    git clone https://github.com/divyat2605/Smart-Wallet-Connect.git
    cd lottery-smart-contract
  2. Compile the smart contract:

    truffle compile
  3. Deploy the smart contract to a local blockchain (e.g., Ganache):

    truffle migrate
  4. Interact with the contract using Truffle Console:

    truffle console
  5. In the console, you can call functions like participate, pickWinner, etc.

Contract Functions

constructor()

Initializes the contract and sets the manager to the address that deploys it.

function participate() public payable

Allows users to participate in the lottery by sending exactly 1 Ether.

function getBalance() public view returns (uint)

Returns the current balance of the contract (only callable by the manager).

function random() internal view returns (uint)

Generates a pseudo-random number based on block properties.

function pickWinner() public

Allows the manager to pick a winner from the participants and transfer the balance to them.

Security Considerations

  • The randomness generation method used in this contract (block.prevrandao) is not secure against manipulation by miners. For production use, consider integrating Chainlink VRF for secure randomness.
  • Ensure proper testing on test networks before deploying to mainnet.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.


### Instructions for Use

1. Replace `yourusername` in the clone URL with your actual GitHub username.
2. Save this content into a file named `README.md` in your project directory.
3. You may want to customize sections or add additional information as needed.

This README provides a comprehensive overview of your Lottery smart contract project, making it easier for others to understand and use! If you need further modifications or additions, feel free to ask!

About

A Solidity-based Lottery Smart Contract that enables users to enter a decentralized lottery by sending Ether, with a manager-controlled winner selection system. Built for Ethereum blockchain development using Truffle and Ganache, featuring event logging, participant management, and automated fund distribution.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors