Blockchain Drive stores file content on IPFS and stores permissions and quota state on an Ethereum smart contract. These two systems complement each other: IPFS gives you immutable, content-addressed storage where the same bytes always produce the same identifier, and Ethereum gives you a tamper-proof ledger where every permission grant and quota change is permanently recorded. The Express backend sits between them, coordinating uploads, enforcing access rules, and deciding how strictly each layer is enforced based on your environment configuration.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ankit-bista/Final-Project/llms.txt
Use this file to discover all available pages before exploring further.
IPFS: content-addressed file storage
When you upload a file, the backend sends the raw buffer to the Kubo daemon via its HTTP API. Kubo computes a content identifier (CID) — a cryptographic hash of the file’s bytes — and pins the file to the local node. The CID is stored in the database asipfs_hash and is also passed to the smart contract as the fileId. Because the CID is derived from content, the same file always produces the same CID, and any modification produces a different one.
services/ipfsService.js
IPFS_GATEWAY_URL to the address of your gateway (for example http://127.0.0.1:5002). The backend constructs gateway URLs in the form IPFS_GATEWAY_URL/ipfs/<cid>.
If the Kubo daemon is not running, uploads will fail with an
IPFS_UNAVAILABLE error. Start the daemon with ipfs daemon and verify IPFS_API_URL matches the API port shown in ipfs config show.Ethereum: on-chain permissions and quota
TheBlockchainDriveUnified smart contract is the authoritative source of truth for two concerns:
- Storage quota — how many bytes each wallet address is allowed to use, how much has been consumed, and whether an upload should be permitted.
- File permissions — who can access which file and with what role (
vieweroreditor).
FileRecorded when a file is uploaded, FileShared when access is granted, AccessRevoked when access is removed, QuotaUpdated after each upload, and QuotaRefunded after a deletion. These events form an immutable audit trail.
Hybrid permission model
The backend uses a hybrid approach that combines on-chain contract checks with database RBAC. When a user requests access to a file, the permission service first callscanUserAccessFile on the contract. If the contract returns true, access is granted. If the contract returns false or is unreachable, the behavior depends on ENFORCE_CONTRACT_PERMISSIONS.
services/permissionService.js
| Variable | Effect when true |
|---|---|
ENFORCE_QUOTA_ON_UPLOAD | Blocks the upload when the on-chain quota check fails |
ENFORCE_CONTRACT_PERMISSIONS | Denies access when the contract check fails; no fallback to DB RBAC |
ENFORCE_CONTRACT_SHARING | Writes the DB share record only if the contract shareFile call succeeds |
false so the app works in prototype mode without a live contract.
Mock vs. real contract mode
SetUSE_REAL_CONTRACTS=true to connect to a real Ethereum network. When this variable is false (the default), the BlockchainService operates in mock mode: quota checks always return success, permission checks always return true, and share/revoke calls are no-ops. The system still sends lightweight transactions to a local Hardhat node to simulate block formation, so the development experience mirrors production without requiring a deployed contract.
services/blockchain.js
GET /blockchain/status. The response includes all six relevant environment variable values.
How the layers interact
Smart contracts
Function signatures, structs, events, and deployment instructions for
BlockchainDriveUnified.Quota management
How storage quota is allocated, tracked on-chain, and enforced during uploads.