[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73YP6S4EN5FRBQ69JNP35ZP":3,"skill-same:01M73YP6S4EN5FRBQ69JNP35ZP":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M73YP6S4EN5FRBQ69JNP35ZP","near-smart-contracts",null,"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.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fnear-smart-contracts\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: near-smart-contracts\ndescription: 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.\nlicense: MIT\nmetadata:\n  author: near\n  version: \"1.0.0\"\n---\n\n# NEAR Smart Contracts Development\n\nComprehensive guide for developing secure and efficient smart contracts on NEAR Protocol using Rust and the NEAR SDK (v5.x).\n\n## When to Apply\n\nReference these guidelines when:\n\n- Writing new NEAR smart contracts in Rust\n- Reviewing existing contract code for security and optimization\n- Implementing cross-contract calls and callbacks\n- Managing contract state and storage\n- Testing and deploying NEAR contracts\n- Optimizing gas usage and performance\n\n## Getting Started\n\n### Prerequisites\n\nInstall the required tools before starting development:\n\n```bash\n# Install Rust (if not already installed)\ncurl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\n\n# Add wasm32 target for compiling contracts\nrustup target add wasm32-unknown-unknown\n\n# Install cargo-near (build, deploy, and manage contracts)\ncurl --proto '=https' --tlsv1.2 -LsSf https:\u002F\u002Fgithub.com\u002Fnear\u002Fcargo-near\u002Freleases\u002Flatest\u002Fdownload\u002Fcargo-near-installer.sh | sh\n\n# Install near-cli-rs (interact with NEAR network)\ncurl --proto '=https' --tlsv1.2 -LsSf https:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-cli-rs\u002Freleases\u002Flatest\u002Fdownload\u002Fnear-cli-rs-installer.sh | sh\n```\n\n### Create a New Project\n\n> **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.\n\n```bash\n# REQUIRED: Create a new contract project using the official template\ncargo near new my-contract\n\n# Navigate to project directory\ncd my-contract\n\n# Build the contract\ncargo near build\n\n# Run tests\ncargo test\n```\n\n**Why `cargo near new` is mandatory:**\n- Generates correct `Cargo.toml` with proper dependencies and build settings\n- Creates proper project structure with `src\u002Flib.rs` template\n- Includes integration test setup in `tests\u002F` directory\n- Configures release profile with `overflow-checks = true`\n- Sets up correct crate-type for WASM compilation\n- Avoids common configuration mistakes that cause build failures\n\n**DO NOT:**\n- Manually create `Cargo.toml`\n- Manually create `src\u002Flib.rs`\n- Copy-paste project structure from examples\n- Skip this step and create files directly\n\n### Project Structure\n\n```\nmy-contract\u002F\n├── Cargo.toml          # Dependencies and project config\n├── src\u002F\n│   └── lib.rs          # Main contract code\n├── tests\u002F              # Integration tests\n│   └── test_basics.rs\n└── README.md\n```\n\n### Deploy to Testnet\n\n```bash\n# Create a testnet account (if needed)\nnear account create-account sponsor-by-faucet-service my-contract.testnet autogenerate-new-keypair save-to-keychain network-config testnet create\n\n# Build in release mode\ncargo near build --release\n\n# Deploy to testnet\ncargo near deploy my-contract.testnet without-init-call network-config testnet sign-with-keychain send\n```\n\n## Rule Categories by Priority\n\n| Priority | Category | Impact | Prefix |\n| --------- | ---------- | -------- | --------- |\n| 1 | Security & Safety | CRITICAL | `security-` |\n| 2 | Contract Structure | HIGH | `structure-` |\n| 3 | State Management | HIGH | `state-` |\n| 4 | Cross-Contract Calls | MEDIUM-HIGH | `xcc-` |\n| 5 | Contract Upgrades | MEDIUM-HIGH | `upgrade-` |\n| 6 | Chain Signatures | MEDIUM-HIGH | `chain-` |\n| 7 | Gas Optimization | MEDIUM | `gas-` |\n| 8 | Yield & Resume | MEDIUM | `yield-` |\n| 9 | Testing | MEDIUM | `testing-` |\n| 10 | Best Practices | MEDIUM | `best-` |\n\n### 1. Security & Safety (CRITICAL)\n\n- `security-storage-checks` - Always validate storage operations and check deposits\n- `security-access-control` - Implement proper access control using `predecessor_account_id`\n- `security-reentrancy` - Protect against reentrancy attacks (update state before external calls)\n- `security-overflow` - Use `overflow-checks = true` in Cargo.toml to prevent overflow\n- `security-callback-validation` - Validate callback results and handle failures\n- `security-private-callbacks` - Mark callbacks as `#[private]` to prevent external calls\n- `security-yoctonear-validation` - Validate attached deposits with `#[payable]` functions\n- `security-sybil-resistance` - Implement minimum deposit checks to prevent spam\n\n### 2. Contract Structure (HIGH)\n\n- `structure-near-bindgen` - Use `#[near(contract_state)]` macro for contract struct (replaces old `#[near_bindgen]`)\n- `structure-initialization` - Implement proper initialization with `#[init]` patterns\n- `structure-versioning` - Plan for contract upgrades with versioning mechanisms\n- `structure-events` - Use `env::log_str()` and structured event logging (NEP-297)\n- `structure-standards` - Follow NEAR Enhancement Proposals (NEPs) for standards\n- `structure-serializers` - Use `#[near(serializers = [json, borsh])]` for data structs\n- `structure-panic-default` - Use `#[derive(PanicOnDefault)]` to require initialization\n\n### 3. State Management (HIGH)\n\n- `state-collections` - Use SDK collections from `near_sdk::store`: `IterableMap`, `IterableSet`, `Vector`, `LookupMap`, `LookupSet`, `UnorderedMap`, `UnorderedSet`, `TreeMap`\n- `state-serialization` - Use Borsh for state, JSON for external interfaces\n- `state-lazy-loading` - Use SDK collections for lazy loading to save gas (loaded on-demand, not all at once)\n- `state-pagination` - Implement pagination with `.skip()` and `.take()` for large datasets\n- `state-migration` - Plan state migration strategies using versioning\n- `state-storage-cost` - Remember: 1 NEAR ≈ 100kb storage, contracts pay for their storage\n- `state-unique-prefixes` - Use unique byte prefixes for all collections (avoid collisions)\n- `state-native-vs-sdk` - Native collections (Vec, HashMap) load all data; use only for \u003C100 entries\n\n### 4. Cross-Contract Calls (MEDIUM-HIGH)\n\n- `xcc-promise-chaining` - Chain promises correctly\n- `xcc-callback-handling` - Handle all callback scenarios (success, failure)\n- `xcc-gas-management` - Allocate appropriate gas for cross-contract calls\n- `xcc-error-handling` - Implement robust error handling\n- `xcc-result-unwrap` - Never unwrap promise results without checks\n\n### 5. Contract Upgrades & Migration (MEDIUM-HIGH)\n\n- `upgrade-migration` - Use enums for state versioning and implement `migrate` method with `#[init(ignore_state)]`\n- `upgrade-self-update` - Pattern for contracts that can update themselves programmatically\n- `upgrade-cleanup-old-state` - Always remove old state structures to free storage\n- `upgrade-dao-controlled` - Use multisig or DAO for production upgrade governance\n\n### 6. Chain Signatures (MEDIUM-HIGH)\n\n- `chain-signatures` - Derive foreign blockchain addresses, request MPC signatures, and build multichain transactions\n- `chain-callback-handling` - Handle MPC signature callbacks properly\n- `chain-gas-allocation` - Allocate sufficient gas for MPC calls (yield\u002Fresume pattern)\n\n### 7. Gas Optimization (MEDIUM)\n\n- `gas-batch-operations` - Batch operations to reduce transaction costs\n- `gas-minimal-state-reads` - Minimize state reads and writes (cache in memory)\n- `gas-efficient-collections` - Choose appropriate collection types (LookupMap vs IterableMap)\n- `gas-view-functions` - Mark read-only functions as view (`&self` in Rust)\n- `gas-avoid-cloning` - Avoid unnecessary cloning of large data structures\n- `gas-early-validation` - Use `require!` early to save gas on invalid inputs\n- `gas-prepaid-gas` - Attach appropriate gas for cross-contract calls (recommended: 30 TGas)\n\n### 8. Yield & Resume (MEDIUM)\n\n- `yield-resume` - Create yielded promises, signal resume, handle timeouts, and manage state between yield\u002Fresume\n- `yield-gatekeeping` - Protect resume methods from unauthorized callers\n\n### 9. Testing (MEDIUM)\n\n- `testing-integration-tests` - Use `near-sandbox` + `near-api` for integration tests\n- `testing-unit-tests` - Write comprehensive unit tests with mock contexts\n- `testing-sandbox` - Test with local sandbox environment before testnet\u002Fmainnet\n- `testing-edge-cases` - Test boundary conditions, overflow, and empty states\n- `testing-gas-profiling` - Profile gas usage in integration tests\n- `testing-cross-contract` - Test cross-contract calls and callbacks thoroughly\n- `testing-failure-scenarios` - Test promise failures and timeout scenarios\n- `testing-time-travel` - Use `sandbox.fast_forward()` for time-sensitive tests\n\n### 10. Best Practices (MEDIUM)\n\n- `best-contract-tools` - Use `near-sdk-contract-tools` for NEP standards (FT, NFT, etc.) and NEP-297 structured events\n- `best-panic-messages` - Provide clear, actionable panic messages\n- `best-logging` - Use `env::log_str()` for debugging and event emission\n- `best-documentation` - Document public methods, parameters, and complex logic\n- `best-error-types` - Define custom error types or use descriptive strings\n- `best-constants` - Use constants for magic numbers and configuration\n- `best-require-macro` - Use `require!` instead of `assert!` for better error messages\n- `best-promise-return` - Return promises from cross-contract calls for proper tracking\n- `best-sdk-crates` - Reuse SDK-exported crates (borsh, serde, base64, etc.)\n- `best-account-id-encoding` - Encode AccountIds in base32 for 40% storage savings\n\n## How to Use\n\nRead individual rule files for detailed explanations and code examples:\n\n```\nrules\u002Fsecurity-storage-checks.md\nrules\u002Fstructure-near-bindgen.md\nrules\u002Fstate-collections.md\nrules\u002Fxcc-promise-chaining.md\nrules\u002Fupgrade-migration.md\nrules\u002Fchain-signatures.md\nrules\u002Fyield-resume.md\nrules\u002Fbest-contract-tools.md\nrules\u002Ftesting-integration-tests.md\n```\n\nEach rule file contains:\n\n- Brief explanation of why it matters\n- Incorrect code example with explanation\n- Correct code example with explanation\n- Additional context and NEAR-specific considerations\n\n## Latest Tools & Versions\n\n### Development Tools\n\n- **cargo-near**: Latest - Build, deploy, and manage contracts (`cargo near build`, `cargo near deploy`)\n- **near-cli-rs**: Latest - Command-line interface for NEAR (`near contract call`, `near contract view`)\n- **rustc**: Latest stable - Rust compiler\n- **near-sandbox**: Latest - Local sandbox environment for integration testing\n- **near-api-rs**: Latest - Rust API client for interacting with NEAR (replaces near-workspaces-rs for tests)\n- **omni-transaction-rs**: Latest - Build transactions for multiple blockchains (Bitcoin, Ethereum, etc.)\n\n### SDK Versions\n\n- **near-sdk-rs**: v5.x (v6.x coming with structured errors support)\n- **near-sdk-contract-tools**: Latest - Derive macros for NEP standards (FT, NFT, Storage Management)\n\n### Key Features\n\n- **Unified macro syntax**: `#[near(contract_state)]` replaces `#[near_bindgen]` + derives\n- **Flexible serialization**: `#[near(serializers = [json, borsh])]` for data structs\n- **Store collections**: `near_sdk::store::IterableMap`, `IterableSet`, `LookupMap`, `LookupSet`, `Vector`, `UnorderedMap`, `UnorderedSet`, `TreeMap`\n- **Simplified cross-contract calls**: High-level promise API with `Promise::new()` and `.then()`\n- **Built-in NEP support**: FT (NEP-141), NFT (NEP-171), and other standards\n- **Result handling**: `#[handle_result]` for methods returning `Result\u003CT, E>` without panicking\n- **Yield\u002FResume**: Contracts can yield execution and wait for external services to resume\n- **Chain Signatures**: Sign transactions for other blockchains (Bitcoin, Ethereum, Solana, etc.)\n- **Contract Tools**: Derive macros for Owner, Pause, Role-based access control patterns\n\n## Resources\n\n- NEAR Documentation: \u003Chttps:\u002F\u002Fdocs.near.org>\n- Smart Contract Quickstart: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fquickstart>\n- Contract Anatomy: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002F>\n- NEAR SDK Rust: \u003Chttps:\u002F\u002Fdocs.near.org\u002Ftools\u002Fsdk>\n- SDK Rust Reference: \u003Chttps:\u002F\u002Fdocs.rs\u002Fnear-sdk>\n- Storage & Collections: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fcollections>\n- Best Practices: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fbest-practices>\n- Cross-Contract Calls: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fcrosscontract>\n- Yield & Resume: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fyield-resume>\n- Contract Upgrades: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Frelease\u002Fupgrade>\n- Chain Signatures: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fchain-abstraction\u002Fchain-signatures>\n- Chain Signatures Implementation: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fchain-abstraction\u002Fchain-signatures\u002Fimplementation>\n- Security Best Practices: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fsecurity\u002Fwelcome>\n- Integration Testing: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Ftesting\u002Fintegration-test>\n- NEP-297 Events: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002FNEPs\u002Fblob\u002Fmaster\u002Fneps\u002Fnep-0297.md>\n- NEAR Standards (NEPs): \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002FNEPs>\n- NEAR Examples: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear-examples>\n- Sandbox Testing: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-sandbox>\n- NEAR API Rust: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-api-rs>\n- Omni Transaction RS: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fomni-transaction-rs>\n- Contract Tools: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-sdk-contract-tools>\n\n## Storage Costs Reference\n\n| Storage | Cost | Notes |\n|---------|------|-------|\n| 1 byte | 0.00001 NEAR | ~10kb per 0.1 NEAR |\n| 100 KB | ~1 NEAR | Approximate reference |\n| AccountId | 64+ bytes | Can save 40% with base32 encoding |\n| Contract code | Variable | Paid by contract account |\n\n## SDK Collections Reference\n\n| Collection | Iterable | Clear | Ordered | Range | Use Case |\n|------------|----------|-------|---------|-------|----------|\n| `Vector` | Yes | Yes | Yes | Yes | Ordered list with index access |\n| `LookupMap` | No | No | No | No | Fast key-value, no iteration needed |\n| `LookupSet` | No | No | No | No | Fast membership checks |\n| `IterableMap` | Yes | Yes | Yes | No | Key-value with iteration |\n| `IterableSet` | Yes | Yes | Yes | No | Set with iteration |\n| `UnorderedMap` | Yes | Yes | No | No | Key-value, unordered iteration |\n| `UnorderedSet` | Yes | Yes | No | No | Set, unordered iteration |\n| `TreeMap` | Yes | Yes | Yes | Yes | Sorted key-value with range queries |\n","# NEAR Smart Contracts Development\n\nComprehensive guide for developing secure and efficient smart contracts on NEAR Protocol using Rust and the NEAR SDK (v5.x).\n\n## When to Apply\n\nReference these guidelines when:\n\n- Writing new NEAR smart contracts in Rust\n- Reviewing existing contract code for security and optimization\n- Implementing cross-contract calls and callbacks\n- Managing contract state and storage\n- Testing and deploying NEAR contracts\n- Optimizing gas usage and performance\n\n## Getting Started\n\n### Prerequisites\n\nInstall the required tools before starting development:\n\n```bash\n# Install Rust (if not already installed)\ncurl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\n\n# Add wasm32 target for compiling contracts\nrustup target add wasm32-unknown-unknown\n\n# Install cargo-near (build, deploy, and manage contracts)\ncurl --proto '=https' --tlsv1.2 -LsSf https:\u002F\u002Fgithub.com\u002Fnear\u002Fcargo-near\u002Freleases\u002Flatest\u002Fdownload\u002Fcargo-near-installer.sh | sh\n\n# Install near-cli-rs (interact with NEAR network)\ncurl --proto '=https' --tlsv1.2 -LsSf https:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-cli-rs\u002Freleases\u002Flatest\u002Fdownload\u002Fnear-cli-rs-installer.sh | sh\n```\n\n### Create a New Project\n\n> **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.\n\n```bash\n# REQUIRED: Create a new contract project using the official template\ncargo near new my-contract\n\n# Navigate to project directory\ncd my-contract\n\n# Build the contract\ncargo near build\n\n# Run tests\ncargo test\n```\n\n**Why `cargo near new` is mandatory:**\n- Generates correct `Cargo.toml` with proper dependencies and build settings\n- Creates proper project structure with `src\u002Flib.rs` template\n- Includes integration test setup in `tests\u002F` directory\n- Configures release profile with `overflow-checks = true`\n- Sets up correct crate-type for WASM compilation\n- Avoids common configuration mistakes that cause build failures\n\n**DO NOT:**\n- Manually create `Cargo.toml`\n- Manually create `src\u002Flib.rs`\n- Copy-paste project structure from examples\n- Skip this step and create files directly\n\n### Project Structure\n\n```\nmy-contract\u002F\n├── Cargo.toml          # Dependencies and project config\n├── src\u002F\n│   └── lib.rs          # Main contract code\n├── tests\u002F              # Integration tests\n│   └── test_basics.rs\n└── README.md\n```\n\n### Deploy to Testnet\n\n```bash\n# Create a testnet account (if needed)\nnear account create-account sponsor-by-faucet-service my-contract.testnet autogenerate-new-keypair save-to-keychain network-config testnet create\n\n# Build in release mode\ncargo near build --release\n\n# Deploy to testnet\ncargo near deploy my-contract.testnet without-init-call network-config testnet sign-with-keychain send\n```\n\n## Rule Categories by Priority\n\n| Priority | Category | Impact | Prefix |\n| --------- | ---------- | -------- | --------- |\n| 1 | Security & Safety | CRITICAL | `security-` |\n| 2 | Contract Structure | HIGH | `structure-` |\n| 3 | State Management | HIGH | `state-` |\n| 4 | Cross-Contract Calls | MEDIUM-HIGH | `xcc-` |\n| 5 | Contract Upgrades | MEDIUM-HIGH | `upgrade-` |\n| 6 | Chain Signatures | MEDIUM-HIGH | `chain-` |\n| 7 | Gas Optimization | MEDIUM | `gas-` |\n| 8 | Yield & Resume | MEDIUM | `yield-` |\n| 9 | Testing | MEDIUM | `testing-` |\n| 10 | Best Practices | MEDIUM | `best-` |\n\n### 1. Security & Safety (CRITICAL)\n\n- `security-storage-checks` - Always validate storage operations and check deposits\n- `security-access-control` - Implement proper access control using `predecessor_account_id`\n- `security-reentrancy` - Protect against reentrancy attacks (update state before external calls)\n- `security-overflow` - Use `overflow-checks = true` in Cargo.toml to prevent overflow\n- `security-callback-validation` - Validate callback results and handle failures\n- `security-private-callbacks` - Mark callbacks as `#[private]` to prevent external calls\n- `security-yoctonear-validation` - Validate attached deposits with `#[payable]` functions\n- `security-sybil-resistance` - Implement minimum deposit checks to prevent spam\n\n### 2. Contract Structure (HIGH)\n\n- `structure-near-bindgen` - Use `#[near(contract_state)]` macro for contract struct (replaces old `#[near_bindgen]`)\n- `structure-initialization` - Implement proper initialization with `#[init]` patterns\n- `structure-versioning` - Plan for contract upgrades with versioning mechanisms\n- `structure-events` - Use `env::log_str()` and structured event logging (NEP-297)\n- `structure-standards` - Follow NEAR Enhancement Proposals (NEPs) for standards\n- `structure-serializers` - Use `#[near(serializers = [json, borsh])]` for data structs\n- `structure-panic-default` - Use `#[derive(PanicOnDefault)]` to require initialization\n\n### 3. State Management (HIGH)\n\n- `state-collections` - Use SDK collections from `near_sdk::store`: `IterableMap`, `IterableSet`, `Vector`, `LookupMap`, `LookupSet`, `UnorderedMap`, `UnorderedSet`, `TreeMap`\n- `state-serialization` - Use Borsh for state, JSON for external interfaces\n- `state-lazy-loading` - Use SDK collections for lazy loading to save gas (loaded on-demand, not all at once)\n- `state-pagination` - Implement pagination with `.skip()` and `.take()` for large datasets\n- `state-migration` - Plan state migration strategies using versioning\n- `state-storage-cost` - Remember: 1 NEAR ≈ 100kb storage, contracts pay for their storage\n- `state-unique-prefixes` - Use unique byte prefixes for all collections (avoid collisions)\n- `state-native-vs-sdk` - Native collections (Vec, HashMap) load all data; use only for \u003C100 entries\n\n### 4. Cross-Contract Calls (MEDIUM-HIGH)\n\n- `xcc-promise-chaining` - Chain promises correctly\n- `xcc-callback-handling` - Handle all callback scenarios (success, failure)\n- `xcc-gas-management` - Allocate appropriate gas for cross-contract calls\n- `xcc-error-handling` - Implement robust error handling\n- `xcc-result-unwrap` - Never unwrap promise results without checks\n\n### 5. Contract Upgrades & Migration (MEDIUM-HIGH)\n\n- `upgrade-migration` - Use enums for state versioning and implement `migrate` method with `#[init(ignore_state)]`\n- `upgrade-self-update` - Pattern for contracts that can update themselves programmatically\n- `upgrade-cleanup-old-state` - Always remove old state structures to free storage\n- `upgrade-dao-controlled` - Use multisig or DAO for production upgrade governance\n\n### 6. Chain Signatures (MEDIUM-HIGH)\n\n- `chain-signatures` - Derive foreign blockchain addresses, request MPC signatures, and build multichain transactions\n- `chain-callback-handling` - Handle MPC signature callbacks properly\n- `chain-gas-allocation` - Allocate sufficient gas for MPC calls (yield\u002Fresume pattern)\n\n### 7. Gas Optimization (MEDIUM)\n\n- `gas-batch-operations` - Batch operations to reduce transaction costs\n- `gas-minimal-state-reads` - Minimize state reads and writes (cache in memory)\n- `gas-efficient-collections` - Choose appropriate collection types (LookupMap vs IterableMap)\n- `gas-view-functions` - Mark read-only functions as view (`&self` in Rust)\n- `gas-avoid-cloning` - Avoid unnecessary cloning of large data structures\n- `gas-early-validation` - Use `require!` early to save gas on invalid inputs\n- `gas-prepaid-gas` - Attach appropriate gas for cross-contract calls (recommended: 30 TGas)\n\n### 8. Yield & Resume (MEDIUM)\n\n- `yield-resume` - Create yielded promises, signal resume, handle timeouts, and manage state between yield\u002Fresume\n- `yield-gatekeeping` - Protect resume methods from unauthorized callers\n\n### 9. Testing (MEDIUM)\n\n- `testing-integration-tests` - Use `near-sandbox` + `near-api` for integration tests\n- `testing-unit-tests` - Write comprehensive unit tests with mock contexts\n- `testing-sandbox` - Test with local sandbox environment before testnet\u002Fmainnet\n- `testing-edge-cases` - Test boundary conditions, overflow, and empty states\n- `testing-gas-profiling` - Profile gas usage in integration tests\n- `testing-cross-contract` - Test cross-contract calls and callbacks thoroughly\n- `testing-failure-scenarios` - Test promise failures and timeout scenarios\n- `testing-time-travel` - Use `sandbox.fast_forward()` for time-sensitive tests\n\n### 10. Best Practices (MEDIUM)\n\n- `best-contract-tools` - Use `near-sdk-contract-tools` for NEP standards (FT, NFT, etc.) and NEP-297 structured events\n- `best-panic-messages` - Provide clear, actionable panic messages\n- `best-logging` - Use `env::log_str()` for debugging and event emission\n- `best-documentation` - Document public methods, parameters, and complex logic\n- `best-error-types` - Define custom error types or use descriptive strings\n- `best-constants` - Use constants for magic numbers and configuration\n- `best-require-macro` - Use `require!` instead of `assert!` for better error messages\n- `best-promise-return` - Return promises from cross-contract calls for proper tracking\n- `best-sdk-crates` - Reuse SDK-exported crates (borsh, serde, base64, etc.)\n- `best-account-id-encoding` - Encode AccountIds in base32 for 40% storage savings\n\n## How to Use\n\nRead individual rule files for detailed explanations and code examples:\n\n```\nrules\u002Fsecurity-storage-checks.md\nrules\u002Fstructure-near-bindgen.md\nrules\u002Fstate-collections.md\nrules\u002Fxcc-promise-chaining.md\nrules\u002Fupgrade-migration.md\nrules\u002Fchain-signatures.md\nrules\u002Fyield-resume.md\nrules\u002Fbest-contract-tools.md\nrules\u002Ftesting-integration-tests.md\n```\n\nEach rule file contains:\n\n- Brief explanation of why it matters\n- Incorrect code example with explanation\n- Correct code example with explanation\n- Additional context and NEAR-specific considerations\n\n## Latest Tools & Versions\n\n### Development Tools\n\n- **cargo-near**: Latest - Build, deploy, and manage contracts (`cargo near build`, `cargo near deploy`)\n- **near-cli-rs**: Latest - Command-line interface for NEAR (`near contract call`, `near contract view`)\n- **rustc**: Latest stable - Rust compiler\n- **near-sandbox**: Latest - Local sandbox environment for integration testing\n- **near-api-rs**: Latest - Rust API client for interacting with NEAR (replaces near-workspaces-rs for tests)\n- **omni-transaction-rs**: Latest - Build transactions for multiple blockchains (Bitcoin, Ethereum, etc.)\n\n### SDK Versions\n\n- **near-sdk-rs**: v5.x (v6.x coming with structured errors support)\n- **near-sdk-contract-tools**: Latest - Derive macros for NEP standards (FT, NFT, Storage Management)\n\n### Key Features\n\n- **Unified macro syntax**: `#[near(contract_state)]` replaces `#[near_bindgen]` + derives\n- **Flexible serialization**: `#[near(serializers = [json, borsh])]` for data structs\n- **Store collections**: `near_sdk::store::IterableMap`, `IterableSet`, `LookupMap`, `LookupSet`, `Vector`, `UnorderedMap`, `UnorderedSet`, `TreeMap`\n- **Simplified cross-contract calls**: High-level promise API with `Promise::new()` and `.then()`\n- **Built-in NEP support**: FT (NEP-141), NFT (NEP-171), and other standards\n- **Result handling**: `#[handle_result]` for methods returning `Result\u003CT, E>` without panicking\n- **Yield\u002FResume**: Contracts can yield execution and wait for external services to resume\n- **Chain Signatures**: Sign transactions for other blockchains (Bitcoin, Ethereum, Solana, etc.)\n- **Contract Tools**: Derive macros for Owner, Pause, Role-based access control patterns\n\n## Resources\n\n- NEAR Documentation: \u003Chttps:\u002F\u002Fdocs.near.org>\n- Smart Contract Quickstart: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fquickstart>\n- Contract Anatomy: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002F>\n- NEAR SDK Rust: \u003Chttps:\u002F\u002Fdocs.near.org\u002Ftools\u002Fsdk>\n- SDK Rust Reference: \u003Chttps:\u002F\u002Fdocs.rs\u002Fnear-sdk>\n- Storage & Collections: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fcollections>\n- Best Practices: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fbest-practices>\n- Cross-Contract Calls: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fcrosscontract>\n- Yield & Resume: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fanatomy\u002Fyield-resume>\n- Contract Upgrades: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Frelease\u002Fupgrade>\n- Chain Signatures: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fchain-abstraction\u002Fchain-signatures>\n- Chain Signatures Implementation: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fchain-abstraction\u002Fchain-signatures\u002Fimplementation>\n- Security Best Practices: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Fsecurity\u002Fwelcome>\n- Integration Testing: \u003Chttps:\u002F\u002Fdocs.near.org\u002Fsmart-contracts\u002Ftesting\u002Fintegration-test>\n- NEP-297 Events: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002FNEPs\u002Fblob\u002Fmaster\u002Fneps\u002Fnep-0297.md>\n- NEAR Standards (NEPs): \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002FNEPs>\n- NEAR Examples: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear-examples>\n- Sandbox Testing: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-sandbox>\n- NEAR API Rust: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-api-rs>\n- Omni Transaction RS: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fomni-transaction-rs>\n- Contract Tools: \u003Chttps:\u002F\u002Fgithub.com\u002Fnear\u002Fnear-sdk-contract-tools>\n\n## Storage Costs Reference\n\n| Storage | Cost | Notes |\n|---------|------|-------|\n| 1 byte | 0.00001 NEAR | ~10kb per 0.1 NEAR |\n| 100 KB | ~1 NEAR | Approximate reference |\n| AccountId | 64+ bytes | Can save 40% with base32 encoding |\n| Contract code | Variable | Paid by contract account |\n\n## SDK Collections Reference\n\n| Collection | Iterable | Clear | Ordered | Range | Use Case |\n|------------|----------|-------|---------|-------|----------|\n| `Vector` | Yes | Yes | Yes | Yes | Ordered list with index access |\n| `LookupMap` | No | No | No | No | Fast key-value, no iteration needed |\n| `LookupSet` | No | No | No | No | Fast membership checks |\n| `IterableMap` | Yes | Yes | Yes | No | Key-value with iteration |\n| `IterableSet` | Yes | Yes | Yes | No | Set with iteration |\n| `UnorderedMap` | Yes | Yes | No | No | Key-value, unordered iteration |\n| `UnorderedSet` | Yes | Yes | No | No | Set, unordered iteration |\n| `TreeMap` | Yes | Yes | Yes | Yes | Sorted key-value with range queries |\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"version":26},"near","1.0.0","master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fmarketplace\u002Fnear-smart-contracts",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill near-smart-contracts",{"tool":43,"command":44},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill near-smart-contracts",{"tool":46,"command":47},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill near-smart-contracts","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fnear-smart-contracts\u002FSKILL.md",true,[],[52,60,67,74,81,88],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":59},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":59},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":59},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":59},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":59},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":59},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]