In this code, we can see the pallet::compact
is used. So why we need this instruction?
quotes code:
#[pallet::weight(1_000)]
pub fn transfer(
origin: OriginFor<T>,
to: T::AccountId,
#[pallet::compact] amount: T::Balance,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
let sender_balance = Self::get_balance(&sender);
let receiver_balance = Self::get_balance(&to);
// Calculate new balances.
let update_sender = sender_balance.saturating_sub(amount);
let update_to = receiver_balance.saturating_add(amount);
// Update both accounts storage.
<BalanceToAccount<T>>::insert(&sender, update_sender);
<BalanceToAccount<T>>::insert(&to, update_to);
// Emit event.
Self::deposit_event(Event::Transferred(sender, to, amount));
Ok(().into())
}