Front-End - https://github.com/SamBorisov/Events-FE
- Marketplace.sol: a proxy factory that deploys a new event contract with specific details and sets the sender of the function as the owner of the new contract.
- Event.sol: saves event details, allows users to buy tickets at a specific price, choose a lucky winner at the end of the event, and allows the owner to withdraw their profit from the sale.
- Install necessary packages:
npm install
- Compile the contracts:
npx hardhat compile
- Set a local node:
npx hardhat node
- Run the tests:
npx hardhat test
- Running Script for One Contract Cycle
- Run the script that covers one contract cycle:
npx hardhat run .\scripts\fullCycle.js
- Install necessary packages:
npm install
- Compile the contracts:
npx hardhat compile
- Set a local node:
npx hardhat node
- Deploy to localhost:
npx hardhat run .\scripts\deploy.js
- Connect your Metamask wallet to localhost (if not set).
- Insert a private key from the Hardhat node with ether to Metamask to interact with the contracts.
- Click the "Balance" button to see your ticket balance. Choose a number for the number of tickets you want to buy and press the "Buy Tickets" button. You can see the current and end time by clicking on the "BTN current and end time". After the sale ends, you can call "Get Lucky Winner" and see the lucky winner's address after it was chosen. (there should be at least 1 bought ticket)
- If you encounter problems with the blocks number (change the network then go again to localhost) or nonce, reset your Metamask account from settings/advanced.