मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)7.0k · #13630

write-contract

यह क्या करती है

यह गाइड दिखाती है कि असली नेटवर्क के लिए तैयार GenLayer intelligent contracts कैसे लिखें। इसमें ज़रूरी runner संस्करण पिन करना, GenLayer कब सही टूल है, और storage, error handling व cross-contract calls के नियम शामिल हैं।

कब इस्तेमाल करें

  • ✓जब आप चाहते हों कि एजेंट नया GenLayer intelligent contract लिखे।
  • ✓जब आप जाँचना चाहते हों कि किसी फ़ीचर को सच में GenLayer consensus की ज़रूरत है या नहीं।
  • ✓जब आप किसी मौजूदा कॉन्ट्रैक्ट को प्रोडक्शन के लिए अपडेट कर रहे हों।

Skill का लिंक

https://github.com/internet-court/internet-court-skill/blob/main/vendored/genlayer/write-contract/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/internet-court/internet-court-skill/blob/main/vendored/genlayer/write-contract/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मुझे ऐसा GenLayer कॉन्ट्रैक्ट चाहिए जो उपयोगकर्ता की समीक्षा सहेजे और उसे AI मॉडल से जाँचे।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट कॉन्ट्रैक्ट को सबसे ऊपर पिन किए runner संस्करण के साथ लिखता है, storage और consensus के नियम मानता है, और नतीजे पर linter चलाता है। कोड देने से पहले वह हेडर और स्किल में दिए नियमों की जाँच करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Write Intelligent Contract

Guidance for writing GenLayer intelligent contracts that pass consensus, handle errors correctly, and survive production.

Critical: Pin the Runner Version

All GenLayer networks reject py-genlayer:test, py-genlayer:latest, and unversioned runner aliases. Every generated contract MUST start with a pinned runner dependency header.

# { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" }

test and latest are local-development aliases for GenLayer runtime developers. They may work only in a specially configured local Studio environment with a GenLayer developer environment variable, but they do not work on GenLayer networks and must not appear in generated user contracts.

Before returning any contract code, verify:

  • The first line is a pinned Depends runner version hash.
  • There is no py-genlayer:test.
  • There is no py-genlayer:latest.
  • There is no unversioned py-genlayer.

Always lint with genvm-lint check after writing or modifying a contract.

When to Use GenLayer

Before writing code, decide whether the feature actually needs GenLayer consensus. Recent builder feedback shows many projects start by treating GenLayer as a generic AI backend; push them toward a clear on-chain consensus role.

Use GenLayer when the contract must coordinate or settle around a subjective, external, or AI-mediated judgment that multiple validators should verify independently:

  • Dispute resolution where evidence must be evaluated and the result affects escrow, payouts, reputation, or access.
  • Prediction/oracle-style markets where the contract needs an independently validated outcome from external evidence.
  • Compliance, moderation, or scoring workflows where the final decision must be reproducible enough for validator agreement but cannot be reduced to a simple deterministic API call.
  • Autonomous agents that need transparent settlement, appeals, and auditable state transitions rather than a private off-chain decision.

Prefer a normal backend, frontend, or off-chain LLM workflow when:

  • The frontend already computes the final answer and GenLayer would only rubber-stamp it.
  • The contract only stores user-provided data with no validator-verifiable judgment.
  • A deterministic smart contract, REST API, or database job can perform the work without AI consensus.
  • The data-fetching/prompting step is not tied to an on-chain state transition, escrow, payout, or appealable decision.

For every contract, write down the boundary before implementation:

  • Frontend/backend owns: UI, user auth, indexing, non-authoritative previews, cached market data, and convenience analytics.
  • GenLayer contract owns: the minimum state transition that needs consensus, the evidence inputs, the validator comparison rule, the final settlement effect, and any appeal/rotation path.
  • External sources own: raw facts or documents; do not treat them as trusted unless validators can re-fetch, normalize, and compare them.

If the boundary is unclear, create a one-page architecture note before coding: user action -> evidence source -> nondeterministic call -> equivalence principle -> state update -> user-visible settlement.

Contract Skeleton

# { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" }

from genlayer import *

class MyContract(gl.Contract):
    # Storage fields — typed, persisted on-chain
    owner: Address
    items: TreeMap[str, Item]
    item_order: DynArray[str]

    def __init__(self, param: str):
        self.owner = gl.message.sender_account

    @gl.public.view
    def get_item(self, item_id: str) -> dict:
        return {"id": item_id, "value": self.items[item_id].value}

    @gl.public.write
    def set_item(self, item_id: str, value: str) -> None:
        if gl.message.sender_account != self.owner:
            raise gl.UserError("Only owner")
        self.items[item_id] = Item(value=value)
        self.item_order.append(item_id)

Runner Dependencies

The first line of a contract declares the GenVM Python runner. Always pin a specific runner version hash. All GenLayer networks reject test, latest, and unversioned runner aliases in generated contracts.

Single-file Python contracts

# { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" }

Multi-file Python contract packages

Use py-genlayer-multi when the contract is packaged across multiple

अक्सर पूछे जाने वाले सवाल

कॉन्ट्रैक्ट को runner संस्करण क्यों पिन करना चाहिए?

GenLayer नेटवर्क test, latest और बिना संस्करण वाले runner उपनाम अस्वीकार करते हैं, इसलिए पिन किया हुआ संस्करण ज़रूरी है।

मुझे GenLayer कब इस्तेमाल नहीं करना चाहिए?

स्किल कहती है कि जब फ़ीचर को किसी व्यक्तिपरक या बाहरी सवाल पर consensus की ज़रूरत न हो, तो उसे छोड़ दें।

क्या एजेंट कोड अपने-आप जाँचता है?

स्किल एजेंट को कहती है कि लिखने या बदलने के बाद हर कॉन्ट्रैक्ट पर genvm-lint चलाएँ।

जानकारी

लेखक का मूल विवरण

Write production-quality GenLayer intelligent contracts. Always pins concrete GenVM runner version hashes and never uses local-only test/latest runner aliases. Covers equivalence principles, storage rules, LLM resilience, and cross-contract interaction.

repo: internet-court/internet-court-skill

लोकप्रियता

GitHub स्टार
7.0k
रैंकिंग में स्थान
#13630
लाइसेंस
—
अपडेट की गई
26/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

internet-court

7.0k

यह आपके एजेंट को AI एजेंट या पेड सेवा से सुरक्षित तरीके से भुगतान और लेन-देन की शुरुआती दिशा देती है, और सही विशेष गाइड बताती है।

AI और एजेंटएजेंट

genlayer-erc7710-connector

7.0k

यह आपके एजेंट को AI समीक्षा के नतीजे को अनुमति प्रणाली से जोड़ने देती है, ताकि खराब समीक्षा एजेंट की अनुमतियाँ सीमित कर सके।

AI और एजेंटएजेंट

genlayer-intelligent-contracts

7.0k

यह आपके एजेंट को AI जज के नियम, सबूत और नतीजे तय करने में मदद करती है, जो जाँचता है कि दूसरा एजेंट अपने अधिकार के दायरे में रहा या नहीं।

AI और एजेंटएजेंट

x402-erc7710

7.0k

यह आपके एजेंट को हर अनुरोध पर वेब सेवा का भुगतान करने और तय सीमा के भीतर लगातार खर्च करने की व्यवस्था में मदद करती है।

AI और एजेंटएजेंट

मिलती-जुलती skills