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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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
Dependsrunner 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.
인기도
- GitHub 스타
- 7.0k
- 순위
- #13630
- 라이선스
- —
- 업데이트
- 2026. 10. 26.
댓글
- …
이 저장소의 다른 스킬
internet-court
7.0k에이전트가 다른 AI 에이전트나 유료 서비스와 안전하게 결제하거나 거래하도록 돕고, 적합한 전문 가이드를 알려 줍니다.
genlayer-erc7710-connector
7.0k에이전트가 GenLayer 검토 결과를 권한 시스템에 연결하도록 돕습니다. 나쁜 검토는 에이전트의 권한을 제한하거나 취소할 수 있습니다.
genlayer-intelligent-contracts
7.0k에이전트가 다른 에이전트가 위임받은 범위를 지켰는지 확인하는 AI 심판의 규칙, 증거, 결과를 정하도록 돕습니다.
x402-erc7710
7.0k에이전트가 웹 서비스 요금을 요청 한 건마다 결제하고, 권한 예산 안에서 지속적인 지출을 설정하도록 돕습니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.