upload_code: TxDescriptor<
    {
        code: Binary;
        determinism: Enum<{ Enforced: undefined; Relaxed: undefined }>;
        storage_deposit_limit?: bigint;
    },
>

Upload new code without instantiating a contract from it.

If the code does not already exist a deposit is reserved from the caller and unreserved only when [Self::remove_code] is called. The size of the reserve depends on the size of the supplied code.

If the code already exists in storage it will still return Ok and upgrades the in storage version to the current InstructionWeights::version.

  • determinism: If this is set to any other value but [Determinism::Enforced] then the only way to use this code is to delegate call into it from an offchain execution. Set to [Determinism::Enforced] if in doubt.

Note

Anyone can instantiate a contract from any uploaded code and thus prevent its removal. To avoid this situation a constructor could employ access control so that it can only be instantiated by permissioned entities. The same is true when uploading through [Self::instantiate_with_code].

Use [Determinism::Relaxed] exclusively for non-deterministic code. If the uploaded code is deterministic, specifying [Determinism::Relaxed] will be disregarded and result in higher gas costs.