Struct pallet_contracts::pallet::Pallet[][src]

pub struct Pallet<T>(_);
Expand description

The pallet implementing the on-chain logic.

Implementations

Makes a call to an account, optionally transferring some balance.

  • 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.

Instantiates a new contract from the supplied code optionally transferring some balance.

This is the only function that can deploy new code to the chain.

Parameters

  • endowment: The balance to transfer from the origin to the newly created contract.
  • gas_limit: The gas limit enforced when executing the constructor.
  • 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 instrumented, 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 endowment is transferred to the new account.
  • The deploy function is executed in the context of the newly-created account.

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.

Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward.

In case of a successful eviction no fees are charged from the sender. However, the reward is capped by the total amount of rent that was paid by the contract while it was alive.

If contract is not evicted as a result of this call, Error::ContractNotEvictable is returned and the sender is not eligible for the reward.

Perform a call to a specified contract.

This function is similar to Self::call, but doesn’t perform any address lookups and better suitable for calling directly from Rust.

Note

debug should only ever be set to true when executing as an RPC because it adds allocations and could be abused to drive the runtime into an OOM panic. If set to true it returns additional human readable debugging information.

It returns the execution result and the amount of used weight.

Instantiate a new contract.

This function is similar to Self::instantiate, but doesn’t perform any address lookups and better suitable for calling directly from Rust.

It returns the execution result, account id and the amount of used weight.

If compute_projection is set to true the result also contains the rent projection. This is optional because some non trivial and stateful work is performed to compute the projection. See Self::rent_projection.

Note

debug should only ever be set to true when executing as an RPC because it adds allocations and could be abused to drive the runtime into an OOM panic. If set to true it returns additional human readable debugging information.

Query storage of a specified contract under a specified key.

Query how many blocks the contract stays alive given that the amount endowment and consumed storage does not change.

Determine the address of a contract,

This is the address generation function used by contract instantiation. Its result is only dependend on its inputs. It can therefore be used to reliably predict the address of a contract. This is akin to the formular of eth’s CREATE2 opcode. There is no CREATE equivalent because CREATE2 is strictly more powerful.

Formula: hash(deploying_address ++ code_hash ++ salt)

Subsistence threshold is the extension of the minimum balance (aka existential deposit) by the tombstone deposit, required for leaving a tombstone.

Rent or any contract initiated balance transfer mechanism cannot make the balance lower than the subsistence threshold in order to guarantee that a tombstone is created.

The only way to completely kill a contract without a tombstone is calling seal_terminate.

The in-memory size in bytes of the data structure associated with each contract.

The data structure is also put into storage for each contract. The in-storage size is never larger than the in-memory representation and usually smaller due to compact encoding and lack of padding.

Note

This returns the in-memory size because the in-storage size (SCALE encoded) cannot be efficiently determined. Treat this as an upper bound of the in-storage size.

Trait Implementations

Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more

Run the benchmarks for this pallet.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the current storage version as supported by the pallet.

Returns the on-chain storage version of the pallet as stored in the storage.

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

The block is being finalized. Implement to have something happen.

This will be run when the block is being finalized (before on_finalize). Implement to have something happen using the remaining weight. Will not fire if the remaining weight is 0. Return the weight used, the hook will subtract it from current weight used and pass the result to the next on_idle hook if it exists. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more

Run integrity test. Read more

Run integrity test. Read more

This function is being called after every block import (when fully synced). Read more

The block is being finalized. Implement to have something happen. Read more

Something that should happen at genesis.

The block is being finalized. Implement to have something happen in case there is leftover weight. Check the passed remaining_weight to make sure it is high enough to allow for your pallet’s extra computation. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

Index of the pallet as configured in the runtime.

Name of the pallet as configured in the runtime.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Generate a storage key unique to this runtime upgrade. Read more

Get temporary storage data written by Self::set_temp_storage. Read more

Write some temporary data to a specific storage that can be read (potentially in post-upgrade hook) via Self::get_temp_storage. Read more

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.