plug-circle-plusFAQ

Frequently Asked Questions (FAQ)

1. What is NEAR by Example?

NEAR by Example is an interactive learning platform designed to teach NEAR Protocol smart contract development through hands-on, executable code examples. It features 60+ categorized examples ranging from beginner-level "Hello World" contracts to advanced topics like NFT marketplaces, cross-contract calls, and security patterns. The platform includes a live code editor where you can modify, compile, and deploy contracts directly to NEAR TestNet, all within your browser.


2. What technologies and frameworks does this project use?

Frontend:

  • Vite - Fast build tool and development server

  • React 18 - UI framework with React Router for navigation

  • Tailwind CSS - Utility-first styling with custom dark mode theming

  • NEAR Wallet Selector - Wallet integration supporting MyNearWallet and Meteor Wallet

  • Lucide React - Icon library

  • AOS - Scroll animations

  • Radix UI - Accessible dialog and sheet components

Backend & Infrastructure:

  • Cloudflare Pages - Static site hosting

  • Cloudflare Functions - Edge middleware for API proxying and SPA routing

  • Express.js backends - Two backend services (Rust and JS compilation) deployed on Fly.io

  • near-api-js - NEAR blockchain integration


3. How do I run this project locally?

To run the project locally, you need Node.js 18+ and npm installed. Here's the quickest way to get started:# Install dependenciesnpm install# Start the development server (runs on port 5173)npm run devThe platform will connect to the existing backend services deployed on Fly.io (near-by-example-backend.fly.dev for Rust and learn-near-backend.fly.dev for JavaScript), so you don't need to run the backend locally unless you're developing backend features. Access the application at http://localhost:5173.


4. What categories of NEAR smart contract examples are available?

The platform organizes examples into the following categories:

  • Basics - Hello World, contract structure, view/change methods, storage, state management (12 examples)

  • Access Control & Security - Owner patterns, role-based access, pausable contracts, multi-signature, reentrancy guards (6 examples)

  • Collections & Data - Storage keys, todo lists, user profiles, voting systems, batch operations (6 examples)

  • NFTs - NFT standards, minting, transfers, metadata, royalties, marketplace (8 examples)

  • Fungible Tokens - Token standards, transfers, allowances, vesting (examples available)

  • Cross-Contract Calls - Inter-contract communication and callbacks

  • Advanced Patterns - Oracle patterns, factory contracts, indexing

Each example is tagged with difficulty level (Beginner/Intermediate/Advanced) and language (Rust/JavaScript/TypeScript).


5. Do I need a NEAR wallet to use the platform?

You can browse and view all examples without a wallet, but you'll need a NEAR wallet to:

  • Deploy contracts to NEAR TestNet

  • Execute contract methods that modify state

  • Test transactions with real blockchain interactions

The platform supports MyNearWallet and Meteor Wallet through the NEAR Wallet Selector. You can create a free testnet wallet at testnet.mynearwallet.com. The wallet connection is seamlessly integrated - just click "Connect Wallet" in the navigation bar.


6. How does the middleware handle routing and API requests?

The Cloudflare Functions middleware (functions/_middleware.js) serves three key purposes:

  1. API Proxying - Routes /api/backend-rust/* requests to the Rust compilation backend and /api/backend-js/* to the JavaScript backend, avoiding CORS issues

  2. Static Asset Handling - Directly serves files with extensions like .js, .css, .png, .wasm, etc., and anything in the /assets/ directory

  3. SPA Routing - Implements client-side routing by serving index.html for all non-static routes, while preserving query parameters (critical for wallet redirect handling with transactionHashes parameters)

This setup ensures the React SPA works correctly when deployed to Cloudflare Pages with proper deep-linking support.

Last updated

Was this helpful?