A decentralized application (dApp) that allows users to timestamp documents on the Ethereum blockchain (Sepolia Testnet).
- Client-Side Hashing: Files are hashed in the browser using the Web Crypto API. The file itself never leaves your device.
- Immutable Proof: The SHA-256 hash is registered on-chain with the owner's address and timestamp.
- Verification: Anyone can verify a document's existence and registration details by re-uploading the file or providing its hash.
- Node.js (v18 or later)
- MetaMask browser extension
-
Clone & Install
git clone <repo-url> cd onchain-doc-proof npm install cd web npm install cd ..
-
Configure Environment
- Copy
.env.exampleto.envin the root directory. - Fill in your
RPC_URL(e.g., from Infura or Alchemy) andPRIVATE_KEY(account to deploy contract).
cp .env.example .env
- Copy
-
Deploy Smart Contract
npx hardhat run scripts/deploy.ts --network sepolia
Copy the deployed contract address from the output.
-
Configure Frontend
- Copy
web/.env.local.exampletoweb/.env.local. - Paste the contract address.
cd web cp .env.local.example .env.local # Edit .env.local and set NEXT_PUBLIC_CONTRACT_ADDRESS
- Copy
-
Run the App
npm run dev
Open http://localhost:3000.
- Open App: Show the "Connect MetaMask" button. Click it and connect your wallet (Sepolia network).
- Upload: Select a file (e.g., an image or PDF). Show the computed SHA-256 hash appearing instantly.
- Register: Click "Register On-Chain". Confirm the transaction in MetaMask.
- Wait: While waiting, explain that only the hash is sent to the chain, preserving privacy.
- Success: Point out the transaction hash link (or toaster notification).
- Verify: Refresh the page or go to the "Verify" section.
- Upload the same file again.
- Click "Verify".
- Show the "✅ Document Found" method with your address and timestamp.
- (Optional) Modify the file slightly, upload, and show it returns "❌ Not Found".
- Privacy: We only store the
bytes32SHA-256 hash. The original file contents are NOT stored on-chain or sent to any server. - Collisions: We assume SHA-256 creates unique hashes for distinct documents.
- Identity: The "owner" is simply the wallet that sent the transaction. It proves possession of the file at that time, but not necessarily authorship.