ERC20ClaimPhases
import "@thirdweb-dev/contracts/eip/interface/IERC20.sol";
import "@thirdweb-dev/contracts/extension/Drop.sol";
Allow other wallets to claim/mint tokens from the contract under the criteria of claim conditions by
implementing ERC20
, LazyMint
and Drop
extensions.
Unlike ERC20ClaimConditions
, this extension allows you to set multiple claim phases.
This is an extension which is detectable in the dashboard if the smart contract implements the
ERC20
and Drop
extensions.
Usage
This is an example smart contract demonstrating how to inherit from the extensions which make up the ERC20ClaimPhases
detectable extension.
The functions which are available to be (optionally) overridden are also detailed.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@thirdweb-dev/contracts/openzeppelin-presets/token/ERC20/ERC20.sol";
import "@thirdweb-dev/contracts/extension/Drop.sol";
import "@thirdweb-dev/contracts/extension/LazyMint.sol";
contract Contract is ERC20, Drop, LazyMint {
constructor(
string memory _name,
string memory _symbol
)
ERC20(
_name,
_symbol
)
{}
/// @dev Runs before every `claim` function call.
function _beforeClaim(
uint256 _tokenId,
address _receiver,
uint256 _quantity,
address _currency,
uint256 _pricePerToken,
AllowlistProof calldata _allowlistProof,
bytes memory _data
) internal virtual override {
// Your custom implementation logic here
}
/// @dev Runs after every `claim` function call.
function _afterClaim(
uint256 _tokenId,
address _receiver,
uint256 _quantity,
address _currency,
uint256 _pricePerToken,
AllowlistProof calldata _allowlistProof,
bytes memory _data
) internal virtual override {
// Your custom implementation logic here
}
function _canSetClaimConditions() internal view override returns (bool) {
// Your custom implementation here
}
function _collectPriceOnClaim(
address _primarySaleRecipient,
uint256 _quantityToClaim,
address _currency,
uint256 _pricePerToken
) internal virtual override {
// Your custom implementation here
}
function _transferTokensOnClaim(address _to, uint256 _quantityBeingClaimed)
internal
virtual
override
returns (uint256 startTokenId)
{
// Your custom implementation here
}
/**
* This function returns who is authorized to lazy mint NFTs on this contract.
*
* As an EXAMPLE, we'll only allow the contract deployer to lazy mint NFTs.
*
* You MUST complete the body of this function to use the `LazyMint` extension.
*/
function _canLazyMint() internal view virtual override returns (bool) {
// Your custom implementation here
}
}
SDK Usage
By adding this extension to a smart contract, the following features, hooks and functions are unlocked in the SDK:
Base Contracts Implementing This Extension
None of the base contracts implement this extension.