Struct noble_contracts::Module[][src]

pub struct Module<T: Config>(_)
where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>
;

Contracts module.

Implementations

impl<T: Config> Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

Can also be called using Call.

pub fn update_schedule(
    origin: T::Origin,
    schedule: Schedule<T>
) -> DispatchResult
[src]

Updates the schedule for metering contracts.

The schedule must have a greater version than the stored schedule.

NOTE: Calling this function will bypass origin filters.

pub fn put_code(origin: T::Origin, code: Vec<u8>) -> DispatchResult[src]

Stores the given binary Wasm code into the chain’s storage and returns its codehash. You can instantiate contracts only with stored code.

NOTE: Calling this function will bypass origin filters.

pub fn call(
    origin: T::Origin,
    dest: <T::Lookup as StaticLookup>::Source,
    value: BalanceOf<T>,
    gas_limit: Gas,
    data: Vec<u8>
) -> DispatchResultWithPostInfo
[src]

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.

NOTE: Calling this function will bypass origin filters.

pub fn instantiate(
    origin: T::Origin,
    endowment: BalanceOf<T>,
    gas_limit: Gas,
    code_hash: CodeHash<T>,
    data: Vec<u8>,
    salt: Vec<u8>
) -> DispatchResultWithPostInfo
[src]

Instantiates a new contract from the code_hash generated by put_code, optionally transferring some balance.

The supplied salt is used for contract address deriviation. See fn contract_address.

Instantiation is executed as follows:

  • 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 ctor_code is executed in the context of the newly-created account. Buffer returned after the execution is saved as the code of the account. That code will be invoked upon any call received by this account.
  • The contract is initialized.

NOTE: Calling this function will bypass origin filters.

pub fn claim_surcharge(
    origin: T::Origin,
    dest: T::AccountId,
    aux_sender: Option<T::AccountId>
) -> DispatchResultWithPostInfo
[src]

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

NOTE: Calling this function will bypass origin filters.

impl<T: Config> Module<T> where
    T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>, 
[src]

Public APIs provided by the contracts module.

pub fn bare_call(
    origin: T::AccountId,
    dest: T::AccountId,
    value: BalanceOf<T>,
    gas_limit: Gas,
    input_data: Vec<u8>
) -> ContractExecResult
[src]

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.

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

pub fn get_storage(address: T::AccountId, key: [u8; 32]) -> GetStorageResult[src]

Query storage of a specified contract under a specified key.

pub fn rent_projection(
    address: T::AccountId
) -> RentProjectionResult<T::BlockNumber>
[src]

pub fn contract_address(
    deploying_address: &T::AccountId,
    code_hash: &CodeHash<T>,
    salt: &[u8]
) -> T::AccountId
[src]

Determine the address of a contract,

This is the address generation function used by contract instantation. 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 CRATE2 opcode. There is no CREATE equivalent because CREATE2 is strictly more powerful.

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

impl<T: Config + 'static> Module<T> where
    T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>, 
[src]

pub fn current_schedule() -> Schedule<T>[src]

Current cost schedule for contracts.

Trait Implementations

impl<T: Config> Callable<T> for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

type Call = Call<T>

impl<T: Clone + Config> Clone for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Copy + Config> Copy for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> Debug for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>,
    T: Debug
[src]

impl<T: Eq + Config> Eq for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> GetNobleVersion for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> IntegrityTest for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> ModuleErrorMetadata for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config + Config> OffchainWorker<<T as Config>::BlockNumber> for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config + Config> OnFinalize<<T as Config>::BlockNumber> for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> OnGenesis for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config + Config> OnInitialize<<T as Config>::BlockNumber> for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> OnRuntimeUpgrade for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: PartialEq + Config> PartialEq<Module<T>> for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> StructuralEq for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

impl<T: Config> StructuralPartialEq for Module<T> where
    T::AccountId: UncheckedFrom<T::Hash>,
    T::AccountId: AsRef<[u8]>, 
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Module<T> where
    T: RefUnwindSafe

impl<T> Send for Module<T> where
    T: Send

impl<T> Sync for Module<T> where
    T: Sync

impl<T> Unpin for Module<T> where
    T: Unpin

impl<T> UnwindSafe for Module<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IsType<T> for T[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 
[src]

pub fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Member for T where
    T: 'static + Send + Sync + Debug + Eq + PartialEq<T> + Clone
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

impl<T, S> UniqueSaturatedInto<T> for S where
    T: Bounded,
    S: TryInto<T>, 

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,