Live & decentralised on Fleek.co(!!!):
Live Kovan testnet version hosted on IPFS & Filecoin click here
Live Kovan testnet version click here
NB: There is some bug with the Keeper. I'm not sure what - maybe an update to how they work since I created this contract, or my I've changed something, or... I need some time to check it out. :P
This app builds and deploys 2 solidity contracts - one is used for the pricefeed ticker displayed at the bottom of the page. The other is a raffle 'lottery' (A raffle is a competition in which people buy tickets, each of which has the chance of winning a prize. At a set condition or time, the winner(s) are drawn at random).
The PriceFeed contract uses Chainlink Price Feeds to get the latest price of an asset. The Raffle Contract uses Chainlink VRF for a verifiably random winner draw. It also uses Chainlink Keepers to tigger an automatic draw once a set number of players has been reached (default is 3).
The frontend uses Next JS, React and Web3 to interact with the blockchain contracts.
This project was built for a presentation so you can take a gander (look at) the presentation slides used in this repo also
Contracts: Truffle, Solidity, Infura, Metamask, Chainlink
Front-end: React, Next (routing, SSR), Web3.
Other npm libs: @truffle/hdwallet-provider, dotenv
Infura Account => Set up guide.
Metamask Wallet => NB: USE A FRESH WALLET WITH NO REAL VALUABLE ASSETS ON IT (test only) AND KEEP YOUR SEED PHRASE HANDY (we need this to deploy the solidity contracts).
Truffle => install using npm command.
npm install -g truffle
Kovan Testnet Link & Eth Tokens Faucet
NB: USE THE DEVELOP BRANCH FOR TESTING > git checkout develop The Main branch has some features specifically for deployment to vercel
- Clone the repo
git clone https://github.com/DeveloperAlly/Chainlink-Keepers.git
- NB: USE THE DEVELOP BRANCH FOR TESTING > git checkout develop - Create a .env file
> touch .env
- Fill in the .env file with the Infura address and the Metamask seed phrase (as per the .example.env file)
- Install dependencies
npm install
- Deploy the contracts
truffle migrate --network kovan
- Add the deployed contract addresses to the .env file
- Add Link to the contract (to pay for VRF transactions) - 1 Link is enough for 10 rounds
- Register the app for Chainlink Keepers here
- Run the front end from the develop branch in root folder
npm run dev
- Navigate to http://localhost:3000 to see the app in action
- Fix front end quirks
- Add Autofill of Link to the Keeper function (for both the Keeper upkeep and the VRF contract upkeep)
- Clear messages after time elapsed (would prefer a toast module tbh)
This is a Next.js project bootstrapped with create-next-app
.
First, run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
npx creat-next-app cd [name of project] truffle init (contracts) npm install dotenv @truffle/hdwallet-provider @chainlink/contracts (frontend) npm install web3 (testing) npm install mocha make .env file truffle.config setup Fund your wallet (contract deployer) with test eth and link (link to rinkeby and kovan faucets) create your contracts create your migration file in /migrations/2_deploy_migrations.js compile your contract > truffle compile Deploy your contracts > truffle migrate --network kovan Put deployed address in .env file Register with Chainlink Keeper Network (https://docs.chain.link/docs/chainlink-keepers/register-upkeep/) Frontend config web3 provider -> create web3.js under pages/api Create ChainlinkKeeper.js under pages/api
- Setting up a Solidity / React Project
- Building & deploying the Contracts
- Building & connecting the Front-end to the contracts