Langsung ke konten
Skillpedia
API & server (backend)7.0k Β· #13656

near-smart-contracts

Fungsinya

Skill ini memandu penulisan dan peninjauan kontrak pintar untuk blockchain NEAR dengan Rust. Skill ini ditujukan untuk pengembang yang membangun di NEAR dan menginginkan kode kontrak yang aman dan efisien.

Kapan dipakai

  • βœ“Saat Anda memulai kontrak pintar NEAR baru dengan Rust.
  • βœ“Ketika Anda ingin kontrak NEAR yang sudah ada ditinjau dari segi keamanan dan penggunaan gas.
  • βœ“Ketika kontrak Anda memerlukan panggilan antarkontrak, callback, atau penanganan penyimpanan.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/internet-court/internet-court-skill/blob/main/vendored/near/near-smart-contracts/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBisakah Anda membantu saya menulis kontrak pintar NEAR dengan Rust yang menyimpan daftar suara pengguna?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent membuat proyek dengan alat cargo-near, lalu menulis kode kontrak dengan state dan aturan akses yang tepat. Agent meninjau panggilan antarkontrak dan pemakaian penyimpanan, serta menjelaskan cara menguji dan men-deploy.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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::
Pertanyaan umum

Bagaimana cara memulai proyek baru?

Skill ini menyatakan memakai perintah cargo near new, bukan membuat berkas proyek secara manual.

Versi SDK mana yang diikuti?

Skill ini didasarkan pada near-sdk versi 5 dengan sintaks makro saat ini.

Apakah skill ini mencakup pengujian dan deployment?

Ya. Skill ini mencakup pengujian, deployment, dan cara mengurangi penggunaan gas.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
7.0k
Peringkat
#13656
Lisensi
β€”
Diperbarui
26/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa