Skip to content

Learn-Near-AI/frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

119 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NEAR by Building

Learn NEAR Protocol smart contract development through interactive, hands-on coding examples.

NEAR by Building is a comprehensive, browser-based learning platform designed to teach developers how to build smart contracts on the NEAR Protocol blockchain. Whether you're a complete beginner or an experienced developer looking to explore NEAR, this platform provides an interactive environment where you can write, compile, deploy, and test smart contracts directly in your browserβ€”no local development environment required.


Table of Contents


🌟 Features

  • Live Code Editor: CodeMirror-based editor with syntax highlighting for Rust and TypeScript/JavaScript
  • Instant Compilation: Backend servers compile your code in real-time with detailed error reporting
  • TestNet Deployment: Deploy contracts directly to NEAR TestNet using wallet-based or CLI-based deployment
  • Interactive Console: Real-time compilation and deployment feedback with transaction links to NEAR Explorer
  • AI-Powered Assistance: Integrated AI assistant to explain code concepts (requires VITE_GEMINI_API_KEY)
  • Function Testing: Test deployed contract methods directly from the interface
  • Onboarding Tour: Guided walkthrough for first-time users
  • Responsive Design: Modern UI built with Tailwind CSS
  • Dark Mode: Optimized for extended coding sessions

πŸ“š Learning Categories

Category Examples Focus
Basics 10 Contract structure, view/change methods, state management
Access Control & Security 5 Owner patterns, RBAC, pausable contracts, upgrades
Collections & Data 5 Todo lists, profiles, voting, marketplaces, batch operations
NFTs 7 NEP-171, metadata, minting, royalties, marketplace
Cross-Contract 5 Simple calls, callbacks, FT/NFT cross-calls, chained calls
Chain Signatures 6 MPC signing, verification, multi-chain, callbacks
Indexing 1 NEP-297 events
Advanced Patterns 1 Unit testing

πŸš€ Getting Started

Prerequisites

Quick Start

# Clone the repository
git clone https://github.com/Learn-Near-AI/near-by-example.git
cd near-by-example

# Install dependencies
npm install

# Copy environment template (see Environment Variables below)
cp .env.example .env

# Start development server
npm run dev

Open http://localhost:5173 and click "Get started" to browse examples.

Build for Production

npm run build
npm run preview  # Preview production build

Environment Variables & Security

  1. Copy .env.example to .env: cp .env.example .env
  2. Never commit .envβ€”it is in .gitignore. Never add API keys or secrets to the repo.
  3. Use .env.example as the template; it documents all optional variables without real values.
Variable Required Description
VITE_GEMINI_API_KEY No Gemini API key for AI assistant. Omit to disable AI features.
VITE_RUST_COMPILE_URL No Override Rust compilation backend URL
VITE_JS_COMPILE_URL No Override JS/TS compilation backend URL
VITE_DEPLOY_URL No Override deployment backend URL

πŸ“ Project Structure

src/
β”œβ”€β”€ components/     # Reusable UI (Nav, Footer, dialogs, etc.)
β”œβ”€β”€ config/         # Centralized configuration (URLs, links)
β”œβ”€β”€ data/           # Static data (examples, constants)
β”œβ”€β”€ features/       # Feature-specific modules
β”‚   β”œβ”€β”€ examples/   # Examples browser, code editor, deployment
β”‚   └── landing/    # Landing page sections
β”œβ”€β”€ hooks/          # Custom React hooks
β”œβ”€β”€ lib/            # Utilities, API clients, logger
β”œβ”€β”€ near/           # NEAR blockchain integration
β”œβ”€β”€ routes/         # Route definitions
└── test/           # Test setup

See docs/ARCHITECTURE.md for wallet and backend integration details.

Architecture Patterns

Pattern Location Purpose
Centralized config src/config/ All URLs, env valuesβ€”single source of truth
Feature modules src/features/ Entry points for features (landing, examples)
Route definitions src/routes/ All routes in one place for maintainability
API layer src/near/ NEAR wallet, contract calls, RPC
Logging src/lib/logger.js Use instead of console.* (debug suppressed in prod)

Component Design

  • components/: Reusable UI (Nav, Footer, dialogs, patterns)
  • features/: Composes components into feature entry points
  • Single responsibility: each component does one thing

πŸ› οΈ Development

Code Quality

# Lint
npm run lint

# Fix lint issues
npm run lint:fix

# Format code
npm run format

# Check formatting
npm run format:check

# Run tests
npm run test

Adding New Examples

See CONTRIBUTING.md for the full guide, including the Content Review Checklist (correctness, no duplication, clear learning goal). Quick steps:

  1. Add example metadata to src/data/examplesData.js
  2. Add code samples to src/data/exampleCode/
  3. Add to WORKING_EXAMPLES in src/data/exampleCode/index.js if fully implemented
  4. Add explanation to src/data/contractExplanations.js
  5. Complete the Content Review Checklist in CONTRIBUTING.md before opening a PR

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository and create a feature branch
  2. Make changes with clear, focused commits
  3. Ensure quality:
    • Run npm run lint and npm run format
    • Run npm run test
  4. Submit a PR with a descriptive title and summary

For new or changed examples, complete the Content Review Checklist in CONTRIBUTING.md.

Pull Request Checklist

  • Code follows project style (lint passes)
  • Code is formatted (Prettier)
  • Tests pass
  • Documentation updated if needed
  • Content Review Checklist completed (for new/changed examples)

Questions?

Open an issue for questions or discussions.


πŸ“œ Code of Conduct

We are committed to providing a welcoming and inclusive environment. By participating, you agree to:

  • Use welcoming and inclusive language
  • Be respectful of differing viewpoints and experiences
  • Accept constructive criticism gracefully
  • Focus on what is best for the community
  • Show empathy towards others

Instances of abusive or harassing behavior may be reported to project maintainers and will be reviewed promptly.

This Code of Conduct is adapted from the Contributor Covenant, version 2.0.


πŸ“„ License

MIT License β€” feel free to use this project for learning and teaching.


Built with ❀️ for the NEAR developer community

About

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages