跳到主要内容

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 owner or operator can issue its token.

Definition

function issueFor(
uint256 _projectId,
string calldata _name,
string calldata _symbol
)
external
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.ISSUE)
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 requirePermission modifier, the function is only accessible by the project's owner, or from an operator that has been given the JBOperations.ISSUE permission by the project owner for the provided _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, _projectId);
  5. Store the newly deployed token contract as the token of the project.

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

    Internal references:

  6. Emit an Issue event with the relevant parameters.

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

    Event references: