Giter Club home page Giter Club logo

web3's Introduction

Web3-Full-Stack-Hiring

Hello! If you're reading this, you are definetly checking out the work I have put into this project. To help in your transition, follow the steps below to get up and running with the project. To get you up and running, follow the instructions below to get you started.

Live Demo

Getting Started

  • Clone the repository $ Git clone https://github.com/Eyansky/Web3-Full-Stack-Hiring-private
  • Install node modules $ npm install
  • Run the project npm start
  • Test the solution
    • Can you be able to input an Ethetheum address and have it converted to any currency of your choice?

Project Description

In this repository, you will create a Web3 integration to look up balances in a smart contract known as Dai. Don't worry if you haven't worked with Web3 before, we'll have plenty of examples and guidance!

Dai is a cryptocurrency known as a stablecoin. It's useful for buying goods and services on cryptocurrency networks -- you use it just like you'd use regular money. Because Dai is a stablecoin, the value of Dai fluctuates very little. In this case, you can assume that 1 DAI is always equal to 1 US Dollar. Various wallets hold balances of DAI. For example, this wallet may hold 28,837,952 DAI (which, for the purposes of this exercise, we can assume is $28,837,952 US Dollars). (The value of DAI in the wallet will fluctuate, but the underlying principle remains the same.)

Your task is to use React, the web3.js library or a React wrapper of your choosing, and some form of styling (we use Tailwind internally, but we understand that you might not have used it before) to create an interface that can query a user's DAI balance on the Ethereum blockchain. Your interface should have:

  • An input bar where a user can enter in an Ethereum address
  • A display that shows the DAI balance for the entered Ethereum address

We don't have strong preferences on the styling -- if you are familiar with Bootstrap, Tailwind, or various Gatsby starters, feel free to use those. If you don't have familiarity with existing styling or templates, minimal styling is perfectly fine as well.

Note that Dai does have an official library, but we want you to use web3 directly since that is what you'll use if you work at Syndicate. You can feel free to look at the official library for inspiration, but you should not use it to complete the project.

Primary Task and Optional Additional Tasks

As discussed above, your primary task is to produce an interface that has:

  • An input bar where a user can enter in an Ethereum address
  • A display that shows the DAI balance for the entered Ethereum address. This should be displayed in US Dollars, not wei. This is described in more detail in the Helpful Resources section below.

If you have extra time available, feel free to show off your strengths! You can style the site, cache the most recent input, or implement any of the following features:

  • Displaying the value of DAI in alternative currencies (e.g. the value of DAI when the 1 DAI = $1 US Dollar representation is converted to Euros)
  • Querying USDC in addition to DAI (You would use the erc20.js ABI and the USDC contract addresses found in Dai-Web3-Example.js). This is harder because USDC uses six decimals while DAI uses 18. Decimals are described in more detail in the Helpful Resources section below.

There is no need to complete any of these additional tasks, but you're always welcome to do so if you want to highlight an area of expertise.

Helpful Resources

To query the Ethereum blockchain for the DAI balance, you will want to use web3.js or a React wrapper for it. You will need a gateway to access the Ethereum blockchain (Dai refers to this as a provider and has examples here). You can use any of the following gateways:

  • The Cloudflare Ethereum Gateway. This does not require any API key.
  • An Infura.io gateway. This does require a free API key. The network you'll want is "mainnet".
  • A local Ethereum server using Ganache. We already have one set up in this repository that contains the hiring test for Solidity engineers. You can use this by running npm install -g ganache-cli, npm install, and then npm start.
  • The MetaMask Chrome browser extension, which will automatically provision a gateway for you and make that available to web3.js.

The DAI code is hosted by a smart contract located here. To query it, you will connect to the Ethereum blockchain via a gateway, import the DAI ABI (essentially a file that specifies the available methods) into web3.js, and then use the DAI's balanceOf method with a user's wallet address to query the DAI smart contract.

We know this can be complicated, so we have already put together a complete example of this process using the tests for our Solidity Hiring Test as a reference. Lines 11 - 20 as well as line 8 show a complete example of this process. These lines include all of the steps to query a web3 contract. We've copied this file to the repository and renamed it to Dai-Web3-Example.js. The abi files referenced are in the abi/ directory.

When you query the contract, you'll note that the value of the balance in the DAI contract is a lot higher than the balance listed on Etherscan. This is because the DAI contract is represented in 18 decimals known as wei. You'll want to convert from wei to ether to get the proper units.

web3's People

Contributors

willpapper avatar wairimuian avatar eyansky avatar

Watchers

 avatar Meshack Mbuvi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.