Token导航 LogoToken导航TokenDH.com
效率需要联网clawhub未标认证来源可访问clear审计提醒

upgrade-stylus-contracts升级手写笔合约

Agent Skill

upgrade-stylus-contracts 用于补充效率相关能力,适合在 OpenClaw 中需要让 Agent 承接效率相关任务时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

8,412

周安装

337

GitHub Stars

公开资料未说明

下载量

2,723
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:upgrade-stylus-contracts(升级手写笔合约)
来源仓库:https://github.com/samledger67-dotcom/upgrade-stylus-contracts
安装命令:
openclaw skills install upgrade-stylus-contracts
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install upgrade-stylus-contracts

简介

在 Arbitrum 上使用 OpenZeppelin 代理模式升级 Stylus Rust 合约。

  • 支持 UUPS 和 Transparent Proxy 两种可升级方案,兼容 WASM 字节码。
  • 适用于高性能链上服务的模块化更新与维护。
  • 使用前请确保 Rust 工具链就绪,并验证合约 ABI 兼容性。
  • 注意升级后需重新编译并部署代理工厂,流程较复杂需谨慎操作。

SKILL.md

name
upgrade-stylus-contracts
description
Upgrade Stylus smart contracts using OpenZeppelin proxy patterns on Arbitrum. Use when users need to: (1) make Stylus Rust contracts upgradeable with UUPS or Beacon proxies, (2) understand Stylus-specific proxy mechanics (logic_flag, WASM reactivation), (3) integrate UUPSUpgradeable with access control, (4) ensure storage compatibility across upgrades, or (5) test upgrade paths for Stylus contracts.
license
AGPL-3.0-only
metadata
author
OpenZeppelin

Stylus Upgrades

Contents

Stylus Upgrade Model

Stylus contracts run on Arbitrum as WebAssembly (WASM) programs alongside the EVM. They share the same state trie, storage model, and account system as Solidity contracts. Because of this, EVM proxy patterns work identically for Stylus — a Solidity proxy can delegate to a Stylus implementation and vice versa.

StylusSolidity
Proxy mechanismSame — delegatecall to implementation contractdelegatecall to implementation contract
Storage layout#[storage] fields map to the same EVM slots as equivalent Solidity structsSequential slot allocation per Solidity rules
EIP standardsERC-1967 storage slots, ERC-1822 proxiable UUIDSame
Context detectionlogic_flag boolean in a unique storage slot (no immutable support)address(this) stored as immutable
InitializationTwo-step: constructor sets logic_flag, then set_version() via proxyConstructor + initializer via proxy
ReactivationWASM contracts must be reactivated every 365 days or after a Stylus protocol upgradeNot applicable

Existing Solidity contracts can upgrade to a Stylus (Rust) implementation via proxy patterns. The #[storage] macro lays out fields in the EVM state trie identically to Solidity, so storage slots line up when type definitions match.

Proxy Patterns

OpenZeppelin Contracts for Stylus provides three proxy patterns:

PatternKey typesBest for
UUPSUUPSUpgradeable, IErc1822Proxiable, Erc1967ProxyMost projects — upgrade logic in the implementation, lighter proxy
BeaconBeaconProxy, UpgradeableBeaconMultiple proxies sharing one implementation — updating the beacon upgrades all proxies atomically
Basic ProxyErc1967Proxy, Erc1967UtilsLow-level building block for custom proxy patterns
Note: The Transparent proxy pattern is not currently provided by OpenZeppelin Contracts for Stylus. Use UUPS instead (recommended for most projects).

UUPS

The implementation contract composes UUPSUpgradeable in its #[storage] struct alongside access control (e.g., Ownable). Integration requires:

  1. Add UUPSUpgradeable (and access control) as fields in the #[storage] struct
  2. Call self.uups.constructor() and initialize access control in the constructor
  3. Expose initialize calling self.uups.set_version() — invoked via proxy after deployment
  4. Implement IUUPSUpgradeableupgrade_to_and_call guarded by access control, upgrade_interface_version delegating to self.uups
  5. Implement IErc1822Proxiableproxiable_uuid delegating to self.uups

The proxy contract is a thin Erc1967Proxy with a constructor that takes the implementation address and initialization data, and a #[fallback] handler that delegates all calls.

Deploy the proxy with set_version as the initialization call data. Use cargo stylus deploy or a deployer contract. The initialization data is the ABI-encoded setVersion call:

let data = MyContractAbi::setVersionCall {}.abi_encode();
// Pass `data` as the proxy constructor's second argument at deployment time.

Beacon

Multiple BeaconProxy contracts point to a single UpgradeableBeacon that stores the current implementation address. Updating the beacon upgrades all proxies in one transaction.

Context detection (Stylus-specific)

Stylus does not support the immutable keyword. Instead of storing __self = address(this), UUPSUpgradeable uses a logic_flag boolean in a unique storage slot:

  • The implementation's constructor sets logic_flag = true in its own storage.
  • When code runs via a proxy (delegatecall), the proxy's storage does not contain this flag, so it reads as false.
  • only_proxy() checks this flag to ensure upgrade functions can only be called through the proxy, not directly on the implementation.

only_proxy() also verifies that the ERC-1967 implementation slot is non-zero and that the proxy-stored version matches the implementation's VERSION_NUMBER.

Examples: See the examples/ directory of the rust-contracts-stylus repository for full working integration examples of UUPS, Beacon, and related patterns.

Access Control

Upgrade functions must be guarded with access control. OpenZeppelin's Stylus contracts do not embed access control into the upgrade logic itself — you must add it in upgrade_to_and_call:

fn upgrade_to_and_call(&mut self, new_implementation: Address, data: Bytes) -> Result<(), Vec<u8>> {
    self.ownable.only_owner()?; // or any access control check
    self.uups.upgrade_to_and_call(new_implementation, data)?;
    Ok(())
}

Common options:

  • Ownable — single owner, simplest pattern
  • AccessControl / RBAC — role-based, finer granularity
  • Multisig or governance — for production contracts managing significant value

Upgrade Safety

Storage compatibility

Stylus #[storage] fields are laid out in the EVM state trie identically to Solidity. The same storage layout rules apply when upgrading:

  • Never reorder, remove, or change the type of existing storage fields
  • Never insert new fields before existing ones
  • Only append new fields at the end of the struct
  • ERC-1967 proxy storage slots are in high, standardized locations — they will not collide with implementation storage

One difference from Solidity: nested structs in Stylus #[storage] (e.g., composing Erc20, Ownable, UUPSUpgradeable as fields) are laid out with each nested struct starting at its own deterministic slot. This is consistent with regular struct nesting in Solidity, but not with Solidity's inheritance-based flat layout where all inherited variables share a single sequential slot range.

Initialization safety

  • The implementation constructor sets logic_flag and any implementation-only state. It runs once at implementation deployment.
  • set_version() must be called via the proxy (during deployment or via upgrade_to_and_call) to write the VERSION_NUMBER into the proxy's storage.
  • If additional initialization is needed (ownership, token supply), expose a protected initialization function and include set_version() in it.
  • Failing to initialize properly can result in orphaned contracts with no owner, uninitialized state, or denied future upgrades.
Front-running warning: Always pass initialization calldata as part of the proxy constructor to ensure deployment and initialization are atomic (single transaction). Never deploy a proxy and initialize in a separate transaction — an attacker can front-run the initialization call, potentially setting themselves as owner or corrupting initial state. The initialization function should include a guard to prevent re-initialization: ``rust // Re-initialization guard pattern fn initialize(&mut self, owner: Address) -> Result<(), Vec<u8>> { if self.initialized.get() { return Err(b"already initialized".to_vec()); } self.initialized.set(true); self.uups.set_version(); self.ownable.init(owner)?; Ok(()) } `` Without such a guard, the initialization function can be called multiple times, allowing an attacker to re-initialize the contract and seize ownership.

UUPS upgrade checks

The UUPS implementation enforces three safety checks:

  1. Access control — restrict upgrade_to_and_call (e.g., self.ownable.only_owner())
  2. Proxy context enforcementonly_proxy() reverts if the call is not via delegatecall
  3. Proxiable UUID validationproxiable_uuid() must return the ERC-1967 implementation slot, confirming UUPS compatibility

Reactivation

Stylus WASM contracts must be reactivated once per year (365 days) or after any Stylus protocol upgrade. Reactivation can be done using cargo-stylus or the ArbWasm precompile. If a contract is not reactivated, it becomes uncallable. This is orthogonal to proxy upgrades but must be factored into maintenance planning.

Testing upgrade paths

Before upgrading a production contract:

  • [ ] Deploy V1 implementation and proxy on a local Arbitrum devnet
  • [ ] Write state with V1, upgrade to V2 via upgrade_to_and_call, and verify that all existing state reads correctly
  • [ ] Verify new functionality works as expected after the upgrade
  • [ ] Confirm access control — only authorized callers can invoke upgrade_to_and_call
  • [ ] Check storage layout — ensure no reordering, removal, or type changes to existing fields
  • [ ] Verify VERSION_NUMBER is incremented in the new implementation
  • [ ] Test reactivation — ensure the upgraded contract can be reactivated
  • [ ] Manual review — there is no automated storage layout validation for Stylus Rust contracts; rely on struct comparison and devnet testing

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

94.27%
按下载量换算2,567

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills