upgrade-cairo-contracts

Automate Cairo contract class hash upgrades on Starknet using OpenZeppelin's UpgradeableComponent.

Updated Oct 17, 2025
One-click install
npx skills add https://github.com/iamcapote/emptyrepo --skill upgrade-cairo-contracts-iamcapote
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: upgrade-cairo-contracts
Source: https://github.com/iamcapote/emptyrepo/tree/main/skills/allied/openzeppelin-skills/skills/upgrade-cairo-contracts
Command: npx skills add https://github.com/iamcapote/emptyrepo --skill upgrade-cairo-contracts-iamcapote

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Upgrade Cairo contracts on Starknet securely by providing a pattern to atomically swap the class hash using replace_class_syscall, preserving existing storage and runtime state.

Core Features & Use Cases

  • OpenZeppelin UpgradeableComponent integration to wrap the replace_class_syscall with validation and events.
  • Guidance on Starknet's class-based upgrade model vs EVM proxies, including how to reason about storage layout and migrations.
  • Access control guards for the upgrade function, plus testing workflows to validate upgrades across V1/V2 classes in devnets.

Quick Start

Follow the guided upgrade pattern to safely swap your Cairo contract's class hash behind an access-controlled upgrade function.

Frequently Asked Questions about upgrade-cairo-contracts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I upgrade Cairo contracts on Starknet?

Cairo contract upgrades on Starknet are automated by atomically swapping a contract's class hash with replace_class_syscall, preserving existing storage and runtime state during the transition.

What is the difference between Starknet class upgrades and EVM proxies?

Starknet uses a class-based upgrade model that swaps class hashes rather than relying on EVM proxy patterns, requiring careful reasoning about storage layout and state migrations across class changes.

How do I securely swap a contract class hash in Cairo?

Secure class hash swaps use OpenZeppelin's UpgradeableComponent to wrap replace_class_syscall with validation, access control guards, and events, ensuring only authorized users trigger upgrades.

Do I need a local devnet to test Cairo upgradeable contracts?

A local devnet or testnet setup is required to test upgrade paths across V1/V2 classes, validating storage compatibility and access control behavior before deploying class changes.

How does OpenZeppelin UpgradeableComponent handle storage compatibility during upgrades?

The UpgradeableComponent integration provides patterns for maintaining storage compatibility during class swaps, ensuring existing runtime state is preserved while applying new contract logic.

What are the limitations of using replace_class_syscall for Cairo upgrades?

Using replace_class_syscall requires explicit dependencies on Cairo upgrade tooling, adherence to component initialization patterns, and careful access control to prevent unauthorized contract modifications.