Skip to main content


Contract: JBDirectory​‌

Interface: IJBDirectory

Project's can set which terminal should be their primary for a particular token.

This is useful in case a project has several terminals connected for a particular token.

The terminal will be set as the primary terminal where ecosystem contracts should route tokens.

If setting a newly added terminal and the funding cycle doesn't allow new terminals, the caller must be the current controller.


function setPrimaryTerminalOf(
uint256 _projectId,
address _token,
IJBPaymentTerminal _terminal
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.SET_PRIMARY_TERMINAL) { ... }
  • Arguments:
    • _projectId is the ID of the project for which a primary token is being set.
    • _token is the token to set the primary terminal of.
    • _terminal is the terminal to make primary.
  • Through the requirePermission modifier, the function is only accessible by the project's owner, or from an operator that has been given the JBOperations.SET_PRIMARY_TERMINAL permission by the project owner for the provided _projectId.
  • The function overrides a function definition from the IJBDirectory interface.
  • The function doesn't return anything.


  1. Make sure the provided terminal accepts to provided token.

    // Can't set the primary terminal for a token if it doesn't accept the token.
    if (!_terminal.acceptsToken(_token, _projectId)) revert TOKEN_NOT_ACCEPTED();

    External references:

  2. Make sure the project's current funding cycle is set to allow setting terminals, or the request to set the terminals is coming from the project's current controller.

    // Add the terminal to the project if it hasn't been already.
    _addTerminalIfNeeded(_projectId, _terminal);

    Internal references:

  3. Store the new terminal as the primary.

    // Store the terminal as the primary for the particular token.
    _primaryTerminalOf[_projectId][_token] = _terminal;

    Internal references:

  4. Emit a SetPrimaryTerminal event with the relevant parameters.

    emit SetPrimaryTerminal(_projectId, _token, _terminal, msg.sender);

    Event references: