createFor
Contract: JBProjects
Interface: IJBProjects
- Step by step
- Code
- Events
- Bug bounty
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β
-
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:
-
Mint a new NFT token belonging to the owner using the projectId as the tokenId.
// Mint the project.
_safeMint(projectId, count);Internal references:
-
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:
-
Emit a
Create
event with all relevant parameters.emit Create(projectId, _owner, _metadata, msg.sender);
Event references:
/**
@notice
Create a new project for the specified owner, which mints an NFT (ERC-721) into their wallet.
@dev
Anyone can create a project on an owner's behalf.
@param _owner The address that will be the owner of the project.
@param _metadata A struct containing metadata content about the project, and domain within which the metadata applies.
@return projectId The token ID of the newly created project.
*/
function createFor(address _owner, JBProjectMetadata calldata _metadata)
external
override
returns (uint256 projectId)
{
// Increment the count, which will be used as the ID.
projectId = ++count;
// Mint the project.
_safeMint(_owner, projectId);
// Set the metadata if one was provided.
if (bytes(_metadata.content).length > 0)
metadataContentOf[projectId][_metadata.domain] = _metadata.content;
emit Create(projectId, _owner, _metadata, msg.sender);
}
Name | Data |
---|---|
Create |
|
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |