Infura: Build dApp Frontends with Infura, React, and IPFS
Learn how to build dApp Frontends with Infura, React, and IPFS
Last updated
Learn how to build dApp Frontends with Infura, React, and IPFS
Last updated
Infura is a blockchain development platform that enables developers to create decentralized application projects and connect them to different blockchain networks such as the Ethereum and Polygon networks.
Read below to learn how to build dApp Frontends with Infura, React, and IPFS.
To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
mkdir dapp-project && cd dapp-project
npm init -y
npm install @openzeppelin/network
npm -g install create-react-app
create-react-app
:npx create-react-app client
create-react-app client
command, and open the src/App.js
file.Replace the placeholder code with the following content:
Replace INFURA_PROJECT_ID with the Infura project ID you previously took note of.
npm start
command while within the ./client
directory of your project.Your browser will open a new window at localhost:3000
displaying your dApp.
./client/src
directory, create a new directory called components, and inside that directory create a file called Web3Data.js
with the following content:./client/src/App.js
file and replace the existing content with the following code, which includes a new function to use the Web3Data.js
script we just created:Your browser will open the localhost:3000
webpage again, this time with a new piece of code that includes a ‘Request Access’ button. Clicking this button will trigger the Metamask plugin to request authentication with the webpage. Choose the ‘Connect’ option in the Metamask plugin, then view the localhost:3000
webpage that will reflect your Metamask address:
.css
file and image files.To do this, we’ll use files stored on IPFS. Head back to your Filebase IPFS bucket that we created at the start of this tutorial. Select the ‘Upload’ option.
Take note of the IPFS CID for each, listed in the CID column seen above.
Replace CSS_THEME_IPFS_CID with the CID associated with your uploaded CSS theme, and replace IMAGE_IPFS_CID with the CID associated with your uploaded file.
Restart your app to see your changes reflected in the browser. From here, you can style your dApp however you’d like, and set up additional features such as an NFT marketplace, or create a dApp that uses wallet authentication for logging into the app. The possibilities are endless!