near-smart-contracts
Qué hace
Esta skill guía la escritura y revisión de contratos inteligentes para la cadena de bloques de NEAR en Rust. Es para desarrolladores que construyen sobre NEAR y quieren código de contrato seguro y eficiente.
Cuándo usarla
- ✓Cuando empiezas un contrato inteligente nuevo de NEAR en Rust.
- ✓Cuando quieres que se revise un contrato existente de NEAR en cuanto a seguridad y uso de gas.
- ✓Cuando tu contrato necesita llamadas entre contratos, callbacks o manejo de almacenamiento.
Link de la skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/near/near-smart-contracts/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“¿Puedes ayudarme a escribir un contrato inteligente de NEAR en Rust que guarde una lista de votos de usuarios?”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente crea el proyecto con la herramienta cargo-near y luego escribe el código del contrato con el estado y las reglas de acceso adecuados. Revisa las llamadas entre contratos y el uso de almacenamiento, y explica cómo probarlo y desplegarlo.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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::
Preguntas frecuentes
¿Cómo empieza un proyecto nuevo?
La skill indica usar el comando cargo near new, en lugar de crear los archivos del proyecto a mano.
¿Qué versión del SDK sigue?
Se basa en near-sdk versión 5, con la sintaxis de macros actual.
¿Cubre las pruebas y el despliegue?
Sí. Cubre las pruebas, el despliegue y formas de reducir el uso de gas.
Detalles
Descripción original del autor
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.
Popularidad
- Estrellas en GitHub
- 7,0 mil
- Posición en el ranking
- #13656
- Licencia
- —
- Actualizada
- 26/10/2026
Comentarios
- …
Más skills de este repositorio
internet-court
7,0 milAyuda a tu agente a pagar, contratar o tratar de forma segura con otro agente de IA o con un servicio de pago, y lo dirige a la guía especializada adecuada.
genlayer-erc7710-connector
7,0 milAyuda a tu agente a conectar el resultado de una revisión de IA con un sistema de permisos, para que una mala revisión limite o cancele los permisos de un agente.
genlayer-intelligent-contracts
7,0 milAyuda a tu agente a definir las reglas, las pruebas y los resultados de un juez de IA que comprueba si otro agente cumplió su mandato.
x402-erc7710
7,0 milAyuda a tu agente a pagar servicios web una solicitud a la vez, y a configurar un gasto continuo que se mantenga dentro de un presupuesto de permisos.
Skills parecidas
api-connector-builder
280 milHace que tu agente cree nuevas conexiones de API siguiendo el patrón existente. Úsalo para añadir una integración más sin inventar otra forma de hacer las cosas.
api-design
280 milAyuda a tu agente a diseñar APIs REST según las buenas prácticas. Es útil para definir cómo se comunican las APIs, cómo se muestran los errores y cómo organizar los datos.
backend-patterns
280 milAyuda a tu agente con patrones de arquitectura del lado del servidor y optimización de bases de datos. Es útil para crear o revisar código que se ejecuta en el servidor.