A standalone web application for interacting with the Miden Counter smart contract on Miden.xyz by Heimlabs.com.
This Next.js application provides a clean, focused interface for incrementing and viewing a counter stored on the Miden rollup. It demonstrates how to interact with Miden smart contracts through a modern web application using the Miden SDK and wallet adapter.
- Wallet Integration: Connect Miden-compatible wallets
- Counter Display: Real-time display of current counter value
- Increment Functionality: Increment the counter with transaction confirmation
- Transaction Tracking: View transaction details on MidenScan
- Responsive Design: Modern UI built with Tailwind CSS
- Node.js 18+
- Yarn package manager
- A Miden-compatible wallet (for incrementing the counter)
-
Navigate to the counter app directory:
cd webapp/counter -
Install dependencies:
yarn install
-
Start the development server:
yarn dev
-
Open http://localhost:3000 to view the application.
- Click the "Connect Wallet" button
- Select your Miden-compatible wallet
- Approve the connection
- Ensure your wallet is connected
- Click the "Increment" button
- Approve the transaction in your wallet
- View the transaction confirmation and updated counter value
- Click the transaction link to view details on MidenScan
- The counter value updates automatically after each successful transaction
The application is configured to work with a deployed Counter contract. Key settings can be found in app/constants.ts:
- Contract Address:
mtst1arjemrxne8lj5qz4mg9c8mtyxg954483 - Network: Miden Testnet
- RPC Endpoint:
https://rpc.testnet.miden.io
counter/
├── app/
│ ├── components/
│ │ └── WalletProviders.tsx # Wallet connection providers
│ ├── constants.ts # Contract addresses and configuration
│ ├── utils.ts # Utility functions for contract interactions
│ ├── page.tsx # Main counter interface
│ ├── layout.tsx # App layout and providers
│ └── globals.css # Global styles
├── package.json # Dependencies and scripts
├── tailwind.config.js # Tailwind CSS configuration
└── next.config.ts # Next.js configuration
yarn dev- Start development serveryarn build- Build for productionyarn start- Start production serveryarn lint- Run ESLint
- Components: Reusable UI components
- Utils: Contract interaction utilities (DRY principle)
- Constants: Configuration values (contract addresses, endpoints)
- Pages: Route-specific components
The app integrates with the Counter contract deployed using the contracts in ../../contracts/. To use a different contract:
- Deploy a new contract using the contracts setup
- Update
COUNTER_CONTRACT_ADDRESSinapp/constants.ts - Update
COUNTER_CONTRACT_CODEif the contract interface changes
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Blockchain: Miden SDK (@demox-labs/miden-sdk)
- Wallets: Miden Wallet Adapter (@demox-labs/miden-wallet-adapter)
- State Management: React hooks
- Connect your repository to Vercel
- Deploy automatically on push to main branch
- Environment variables can be configured in Vercel dashboard
yarn build
yarn startSee contributing.md for contribution guidelines, including Markdown formatting with Prettier.
This counter app is designed to work with contracts deployed using the companion contracts setup in ../../contracts/. The contract ID obtained from running the deployment script should be used in the constants file.