본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)7.0k · #13656

near-smart-contracts

하는 일

이 스킬은 Rust로 NEAR 블록체인용 스마트 컨트랙트를 작성하고 검토하는 방법을 안내합니다. 안전하고 효율적인 컨트랙트 코드를 원하는 NEAR 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Rust로 새 NEAR 스마트 컨트랙트를 시작할 때.
  • ✓기존 NEAR 컨트랙트를 보안과 가스 사용 측면에서 검토받고 싶을 때.
  • ✓컨트랙트가 다른 컨트랙트 호출, 콜백, 저장소 처리를 필요로 할 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/internet-court/internet-court-skill/blob/main/vendored/near/near-smart-contracts/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사용자 투표 목록을 저장하는 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
라이선스
—
업데이트
2026. 10. 26.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬