跳到主要内容

createFor

Contract: JBProjects

Interface: IJBProjects

Create a new project for the specified owner, which mints an NFT (ERC-721) into their wallet.

Anyone can create a project on an owner's behalf.

Definition

function createFor(address _owner, JBProjectMetadata calldata _metadata)
external
override
returns (uint256 projectId) { ... }
  • Arguments:
    • _owner is the address that will be the owner of the project.
    • _metadata is a struct containing metadata content about the project, and domain within which the metadata applies.
  • The function can be accessed externally by anyone.
  • The function overrides a function definition from the IJBProjects interface.
  • The function returns the token ID of the newly created project.

Body

  1. Increment the count. Set it as the project's ID which is the returned value.

    // Increment the count, which will be used as the ID.
    projectId = ++count;

    Internal references:

  2. Mint a new NFT token belonging to the owner using the projectId as the tokenId.

    // Mint the project.
    _safeMint(projectId, count);

    Internal references:

  3. If metadata was provided (meaning its content is not an empty string), store it for newly created project under the provided domain.

    // Set the metadata if one was provided.
    if (bytes(_metadata.content).length > 0)
    metadataContentOf[projectId][_metadata.domain] = _metadata.content;

    Internal references:

  4. Emit a Create event with all relevant parameters.

    emit Create(projectId, _owner, _metadata, msg.sender);

    Event references: