# Design Reliable GenLayer Intelligent Contracts

GenLayer contracts must survive validator disagreement, changing external data, storage constraints, and unpredictable LLM responses. This skill provides practical patterns for consensus-safe contract design, error handling, storage, and cross-contract workflows.

## Install

```bash
npx skillstore add internet-court/write-contract
```

## Metadata

- Status: approved
- Slug: internet-court-write-contract
- Skillstore revision: r2
- Version status: missing
- Tree hash: 2625b03d3c1f495611c52580d71fbea850e8f760efd7536616f467595fa55ac1
- Author: internet-court
- GitHub username: internet-court
- License: MIT
- Repository: https://github.com/internet-court/internet-court-skill/tree/main/vendored/genlayer/write-contract
- Ref: 1c2ebded2116f8124f45dba86a2e567f56e64d8e
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: scripts, external\_commands, network
- Quality score: 77
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/internet-court-write-contract
- Manifest: https://skillstore.pages.dev/api/skills/internet-court-write-contract/manifest

## Capabilities

- Explain when GenLayer consensus is appropriate for a contract workflow.
- Select strict equality or comparative validation for nondeterministic operations.
- Design persistent storage with GenLayer types such as TreeMap and DynArray.
- Handle LLM, external API, and transient errors with explicit error categories.
- Show patterns for web requests, cross-contract calls, factories, and cross-chain RPC.
- Recommend pinned GenVM runner dependencies and a contract testing sequence.

## Use Cases

- Build a dispute contract: Define evidence inputs, validator comparison, settlement effects, and an appeal path for an on-chain dispute workflow.
- Review consensus logic: Assess whether a proposed LLM or web workflow independently verifies the leader result and compares the fields that affect state.
- Plan contract storage: Translate ordinary Python collections and numeric values into persistent GenLayer types with upgrade-aware layout rules.

## Prompt Templates

### Choose a GenLayer boundary

```
Assess this feature: [describe feature]. State whether GenLayer consensus is necessary. Separate frontend, backend, contract, and external-source responsibilities.
```

### Select a validation principle

```
Design validation for this operation: [describe operation]. Identify nondeterministic inputs, stable decision fields, comparison rules, failure behavior, and cases where strict equality is unsafe.
```

### Map contract storage

```
Convert this state model into GenLayer storage: [describe fields]. Recommend types, initialization, numeric representation, collection indexes, and upgrade-safe field ordering.
```

### Harden a contract workflow

```
Review this contract design: [paste design]. Produce a threat model covering validator disagreement, leader manipulation, external data, LLM errors, cross-contract calls, RPC endpoints, and resource limits. Give prioritized fixes and tests.
```

## Limitations

- It provides guidance and examples, not a deployed contract or audited implementation.
- It cannot verify current GenLayer APIs, runner hashes, network behavior, or RPC availability.
- External web data can change, fail, or disagree between validator requests.
- Generated contracts still require linting, tests, review, and deployment-specific security analysis.

## Best Practices

- Pin a concrete runner hash and verify the dependency header before returning contract code.
- Compare substantive decision fields or independently derive outcomes from the same source data.
- Classify errors explicitly and force disagreement when an LLM produces an invalid result.

## Anti Patterns

- Do not use strict equality for nondeterministic LLM calls or changing web pages.
- Do not let validators check only output shape, labels, or confidence ranges.
- Do not store native Python lists, dictionaries, or unscaled floating-point money values.

## Security Audit

- Audited at: 2026-08-07T09:21:56.025\+00:00
- Summary: Three eval-related findings are confirmed because the skill recommends executing LLM-generated expressions, despite restricted builtins and a sandbox. The remaining static findings are false positives caused by markdown backticks, headings, prose, or legitimate web and RPC guidance.

## Stats

- Views: 0
- Downloads: 5
- Favorites: 1
- Popularity score: 0
