전송 함수 테스트하기
transfer 함수 개요
transfer 함수 개요#[pallet::weight(10_000)]
pub (super) fn transfer(
origin: OriginFor<T>,
to: T::AccountId,
#[pallet::compact] amount: T::Balance,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
Accounts::<T>::mutate(&sender, |bal| {
*bal = bal.saturating_sub(amount);
});
Accounts::<T>::mutate(&to, |bal| {
*bal = bal.saturating_add(amount);
});
Self::deposit_event(Event::<T>::Transferred(sender, to, amount))
Ok(().into())
}송신자의 잔액이 충분한지 확인
오류 처리 구성
송신 계정이 최소 잔액 아래로 내려가지 않는지 확인
두 테스트가 함께 작동하는지 확인
더스트 계정 처리
예제
자원
Last updated