I'm trying to use Ink as a programmable hook for my pallet.


My pallet will store Agreement.

struct Agreement<T> {
  // ...
  pub on_approve: T::AccountId // this point to an Ink contract

and there is a call

pub fn approve(origin: OriginFor<T>, aggrement_id: u32) {
  let origin = ensure_signed(origin)?;
  let mut agreement = Agreement::<T>::get(aggrement_id)?;

  // TODO: call agreement.on_success


I can call an Ink contract via pallet_contracts::Pallet::<T>::bare_call(). However, I want to ensure the contract must conform to a specific interface.

for example

pub trait MyPalletHook {
    fn on_success(&mut self, agreement: Agreement);

Is my idea reasonable? Can pre-check a smart contract code or deployed instance implement a specific trait? How to call the contract via function definition in the trait?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.