Upgradeable

Trait Upgradeable 

Source
pub trait Upgradeable {
    // Required method
    fn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address);
}
Expand description

High-level trait for contract upgrades.

This trait defines the external entry point and can be used in two ways:

  1. Standalone – Implement this trait directly when full control over access control and upgrade logic is required. In this case, the implementor is responsible for ensuring:

    • Proper authorization of the operator
    • Versioning management
  2. Framework-assisted usage – When using the lightweight upgrade framework provided in this module, you should NOT manually implement this trait. Instead:

    • Derive it using #[derive(Upgradeable)]
    • Provide access control by implementing UpgradeableInternal with your custom logic

Required Methods§

Source

fn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address)

Upgrades the contract by setting a new WASM bytecode. The contract will only be upgraded after the invocation has successfully completed.

§Arguments
  • e - Access to Soroban environment.
  • new_wasm_hash - A 32-byte hash identifying the new WASM blob, uploaded to the ledger.
  • operator - The authorized address performing the upgrade.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§