Skip to main content

issueFor

Contract: JBTokenStore​‌

Interface: IJBTokenStore

Issues an project's ERC-20 tokens that'll be used when claiming tokens.

Deploys a project's ERC-20 token contract.

Only a project's current controller can issue its token.

Definition

function issueFor(
uint256 _projectId,
string calldata _name,
string calldata _symbol
) external override onlyController(_projectId) returns (IJBToken token) { ... }
  • Arguments:
    • _projectId is the ID of the project being issued tokens.
    • _name is the ERC-20's name.
    • _symbol is the ERC-20's symbol.
  • Through the onlyController modifier, the function can only be accessed by the controller of the _projectId.
  • The function overrides a function definition from the IJBTokenStore interface.
  • The function returns the token that was issued.

Body

  1. Make sure a name was provided.

    // There must be a name.
    if (bytes(_name).length == 0) revert EMPTY_NAME();
  2. Make sure a symbol was provided.

    // There must be a symbol.
    if (bytes(_symbol).length == 0) revert EMPTY_SYMBOL();
  3. Make sure the project doesn't already have a token.

    // The project shouldn't already have a token.
    if (tokenOf[_projectId] != IJBToken(address(0))) revert PROJECT_ALREADY_HAS_TOKEN();

    Internal references:

  4. Deploy a new instance of a JBToken contract. Assign it to the return value.

    // Deploy the token contract.
    token = new JBToken(_name, _symbol);
  5. Store the newly deployed token contract as the token of the project.

    // Store the token contract.
    tokenOf[_projectId] = token;

    Internal references:

  6. Store the project the token is being used for.

    // Store the project for the token.
    projectOf[token] = _projectId;

    Internal references:

  7. Emit an Issue event with the relevant parameters.

    emit Issue(_projectId, token, _name, _symbol, msg.sender);

    Event references: