NEAR Wallet & AI Assistant
Near Wallet Integration
Wallet integration is handled through the NEAR Wallet Selector library, which provides a unified interface for multiple wallet providers. The platform currently supports MyNearWallet and Meteor Wallet. The wallet selector is initialized in src/near/near.js, which sets up the selector with testnet configuration and creates a modal UI for wallet connection.
When users need to interact with contracts (for change methods or wallet-based deployments), the platform calls initWalletSelector() to get the selector instance, retrieves the active account, and uses the wallet's signAndSendTransaction method to send transactions. The wallet integration includes security validations: account IDs are validated for proper format, contract sizes are checked against NEAR's 4MB limit, and deployments are restricted to testnet for safety.

AI Assistant Integration
The AI Assistant tab integrates Google's Gemini 2.5 Flash model to provide contextual code explanations. When users ask questions, the frontend constructs a prompt that includes the current example name, difficulty level, active language, and the full contract code. The prompt instructs the AI to format responses in Markdown and keep them concise (under 300 words). The AI response is rendered using react-markdown with custom styling that matches the platform's dark theme.
The AI integration requires a VITE_GEMINI_API_KEY environment variable. If not configured, the platform displays a helpful error message. The chat interface maintains conversation history, allows suggested questions for quick starts, and automatically scrolls to show new messages. Responses are limited to 300 words to ensure quick, focused answers.

Last updated
Was this helpful?