A blockchain-backed file storage application built with Solidity smart contracts, Hardhat for development, and React for the frontend. Files are stored on IPFS via Pinata, with metadata tracked on-chain.
- Upload files to IPFS through Pinata
- Store file metadata on Ethereum blockchain
- Retrieve and display uploaded files
- Local blockchain testing with Hardhat
- Node.js (v16 or higher)
- npm or yarn
- Git
- MetaMask (for interacting with the deployed contracts)
git clone https://github.com/yourusername/file-storage-system.git
cd file-storage-system# Install root dependencies
npm install
# Install client dependencies
cd client
npm installCreate a .env file in the project root:
API_URL=https://eth-sepolia.g.alchemy.com/v2/your-api-key
PRIVATE_KEY=your-wallet-private-keyCreate a .env file in the client directory:
REACT_APP_PINATA_API_KEY=your_pinata_api_key
REACT_APP_PINATA_SECRET_API_KEY=your_pinata_secret_keySecurity Warning: Never commit
.envfiles to version control. Add them to.gitignore.
In one terminal window:
cd client
npx hardhat nodeThis starts a local Ethereum node at http://127.0.0.1:8545/
In another terminal window:
cd client
npx hardhat run scripts/deploy.js --network localhostCopy the deployed contract address from the output.
cd client
npm startThe app will open at http://localhost:3000
file-storage-system/
├── client/
│ ├── contracts/ # Solidity smart contracts
│ ├── scripts/ # Deployment scripts
│ ├── src/ # React application source
│ ├── hardhat.config.js # Hardhat configuration
│ └── package.json
├── .gitignore
├── package.json
└── README.md
| Variable | Location | Description |
|---|---|---|
API_URL |
Root .env |
Alchemy or Infura RPC URL |
PRIVATE_KEY |
Root .env |
Wallet private key for deployment |
REACT_APP_PINATA_API_KEY |
client/.env |
Pinata API key |
REACT_APP_PINATA_SECRET_API_KEY |
client/.env |
Pinata secret key |
- Add
.envfiles to.gitignore - Use
.env.examplefiles for templates - Never hardcode secrets in source code
REACT_APP_*variables are exposed in the browser bundle- For production, use a backend proxy for sensitive API operations
Run smart contract tests:
cd client
npx hardhat test- Ensure you have testnet ETH in your wallet
- Configure
API_URLin.envwith your Alchemy/Infura endpoint - Deploy:
cd client
npx hardhat run scripts/deploy.js --network sepoliaThe React app can be deployed to:
- Vercel:
vercel deploy - Netlify:
netlify deploy - GitHub Pages: Configure in
package.json
Remember to set environment variables in your hosting platform's dashboard.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hardhat - Ethereum development environment
- Pinata - IPFS pinning service
- OpenZeppelin - Secure smart contract libraries