Перейти к содержанию
Skillpedia
API и серверы (бэкенд)7.0k · #13656

near-smart-contracts

Что он делает

Этот скилл ведёт написание и проверку смарт-контрактов для блокчейна NEAR на Rust. Он нужен разработчикам, которые создают на NEAR и хотят безопасный и эффективный код контрактов.

Когда использовать

  • ✓Когда вы начинаете новый смарт-контракт NEAR на Rust.
  • ✓Когда нужно проверить существующий контракт NEAR на безопасность и расход газа.
  • ✓Когда контракту нужны межконтрактные вызовы, колбэки или работа с хранилищем.

Ссылка на скилл

https://github.com/internet-court/internet-court-skill/blob/main/vendored/near/near-smart-contracts/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/internet-court/internet-court-skill/blob/main/vendored/near/near-smart-contracts/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Помоги написать смарт-контракт NEAR на Rust, который хранит список голосов пользователей.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент создаёт проект с помощью инструмента cargo-near, затем пишет код контракта с правильными правилами состояния и доступа. Он проверяет вызовы между контрактами и использование хранилища и объясняет, как протестировать и развернуть контракт.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

NEAR Smart Contracts Development

Comprehensive guide for developing secure and efficient smart contracts on NEAR Protocol using Rust and the NEAR SDK (v5.x).

When to Apply

Reference these guidelines when:

  • Writing new NEAR smart contracts in Rust
  • Reviewing existing contract code for security and optimization
  • Implementing cross-contract calls and callbacks
  • Managing contract state and storage
  • Testing and deploying NEAR contracts
  • Optimizing gas usage and performance

Getting Started

Prerequisites

Install the required tools before starting development:

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Add wasm32 target for compiling contracts
rustup target add wasm32-unknown-unknown

# Install cargo-near (build, deploy, and manage contracts)
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh

# Install near-cli-rs (interact with NEAR network)
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh

Create a New Project

CRITICAL: ALWAYS run cargo near new to create new projects. NEVER manually create Cargo.toml, lib.rs, or any project files. The command generates all required files with correct configurations.

# REQUIRED: Create a new contract project using the official template
cargo near new my-contract

# Navigate to project directory
cd my-contract

# Build the contract
cargo near build

# Run tests
cargo test

Why cargo near new is mandatory:

  • Generates correct Cargo.toml with proper dependencies and build settings
  • Creates proper project structure with src/lib.rs template
  • Includes integration test setup in tests/ directory
  • Configures release profile with overflow-checks = true
  • Sets up correct crate-type for WASM compilation
  • Avoids common configuration mistakes that cause build failures

DO NOT:

  • Manually create Cargo.toml
  • Manually create src/lib.rs
  • Copy-paste project structure from examples
  • Skip this step and create files directly

Project Structure

my-contract/
├── Cargo.toml          # Dependencies and project config
├── src/
│   └── lib.rs          # Main contract code
├── tests/              # Integration tests
│   └── test_basics.rs
└── README.md

Deploy to Testnet

# Create a testnet account (if needed)
near account create-account sponsor-by-faucet-service my-contract.testnet autogenerate-new-keypair save-to-keychain network-config testnet create

# Build in release mode
cargo near build --release

# Deploy to testnet
cargo near deploy my-contract.testnet without-init-call network-config testnet sign-with-keychain send

Rule Categories by Priority

Priority Category Impact Prefix
1 Security & Safety CRITICAL security-
2 Contract Structure HIGH structure-
3 State Management HIGH state-
4 Cross-Contract Calls MEDIUM-HIGH xcc-
5 Contract Upgrades MEDIUM-HIGH upgrade-
6 Chain Signatures MEDIUM-HIGH chain-
7 Gas Optimization MEDIUM gas-
8 Yield & Resume MEDIUM yield-
9 Testing MEDIUM testing-
10 Best Practices MEDIUM best-

1. Security & Safety (CRITICAL)

  • security-storage-checks - Always validate storage operations and check deposits
  • security-access-control - Implement proper access control using predecessor_account_id
  • security-reentrancy - Protect against reentrancy attacks (update state before external calls)
  • security-overflow - Use overflow-checks = true in Cargo.toml to prevent overflow
  • security-callback-validation - Validate callback results and handle failures
  • security-private-callbacks - Mark callbacks as #[private] to prevent external calls
  • security-yoctonear-validation - Validate attached deposits with #[payable] functions
  • security-sybil-resistance - Implement minimum deposit checks to prevent spam

2. Contract Structure (HIGH)

  • structure-near-bindgen - Use #[near(contract_state)] macro for contract struct (replaces old #[near_bindgen])
  • structure-initialization - Implement proper initialization with #[init] patterns
  • structure-versioning - Plan for contract upgrades with versioning mechanisms
  • structure-events - Use `env::
Частые вопросы

Как скилл начинает новый проект?

Скилл велит использовать команду cargo near new, а не создавать файлы проекта вручную.

Какую версию SDK он использует?

Он основан на near-sdk версии 5 с актуальным синтаксисом макросов.

Охватывает ли он тестирование и развёртывание?

Да. Он охватывает тестирование, развёртывание и способы снизить расход газа.

Подробности

Оригинальное описание автора

NEAR Protocol smart contract development in Rust. Use when writing, reviewing, or deploying NEAR smart contracts. Covers contract structure, state management, cross-contract calls, testing, security, and optimization patterns. Based on near-sdk v5.x with modern macro syntax.

repo: internet-court/internet-court-skill

Популярность

Звёзды на GitHub
7.0k
Место в рейтинге
#13656
Лицензия
—
Обновлён
26.10.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы