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:
-
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
- Proper authorization of the
-
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
UpgradeableInternalwith your custom logic
- Derive it using
Required Methods§
Sourcefn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address)
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.