after importing pallet_vesting, one of the pre-built pallets https://docs.substrate.io/rustdocs/latest/pallet_vesting/pallet/enum.Call.html

I have imported sp_runtime

use frame_support::{
    sp_runtime::traits::{Hash, StaticLookup, Zero},
    traits::{Currency, LockableCurrency, ReservableCurrency},
use pallet_vesting;

I would like to use the following functions from that pallet_vesting source code:

  fn add_vesting_schedule(
    who: &T::AccountId,
    locked: BalanceOf<T>,
    per_block: BalanceOf<T>,
    starting_block: T::BlockNumber,
  ) -> DispatchResult {...}

pub fn vested_transfer(
  origin: OriginFor<T>,
  target: <T::Lookup as StaticLookup>::Source,
  schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
) -> DispatchResult {...}

I have figured out those types:

OriginFor<T> for origin type

BlockNumberFor<T>, for starting_block T::BlockNumber type

T::AccountId, for my target or destination arguments

BalanceOf<T> for locked type and per_block type

  type BalanceOf<T> =
    <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;

But that T::AccountId is not compatible with the vested_transfer() function's target type! See the error message below:

type annotations needed cannot satisfy _: pallet_vesting::ConfigrustcE0283 lib.rs(281, 10): required by a bound in pallet_vesting::Pallet::<T>::vested_transfer

how can I import the correct target type?

further digging into the source code, I got this:

use sp_runtime::traits::{StaticLookup, Zero};
  impl<T: Config> Lookup for ChainContext<T> {
    type Source = <T::Lookup as StaticLookup>::Source;
    type Target = <T::Lookup as StaticLookup>::Target;

Please help. Thank you!

  • Can you please add the code that exhibits the error you are encountering? Mar 24, 2022 at 11:04

1 Answer 1


I am just assuming that you are looking for some syntax to mention the associated types of a type that implements StaticLookup. Should work like this:

type SourceOf<T> = <T::Lookup as StaticLookup>::Source;
type TargetOf<T> = <T::Lookup as StaticLookup>::Target; 
  • Hi Alexander! Thanks, after adding your TargetOf<T>, now I got this error: associated type Lookup not found for T, how to fix this? Thanks!
    – Russo
    Mar 24, 2022 at 11:16
  • Depends on where you try to use this type alias from. You probably need to ad some trait bound on T. Mar 24, 2022 at 14:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.