upgrade-cairo-contracts

Replace Cairo contract class hashes while preserving addresses and storage.

203|28|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/OpenZeppelin/openzeppelin-skills --skill upgrade-cairo-contracts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: upgrade-cairo-contracts
Source: https://github.com/OpenZeppelin/openzeppelin-skills/tree/main/skills/upgrade-cairo-contracts
Command: npx skills add https://github.com/OpenZeppelin/openzeppelin-skills --skill upgrade-cairo-contracts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enables developers to perform atomic upgrades of deployed Cairo contracts by replacing class hashes while preserving contract addresses and on-chain storage, and guides them to avoid storage corruption and unauthorized upgrades.

Core Features & Use Cases

  • Starknet upgrade model explained: clarifies replace_class_syscall semantics and contrasts class-based upgrades with EVM proxy patterns.
  • Integrate UpgradeableComponent: shows how to add OpenZeppelin's UpgradeableComponent, emit Upgraded events, and use IUpgradeAndCall for post-upgrade initialization.
  • Access control and safety: recommends guarding upgrade entry points with Ownable, RBAC, multisig, and provides storage compatibility rules and testing checklists for devnet upgrades.
  • Use Case: prepare a safe upgrade plan for a production Cairo contract: declare the new class, run devnet migrations, verify storage reads, and restrict the upgrade call to authorized signers.

Quick Start

Use the upgrade-cairo-contracts skill to create a step-by-step upgrade plan that replaces a contract's class hash, preserves storage compatibility, and enforces owner-only access control.

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 without changing the deployed address?

To upgrade Cairo contracts on Starknet without changing the deployed address, use the replace_class_syscall to atomically replace the contract's class hash. This applies new code while preserving the original contract address and on-chain storage.

What is the difference between Starknet class-based upgrades and EVM proxy patterns?

Starknet class-based upgrades use replace_class_syscall semantics to swap class hashes directly, contrasting with EVM proxy patterns that delegate calls. This model enables atomic class replacements while preserving contract addresses and storage layout.

How do I integrate OpenZeppelin's UpgradeableComponent for Cairo contract upgrades?

To integrate OpenZeppelin's UpgradeableComponent for Cairo contract upgrades, add the component to your contract, emit Upgraded events upon execution, and use IUpgradeAndCall for any required post-upgrade initialization steps.

How do I prevent unauthorized upgrades and storage corruption during Starknet contract upgrades?

To prevent unauthorized upgrades and storage corruption during Starknet contract upgrades, guard upgrade entry points with Ownable or RBAC access-control. Additionally, follow storage compatibility rules and run devnet-based upgrade testing checklists.

Can I use devnet to test storage compatibility before upgrading a production Cairo contract?

Yes, you can use devnet to test storage compatibility before upgrading a production Cairo contract. Run devnet migrations to declare the new class, verify storage reads, and ensure the upgrade plan preserves storage layout safely.

What is the step-by-step process to safely replace a contract class hash on Starknet?

The step-by-step process to safely replace a contract class hash on Starknet involves declaring the new class, running devnet migrations, verifying storage compatibility, restricting the upgrade call to authorized signers, and emitting Upgraded events.