A lightweight, blockchain-backed stopwatch with a minimal UI and React hook.
Interact with an on-chain stopwatch smart contract that provides verifiable, decentralized timing using the Flare Coston2 network.
**Address:** `0xE6e88A039449918a1E617a7Ec190E5C681a4Ab83`
**Explorer:** https://coston2-explorer.flare.network/address/0xE6e88A039449918a1E617a7Ec190E5C681a4Ab83
This project includes a basic frontend and a React hook for interacting with a deployed on-chain stopwatch smart contract.
It demonstrates how to:
- Connect a wallet using Wagmi
- Read on-chain stopwatch state
- Start, stop, and reset the stopwatch
- Handle transactions and real-time updates
It is ideal for:
- Developer demos
- Learning on-chain time concepts
- Integrating decentralized time tracking
- Demonstrating contract → UI interactions
| File | Purpose |
|---|---|
lib/contract.ts |
Contract address + ABI (viem/wagmi compatible) |
hooks/useContract.ts |
React hook that wraps reads & writes |
components/sample.tsx |
Minimal UI demonstrating functionality |
- Requires wallet connection
- Seamlessly uses Wagmi connectors
elapsedTime— total elapsed seconds (formatted in UI)isRunning— current running/stopped statestartTime— timestamp the stopwatch last startedgetCurrentTime()— latest chain timestamp
start()— starts the stopwatchstop()— stops and records elapsed timereset()— clears stopwatch values
- Displays pending → confirming → confirmed states
- Shows transaction hash
- Handles errors gracefully
- Auto-refresh and manual refresh support
- Minimal design
- Clear button states
- Great for demos and prototyping
Most apps rely on centralized clocks that can’t be independently verified.
This stopwatch uses on-chain timestamps, enabling:
- Decentralized timing — trustless and validated by blockchain consensus
- Auditability — every action is on the public ledger
- Verifiability — elapsed time is provable
- Stateless frontend — all real data lives on-chain
- On-chain contests or games
- Timed auctions
- Educational Web3 demos
- Immutable time-based logging
- Process tracking
- Smart contract time experiments
- Built using Wagmi + viem for contract communication
- Uses:
useReadContractuseWriteContractuseWaitForTransactionReceipt
- UI formats timestamps to:
HH:MM:SS- ISO date formats
- No application-level state — blockchain is the source of truth
- Set up a React project (Vite, Next.js, or CRA).
- Install and configure Wagmi + Viem.
- Add the following files to your project:
lib/contract.tshooks/useContract.tscomponents/sample.tsx
- Import and render the component:
<StopwatchSample />