write-contract
O que ela faz
Este guia mostra como escrever contratos inteligentes da GenLayer prontos para redes reais. Ele explica a fixação obrigatória da versão do runner, quando a GenLayer é a ferramenta certa, e as regras de armazenamento, tratamento de erros e chamadas entre contratos.
Quando usar
- ✓Quando você quer que o agente escreva um novo contrato inteligente da GenLayer.
- ✓Quando você quer verificar se um recurso realmente precisa do consenso da GenLayer.
- ✓Quando você está atualizando um contrato existente para uso em produção.
Link da skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/genlayer/write-contract/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Quero um contrato da GenLayer que armazene a avaliação de um usuário e a verifique com um modelo de IA.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente escreve o contrato com uma versão de runner fixada no topo, segue as regras de armazenamento e consenso e executa o linter no resultado. Antes de entregar o código, verifica o cabeçalho e as regras listadas na skill.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Por que o contrato precisa fixar uma versão do runner?
As redes da GenLayer rejeitam aliases de runner de teste, latest e sem versão, então uma versão fixada é obrigatória.
Quando não devo usar a GenLayer?
A skill diz para não usá-la quando o recurso não precisa de consenso sobre uma questão subjetiva ou externa.
O agente verifica o código automaticamente?
A skill manda o agente executar o genvm-lint em cada contrato depois de escrevê-lo ou alterá-lo.
Detalhes
Descrição original do autor
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.
Popularidade
- Estrelas no GitHub
- 7,0 mil
- Posição no ranking
- #13630
- Licença
- —
- Atualizada em
- 26/10/2026
Comentários
- …
Mais skills deste repositório
internet-court
7,0 milAjuda seu agente a pagar, contratar ou negociar com segurança outro agente de IA ou um serviço pago, e o direciona para o guia especializado certo.
genlayer-erc7710-connector
7,0 milAjuda seu agente a conectar o resultado de uma revisão de IA a um sistema de permissões, para que uma revisão ruim possa limitar ou cancelar as permissões de um agente.
genlayer-intelligent-contracts
7,0 milAjuda seu agente a definir as regras, as evidências e os resultados de um juiz de IA que verifica se outro agente seguiu o seu mandato.
x402-erc7710
7,0 milAjuda seu agente a pagar por serviços web uma requisição de cada vez, e a configurar gastos contínuos que fiquem dentro de um orçamento de permissão.
Skills parecidas
api-connector-builder
280 milFaz seu agente construir novas conexões com APIs seguindo o padrão já existente. Use quando precisar adicionar mais uma integração sem criar um novo jeito de fazer.
api-design
280 milAjuda seu agente a projetar APIs REST seguindo as melhores práticas. É útil para definir como as APIs se comunicam, como os erros são mostrados e como organizar os dados.
backend-patterns
280 milAjuda seu agente com padrões de arquitetura do lado do servidor e otimização de banco de dados. É útil para construir ou revisar o código que roda no servidor.