본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)7.0k · #13630

write-contract

하는 일

이 가이드는 실제 네트워크에서 쓸 준비가 된 GenLayer 지능형 컨트랙트를 작성하는 방법을 보여 줍니다. 필수 러너 버전 고정, GenLayer가 적합한 도구인 때, 저장소와 오류 처리, 컨트랙트 간 호출 규칙을 설명합니다.

사용하는 경우

  • ✓에이전트가 새 GenLayer 지능형 컨트랙트를 작성하도록 하고 싶을 때.
  • ✓어떤 기능에 정말 GenLayer 합의가 필요한지 확인하고 싶을 때.
  • ✓운영 환경에 맞게 기존 컨트랙트를 업데이트할 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/internet-court/internet-court-skill/blob/main/vendored/genlayer/write-contract/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사용자의 리뷰를 저장하고 AI 모델로 검사하는 GenLayer 컨트랙트를 만들어 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 맨 위에 러너 버전을 고정해 컨트랙트를 작성하고, 저장소와 합의 규칙을 따르며, 결과물에 린터를 실행합니다. 코드를 주기 전에 헤더와 스킬에 나열된 규칙을 확인합니다.

기술 내용 (원본 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

자주 묻는 질문

컨트랙트가 러너 버전을 왜 고정해야 하나요?

GenLayer 네트워크는 test, latest, 버전이 없는 러너 별칭을 거부하므로 고정된 버전이 필요합니다.

언제 GenLayer를 쓰지 말아야 하나요?

주관적이거나 외부의 질문에 대해 합의가 필요하지 않은 기능이면 건너뛰라고 스킬은 말합니다.

에이전트가 코드를 자동으로 검사하나요?

네. 스킬은 작성하거나 바꾼 모든 컨트랙트에 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
라이선스
—
업데이트
2026. 10. 26.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬