Skip to content

doc: rewrite contracts.adoc with modern Starknet patterns#9757

Draft
eytan-starkware wants to merge 1 commit intomainfrom
eytan_graphite/doc_rewrite_contracts.adoc_with_modern_starknet_patterns
Draft

doc: rewrite contracts.adoc with modern Starknet patterns#9757
eytan-starkware wants to merge 1 commit intomainfrom
eytan_graphite/doc_rewrite_contracts.adoc_with_modern_starknet_patterns

Conversation

@eytan-starkware
Copy link
Copy Markdown
Contributor

@eytan-starkware eytan-starkware commented Mar 19, 2026

Summary

Updates the Cairo contracts documentation to use the modern #[starknet::interface] and #[abi(embed_v0)] pattern instead of the deprecated #[external(v0)] attribute. Replaces LegacyMap with Map and updates storage access syntax from x::read() to self.x.read().


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The documentation was showing deprecated patterns that are no longer recommended for new Cairo contracts. The #[external(v0)] attribute and LegacyMap are deprecated in favor of the interface trait pattern and Map type. This was misleading developers who would follow outdated examples.


What was the behavior or documentation before?

  • Used #[external(v0)] attribute on individual functions
  • Used LegacyMap for storage mappings
  • Storage access via x::read() and x::write() syntax
  • No interface trait definitions shown
  • Missing required import statements for storage access traits

What is the behavior or documentation after?

  • Uses #[starknet::interface] trait definitions with #[abi(embed_v0)] implementations
  • Uses Map<K, V> for storage mappings
  • Storage access via self.x.read() and self.x.write() syntax
  • Shows proper interface definitions and implementations
  • Includes necessary import statements for storage traits
  • Adds note about legacy #[external(v0)] still being supported but deprecated

Related issue or discussion (if any)


Additional context

This change ensures developers learn the current best practices for Cairo contract development rather than deprecated patterns. The examples now demonstrate the complete modern contract structure including interfaces, implementations, and proper storage handling.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

eytan-starkware commented Mar 19, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@eytan-starkware eytan-starkware force-pushed the eytan_graphite/doc_rewrite_contracts.adoc_with_modern_starknet_patterns branch from aa14e08 to 05947b2 Compare March 22, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants