Skip to content
Merged
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
27 changes: 27 additions & 0 deletions lib/wagmi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { http, createConfig } from "wagmi";
import { base, baseSepolia } from "wagmi/chains";
import { injected } from "wagmi/connectors";

export const config = createConfig({
chains: [base, baseSepolia],
connectors: [injected()],
transports: {
[base.id]: http(
process.env.NEXT_PUBLIC_CHAIN_ID === "8453"
? process.env.NEXT_PUBLIC_RPC_URL
: undefined,
),
[baseSepolia.id]: http(
process.env.NEXT_PUBLIC_CHAIN_ID !== "8453"
? process.env.NEXT_PUBLIC_RPC_URL
: undefined,
),
},
ssr: true,
});

declare module "wagmi" {
interface Register {
config: typeof config;
}
}
195 changes: 192 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
"@supabase/supabase-js": "^2.99.1",
"@tanstack/react-query": "^5.90.21",
"next": "16.1.6",
"react": "19.2.3",
"react-dom": "19.2.3",
"viem": "^2.47.2"
"viem": "^2.47.2",
"wagmi": "^3.5.0"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import { Geist_Mono } from "next/font/google";
import { Providers } from "./providers";
import "./globals.css";

const geistMono = Geist_Mono({
Expand All @@ -19,7 +20,9 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body className={`${geistMono.variable} antialiased`}>{children}</body>
<body className={`${geistMono.variable} antialiased`}>
<Providers>{children}</Providers>
</body>
</html>
);
}
5 changes: 5 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ConnectWallet } from "@/components/ConnectWallet";

export default function Home() {
return (
<div className="flex min-h-screen flex-col items-center justify-center px-6">
<header className="fixed top-0 right-0 p-4">
<ConnectWallet />
</header>
<main className="flex flex-col items-center gap-6 text-center">
<h1 className="text-accent text-2xl font-bold tracking-tight">
PlotLink
Expand Down
16 changes: 16 additions & 0 deletions src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use client";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { WagmiProvider } from "wagmi";
import { config } from "../../lib/wagmi";
import { useState } from "react";

export function Providers({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient());

return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</WagmiProvider>
);
}
40 changes: 40 additions & 0 deletions src/components/ConnectWallet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use client";

import { useAccount, useConnect, useDisconnect } from "wagmi";
import { injected } from "wagmi/connectors";

function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}

export function ConnectWallet() {
const { address, isConnected } = useAccount();
const { connect, isPending } = useConnect();
const { disconnect } = useDisconnect();

if (isConnected && address) {
return (
<div className="border-border flex items-center gap-3 rounded border px-3 py-2 text-sm">
<span className="text-accent font-medium">
{truncateAddress(address)}
</span>
<button
onClick={() => disconnect()}
className="text-muted hover:text-error transition-colors"
>
disconnect
</button>
</div>
);
}

return (
<button
onClick={() => connect({ connector: injected() })}
disabled={isPending}
className="border-accent text-accent hover:bg-accent hover:text-background rounded border px-4 py-2 text-sm transition-colors disabled:opacity-50"
>
{isPending ? "connecting..." : "connect wallet"}
</button>
);
}
Loading