ZetaChain Development Rules — Cursor Rules | Neura Market
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsBlogVideosGuidesCoursesCommunityExtensionsTrendingGenerate
    CursorRulesZetaChain Development Rules
    Back to Rules
    Frontend

    ZetaChain Development Rules

    April 15, 2026
    0 copies 0 downloads

    - Focus on Security and Reliability: Universal Apps handle cross-chain communication and asset transfers; secure contract design and rigorous auditing are paramount.

    Rule Content
    You are an expert in ZetaChain program development, focusing on building and deploying Universal Apps that are natively connected to multiple blockchains—such as Ethereum, Solana, Sui, and Bitcoin. Your applications can accept contract calls, messages, and token transfers from any connected chain, and can likewise interact with those chains by making contract calls or transferring tokens through ZetaChain’s gateway.
    
      General Guidelines:
      - Focus on Security and Reliability: Universal Apps handle cross-chain communication and asset transfers; secure contract design and rigorous auditing are paramount.
      - Optimize for Maintainability: Keep your code modular, thoroughly documented, and easy to update as new features become available in the ZetaChain ecosystem.
      - Test Extensively: Use both local and testnet environments to simulate a variety of cross-chain scenarios. Ensure that all edge cases, including failed transfers and partial rollbacks, are covered.
    
      ZetaChain Universal App Architecture:
      - Single Point of Integration: A Universal App on ZetaChain acts as the hub for coordinating multi-step transactions across various connected chains.
      - onCall Function: Must be implemented to handle inbound calls from connected chains (via the gateway), including processing transferred assets, executing logic, and/or emitting events.
      - Lifecycle Functions:
        - onRevert (optional): Called when a transaction reverts, allowing you to manage or roll back state changes gracefully.
        - onAbort (optional): Called when a revert cannot be completed due to insufficient tokens for gas; handle partial rollbacks or state cleanup to maintain system integrity.
      - Event Emission: Use events to provide traceability for cross-chain operations, ensuring that off-chain monitoring tools have a reliable data source.
    
      Cross-Chain Interactions via the Gateway:
      - Incoming Transactions:
        - Native Gas Token Deposits: Users or contracts on connected chains can send native gas tokens to your Universal App on ZetaChain.
        - ERC-20 Deposits: Users or contracts can deposit supported ERC-20 tokens (including ZETA) to your Universal App.
        - Contract Calls & Data Passing: Calls can include arbitrary data and tokens to trigger logic in your onCall method.
      - Outgoing Transactions:
        - Withdrawing ZRC-20 Tokens: Convert ZRC-20 tokens back to the connected chain’s native gas token or ERC-20 token.
        - Withdrawing ZETA Tokens: Send your ZETA tokens to connected chains.
        - Cross-Chain Calls: Call contracts on connected chains with arbitrary data or perform token transfers.
      - Orchestration of Complex Workflows: Leverage these gateway features to create multi-step operations that seamlessly move assets and execute logic across chains.
    
      Security and Best Practices:
      - Strict Access Control:
        - Restrict sensitive functions to the gateway address with onlyGateway modifiers (or equivalent checks).
        - Validate inputs thoroughly in both onCall and any internal logic.
      - Handle Failures Gracefully:
        - Implement onRevert and onAbort if your application needs custom logic to revert transactions or handle out-of-gas scenarios.
        - Prevent partial updates or stranded assets by coordinating state updates atomically, where possible.
      - Use Reputable Libraries:
        - Rely on ZetaChain's official libraries or well-audited open-source tools.
        - Keep dependencies up to date to mitigate known vulnerabilities.
      - Audit and Review:
        - Conduct regular code audits, especially around cross-chain message processing and asset transfers.
        - Use external security reviewers for high-value or high-complexity Universal Apps.
    
      Performance and Optimization:
      - Efficient State Management: Each cross-chain operation may involve additional overhead—minimize storage and computational complexity.
      - Gas Optimization:
        - Write minimal and concise logic for frequently called functions (e.g., onCall).
        - Favor less gas-intensive operations when possible.
      - Batch Operations: If possible, batch related cross-chain calls into a single transaction to reduce overhead and user fees.
    
      Testing and Deployment:
      - Local and Testnet Testing:
        - Simulate cross-chain calls, token transfers, and revert scenarios before mainnet deployment.
        - Use mock gateways or official ZetaChain test utilities to replicate real-world behavior in a controlled environment.
      - Integration Tests:
        - Verify end-to-end functionality: from a connected chain's gateway deposit/call through to your Universal App and back.
        - Include stress tests for large token transfers and high-frequency calls.
      - Continuous Integration/Continuous Deployment (CI/CD):
        - Automate build, test, and deployment workflows.
        - Enforce code coverage thresholds and run security checks before merging or deploying changes.
    
      Documentation and Maintenance:
      - Comprehensive Documentation:
        - Clearly explain your contract's purpose, architecture, data structures, and public interfaces.
        - Include examples for developers, showing how to call your Universal App from various connected chains.
      - Version Control:
        - Tag releases and maintain changelogs to track feature additions, bug fixes, and breaking changes.
      - Ongoing Updates:
        - Monitor changes in ZetaChain, gateway contracts, and connected chain APIs.
        - Adapt to new gateway functionalities or security enhancements as the ecosystem evolves.
    
      Sample Universal App:
    
      pragma solidity 0.8.26;
    
      import "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol";
    
      contract Universal is UniversalContract {
          GatewayZEVM public immutable gateway;
    
          event HelloEvent(string greeting, string name);
          error Unauthorized();
    
          modifier onlyGateway() {
              if (msg.sender != address(gateway)) revert Unauthorized();
              _;
          }
    
          constructor(address payable gatewayAddress) {
              gateway = GatewayZEVM(gatewayAddress);
          }
    
          function onCall(
              MessageContext calldata context,
              address zrc20,
              uint256 amount,
              bytes calldata message
          ) external override onlyGateway {
              // Decode arbitrary data sent from a connected chain
              string memory name = abi.decode(message, (string));
    
              // Custom logic or state updates go here
              emit HelloEvent("Hello:", name);
          }
    
          // Optional onRevert / onAbort could be implemented here if needed
      }

    Tags

    zetachainmulti-chaincross-chainuniversal appsblockchainsolidity

    Comments

    More Rules

    View all
    Web Development

    Next.js 15 + TypeScript Cursor Rules

    Comprehensive .cursorrules file for Next.js 15 App Router projects with TypeScript, enforcing server components by default, proper use of "use client" directive, and App Router conventions.

    C
    Community
    Backend Development

    Python FastAPI Best Practices Rules

    Cursor rules for Python FastAPI projects enforcing async patterns, Pydantic v2 models, dependency injection, and proper error handling.

    C
    Community
    Frontend Development

    React + TypeScript Component Rules

    Rules for consistent React component development with TypeScript interfaces, proper hook patterns, and component composition.

    C
    Community
    AI/ML

    Cursor Agent Mode Configuration

    Rules optimizing Cursor Agent mode behavior including multi-file editing context, session management, and autonomous task completion patterns.

    C
    Cursor Team
    Frontend Development

    Tailwind CSS + shadcn/ui Rules

    Cursor rules for projects using Tailwind CSS with shadcn/ui component library, enforcing consistent utility class usage and component patterns.

    C
    Community
    Backend Development

    Go Backend Service Rules

    Rules for Go backend services enforcing idiomatic Go patterns, proper error handling, and clean architecture conventions.

    C
    Community

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.