Contracts::Call

Variant 366 v393

pallet_contracts::pallet::Call

Contains a variant per dispatchable extrinsic that this pallet has.

About This Type

Call enum for the Call pallet.

Contains all dispatchable functions (extrinsics) for the Call pallet. Each variant represents a different callable function with its parameters.

Variants (10)

IndexNameFieldsDocs
0call_old_weight
gas_limit: Compact<u64>
storage_deposit_limit: Option
data: Vec<u8>
Deprecated version if [`Self::call`] for use in an in-storage `Call`.
1instantiate_with_code_old_weight
gas_limit: Compact<u64>
storage_deposit_limit: Option
code: Vec<u8>
data: Vec<u8>
salt: Vec<u8>
Deprecated version if [`Self::instantiate_with_code`] for use in an in-storage `Call`.
2instantiate_old_weight
gas_limit: Compact<u64>
storage_deposit_limit: Option
code_hash: H256
data: Vec<u8>
salt: Vec<u8>
Deprecated version if [`Self::instantiate`] for use in an in-storage `Call`.
3upload_code
code: Vec<u8>
storage_deposit_limit: Option
determinism: Determinism
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`](InstructionWeights). - `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.
4remove_code
code_hash: H256
Remove the code stored under `code_hash` and refund the deposit to its owner. A code can only be removed by its original uploader (its owner) and only if it is not used by any contract.
5set_code
code_hash: H256
Privileged function that changes the code of an existing contract. This takes care of updating refcounts and all other necessary operations. Returns an error if either the `code_hash` or `dest` do not exist. # Note This does **not** change the address of the contract in question. This means that the contract address is no longer derived from its code hash after calling this dispatchable.
6call
gas_limit: Weight
storage_deposit_limit: Option
data: Vec<u8>
Makes a call to an account, optionally transferring some balance. # Parameters * `dest`: Address of the contract to call. * `value`: The balance to transfer from the `origin` to `dest`. * `gas_limit`: The gas limit enforced when executing the constructor. * `storage_deposit_limit`: The maximum amount of balance that can be charged from the caller to pay for the storage consumed. * `data`: The input data to pass to the contract. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
7instantiate_with_code
gas_limit: Weight
storage_deposit_limit: Option
code: Vec<u8>
data: Vec<u8>
salt: Vec<u8>
Instantiates a new contract from the supplied `code` optionally transferring some balance. This dispatchable has the same effect as calling [`Self::upload_code`] + [`Self::instantiate`]. Bundling them together provides efficiency gains. Please also check the documentation of [`Self::upload_code`]. # Parameters * `value`: The balance to transfer from the `origin` to the newly created contract. * `gas_limit`: The gas limit enforced when executing the constructor. * `storage_deposit_limit`: The maximum amount of balance that can be charged/reserved from the caller to pay for the storage consumed. * `code`: The contract code to deploy in raw bytes. * `data`: The input data to pass to the contract constructor. * `salt`: Used for the address derivation. See [`Pallet::contract_address`]. Instantiation is executed as follows: - The supplied `code` is deployed, and a `code_hash` is created for that code. - If the `code_hash` already exists on the chain the underlying `code` will be shared. - The destination address is computed based on the sender, code_hash and the salt. - The smart-contract account is created at the computed address. - The `value` is transferred to the new account. - The `deploy` function is executed in the context of the newly-created account.
8instantiate
gas_limit: Weight
storage_deposit_limit: Option
code_hash: H256
data: Vec<u8>
salt: Vec<u8>
Instantiates a contract from a previously deployed wasm binary. This function is identical to [`Self::instantiate_with_code`] but without the code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary must be supplied.
9migrate
weight_limit: Weight
When a migration is in progress, this dispatchable can be used to run migration steps. Calls that contribute to advancing the migration have their fees waived, as it's helpful for the chain. Note that while the migration is in progress, the pallet will also leverage the `on_idle` hooks to run migration steps.

SCALE Encoding

Rule
1-byte variant index followed by variant-specific field data. 10 possible variants.
Size
variable (1+ bytes)

Examples

call_old_weight = call_old_weight(dest, value, gas_limit, storage_deposit_limit, data)
0x00<field0><field1><field2><field3><field4>
00 Variant index 0 = call_old_weight
field 0 dest: MultiAddress
field 1 value: Compact<u64>
field 2 gas_limit: Compact<u64>
field 3 storage_deposit_limit: Option
field 4 data: Vec<u8>
instantiate_with_code_old_weight = instantiate_with_code_old_weight(value, gas_limit, storage_deposit_limit, code, data, salt)
0x01<field0><field1><field2><field3><field4><field5>
01 Variant index 1 = instantiate_with_code_old_weight
field 0 value: Compact<u64>
field 1 gas_limit: Compact<u64>
field 2 storage_deposit_limit: Option
field 3 code: Vec<u8>
field 4 data: Vec<u8>
field 5 salt: Vec<u8>
instantiate_old_weight = instantiate_old_weight(value, gas_limit, storage_deposit_limit, code_hash, data, salt)
0x02<field0><field1><field2><field3><field4><field5>
02 Variant index 2 = instantiate_old_weight
field 0 value: Compact<u64>
field 1 gas_limit: Compact<u64>
field 2 storage_deposit_limit: Option
field 3 code_hash: H256
field 4 data: Vec<u8>
field 5 salt: Vec<u8>

Code Examples

import { TypeRegistry } from "@polkadot/types";

const registry = new TypeRegistry();

// Encode Contracts::Call — variant "call_old_weight"
const value = registry.createType("Contracts::Call", { call_old_weight: { dest: 0, value: 0, gas_limit: 0, storage_deposit_limit: 0, data: 0 } });
console.log("Hex:", value.toHex());

Type Parameters

T

Referenced By (23)

and 3 more...

Also See

Type Information

Type ID
366
Kind
Variant
Path
pallet_contracts::pallet::Call
Runtime
v393