Create a lean, user-friendly application that lets users safely wager varying amounts of ether by relying on randomness provided via Chainlink VRF and the proven security Ethereum provides as a platform
- Create, deploy, and test Ethereum smart contracts to local, test, and mainnet
- Make use of Oracles to fetch off-chain data
- Seamlessly connect smart contracts to front-ends built in React
- Ethereum Development Environment: Hardhat
- Web Client Library: ethers.js
- Blockhain Gateway and Wallet: Metamask
- Testing: Chai
- Front-End: React
- Smart Contract Language: Solidity
- Oracle: Chainlink VRF
- Smart Contract Security Analysis: Consensys MythX
- Clone this repository
git clone https://github.com/JaredBorders/2X
- Install the dependencies
yarn
- Create a .env file in the root directory of your project. Add these environment-specific variables on new lines in the form of NAME=VALUE:
- PRIVATE_KEY={YOUR_KEY_FROM_METAMASK}
- INFURA_KOVAN_NETWORK={SEE_HERE}
- Deploy the contract (WagerFactory) to the Kovan network.
npx hardhat run scripts/deploy.js --network kovan
-
Once the script finishes deploying the WagerFactory, it will log the address of where the contract was deployed to. Update src/pages/Splash.js with this value. (see
wagerFactoryAddress
) -
Add LINK token to the RandomNumberConsumer contract. (The public state variable stored in the WagerFactory (
randomNumberConsumerAddress
) records the address of the RandomNumberConsumer contract) -
Run the app
yarn start
- Any changes made to any of the contracts will require you to recompile them. To recompile
npx hardhat compile
- Don't forget to update src/pages/Splash.js with the current address if you redeploy your WagerFactory!
- Copy the WagerFactory address logged after running the deploy script
npx hardhat run scripts/deploy.js --network kovan
npx hardhat console --network kovan
const Factory = await ethers.getContractFactory("WagerFactory")
const factory = await Factory.attach("ADDRESS_LOGGED_FROM_DEPLOY_SCRIPT")
await factory.randomNumberConsumerAddress()
- After getting LINK from a faucet, send it to the address
factory.randomNumberConsumerAddress()
returns
- After wager has expired, automatically send eth back to wagerer. (May be problematic given that it costs gas to both create & remove wager)
- Further contract testing is always welcome
Read this guide first, check TODO list, and don't hesitate to reach out!