Skip to content

Latest commit

 

History

History
131 lines (84 loc) · 6.17 KB

README.md

File metadata and controls

131 lines (84 loc) · 6.17 KB

See this project live

Live & decentralised on Fleek.co(!!!):

Live Kovan testnet version hosted on IPFS & Filecoin click here

Live Kovan testnet version click here

Screen Shot 2021-07-20 at 1 08 25 am

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

Details

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

Framework

Contracts: Truffle, Solidity, Infura, Metamask, Chainlink

Front-end: React, Next (routing, SSR), Web3.

Other npm libs: @truffle/hdwallet-provider, dotenv

Requirements/Dependencies

Node js.

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

Running the App

NB: USE THE DEVELOP BRANCH FOR TESTING > git checkout develop The Main branch has some features specifically for deployment to vercel

  1. Clone the repo git clone https://github.com/DeveloperAlly/Chainlink-Keepers.git - NB: USE THE DEVELOP BRANCH FOR TESTING > git checkout develop
  2. Create a .env file > touch .env
  3. Fill in the .env file with the Infura address and the Metamask seed phrase (as per the .example.env file)
  4. Install dependencies npm install
  5. Deploy the contracts truffle migrate --network kovan
  6. Add the deployed contract addresses to the .env file
  7. Add Link to the contract (to pay for VRF transactions) - 1 Link is enough for 10 rounds
  8. Register the app for Chainlink Keepers here
  9. Run the front end from the develop branch in root folder npm run dev
  10. Navigate to http://localhost:3000 to see the app in action

To Do

  • 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)

Next.js documentation

This is a Next.js project bootstrapped with create-next-app.

Getting Started

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.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

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.

Making this project from Scratch

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

Project Blogposts

  1. Setting up a Solidity / React Project
  2. Building & deploying the Contracts
  3. Building & connecting the Front-end to the contracts