A modern decentralized application built on Base blockchain using Reown AppKit (formerly WalletConnect) for seamless wallet integration. This project demonstrates smart contract interaction with a simple counter contract deployed on Base mainnet.
- Base Blockchain Integration - Built specifically for the Base ecosystem
- Reown AppKit - Modern wallet connection using WalletConnect v2
- Smart Contract Interaction - Deploy and interact with counter contracts
- Next.js 15 - Latest React framework with App Router
- TypeScript - Full type safety throughout the application
- Wagmi v2 - React hooks for Ethereum
- Viem - TypeScript interface for Ethereum
- Frontend: Next.js 15, React 19, TypeScript
- Blockchain: Base (Ethereum L2)
- Wallet: Reown AppKit (WalletConnect v2)
- Smart Contracts: Solidity, Foundry
- Web3: Wagmi v2, Viem
- Styling: CSS Modules
- Node.js 18+
- npm, yarn, pnpm, or bun
- Git
- A Reown project ID (get one at dashboard.reown.com)
git clone https://github.com/anastlaaaf/base-contract.git
cd base-contractnpm install
# or
yarn install
# or
pnpm install
# or
bun installCreate a .env.local file in the root directory:
# Get your project ID from https://dashboard.reown.com
NEXT_PUBLIC_PROJECT_ID=your_project_id_here
# Optional: Project name for metadata
NEXT_PUBLIC_PROJECT_NAME=Base Counter dAppnpm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 to see the application.
The project includes a simple counter contract deployed on Base mainnet:
Contract Address: 0x349cBCdd020c52485A0683ba65199e975964e2aD
number()- View function to get current countincrement()- Function to increment the counter by 1
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract Counter {
uint256 public number;
function setNumber(uint256 newNumber) public {
number = newNumber;
}
function increment() public {
number++;
}
}base-contract/
├── app/ # Next.js app directory
│ ├── page.tsx # Main page component
│ ├── layout.tsx # Root layout
│ ├── globals.css # Global styles
│ └── calls.ts # Contract interaction calls
├── config/ # Configuration files
│ └── index.tsx # Wagmi and Reown config
├── context/ # React context providers
│ └── index.tsx # AppKit context provider
├── contracts/ # Smart contracts
│ ├── src/ # Solidity source files
│ ├── test/ # Contract tests
│ └── script/ # Deployment scripts
└── public/ # Static assets
The app uses Reown AppKit for wallet connection with the following features:
- Supported Wallets: All major wallets via WalletConnect
- Networks: Base mainnet
- Storage: Cookie-based for SSR support
- Analytics: Optional usage analytics
- Chains: Base
- Transports: HTTP RPC
- Storage: Cookie storage for SSR
- SSR: Enabled for Next.js compatibility
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The app can be deployed to any platform that supports Next.js:
- Netlify
- Railway
- Render
- AWS Amplify
This project follows security best practices:
- ✅ No private keys in code
- ✅ Environment variables for sensitive data
- ✅ Client-side wallet connection only
- ✅ Public contract addresses only
- ✅ Proper .gitignore for sensitive files
- Base Documentation
- Reown AppKit Documentation
- Wagmi Documentation
- Next.js Documentation
- Viem Documentation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some 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.