-
Notifications
You must be signed in to change notification settings - Fork 2
chore: update contract feature docs #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for genlayer-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThis PR updates dependencies (Next.js, TypeScript, Playwright, and theme packages) and restructures intelligent contracts documentation by migrating content from an "advanced-features" section to a new "features" section with reorganized feature pages. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ce58580 to
2d46af8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pages/developers/intelligent-contracts/features/special-methods.mdx (1)
25-48: Fix Mermaid node syntax to avoid diagram render failure.Line 29 looks malformed (
unhandled_message>unhandled message]). Consider normal Mermaid node syntax, e.g.:- unhandled_message>unhandled message] ---> has_value[has value?] + unhandled_message[unhandled message] --> has_value[has value?]Also consider adding
import typingto the snippet (since it usestyping.Any) to keep it copy/paste friendly.
🧹 Nitpick comments (3)
pages/developers/intelligent-contracts/features/interacting-with-evm-contracts.mdx (1)
52-54: Tighten wording in the finality constraint callout.
Suggest: “Messages to EVM contracts can only be emitted on finality (i.e.,on='finalized').” (and add a period).pages/developers/intelligent-contracts/features/types.mdx (1)
1-1: Consider adding a short stub (or redirect/link) so the page isn’t empty.
Even 2–3 bullets outlining what “Types” will cover (and linking to the canonical type system docs) helps.pages/developers/intelligent-contracts/features/upgradability.mdx (1)
3-8: Improve wording clarity and code comment consistency.Lines 3–5 need grammar polish: "A contract may freeze certain storage slots during deployment. Frozen slots can be modified only if the transaction sender is in the upgraders list. Therefore, a frozen empty upgraders list with a frozen code slot makes the contract non-upgradable."
Line 25: The comment references "message.sender" but all other docs use
gl.message.sender_address. Either clarify this is pseudocode or use the actual API name for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
package.json(1 hunks)pages/developers/decentralized-applications/genlayer-js.mdx(1 hunks)pages/developers/intelligent-contracts/_meta.json(1 hunks)pages/developers/intelligent-contracts/advanced-features/_meta.json(0 hunks)pages/developers/intelligent-contracts/advanced-features/contract-to-contract-interaction.mdx(0 hunks)pages/developers/intelligent-contracts/advanced-features/error-handling.mdx(0 hunks)pages/developers/intelligent-contracts/features/_meta.json(1 hunks)pages/developers/intelligent-contracts/features/balances.mdx(1 hunks)pages/developers/intelligent-contracts/features/calling-llms.mdx(1 hunks)pages/developers/intelligent-contracts/features/debugging.mdx(1 hunks)pages/developers/intelligent-contracts/features/error-handling.mdx(1 hunks)pages/developers/intelligent-contracts/features/features.mdx(1 hunks)pages/developers/intelligent-contracts/features/interacting-with-evm-contracts.mdx(1 hunks)pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdx(1 hunks)pages/developers/intelligent-contracts/features/non-determinism.mdx(1 hunks)pages/developers/intelligent-contracts/features/special-methods.mdx(1 hunks)pages/developers/intelligent-contracts/features/storage.mdx(1 hunks)pages/developers/intelligent-contracts/features/types.mdx(1 hunks)pages/developers/intelligent-contracts/features/upgradability.mdx(1 hunks)pages/developers/intelligent-contracts/features/web-access.mdx(1 hunks)pages/developers/intelligent-contracts/storage.mdx(1 hunks)
💤 Files with no reviewable changes (3)
- pages/developers/intelligent-contracts/advanced-features/error-handling.mdx
- pages/developers/intelligent-contracts/advanced-features/contract-to-contract-interaction.mdx
- pages/developers/intelligent-contracts/advanced-features/_meta.json
🧰 Additional context used
📓 Path-based instructions (2)
pages/**/*.mdx
📄 CodeRabbit inference engine (CLAUDE.md)
pages/**/*.mdx: All content is in MDX format supporting React components
Import and use custom components within MDX files
Create .mdx file in appropriate pages/ subdirectory when adding new pages
All content should support React components in MDX files
Files:
pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdxpages/developers/intelligent-contracts/features/interacting-with-evm-contracts.mdxpages/developers/intelligent-contracts/features/web-access.mdxpages/developers/intelligent-contracts/features/types.mdxpages/developers/intelligent-contracts/features/non-determinism.mdxpages/developers/intelligent-contracts/features/calling-llms.mdxpages/developers/decentralized-applications/genlayer-js.mdxpages/developers/intelligent-contracts/features/features.mdxpages/developers/intelligent-contracts/features/debugging.mdxpages/developers/intelligent-contracts/features/special-methods.mdxpages/developers/intelligent-contracts/features/storage.mdxpages/developers/intelligent-contracts/features/error-handling.mdxpages/developers/intelligent-contracts/storage.mdxpages/developers/intelligent-contracts/features/upgradability.mdxpages/developers/intelligent-contracts/features/balances.mdx
pages/**/_meta.json
📄 CodeRabbit inference engine (CLAUDE.md)
pages/**/_meta.json: Navigation is controlled by _meta.json files in each directory
Edit _meta.json files to change page ordering or titles
Update corresponding _meta.json to include the new page when adding new pages
Files:
pages/developers/intelligent-contracts/features/_meta.jsonpages/developers/intelligent-contracts/_meta.json
🧠 Learnings (16)
📓 Common learnings
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-docs PR: 244
File: next-env.d.ts:3-6
Timestamp: 2025-07-09T18:27:44.033Z
Learning: Next.js automatically updates next-env.d.ts file during dependency updates, including adding new type references like "next/navigation-types/compat/navigation" when upgrading versions. These changes are not manual edits and should not be flagged as problematic.
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Setup Guide Updates (pages/validators/setup-guide.mdx): Update version references in download examples and version lists, update configuration examples with new contract addresses when applicable, enhance command documentation when new features are added to existing commands, update genesis block configuration in consensus section when network upgrades occur
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Update configuration examples with new contract addresses in setup-guide.mdx when applicable
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Update version list in curl command output example (line ~88), download command version variable (line ~113), consensus contract addresses and genesis block number (lines ~143-146), and command documentation (line ~347) in setup-guide.mdx for new validator releases
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Update configuration examples with new contract addresses in setup-guide.mdx when applicable
Applied to files:
pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdxpages/developers/intelligent-contracts/features/interacting-with-evm-contracts.mdxpages/developers/intelligent-contracts/features/web-access.mdxpages/developers/intelligent-contracts/features/non-determinism.mdxpages/developers/decentralized-applications/genlayer-js.mdxpages/developers/intelligent-contracts/features/features.mdxpages/developers/intelligent-contracts/features/special-methods.mdxpages/developers/intelligent-contracts/features/storage.mdxpages/developers/intelligent-contracts/features/error-handling.mdxpages/developers/intelligent-contracts/features/upgradability.mdxpages/developers/intelligent-contracts/features/balances.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Setup Guide Updates (pages/validators/setup-guide.mdx): Update version references in download examples and version lists, update configuration examples with new contract addresses when applicable, enhance command documentation when new features are added to existing commands, update genesis block configuration in consensus section when network upgrades occur
Applied to files:
pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdxpages/developers/intelligent-contracts/features/interacting-with-evm-contracts.mdxpages/developers/intelligent-contracts/features/web-access.mdxpages/developers/intelligent-contracts/features/non-determinism.mdxpages/developers/intelligent-contracts/features/calling-llms.mdxpages/developers/decentralized-applications/genlayer-js.mdxpages/developers/intelligent-contracts/features/features.mdxpages/developers/intelligent-contracts/features/debugging.mdxpages/developers/intelligent-contracts/features/error-handling.mdxpages/developers/intelligent-contracts/features/upgradability.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/**/_meta.json : Update corresponding _meta.json to include the new page when adding new pages
Applied to files:
pages/developers/intelligent-contracts/features/_meta.json
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/**/_meta.json : Edit _meta.json files to change page ordering or titles
Applied to files:
pages/developers/intelligent-contracts/features/_meta.json
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/**/_meta.json : Navigation is controlled by _meta.json files in each directory
Applied to files:
pages/developers/intelligent-contracts/features/_meta.json
📚 Learning: 2025-07-09T18:27:44.033Z
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-docs PR: 244
File: next-env.d.ts:3-6
Timestamp: 2025-07-09T18:27:44.033Z
Learning: Next.js automatically updates next-env.d.ts file during dependency updates, including adding new type references like "next/navigation-types/compat/navigation" when upgrading versions. These changes are not manual edits and should not be flagged as problematic.
Applied to files:
pages/developers/intelligent-contracts/features/types.mdxpackage.json
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/**/*.mdx : All content is in MDX format supporting React components
Applied to files:
pages/developers/intelligent-contracts/features/types.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to theme.config.tsx : Nextra configuration is in theme.config.tsx, including logos, social links, SEO, and LaTeX support
Applied to files:
package.json
📚 Learning: 2025-08-19T21:48:24.895Z
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-docs PR: 278
File: components/copy-page.tsx:0-0
Timestamp: 2025-08-19T21:48:24.895Z
Learning: In the genlayer-docs project, markdown files are generated during the build process via `npm run sync-mdx`. If markdown generation fails, the entire deployment process fails, ensuring that markdown files will always exist in production environments.
Applied to files:
package.json
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to theme.config.tsx : Use nextra-theme-docs with custom styling as configured
Applied to files:
package.json
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Update genesis block configuration in consensus section of setup-guide.mdx when network upgrades occur
Applied to files:
pages/developers/intelligent-contracts/features/non-determinism.mdxpages/developers/decentralized-applications/genlayer-js.mdxpages/developers/intelligent-contracts/features/upgradability.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Update consensus contract addresses and genesis block number in setup-guide.mdx when network upgrades occur
Applied to files:
pages/developers/intelligent-contracts/features/non-determinism.mdxpages/developers/decentralized-applications/genlayer-js.mdxpages/developers/intelligent-contracts/features/upgradability.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : Consensus contract addresses change with network upgrades and must be updated in configuration examples
Applied to files:
pages/developers/intelligent-contracts/features/non-determinism.mdx
📚 Learning: 2025-07-24T07:56:58.272Z
Learnt from: CR
Repo: genlayerlabs/genlayer-docs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T07:56:58.272Z
Learning: Applies to pages/validators/setup-guide.mdx : GenVM diagnostics integration affects the doctor command behavior and should be documented in the validator setup guide
Applied to files:
pages/developers/intelligent-contracts/features/debugging.mdx
📚 Learning: 2025-08-06T03:05:43.455Z
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-docs PR: 273
File: pages/developers/intelligent-contracts/types/collections.mdx:52-56
Timestamp: 2025-08-06T03:05:43.455Z
Learning: GenVM typing convention: Storage field declarations use GenVM-specific sized types (u256, u8, etc.) while method parameters and return types must use standard Python types (int, str, bool). For example, a storage field can be `numbers: DynArray[u256]` but the method parameter must be `num: int` or `row: DynArray[int]`. GenVM handles conversion automatically between method parameter types and storage types.
Applied to files:
pages/developers/intelligent-contracts/features/storage.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Playwright E2E
🔇 Additional comments (6)
pages/developers/decentralized-applications/genlayer-js.mdx (1)
52-55: Verify the updated relative link resolves in the rendered site.
../intelligent-contracts/features/interacting-with-intelligent-contractslooks consistent with the new structure, but please confirm the route resolves (no trailing/features/index prefix differences) after the re-org.pages/developers/intelligent-contracts/storage.mdx (1)
197-206: Whitespace-only change looks safe; just ensure the code fence still renders as intended.Given this is inside a fenced block, a quick preview/build check will catch any accidental fence breakage.
pages/developers/intelligent-contracts/_meta.json (1)
2-4: Confirm the new"features"nav entry matches the actual route/landing page.If the landing page is
features/features.mdx(common pattern), confirm the intended user-facing sidebar item still points where you expect (and not to a missing/featuresindex).pages/developers/intelligent-contracts/features/_meta.json (1)
1-16: LGTM — metadata mapping looks consistent and complete for the added feature pages.pages/developers/intelligent-contracts/features/debugging.mdx (1)
1-31: Well-structured debugging documentation with proper component usage.The new debugging guide imports and uses the Callout component correctly. Content is clear, sections are logically organized, and the code example has the proper language identifier.
pages/developers/intelligent-contracts/features/features.mdx (1)
1-25: No issues found — all referenced feature pages exist and are correctly configured.The features index properly structures content using Card and Cards components from nextra-theme-docs with correct relative href paths. Verification confirms all 13 referenced feature pages exist in the features directory: types, storage, error-handling, upgradability, balances, interacting-with-intelligent-contracts, interacting-with-evm-contracts, vector-storage, debugging, special-methods, non-determinism, calling-llms, and web-access.
| "dependencies": { | ||
| "clsx": "^2.1.1", | ||
| "next": "^15.0.0", | ||
| "nextjs-google-analytics": "^2.3.3", | ||
| "nextra": "^2.13.2", | ||
| "nextra-theme-docs": "^2.13.2", | ||
| "next": "^15.5.9", | ||
| "nextjs-google-analytics": "^2.3.7", | ||
| "nextra": "^2.13.4", | ||
| "nextra-theme-docs": "^2.13.4", | ||
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.55.0", | ||
| "@playwright/test": "^1.57.0", | ||
| "@types/node": "22.10.1", | ||
| "typescript": "^5.0.0" | ||
| "typescript": "^5.9.3" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Next.js 15.5.9 React version requirements minimum supported React version
💡 Result:
Minimum supported React (and react-dom) for Next.js 15.x (including 15.5.9) is React 19. (nextjs.org)
Citations:
🌐 Web query:
Nextra 2.13.4 Next.js 15 React 18 compatibility requirements
💡 Result:
Short answer
- Nextra 2.13.4 itself lists fairly loose peerDependencies: next >= 9.5.3, react >= 16.13.1, react-dom >= 16.13.1. [1]
- Next.js 15, however, targets React 19 for the App Router and only officially keeps backward compatibility for React 18 on the Pages Router — running the App Router with React 18 is not recommended. If you plan to use Next.js 15 + App Router, you should move to React 19 (or accept the risks of mixing). [2]
Recommendation
- If you want to use Nextra 2.13.4 with Next.js 15 while keeping React 18, use the Pages Router (Next.js 15 supports Pages Router on React 18). For App Router features on Next 15, upgrade to React 19. [1][2]
Sources
- Nextra 2.13.4 package/lock metadata (peerDependencies: next >= 9.5.3, react >= 16.13.1, react-dom >= 16.13.1). [1]
- Next.js 15 blog/upgrade notes (React 19 primary for App Router; Pages Router backward-compatible with React 18). [2]
🌐 Web query:
Next.js 15 React 18 vs React 19 support compatibility
💡 Result:
Short answer
- Next.js 15 targets React 19 as the minimum and primary runtime (especially for the App Router). [1][2]
- Next.js 15 retains backward compatibility so the Pages Router can still run on React 18, but the App Router expects React 19 (mixing routers/React versions in one app is not recommended). [1][2]
- If you rely on third‑party packages that don’t support React 19 yet, you can keep React 18 for Pages Router usage, but expect possible incompatibilities with App Router features; Next’s upgrade docs and codemods are recommended. [2][3]
Sources
[1] Next.js 15 release notes/blog.
[2] Next.js 15 upgrade guide (docs).
[3] Next.js 15.1 blog (React 19 support details).
Upgrade React to version 19.x: Next.js 15.5.9 requires React 19 as its minimum supported version.
Next.js 15.x officially targets React 19. While the Pages Router can technically run on React 18, the App Router expects React 19. Keeping React 18.3.1 will cause incompatibilities, especially if the project uses App Router features. Update "react": "^19.0.0" and "react-dom": "^19.0.0" in dependencies to align with Next.js 15.5.9 requirements. Nextra 2.13.4 is compatible with both React versions, but the Next.js + React combination must match.
🤖 Prompt for AI Agents
In package.json around lines 27 to 40, the project lists react and react-dom at
18.3.1 which is incompatible with Next.js 15.5.9 that requires React 19; update
the dependencies to use "react": "^19.0.0" and "react-dom": "^19.0.0" (or a
compatible 19.x range) and then run install to update the lockfile, ensuring any
peer-dependency warnings are addressed and run your app/test suite to verify
compatibility.
| ## Transferring Funds | ||
|
|
||
| Transfer funds from sender to current contract: | ||
|
|
||
| ```python | ||
| other_contract = gl.get_contract_at(gl.message.sender_address) | ||
| other_contract.emit_transfer(value=u256(5)) | ||
| other_contract.emit(value=u256(5), on='finalized').transfer(Address("0x...")) | ||
| ``` | ||
|
|
||
| ## Balance Context | ||
|
|
||
| Balance behavior depends on execution context: | ||
| - In `write` methods: `self.balance` reflects actual contract balance after state changes | ||
| - In `view` methods: Balance shows current state without modifications | ||
| - Transfers can only occur in write context | ||
|
|
||
| <Callout type="warning"> | ||
| If message is emitted on acceptance and previous transaction gets successfully appealed after the emit, | ||
| the balance will be decremented nonetheless | ||
| </Callout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
GenLayer GenVM intelligent contract transfer funds emit_transfer API
💡 Result:
Short answer
- GenLayer's GenVM exposes ContractAt.emit_transfer(...) to send native-token transfers when calling another contract; it's a "nameless" transfer (no method name) and you pass value as an argument. Recipients handle these by implementing receive and senders attach value or use @gl.public.write.payable for payable methods. [1][2][3]
Minimal example (Python Intelligent Contract)
- Sender:
from genlayer import *
class Sender(gl.Contract):
@gl.public.write
def pay(self, to: Address, amount: int):
gl.ContractAt(to).emit_transfer(value=amount) - Receiver:
from genlayer import *
class Receiver(gl.Contract):
def receive(self):
# called when contract receives a nameless transfer
payer = gl.message.sender
amt = gl.message.value
# handle funds...
Key notes
- Use @gl.public.write.payable on methods that should accept incoming value. [1][3]
- Contract balance available via contract.balance; outgoing transfers use ContractAt(...).emit_transfer(value=...). [1][2]
- See GenLayer docs for full API, types, and simulator testing. [1][2]
Sources
[1] GenLayer — Working With Balances (emit_transfer, payable, receive).
[2] GenLayer SDK — gl.ContractAt and emit_transfer API.
[3] GenLayer Docs — Your First Contract (decorators, payable usage).
🌐 Web query:
GenLayer finalized vs accepted contract event emission semantics
💡 Result:
Short answer — Accepted = tentative; Finalized = irreversible.
-
"Accepted" means validators reached majority but the finality/appeal window is still open. State and logs at Accepted can be appealed/recomputed and therefore may be be rolled back or changed. Use Accepted if you need faster, optimistic visibility but can tolerate reversions. [1][2][3]
-
"Finalized" means the appeal window passed (or fast-finality paid) and the transaction is immutable — contract state, messages and any durable outputs are permanent. Emit events/messages only when you require irreversible guarantees. [2][3]
-
GenLayer supports message-based contract-to-contract writes and lets developers choose when a message is emitted; messages emitted as part of an Accepted-state execution can be subject to appeals, while messages/emissions tied to Finalized state are non-reversible. For cross-contract interaction the docs explicitly point out message emission semantics to avoid cascading rollbacks. [4][2]
If you want, tell me which event/message in your contract you plan to emit and I’ll advise whether to emit at Accepted (optimistic, faster) or wait for Finalized (durable, safe), and show code examples. [1][2][3][4]
Sources:
- GenLayer — Transaction Processing / Statuses. [docs.genlayer.com]. [1]
- GenLayer — Finality / Finality Window (appeals, fast finality). [docs.genlayer.com]. [2]
- GenLayer API — gen_getContractState (status param: "accepted" or "finalized"). [docs.genlayer.com]. [3]
- Explanation of GenLayer contract-to-contract messaging and non-reversibility choices. (Medium article). [4]
Code snippet has two issues: incorrect transfer API syntax and misleading warning semantics.
The .emit(..., on='finalized').transfer(...) pattern is not part of the documented GenLayer API. Use the canonical emit_transfer(value=...) method only. Additionally:
- The snippet description "Transfer funds from sender to current contract" is backwards—transfers go TO another contract.
- The warning callout mentions "emitted on acceptance" but references
on='finalized'; these are contradictory. Transfers emitted during Accepted state can be appealed/rolled back; Finalized emissions are irreversible. Clarify which context applies and align the warning accordingly.
🤖 Prompt for AI Agents
pages/developers/intelligent-contracts/features/balances.mdx lines 25-45: the
sample uses a non-existent emit(..., on='finalized').transfer(...) pattern and
the prose/warning misstates transfer direction and lifecycle semantics; replace
the chained emit call with the documented emit_transfer(value=...) API, update
the explanatory text to state that transfers move funds from the current
contract to another contract (or vice versa depending on the example), and fix
the callout to reference the correct lifecycle state (use "emitted on
acceptance" and on='accepted' if an emission can be appealed/rolled back, or use
"emitted on finalized" and on='finalized' if irreversible) so example code and
warning consistently match the chosen state.
| ## JSON Response Format | ||
|
|
||
| Request structured responses from LLMs: | ||
|
|
||
| ```python | ||
| def structured_llm_call(): | ||
| prompt = """ | ||
| Return a JSON object with these keys: | ||
| - "score": random integer from 1 to 100 | ||
| - "status": either "active" or "inactive" | ||
| """ | ||
| return gl.nondet.exec_prompt(prompt, response_format='json') | ||
|
|
||
| result = gl.eq_principle.strict_eq(structured_llm_call) | ||
| score = result['score'] # Access JSON fields | ||
| ``` | ||
|
|
||
| This approach guarantees that `exec_prompt` returns a valid JSON object, however | ||
| correspondence to the specified format depends on the underlying LLM. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make JSON expectations explicit (avoid implying schema validation).
Line 33-35 correctly notes that “valid JSON” ≠ “matches your schema”, but the examples should also reflect that: the prompt in validated_call doesn’t require a number key, yet the code assumes response['number']. Consider tightening the prompt (and optionally showing a defensive .get() + error).
def validated_call():
response = gl.nondet.exec_prompt(
- "Generate a number between 1 and 100",
+ 'Return JSON like {"number": <integer 1..100>}. Only return JSON.',
response_format='json'
)
# Validate the response
- if response['number'] < 1 or response['number'] > 100:
- raise Exception(f"Invalid number: {response['number']}")
+ number = response.get("number")
+ if not isinstance(number, int) or number < 1 or number > 100:
+ raise ValueError(f"Invalid number: {number!r}")
- return response['number']
+ return numberAlso applies to: 54-72
| ```python | ||
| def vision_analysis(): | ||
| prompt = "Describe what you see in this image" | ||
| image_data = b"\x89PNG...' | ||
| return gl.nondet.exec_prompt( | ||
| prompt, | ||
| images=[image_data] | ||
| ) | ||
|
|
||
| description = gl.eq_principle.strict_eq(vision_analysis) | ||
| ``` | ||
|
|
||
| Limit of images is just two | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix broken Python snippet (image_data bytes literal) and clarify the image limit text.
Line 43 has a mismatched quote (b"\x89PNG...') which will not run if copied. Also, consider making the “2 images” constraint a callout/note and phrasing it as a hard limit (if it is).
def vision_analysis():
prompt = "Describe what you see in this image"
- image_data = b"\x89PNG...'
+ image_data = b"\x89PNG..."
return gl.nondet.exec_prompt(
prompt,
images=[image_data]
)🤖 Prompt for AI Agents
In pages/developers/intelligent-contracts/features/calling-llms.mdx around lines
40 to 53, the Python snippet has a mismatched quote in the image_data bytes
literal and the surrounding text about image limits is vague; fix the code by
using a valid, consistently quoted bytes literal placeholder (e.g.,
b'\x89PNG...' or b"\x89PNG...") so it’s syntactically correct, and update the
prose to add a clear callout/note stating the hard limit of 2 images (phrase it
as a strict limit) so readers know they may pass at most two images.
| Exit codes terminate execution immediately: | ||
|
|
||
| ```python | ||
| if invalid_condition: | ||
| exit(1) | ||
| ``` | ||
|
|
||
| Unhandled exceptions also become unrecoverable: | ||
|
|
||
| ```python | ||
| raise Exception("Critical error") # Becomes exit(1) | ||
| ``` | ||
|
|
||
| ## UserError | ||
|
|
||
| User-generated errors with UTF-8 encoded messages: | ||
|
|
||
| ```python | ||
| # Can be caught in current sub-vm | ||
| raise gl.UserError("Invalid input") | ||
|
|
||
| # Immediate user error, more efficient but can't be caught | ||
| gl.user_error_immediate("Insufficient funds") | ||
| ``` | ||
|
|
||
| ## VMError | ||
|
|
||
| VM-generated errors with predefined string codes: | ||
|
|
||
| ```python | ||
| # Non-zero exit codes become VMError | ||
| exit(1) # Results in VMError with specific code | ||
|
|
||
| # Resource limit violations also trigger VMError | ||
| # (handled automatically by the VM) | ||
| ``` | ||
|
|
||
| ## Catching UserError | ||
|
|
||
| Handle user errors from sub-VMs: | ||
|
|
||
| ```python | ||
| def risky_operation(): | ||
| raise gl.UserError("Operation failed") | ||
|
|
||
| try: | ||
| result = gl.eq_principle.strict_eq(risky_operation) | ||
| except gl.UserError as e: | ||
| print(f"Caught user error: {e.message}") | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Search for GenLayer documentation on error handling and APIs
git ls-files | grep -E '(README|docs|DOCS|guide|API|api)' | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 984
🏁 Script executed:
# Look for Python SDK or contract documentation files
fd -e md -e mdx -e py | grep -iE '(error|exception|api|contract)' | head -30Repository: genlayerlabs/genlayer-docs
Length of output: 1838
🏁 Script executed:
# Search for references to gl.UserError in codebase
rg 'gl\.UserError|user_error' -t py -t md -t mdx | head -40Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
# Search for exit code handling documentation
rg 'exit\(|SystemExit|gl\.user_error_immediate' -t py -t md -t mdx | head -40Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
# Search for UserError and user_error patterns without type filter
rg 'UserError|user_error' | grep -E '\.(py|mdx):' | head -50Repository: genlayerlabs/genlayer-docs
Length of output: 1539
🏁 Script executed:
# Read the target file to see exact content
cat -n pages/developers/intelligent-contracts/features/error-handling.mdx | head -60Repository: genlayerlabs/genlayer-docs
Length of output: 1614
🏁 Script executed:
# Read the Python API reference documentation
cat -n pages/api-references/genlayer-py.mdx | head -100Repository: genlayerlabs/genlayer-docs
Length of output: 3009
🏁 Script executed:
# Read more of genlayer-py.mdx looking for UserError/error documentation
cat -n pages/api-references/genlayer-py.mdx | tail -200Repository: genlayerlabs/genlayer-docs
Length of output: 4204
🏁 Script executed:
# Check equivalence-principle.mdx for UserError usage context
cat -n pages/developers/intelligent-contracts/equivalence-principle.mdx | grep -A 5 -B 5 'gl.vm.UserError'Repository: genlayerlabs/genlayer-docs
Length of output: 1270
🏁 Script executed:
# Search for exception attribute patterns (.message, .code, etc.)
rg 'e\.(message|code|value|str)' pages/developers/intelligent-contracts/ -A 1 -B 1Repository: genlayerlabs/genlayer-docs
Length of output: 5038
🏁 Script executed:
# Look for exit() usage patterns in examples
rg 'exit\(' pages/developers/intelligent-contracts/ -A 2 -B 2Repository: genlayerlabs/genlayer-docs
Length of output: 1346
🏁 Script executed:
# Search for gl.UserError vs gl.vm.UserError usage patterns
rg 'gl\.(UserError|vm\.UserError|user_error)' pages/developers/ -B 2 -A 2Repository: genlayerlabs/genlayer-docs
Length of output: 3665
🏁 Script executed:
# Check if there are import statements clarifying the namespace
rg 'import.*gl|from.*gl' pages/developers/intelligent-contracts/ | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 428
🏁 Script executed:
# Look for more complete error handling documentation
find pages/developers/intelligent-contracts -name "*.mdx" -exec grep -l "error\|exception\|Error" {} \;Repository: genlayerlabs/genlayer-docs
Length of output: 2073
🏁 Script executed:
# Check first-contract.mdx to understand the gl namespace import better
cat pages/developers/intelligent-contracts/first-contract.mdx | head -80Repository: genlayerlabs/genlayer-docs
Length of output: 3474
🏁 Script executed:
# Search all files for how gl is imported/used to determine correct namespace
rg 'import.*gl|from.*gl|import \*' pages/developers/intelligent-contracts/ --type-list | head -30Repository: genlayerlabs/genlayer-docs
Length of output: 459
🏁 Script executed:
# Search for all UserError references to see the full pattern
rg 'UserError' pages/developers/intelligent-contracts/ -B 1 -A 1Repository: genlayerlabs/genlayer-docs
Length of output: 3440
🏁 Script executed:
# Look for any examples showing error handling in working contracts
cat pages/developers/intelligent-contracts/examples/_advanced/_adr-validator.mdx | grep -A 10 -B 10 -i "error\|exception" | head -40Repository: genlayerlabs/genlayer-docs
Length of output: 833
Clarify exception namespace and document undocumented error APIs.
The error handling examples use gl.UserError for raising and catching exceptions, but the equivalence-principle documentation references gl.vm.UserError in type annotations—confirm which namespace is correct. Additionally, gl.user_error_immediate() is documented only in this file with no supporting documentation elsewhere, and the exit(code) pattern lacks any documentation in the SDK reference. The .message attribute usage appears consistent, but the namespace inconsistency and undocumented functions should be clarified against the actual GenLayer runtime to ensure developers use the correct APIs.
🤖 Prompt for AI Agents
In pages/developers/intelligent-contracts/features/error-handling.mdx around
lines 5 to 54, the examples mix namespaces and reference undocumented APIs:
confirm whether the runtime exposes UserError as gl.UserError or gl.vm.UserError
and make all examples and type annotations match the actual runtime export; add
short SDK docs for gl.user_error_immediate() (behavior, catchability, UTF-8
message semantics) and document the exit(code) pattern and how it maps to
VMError/exit codes; ensure the example uses the correct exception attribute
(e.g., .message) that exists on the runtime error object and update the text to
point readers to the authoritative runtime API reference.
| ```python | ||
| contract_address = Address("0x03FB09251eC05ee9Ca36c98644070B89111D4b3F") | ||
|
|
||
| dynamically_typed_contract = gl.get_contract_at(contract_address) | ||
|
|
||
| @gl.contract_interface | ||
| class GenLayerContractIface: | ||
| class View: | ||
| def method_name(self, a: int, b: str): ... | ||
|
|
||
| class Write: | ||
| pass | ||
|
|
||
| statically_typed_contract = GenLayerContractIface(contract_address) | ||
| ``` | ||
|
|
||
| Both approaches result in the same runtime value, | ||
| however the statically typed approach provides type checking and autocompletion in IDEs. | ||
|
|
||
| ## Calling View Methods | ||
|
|
||
| Call read-only methods on other contracts: | ||
|
|
||
| ```python | ||
| addr: Address = ... | ||
| other = gl.get_contract_at(addr) | ||
| result = other.view().get_token_balance() | ||
| ``` | ||
|
|
||
| ## Emitting Messages | ||
|
|
||
| Send asynchronous messages to other contracts: | ||
|
|
||
| ```python | ||
| other = gl.get_contract_at(addr) | ||
| other.emit(on='accepted').update_status("active") | ||
| other.emit(on='finalized').update_status("active") | ||
| ``` | ||
|
|
||
| ## Deploying New Contracts | ||
|
|
||
| ```python | ||
| gl.deploy_contract(code=contract_code) | ||
| salt: u256 = u256(1) # not zero | ||
| child_address = gl.deploy_contract(code=contract_code, salt=salt) | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Search for contract interaction API implementations
find . -type f \( -name "*.py" -o -name "*.ts" -o -name "*.js" \) | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 624
🏁 Script executed:
# Look for get_contract_at implementation
rg "get_contract_at|contract_interface|\.view\(|\.emit\(" --type py --type ts --type js -A 2 | head -50Repository: genlayerlabs/genlayer-docs
Length of output: 52
🏁 Script executed:
# Search for deploy_contract implementation
rg "deploy_contract" --type py --type ts --type js -B 2 -A 5 | head -60Repository: genlayerlabs/genlayer-docs
Length of output: 52
🏁 Script executed:
# Check for SDK/runtime files that might define these APIs
find . -type f -name "*.py" -path "*/sdk/*" -o -name "*.py" -path "*/runtime/*" | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 52
🏁 Script executed:
# Look at the file being reviewed for context
cat -n pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdx | head -70Repository: genlayerlabs/genlayer-docs
Length of output: 1643
🏁 Script executed:
# Look for SDK or API reference files
find . -type f \( -name "*.mdx" -o -name "*.md" \) | grep -E "(sdk|api|reference|spec)" | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 953
🏁 Script executed:
# Search for mentions of contract interaction APIs in other docs
rg "get_contract_at|contract_interface|\.view\(\)|\.emit\(" --type mdx -B 2 -A 2 | head -80Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
# Check if there's a reference to external SDK documentation
rg "sdk|SDK|genlayer" ./pages/developers --type mdx | grep -i "reference\|doc\|github" | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
# Look at similar example patterns in other files
find ./pages/developers -name "*.mdx" -exec head -50 {} + | grep -A 3 "Address\|addr: Address" | head -40Repository: genlayerlabs/genlayer-docs
Length of output: 1508
🏁 Script executed:
# Check for any SDK import or setup documentation
rg "import.*gl|from.*gl|gl\." ./pages --type mdx | head -30Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
# Read the Python SDK API reference file
cat -n pages/api-references/genlayer-py.mdx | head -150Repository: genlayerlabs/genlayer-docs
Length of output: 4204
🏁 Script executed:
# Search for get_contract_at in the docs
grep -rn "get_contract_at" ./pages --include="*.mdx" --include="*.md"Repository: genlayerlabs/genlayer-docs
Length of output: 738
🏁 Script executed:
# Search for contract_interface in the docs
grep -rn "contract_interface" ./pages --include="*.mdx" --include="*.md"Repository: genlayerlabs/genlayer-docs
Length of output: 303
🏁 Script executed:
# Search for emit and view in contract context
grep -rn "\.emit\|\.view" ./pages --include="*.mdx" --include="*.md" | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 2236
🏁 Script executed:
# Search for deploy_contract in docs
grep -rn "deploy_contract" ./pages --include="*.mdx" --include="*.md"Repository: genlayerlabs/genlayer-docs
Length of output: 703
🏁 Script executed:
# Read the balances.mdx file to see get_contract_at context
cat -n pages/developers/intelligent-contracts/features/balances.mdxRepository: genlayerlabs/genlayer-docs
Length of output: 1617
🏁 Script executed:
# Look for documentation on contract-to-contract calls (gl. prefix vs client.)
grep -rn "gl\.get_contract_at\|gl\.emit\|gl\.deploy_contract" ./pages --include="*.mdx" -B 2 -A 2Repository: genlayerlabs/genlayer-docs
Length of output: 3625
🏁 Script executed:
# Check context around contract_code usage
grep -rn "contract_code" ./pages --include="*.mdx" -B 3 -A 3 | head -60Repository: genlayerlabs/genlayer-docs
Length of output: 3747
🏁 Script executed:
# Look for any documentation on how to define contract_code
grep -rn "code=" ./pages --include="*.mdx" -B 2 -A 2 | head -50Repository: genlayerlabs/genlayer-docs
Length of output: 799
🏁 Script executed:
# Verify .view() and .emit() method signatures from examples
grep -rn "\.view()\|\.emit(" ./pages --include="*.mdx" -B 1 -A 1Repository: genlayerlabs/genlayer-docs
Length of output: 2317
Update placeholder examples for clarity: The code snippets use undefined placeholders (addr and contract_code) that can confuse developers implementing these patterns.
For addr on line 31, provide a concrete example:
-addr: Address = ...
+addr: Address = Address("0x03FB09251eC05ee9Ca36c98644070B89111D4b3F")For contract_code on line 49, reference how to load contract code (consistent with testing examples):
-gl.deploy_contract(code=contract_code)
+contract_code = open("contracts/my_contract.py").read()
+gl.deploy_contract(code=contract_code)The API methods (get_contract_at, @gl.contract_interface, .view(), .emit(on=...), deploy_contract) are correctly documented and match usage across other documentation files.
🤖 Prompt for AI Agents
In
pages/developers/intelligent-contracts/features/interacting-with-intelligent-contracts.mdx
around lines 7 to 52, replace the ambiguous placeholders with concrete examples:
show `addr` as a realistic Address value (e.g., Address("0x...") or a child
address returned from a prior deploy) and show `contract_code` as being loaded
consistent with tests (e.g., read from a file or obtained via the project
compiler helper), and update the snippets to reference those concrete variables
so readers can copy/paste and run the examples.
| ```python | ||
| def non_deterministic_function(): | ||
| # This code may produce different results on different nodes | ||
| return random.randint(1, 100) | ||
|
|
||
| # Validators reach consensus on the result | ||
| result = gl.eq_principle.strict_eq(non_deterministic_function) | ||
| ``` | ||
|
|
||
| ## Accessing External Data | ||
|
|
||
| Use non-deterministic blocks for external API calls: | ||
|
|
||
| ```python | ||
| @gl.public.write | ||
| def fetch_external_data(self): | ||
| def fetch_data(): | ||
| # External API call - inherently non-deterministic | ||
| response = requests.get("https://api.example.com/data") | ||
| return response.json() | ||
|
|
||
| # Consensus ensures all validators agree on the result | ||
| data = gl.eq_principle.strict_eq(fetch_data) | ||
| return data | ||
| ``` | ||
|
|
||
| ## Random Values | ||
|
|
||
| Generate consensus-based random values: | ||
|
|
||
| ```python | ||
| @gl.public.write | ||
| def generate_random(self): | ||
| def random_generator(): | ||
| import random | ||
| return random.random() | ||
|
|
||
| # All validators will agree on this "random" value | ||
| consensus_random = gl.eq_principle.strict_eq(random_generator) | ||
| return consensus_random | ||
| ``` | ||
|
|
||
| ## When to Use | ||
|
|
||
| Non-deterministic operations are needed for: | ||
| - External API calls | ||
| - Random number generation | ||
| - Current timestamp access | ||
| - File system operations | ||
| - Any operation that might vary between nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n pages/developers/intelligent-contracts/features/non-determinism.mdxRepository: genlayerlabs/genlayer-docs
Length of output: 1818
🏁 Script executed:
find pages -name "*web*" -type f | head -20Repository: genlayerlabs/genlayer-docs
Length of output: 271
🏁 Script executed:
cat -n pages/developers/intelligent-contracts/features/web-access.mdxRepository: genlayerlabs/genlayer-docs
Length of output: 1174
🏁 Script executed:
cat -n pages/developers/intelligent-contracts/examples/fetch-web-content.mdxRepository: genlayerlabs/genlayer-docs
Length of output: 6547
🏁 Script executed:
rg -i "file.?system|filesystem|file.?access" pages/developers/intelligent-contracts --type mdx -A 2Repository: genlayerlabs/genlayer-docs
Length of output: 97
🏁 Script executed:
rg -i "file.?system|filesystem|file.?access" pages/developers/intelligent-contracts -A 2Repository: genlayerlabs/genlayer-docs
Length of output: 276
🏁 Script executed:
rg -i "contract.*limitation|not.*support|cannot.*access" pages/developers/intelligent-contracts --max-count 10Repository: genlayerlabs/genlayer-docs
Length of output: 927
🏁 Script executed:
rg "gl\.(nondet|eq_principle|get_webpage)" pages/developers/intelligent-contracts/features/ -B 2 -A 2Repository: genlayerlabs/genlayer-docs
Length of output: 8197
Add missing import and use consistent platform API for HTTP requests
Line 10: random.randint(1, 100) must include import random before use (this is done correctly in the "Random Values" section later, but not in the first example).
Line 25: Replace requests.get() with gl.nondet.web.request() to maintain consistency with the web-access.mdx feature documentation:
- response = requests.get("https://api.example.com/data")
- return response.json()
+ resp = gl.nondet.web.request("https://api.example.com/data", method="GET")
+ return resp.json()Also remove "File system operations" from the bulleted list (line 55), as there is no documentation or examples showing file system access is available to contracts.
🤖 Prompt for AI Agents
In pages/developers/intelligent-contracts/features/non-determinism.mdx around
lines 7 to 56, the examples and bullet list need three fixes: add an import
random statement before using random.randint in the first example; replace the
external HTTP call requests.get(...) with the platform API
gl.nondet.web.request(...) in the fetch_external_data example to be consistent
with web-access docs; and remove the "File system operations" entry from the
"When to Use" bulleted list. Ensure you only add the import line at the top of
that first code block, change the function call to gl.nondet.web.request with
the same URL and response handling, and delete the filesystem bullet.
| ```python | ||
| class Contract(gl.Contract): | ||
| counter: u32 | ||
| name: str | ||
| active: bool | ||
|
|
||
| @gl.public.write | ||
| def set_data(self, count: u32, new_name: str): | ||
| self.counter = count | ||
| self.name = new_name | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs/type-convention mismatch: method params should be standard Python types, not u32.
Per the GenVM typing convention, keep sized ints for storage fields, but use int for method parameters/returns in examples (conversion is handled).
(Based on learnings, GenVM typing convention.)
class Contract(gl.Contract):
counter: u32
name: str
active: bool
@gl.public.write
- def set_data(self, count: u32, new_name: str):
+ def set_data(self, count: int, new_name: str) -> None:
self.counter = count
self.name = new_name class Contract(gl.Contract):
balances: TreeMap[str, u32]
@gl.public.write
- def update_balance(self, user: str, amount: u32):
+ def update_balance(self, user: str, amount: int) -> None:
self.balances[user] = amount
@gl.public.view
- def get_balance(self, user: str):
+ def get_balance(self, user: str) -> int:
return self.balances.get(user, u32(0))Also applies to: 43-54
🤖 Prompt for AI Agents
In pages/developers/intelligent-contracts/features/storage.mdx around lines 9 to
19 (and also apply same change to lines 43 to 54), update the example so that
storage fields keep sized integer types (e.g., counter: u32) but method
parameters and return types use standard Python types (e.g., use int for count
parameter) — replace any method signatures that use u32 in parameters/returns
with int while leaving storage field declarations as u32; keep a note that
conversion between int and sized types is handled by GenVM if present in
surrounding text.
| ```python | ||
| def post_request(): | ||
| response = gl.nondet.web.request( | ||
| webhook_url, | ||
| method='POST', | ||
| body={} | ||
| ) | ||
| return response.status_code | ||
|
|
||
| status_code = gl.eq_principle.strict_eq(post_request) | ||
| ``` | ||
|
|
||
| ## Web Rendering | ||
|
|
||
| Render web page and extract content: | ||
|
|
||
| ```python | ||
| def render_page(): | ||
| # Render HTML content | ||
| html_content = gl.nondet.web.render(url, mode='html') | ||
| return html_content | ||
|
|
||
| page_html = gl.eq_principle.strict_eq(render_page) | ||
| ``` | ||
|
|
||
| ## Screenshot Capture | ||
|
|
||
| Take screenshots of web pages: | ||
|
|
||
| ```python | ||
| def take_screenshot(): | ||
| # Capture page as image | ||
| screenshot = gl.nondet.web.render(url, mode='screenshot') | ||
| return screenshot | ||
|
|
||
| image_data = gl.eq_principle.strict_eq(take_screenshot) | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
fd -t f "web-access.mdx" pages/Repository: genlayerlabs/genlayer-docs
Length of output: 132
🏁 Script executed:
cat -n pages/developers/intelligent-contracts/features/web-access.mdx | head -50Repository: genlayerlabs/genlayer-docs
Length of output: 1174
🌐 Web query:
GenLayer GenVM gl.nondet.web.request parameters documentation
💡 Result:
API summary — gl.nondet.web.request
-
Signature: genlayer.gl.nondet.web.request(url: str, *, method: Literal['GET','POST','DELETE','HEAD','OPTIONS','PATCH'], body: str | bytes | None = None, headers: dict[str, str | bytes] = {}) -> Response. [1]
-
Parameters:
- url (str): target URL. [1]
- method (literal): HTTP method (GET, POST, DELETE, HEAD, OPTIONS, PATCH). [1]
- body (str | bytes | None): optional request body. [1]
- headers (dict[str, str | bytes]): optional headers mapping. [1]
-
Return: genlayer.gl.nondet.web.Response with fields status: int, headers: dict[str, bytes], body: bytes | None. [1]
-
Notes: supports a .lazy() variant (returns Lazy). The same module also exposes web.render and web.delete. [1][2]
Sources: GenLayer SDK API docs and genlayer.gl module reference. [1] [2]
References
[1] GenLayer SDK — genlayer.gl.nondet.web API (request, Response).
[2] genlayer.gl module source / docs.
🌐 Web query:
GenLayer GenVM gl.nondet.web.render mode parameters documentation
💡 Result:
Summary — gl.nondet.web.render(url, *, wait_after_loaded=None, mode=...):
- Signature and modes: gl.nondet.web.render(url: str, *, wait_after_loaded: str | None = None, mode: Literal['text','html']) → str; and mode: 'screenshot' → Image. [1][2]
- Parameters:
- url (str): target webpage. [1]
- mode: 'text' or 'html' returns rendered page as string; 'screenshot' returns an Image object. [1][2]
- wait_after_loaded (optional str): time to wait after DOM loaded for dynamic JS content (format examples: "1000ms" or "1s"). [1]
- Notes:
- There is a .lazy() variant that returns a Lazy. [1]
- This API is part of the GenLayer SDK / GenVM web module used for nondeterministic Web access. [2][3]
Sources:
[1] GenLayer SDK API reference — genlayer.gl.nondet.web.render.
[2] genlayer.gl source/module documentation (genlayer.gl).
[3] GenLayer GenVM / web-module docs (context on GenVM web access).
Add placeholder values and fix body parameter type error in code examples.
The snippets use undefined variables (webhook_url, url) that prevent copy/paste execution. Add placeholder assignments before use.
Additionally, body={} is incorrect: the gl.nondet.web.request() API expects body: str | bytes | None, not a dict. Use an empty string or None instead:
def post_request():
+ webhook_url = "https://example.com/webhook"
response = gl.nondet.web.request(
webhook_url,
method='POST',
- body={}
+ body=""
)
return response.status_code def render_page():
+ url = "https://example.com"
# Render HTML content
html_content = gl.nondet.web.render(url, mode='html')
return html_content def take_screenshot():
+ url = "https://example.com"
# Capture page as image
screenshot = gl.nondet.web.render(url, mode='screenshot')
return screenshot🤖 Prompt for AI Agents
In pages/developers/intelligent-contracts/features/web-access.mdx around lines 7
to 43, the examples reference undefined variables and pass the wrong type for
the request body; add placeholder assignments for webhook_url and url (e.g.,
webhook_url = "https://example.com/webhook" and url = "https://example.com")
before they are used, and change the request body from a dict to a permitted
type such as an empty string or None (body="" or body=None) to match
gl.nondet.web.request's expected body: str | bytes | None; keep the rest of the
examples intact so they run copy/paste-ready.
|
patch types part |
|
add eval to llms example |
Description
Closes GVM-169
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.