Skip to content

vriveraPeersyst/StakeNPRO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

69 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StakeNPRO πŸš€

A production-ready NEAR staking dApp that allows users to stake NEAR tokens to the NPRO validator and earn NPRO rewards.

Built with Next.js NEAR Protocol TypeScript Tailwind CSS

🌟 Overview

StakeNPRO is a modern, secure, and user-friendly staking platform built on the NEAR Protocol. Stake your NEAR tokens with the NPRO validator pool and earn both NEAR staking rewards and NPRO token incentives.

✨ Features

  • πŸ” Wallet Integration: Supports multiple wallets via NEAR Wallet Selector (Ledger, MyNearWallet, HERE, HOT, Meteor)
  • πŸ’° Staking Operations: Stake, unstake, and withdraw NEAR tokens seamlessly
  • πŸ“Š Real-time Balances: View staked, unstaked, and total balances with live updates
  • 🎁 NPRO Rewards: Earn NPRO tokens by staking to the NPRO validator
  • πŸ“± Responsive Design: Mobile-first design with Tailwind CSS
  • πŸ’± Price Display: Real-time NEAR to USD conversion (CoinGecko API)
  • ⚑ Fast Performance: Built with Next.js 14 and optimized for speed
  • πŸ”’ Secure: Client-side transaction signing, no private key exposure

Supported Wallets

  • Ledger: Hardware wallet support for maximum security
  • MyNearWallet: Web wallet for NEAR ecosystem
  • HERE Wallet: Mobile-first NEAR wallet
  • HOT Wallet: Telegram-based wallet integration
  • Meteor Wallet: Browser extension wallet
  • NEAR Mobile: Native mobile app wallet (coming soon)

Staking Information

Validator Pool

  • Pool ID: npro.poolv1.near
  • Network: NEAR Mainnet
  • Rewards: NEAR staking rewards + NPRO tokens

Unstaking Process

  • Duration: ~30-37 hours (4 epochs)
  • Epoch Length: ~43,200 blocks (β‰ˆ7 hours each)
  • Process: After unstaking, tokens must wait for 4 epochs before they can be withdrawn

Safety Buffer

  • The application automatically reserves 0.02 Ⓝ for transaction fees when using "Max" stake amount

Environment Variables

Create a .env.local file with the following variables:

# Required
NEXT_PUBLIC_NETWORK_ID=mainnet
NEXT_PUBLIC_POOL_ID=npro.poolv1.near
NEXT_PUBLIC_RPC_URL=https://rpc.mainnet.near.org
NEXT_PUBLIC_EXPLORER_BASE=https://nearblocks.io

# Optional Features
NEXT_PUBLIC_SHOW_FIAT=true
NEXT_PUBLIC_SHOW_APR=false

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ (LTS recommended)
  • pnpm package manager
  • Git

Installation

# Clone the repository
git clone https://github.com/your-username/stakeNPRO.git
cd stakeNPRO

# Install dependencies
pnpm install

# Copy environment variables
cp .env.example .env.local
# Edit .env.local with your configuration

# Start development server
pnpm dev

Open http://localhost:3000 in your browser to see the application.

πŸ“‹ Available Scripts

# Development
pnpm dev          # Start development server
pnpm build        # Build for production
pnpm start        # Start production server
pnpm preview      # Start production server on port 4000

# Code Quality
pnpm lint         # Run ESLint
pnpm typecheck    # Run TypeScript compiler check
pnpm format       # Format code with Prettier

# Testing
pnpm test         # Run tests with Vitest

πŸ—οΈ Architecture

Tech Stack

  • Frontend: Next.js 14 (App Router), React 18, TypeScript
  • Styling: Tailwind CSS with custom design system
  • State Management: TanStack Query for server state
  • Blockchain: NEAR Protocol via near-api-js
  • Wallet Integration: NEAR Wallet Selector

Key Components

  • src/lib/wallet.ts - Wallet Selector configuration and initialization
  • src/lib/pool.ts - Staking pool interactions and view methods
  • src/lib/near.ts - NEAR provider and utility functions
  • src/hooks/useWallet.ts - Wallet connection and state management
  • src/hooks/useBalances.ts - Account balance queries
  • src/components/StakeCard.tsx - Main staking interface

File Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ globals.css        # Global styles and fonts
β”‚   β”œβ”€β”€ layout.tsx         # Root layout with providers
β”‚   β”œβ”€β”€ page.tsx           # Home page
β”‚   β”œβ”€β”€ terms/page.tsx     # Terms of service
β”‚   β”œβ”€β”€ privacy/page.tsx   # Privacy policy
β”‚   └── api/price/route.ts # Price API proxy
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ Navbar.tsx        # Navigation bar
β”‚   β”œβ”€β”€ StakeCard.tsx     # Main staking interface
β”‚   β”œβ”€β”€ AmountInput.tsx   # Amount input with chips
β”‚   β”œβ”€β”€ AppBanner.tsx     # App download banner
β”‚   └── FooterBar.tsx     # Footer component
β”œβ”€β”€ hooks/                # Custom React hooks
β”‚   β”œβ”€β”€ useWallet.ts      # Wallet management
β”‚   β”œβ”€β”€ useBalances.ts    # Balance queries
β”‚   β”œβ”€β”€ useStake.ts       # Staking transactions
β”‚   β”œβ”€β”€ useUnstake.ts     # Unstaking transactions
β”‚   └── useWithdraw.ts    # Withdrawal transactions
β”œβ”€β”€ lib/                  # Core utilities
β”‚   β”œβ”€β”€ wallet.ts         # Wallet Selector setup
β”‚   β”œβ”€β”€ pool.ts           # Pool contract interactions
β”‚   β”œβ”€β”€ near.ts           # NEAR provider setup
β”‚   └── prices.ts         # Price fetching utilities
└── styles/
    └── tokens.md         # Design token documentation

πŸš€ Deployment

Vercel (Recommended)

  1. Connect your repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Manual Deployment

# Build the application
pnpm build

# Start production server
pnpm start

πŸ”’ Security Considerations

  • All private keys remain in user wallets - this app never handles private keys
  • Transactions are signed client-side using Wallet Selector
  • Environment variables are properly configured for client/server separation
  • Input validation and sanitization on all user inputs
  • Safe math operations using NEAR's utility functions

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Convention

This project uses Conventional Commits:

  • feat: - New features
  • fix: - Bug fixes
  • docs: - Documentation changes
  • style: - Code style changes (formatting, etc.)
  • refactor: - Code refactoring
  • test: - Adding or updating tests
  • chore: - Maintenance tasks

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’¬ Support

For questions and support:


⚠️ Disclaimer: This is experimental software. Users should understand the risks involved in staking cryptocurrencies before using this application.

About

Stake NPRO dApp

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors