Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions counter-dapp-starter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions counter-dapp-starter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
18 changes: 18 additions & 0 deletions counter-dapp-starter/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);

export default eslintConfig;
7 changes: 7 additions & 0 deletions counter-dapp-starter/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
28 changes: 28 additions & 0 deletions counter-dapp-starter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "solidity-counter",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"ethers": "^6.16.0",
"lucide-react": "^0.577.0",
"next": "16.1.6",
"react": "19.2.3",
"react-dom": "19.2.3"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.6",
"tailwindcss": "^4",
"typescript": "^5"
}
}
7 changes: 7 additions & 0 deletions counter-dapp-starter/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};

export default config;
1 change: 1 addition & 0 deletions counter-dapp-starter/public/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions counter-dapp-starter/public/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions counter-dapp-starter/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions counter-dapp-starter/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions counter-dapp-starter/public/window.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added counter-dapp-starter/src/app/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions counter-dapp-starter/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@import "tailwindcss";

:root {
--background: #000000;
--foreground: #ffffff;
}

@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}

body {
background: var(--background);
color: var(--foreground);
font-family: var(--font-sans), Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
overflow-x: hidden;
}
34 changes: 34 additions & 0 deletions counter-dapp-starter/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "Counter DApp",
description: "A Counter DApp",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
);
}
131 changes: 131 additions & 0 deletions counter-dapp-starter/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
"use client";

import { useState } from "react";
import { Wallet } from "lucide-react";

export default function Home() {
const [count, setCount] = useState<number>(0);
const [isConnecting, setIsConnecting] = useState(false);
const [isConnected, setIsConnected] = useState(false);

// Mock functions for wallet and counter
const handleConnectWallet = async () => {
setIsConnecting(true);
// Simulate connection delay
setTimeout(() => {
setIsConnected(true);
setIsConnecting(false);
}, 800);
};

const handleGetCount = async () => {
// dummy
};

const handleIncrease = async () => {
if (!isConnected) return;
setCount((prev) => prev + 1);
};

const handleDecrease = async () => {
if (!isConnected) return;
setCount((prev) => prev - 1);
};

return (
<div className="min-h-screen bg-black text-white selection:bg-white selection:text-black font-sans flex flex-col">
{/* Navbar */}
<header className="w-full flex justify-between items-center p-6 border-b border-white/10 sticky top-0 bg-black/80 backdrop-blur-md z-10 transition-all duration-300">
<div className="text-xl font-medium tracking-tighter flex items-center gap-2 select-none">
<div className="w-4 h-4 rounded-full bg-white animate-pulse" />
COUNTER
</div>
<button
onClick={handleConnectWallet}
disabled={isConnected || isConnecting}
className={`flex items-center gap-2 px-5 py-2.5 rounded-full text-sm font-medium transition-all duration-500 border
${
isConnected
? "bg-white text-black border-transparent cursor-default"
: "bg-transparent text-white border-white/20 hover:border-white hover:bg-white hover:text-black active:scale-95 cursor-pointer"
}
`}
>
{isConnected ? (
<>
<div className="w-2 h-2 rounded-full bg-black animate-pulse" />
Connected
</>
) : isConnecting ? (
<span className="animate-pulse">Connecting...</span>
) : (
<>
<Wallet size={16} />
Connect Wallet
</>
)}
</button>
</header>

<main className="flex-1 flex flex-col items-center justify-center p-6 w-full max-w-4xl mx-auto relative overflow-hidden">
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[500px] bg-white/2 rounded-full blur-[100px] pointer-events-none" />

<div className="relative z-10 flex flex-col items-center gap-12 sm:gap-16 w-full transition-all duration-700 ease-out transform translate-y-0 opacity-100">
{/* Current count display */}
<div className="flex flex-col items-center gap-2">
<span className="text-sm font-medium tracking-[0.2em] text-white/40 uppercase">
Current Count
</span>
<div className="text-[12rem] leading-none font-medium tracking-tighter text-white transition-all duration-500">
{count}
</div>
</div>

{/* Action Buttons */}
<div className="flex flex-col sm:flex-row items-center gap-4 w-full justify-center max-w-xl">
<button
onClick={handleGetCount}
className="group relative w-full sm:w-auto px-8 py-4 bg-transparent text-white border border-white/20 rounded-2xl hover:border-white transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed overflow-hidden active:scale-[0.98]"
>
<span className="relative z-10 font-medium tracking-wide">
Get Count
</span>
<div className="absolute inset-0 bg-white translate-y-full group-hover:translate-y-0 transition-transform duration-300 ease-in-out" />
<span className="absolute inset-0 z-20 flex items-center justify-center text-black opacity-0 group-hover:opacity-100 transition-opacity duration-300 font-medium tracking-wide">
Get Count
</span>
</button>

<button
onClick={handleIncrease}
disabled={!isConnected}
className="group relative w-full sm:w-auto px-8 py-4 bg-white text-black border border-transparent rounded-2xl hover:bg-transparent hover:text-white hover:border-white transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-white disabled:hover:text-black disabled:hover:border-transparent overflow-hidden active:scale-[0.98]"
>
<span className="relative z-10 font-medium tracking-wide">
Increase Count
</span>
</button>

<button
onClick={handleDecrease}
disabled={!isConnected || count === 0}
className="group relative w-full sm:w-auto px-8 py-4 bg-transparent text-white border border-white/20 rounded-2xl hover:border-white transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed overflow-hidden active:scale-[0.98]"
>
<span className="relative z-10 font-medium tracking-wide">
Decrease Count
</span>
<div className="absolute inset-0 bg-white translate-y-full group-hover:translate-y-0 transition-transform duration-300 ease-in-out" />
<span className="absolute inset-0 z-20 flex items-center justify-center text-black opacity-0 group-hover:opacity-100 transition-opacity duration-300 font-medium tracking-wide">
Decrease Count
</span>
</button>
</div>
</div>
</main>

<footer className="w-full p-6 text-center text-xs text-white/30 font-medium tracking-wider uppercase">
Built with Next.js and Solidity
</footer>
</div>
);
}
34 changes: 34 additions & 0 deletions counter-dapp-starter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules"]
}