Skip to main content

transferFrom

Contract: JBTokenStore​‌

Interface: IJBTokenStore

Allows a holder to transfer unclaimed tokens to another account.

Only a token holder or an operator can transfer its unclaimed tokens.

Definition

function transferFrom(
address _holder,
uint256 _projectId,
address _recipient,
uint256 _amount
) external override requirePermission(_holder, _projectId, JBOperations.TRANSFER) { ... }
  • Arguments:
    • _holder is the address to transfer tokens from.
    • _projectId is the ID of the project whose tokens are being transferred.
    • _recipient is thhe recipient of the tokens.
    • _amount is the amount of tokens to transfer.
  • Through the requirePermission modifier, the function is only accessible by the token holder, or from an operator that has been given the JBOperations.TRANSFER permission by the token holder.
  • The function overrides a function definition from the IJBTokenStore interface.
  • The function doesn't return anything.

Body

  1. Get a reference to the project's current funding cycle.

    // Get a reference to the current funding cycle for the project.
    JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);

    Internal references:

  2. Make sure the project's current funding cycle is not set to pause transfers.

    // Must not be paused.
    if (_fundingCycle.global().pauseTransfers) revert TRANSFERS_PAUSED();

    Library references:

  3. Make sure a non-zero recipient was specified.

    // Can't transfer to the zero address.
    if (_recipient == address(0)) revert RECIPIENT_ZERO_ADDRESS();
  4. Get a reference to the amount of unclaimed project tokens the holder has.

    // Get a reference to the holder's unclaimed project token balance.
    uint256 _unclaimedBalance = unclaimedBalanceOf[_holder][_projectId];

    Internal references:

  5. Make sure the holder has enough unclaimed tokens to transfer.

    // The holder must have enough unclaimed tokens to transfer.
    if (_amount > _unclaimedBalance) revert INSUFFICIENT_UNCLAIMED_TOKENS();
  6. Subtract the amount from the holder's unclaimed balance of project tokens.

    // Subtract from the holder's unclaimed token balance.
    unchecked {
    unclaimedBalanceOf[_holder][_projectId] = _unclaimedBalance - _amount;
    }

    Internal references:

  7. Add the amount of unclaimed project tokens to the recipient's balance.

    // Add the unclaimed project tokens to the recipient's balance.
    unclaimedBalanceOf[_recipient][_projectId] =
    unclaimedBalanceOf[_recipient][_projectId] +
    _amount;

    Internal references:

  8. Emit a Transfer event with the relevant parameters.

    emit Transfer(_holder, _projectId, _recipient, _amount, msg.sender);

    Event references: