Coder Social home page Coder Social logo

shanzson / erc-721-and-ipfs-dapp Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 2.12 MB

This is a simple IPFS Dapp that allows minting of NFTs by simply uploading the files. And files are automatically stored on IPFS.

JavaScript 77.67% HTML 10.85% CSS 0.14% Solidity 11.34%
nft ethereum solidity erc-721 file-upload minting blockchain ipfs

erc-721-and-ipfs-dapp's Introduction

ERC-721 NFT on IPFS Dapp

This is a Dapp that uploads files on IPFS and mints its corresponding NFT of ERC-721 standard on Blockchain.

Quickstart

Run the following command to install npm dependencies

npm install

Now run the Ganache-cli with the following command

ganache-cli

To sign the transactions, you will need to connect your Metamask wallet with Ganache-cli. From the accounts created by Ganache in the terminal, copy the private key of the first account, go to your metamask wallet, click on import new account and paste the private key. Your account will be successfully imported and you will have 100 Eth in your wallet!

Now deploy the project to your local blockchain using the following commands-

truffle compile
truffle migrate --reset

To start the React client run this command-

npm run start

How to Mint your First NFT?

After you have succesfully run the above commands, you will be ready to mint your first NFT. Choose any file and click on Submit Query. If the file is visible in the React frontend then you have successfully minted your first NFT!

How does it work?

When you upload your image to the application, the file gets uploaded to the IPFS via ipfsClient using the ipfs.addAll() method in App.js. You can read more about this here. The IPFS then returns an object containing the path to the file which is also referred to as IPFS hash. You can get your file from IPFS using the same hash. We have used Infura API here, so you will find the file at https://ipfs.infura.io/ipfs/$ (just replace the IPFS path with $ here).

In this Dapp, IPFS hash of NFT is set using the set() function that is called during the minting of NFT using awardItem() function in File.sol. After minting the NFT, the Frontend loads the image of the NFT from the Blockchain using the get() function in File.sol. You can check if its working correctly by refreshing the page after uploading the file. The image should still be there as it is getting loaded from the Blockchain directly.

References

erc-721-and-ipfs-dapp's People

Contributors

shanzson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jesse-21

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.