In the crowdfund pallet linked here:


the withdraw function works by calling the T::Currency::withdraw() fn in currency trait and passing that return value into the T::Currency::resolve_into_existing() fn instead why can i just use T::Currency::transfer like its done in the contribute() fn but swap the source and dest ?enter image description here

enter image description here

  • Edit your post to include the code as code blocks instead of pictures.
    – Simson
    Jun 8, 2023 at 4:39

1 Answer 1


A great resource for this is to just look at the definitions of transfer and withdraw for the Currency trait inside of the Substrate repo.


    /// Transfer some liquid free balance to another staker.
    /// This is a very high-level function. It will ensure all appropriate fees are paid
    /// and no imbalance in the system remains.
    fn transfer(
        source: &AccountId,
        dest: &AccountId,
        value: Self::Balance,
        existence_requirement: ExistenceRequirement,
    ) -> DispatchResult;


    /// Removes some free balance from `who` account for `reason` if possible. If `liveness` is
    /// `KeepAlive`, then no less than `ExistentialDeposit` must be left remaining.
    /// This checks any locks, vesting, and liquidity requirements. If the removal is not possible,
    /// then it returns `Err`.
    /// If the operation is successful, this will return `Ok` with a `NegativeImbalance` whose value
    /// is `value`.
    fn withdraw(
        who: &AccountId,
        value: Self::Balance,
        reasons: WithdrawReasons,
        liveness: ExistenceRequirement,
    ) -> Result<Self::NegativeImbalance, DispatchError>;

Most runtimes use the pallet_balances inside the Substrate repo that implements the Currency trait so reading the implementation of both methods in this pallet can also help a lot to understand how they work and what they do.

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.