Installable skillApache-2.0

Cairo Method Syntax

Explain Cairo method syntax, traits/impl blocks, `self` parameter forms, and associated functions; use when a request involves defining or calling methods on structs in Cairo.

BY David-Li0406UPDATED Oct 30, 2026
INTENDED FOR◈OpenClawInstall in a listed agent.

instructions.md

---
name: cairo-method-syntax-5f17add44484
description: Explain Cairo method syntax, traits/impl blocks, `self` parameter forms, and associated functions; use when a request involves defining or calling methods on structs in Cairo.
---

# Cairo Method Syntax

## Overview
Guide method definitions using traits and impl blocks, with correct `self` forms.

## Quick Use
- Read `references/method-syntax.md` before answering.
- Show a small struct with an impl block and a method taking `self` or `@self`.
- Mention associated functions for constructors like `new` or `square`.

## Response Checklist
- Use `self` by value for ownership-taking methods.
- Use `@self` for read-only methods and `ref self` for mutation.
- Note that methods are defined in traits and implemented in `impl` blocks.

## Example Requests
- "How do I define a method on a Cairo struct?"
- "What's the difference between `self`, `@self`, and `ref self`?"
- "How do I write a constructor-like associated function?"

## Cairo by Example
- [Methods](https://cairo-by-example.xyz/fn/methods)
COMPATIBILITY & REFERENCES

Platform guidance

Imported from the listed AgentSkill.sh category. Complete supplied package files and notices are retained. Required external tools and credentials are not installed. No bundled code was executed during import. Individual agent task behavior has not been tested.