Skip to content

QuantumFusion-network/react-vite-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Quantum Fusion Network (QFN) dApp Template

A production-ready template for building Quantum Fusion Network (QFN) dApps with polkadot-api, React 19, and TypeScript. QFN is a solochain built on the Polkadot SDK.

Features

✨ Pre-built Infrastructure

  • Wallet connection (Polkadot.js, Talisman, SubWallet support)
  • Chain connection with auto-reconnect
  • Transaction lifecycle management
  • Comprehensive error handling
  • Toast notifications
  • TanStack Query integration

🎨 Modern Stack

  • React 19 + TypeScript
  • Vite build system
  • Tailwind CSS + Radix UI
  • polkadot-api (type-safe blockchain interactions)

πŸ“¦ Included Example

  • Full asset management implementation (create, mint, transfer, destroy)
  • Ready to customize or extend

Quick Start

1. Clone Template

npx degit user/polkadot-dapp-template my-polkadot-app
cd my-polkadot-app

2. Install Dependencies

pnpm install

This will automatically:

  • Install all dependencies
  • Generate type descriptors via papi (postinstall hook)

3. Start Development Server

pnpm dev

Open http://localhost:5173 in your browser.

4. Connect Wallet

Install a wallet extension for QFN (compatible with Polkadot.js ecosystem):

Customization with Claude Code

This template is designed to work with the QFN dApp workflow generator:

Option 1: Use Wizard (Recommended)

  1. Complete the wizard at [wizard-url] to generate your config
  2. Run the provided npx degit command
  3. Open in Claude Code: claude-code .
  4. Run: /setup

The workflow will customize the template based on your selections.

Option 2: Manual Customization

  1. Clone this template
  2. Create polkadot-config.json (see polkadot-config.example.json)
  3. Open in Claude Code
  4. Run: /setup

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/       # React components
β”‚   β”‚   β”œβ”€β”€ ui/          # Reusable UI components (buttons, cards, etc.)
β”‚   β”‚   └── ...          # Feature components
β”‚   β”œβ”€β”€ contexts/        # React Context providers
β”‚   β”‚   β”œβ”€β”€ WalletContext.tsx
β”‚   β”‚   β”œβ”€β”€ ConnectionContext.tsx
β”‚   β”‚   └── TransactionContext.tsx
β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useWallet.ts
β”‚   β”‚   β”œβ”€β”€ useTransaction.ts
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ lib/             # Business logic & utilities
β”‚   β”‚   β”œβ”€β”€ assetOperations.ts
β”‚   β”‚   β”œβ”€β”€ errorParsing.ts
β”‚   β”‚   └── utils.ts
β”‚   β”œβ”€β”€ App.tsx          # Main application
β”‚   └── main.tsx         # Entry point
β”œβ”€β”€ .papi/               # polkadot-api configuration
β”‚   β”œβ”€β”€ polkadot-api.json
β”‚   └── metadata/
β”œβ”€β”€ .claude/             # Claude Code workflow assets
β”‚   β”œβ”€β”€ commands/
β”‚   └── docs/
β”œβ”€β”€ public/              # Static assets
β”œβ”€β”€ CLAUDE.md            # Project documentation for AI assistants
└── package.json

Configuration

Chain Configuration

Edit .papi/polkadot-api.json to connect to different chains:

{
  "version": 0,
  "descriptorPath": ".papi/descriptors",
  "entries": {
    "qfn": {
      "wsUrl": "wss://test.qfnetwork.xyz",
      "metadata": ".papi/metadata/qfn.scale"
    }
  }
}

Add New Chain

# From WSS URL
pnpm papi add mychain -w wss://my-chain-url

# From well-known chain
pnpm papi add dot -n polkadot

Then update src/hooks/useConnectionStatus.ts to use the new descriptor.

Key Patterns

Transaction Flow

import { useTransaction } from '@/hooks'

const { executeTransaction } = useTransaction(toastConfig)

// Execute transaction
await executeTransaction('operationType', observable, params)

Query Pattern

import { useQuery } from '@tanstack/react-query'
import { useConnectionContext } from '@/hooks'

const { api } = useConnectionContext()

const query = useQuery({
  queryKey: ['key', param],
  queryFn: async () => await api.query.Pallet.Storage.getValue(param),
  staleTime: 30_000,
})

Error Handling

All errors are automatically parsed and displayed with user-friendly messages. See src/lib/errorParsing.ts for implementation.

Scripts

  • pnpm dev - Start development server
  • pnpm build - Build for production
  • pnpm preview - Preview production build
  • pnpm lint - Lint and fix code
  • pnpm lint:check - Check linting without fixing
  • pnpm typecheck - Type check without emitting
  • pnpm format - Format code with Prettier

Documentation

  • CLAUDE.md - Comprehensive project documentation following best practices
  • polkadot-api - Official docs
  • React 19 - React docs

License

MIT

Contributing

This is a template repository. For issues or improvements, please visit [repo-url].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors