mintFor
Contract: JBTokenStore
Interface: IJBTokenStore
- Step by step
- Code
- Events
- Bug bounty
Mint new project tokens.
Only a project's current controller can mint its tokens.
Definition
function mintFor(
address _holder,
uint256 _projectId,
uint256 _amount,
bool _preferClaimedTokens
) external override onlyController(_projectId) { ... }
- Arguments:
_holder
is the address receiving the new tokens._projectId
is the ID of the project to which the tokens belong._amount
is the amount of tokens to mint._preferClaimedTokens
is a flag indicating whether there's a preference for minted tokens to be claimed automatically into the_holder
s wallet if the project currently has a token contract attached.
- 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 doesn't return anything.
Body
-
Get a reference to the project's current token.
// Get a reference to the project's current token.
IJBToken _token = tokenOf[_projectId];Internal references:
-
Check if tokens should be minted using the internal accounting mechanism, or if they should be claimed into the holder's wallet. Tokens should be claimed if the project has issued tokens, and either the project forces tokens to be claimed or if the
_preferClaimedTokens
flag is true. The internal accounting mechanism uses less gas, and tokens issued using it can later be claimed into the holders wallet by anyone who submits aclaimFor
transaction.// Save a reference to whether there exists a token and the caller prefers these claimed tokens or the project requires it.
bool _shouldClaimTokens = (requireClaimFor[_projectId] || _preferClaimedTokens) &&
_token != IJBToken(address(0));