HackFS started with a total bonus of more than 120,000 US dollars, and this project was officially praised
On July 6th, HackFS, the second event in the Filecoin Ignite series, officially started! Juan, the founder of Filecoin, and Vitalik, the founder of ETH, as the judges of this competition, sent a congratulatory message to the conference and invited developers from all over the world to build and showcase their outstanding projects in the event.
HackFS is a 30-day virtual hackathon aimed at laying the groundwork for the decentralized web. Developers will build dapps, games, dev tools, DeFi integrations, and other tricks to leverage distributed storage. It is reported that the bonus of this event exceeds 120,000 US dollars, which is exciting!
introduce
introduce
Storage on Ethereum is expensive. Usually, you don't need to put files directly on Ethereum. You can store the file elsewhere and provide a reference to it in the smart contract. However, your censorship resistance is the weakest link!
IPFS is a protocol for storing and retrieving files in a distributed network. A central server that no one can shut down, where anyone can store files and participate. Files stored in IPFS are addressable by hash content, so if a file changes, the address of that file will also change.
secondary title
prerequisite
You will need NodeJS >= 10, Yarn and Git installed.
secondary title
Getting started
Open a terminal and clone the scaffold-eth repo. This contains everything we need for prototyping and building decentralized applications:
git clone https://github.com/austintgriffith/scaffold-ethhackfs
cd hackfs
git checkout ipfs-example
yarn install
Note that you may get warnings like this error when running yarn install continue on and running the next three commands. It might work!
Open the code locally in your favorite editor, and check it out:
In packages/buidler/contracts you will find Attestor.sol. This is our smart contract (backend).
In packages/react-app/src is App.js which is our web application (front end).
Start your frontend: yarn start
Note that if you don't run the following two lines, the CPU will be stretched to the limit. In the second terminal, start the local blockchain powered by 👷Buidler: yarn run chain
In a third terminal, compile and deploy the Attestor contract: yarn run deploy
front end
front end
Open http://localhost:3000 in a web browser:
the code
the code
The code used to send files to IPFS is very simple. You'll find the following in App.js in the file we brought into the ipfs-client packages/react-app/src:
const ipfsAPI = require('ipfs-http-client');
Then, we connect via Infura:
const ipfs = ipfsAPI({host:'ipfs.infura.io',port:'5001',protocol:'https'})
To get a file from IPFS use:
ipfs.get(hashToGet)
blockchain
ipfs.add(fileToUpload)
blockchain
Time to write your IPFS hash to Ethereum, we have contracts in packages/buidler/contracts at Attestor.sol:
As you can see, the contract is very simple. There is a function attest that accepts a hash. This hash will be saved in memory at the given address and the event will also be fired. (Depending on your use case, you may only want to fire an event, since it's much cheaper than storing data on-chain.)
in conclusion
tx(writeContracts [“ Attestor”]。attest(ipfsHash))
in conclusion
That's the TL;DR. You'll have to dig into the code to find out more, but this sample dapp should get you started! Ethereum + IPFS can build many great applications, welcome to leave a message to express your thoughts💬. We started a Scaffold-ETH & IPFS HackFS support chat, welcome to join us!


