This guide will show you how to deploy a basic decentralized application (dApp) on the Ethereum blockchain using the ethfs-cli tool.
-
MacOS Version 14+, Ubuntu 20.04+, or Windows with WSL2
-
Node.js 17+
-
Create a folder named
dist
. -
Inside
dist
, add two files:-
app.html
with the following content:<html> <head> <script> async function fetchData() { const url = 'web3://0xf14e64285Db115D3711cC5320B37264708A47f89:11155111/greeting'; const response = await fetch(url); const data = await response.text(); document.getElementById('content').textContent = data; } window.onload = fetchData; </script> </head> <body> <div id="content"> Loading greeting... </div> <br> <img src="./degen.jpeg" alt=""> </body> </html>
-
degen.jpeg
(an image file, e.g.,degen.jpeg
).
-
Deploy a simple smart contract on Sepolia
pragma solidity >=0.8.2 <0.9.0;
contract App {
function greeting() public pure returns (string memory) {
return "LFG, Degen!";
}
}
Install ethfs-cli
using npm:
npm i -g ethfs-cli
Create a FlatDirectory on Sepolia:
ethfs-cli create -p <your-private-key> -c 11155111
Upload your application to the FlatDirectory:
ethfs-cli upload -f dist -a <flat-directory-address> -c 11155111 -p <your-private-key> -t 1
Replace with the address from the previous step. This will deploy the files using Ethereum's native storage.
Once deployed, you can access your dApp via a web3 URL:
web3://<flat-directory-address>:11155111/app.html
web3://0x49EDFB27a463545337487D39a8349760B345F160:11155111/app.html
To reduce upload costs using Ethereum's EIP-4844 BLOBs:
Install the eth-blob-uploader tool:
npm i -g eth-blob-uploader
Upload your files using BLOBs:
eth-blob-uploader -r <Sepolia RPC URL> -p <your-private-key> -f dist/app.html -t <any-address>
eth-blob-uploader -r <Sepolia RPC URL> -p <your-private-key> -f dist/degen.jpeg -t <any-address>