Skip to main content

changeTokenOf

Contract: JBController​‌

Interface: IJBController

Swap the current project's token that is minted and burned for another, and transfer ownership of the current token to another address if needed.

Only a project's owner or operator can change its token.

Definition

function changeTokenOf(
uint256 _projectId,
IJBToken _token,
address _newOwner
)
external
virtual
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.CHANGE_TOKEN) { ... }
  • Arguments:
    • _projectId is the ID of the project to which the changed token belongs.
    • _token is the new token, which must adhere to the IJBToken specification.
    • _newOwner is an address to transfer the current token's ownership to. This is optional, but it cannot be done later.
  • Through the requirePermission modifier, the function is only accessible by the project's owner, or from an operator that has been given the JBOperations.CHANGE_TOKEN permission by the project owner for the provided _projectId.
  • The function can be overriden by inheriting contracts.
  • The function overrides a function definition from the IJBController interface.
  • The function doesn't return anything.

Body

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

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

    Internal references:

    External references:

  2. Make sure the current funding cycle for the project allows changing tokens.

    // The current funding cycle must not be paused.
    if (!_fundingCycle.changeTokenAllowed()) revert CHANGE_TOKEN_NOT_ALLOWED();

    Library references:

  3. Forward the call to the token store.

    // Change the token in the store.
    tokenStore.changeFor(_projectId, _token, _newOwner);

    Internal references:

    External references: