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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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 newto 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.tomlwith proper dependencies and build settings - Creates proper project structure with
src/lib.rstemplate - 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 depositssecurity-access-control- Implement proper access control usingpredecessor_account_idsecurity-reentrancy- Protect against reentrancy attacks (update state before external calls)security-overflow- Useoverflow-checks = truein Cargo.toml to prevent overflowsecurity-callback-validation- Validate callback results and handle failuressecurity-private-callbacks- Mark callbacks as#[private]to prevent external callssecurity-yoctonear-validation- Validate attached deposits with#[payable]functionssecurity-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]patternsstructure-versioning- Plan for contract upgrades with versioning mechanismsstructure-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.
인기도
- GitHub 스타
- 7.0k
- 순위
- #13656
- 라이선스
- —
- 업데이트
- 2026. 10. 26.
댓글
- …
이 저장소의 다른 스킬
internet-court
7.0k에이전트가 다른 AI 에이전트나 유료 서비스와 안전하게 결제하거나 거래하도록 돕고, 적합한 전문 가이드를 알려 줍니다.
genlayer-erc7710-connector
7.0k에이전트가 GenLayer 검토 결과를 권한 시스템에 연결하도록 돕습니다. 나쁜 검토는 에이전트의 권한을 제한하거나 취소할 수 있습니다.
genlayer-intelligent-contracts
7.0k에이전트가 다른 에이전트가 위임받은 범위를 지켰는지 확인하는 AI 심판의 규칙, 증거, 결과를 정하도록 돕습니다.
x402-erc7710
7.0k에이전트가 웹 서비스 요금을 요청 한 건마다 결제하고, 권한 예산 안에서 지속적인 지출을 설정하도록 돕습니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.