Dollar Store Kids

This page highlights an example implementation of the CapsuleNFT Protocol with the popular NFT collection, Dollar Store Kids.

Summary of Dollar Store Kids

Dollar Store Kids is the first NFT Collection of its kind in which every NFT in the collection can be redeemed for $1 USDC. Redeeming an NFT in the collection permanently burns the NFT, thereby reducing the total Dollar Store Kids NFTs in the collection by one.

The execution of this collection can be extrapolated to the initial NFT offering (INO) use case. By adding varying amounts of project tokens in place of the $1 USDC, projects have the opportunity to distribute their tokens through NFTs in an unprecedented fashion.

At any time, the final version of the Dollar Store Kids code can be viewed on Github and is free for public use. The code has been audited by Quantstamp, with results viewable here.

Code Overview

Before hopping into the code, let's explore how this contract worked:

  • Upon deployment of the Dollar Store Kids contract, the constructor would deploy its own Capsule NFT Collection (it now owns that collection) with specific parameters (further information here).

  • The collection baseURI (collection metadata) is set through the constructor, but can also be changed at any time through the updateBaseURI() method.

  • The moment the toggleMint() method is called, anyone can mint their own DSK from the contract by calling mint().

  • At any time, any user may redeem their DSK by calling the burn() function.

Other Considerations

The Dollar Store Kids were launched under the following conditions:

  • The Dollar Store Kids maximum total supply (MAX_DSK) was set to X.

  • The Dollar Store Kids contract was funded with USDC. This was to X, to correspond to the maximum total supply.

  • In order to mint a Dollar Store Kid, the user would pay 0.001 ETH. This is the fee to mint an NFT using the Capsule NFT protocol.

  • Mint is limited to one Dollar Store Kid per account.

Dollar Store Kids Code

This section will go over some implementation requirements and decisions made in the Dollar Store Kids contract.

Implementing the CapsuleNFT Protocol

Adding the CapsuleNFT protocol to the contract is as simple as below:

ICapsuleFactory public constant CAPSULE_FACTORY = ICapsuleFactory(0x4Ced59c19F1f3a9EeBD670f746B737ACf504d1eB);
ICapsuleMinter public constant CAPSULE_MINTER = ICapsuleMinter(0xb8Cf4A28DA322598FDB78a1406a61B72d6F6b396);
ICapsule public immutable capsuleCollection;

This allows to you interact with all of the methods of the CapsuleNFT Protocol, alongside any ERC-721 NFT based methods (within ICapsule).

Core Functions

Since this is an NFT Collection owner, the most important methods are for users to mint and burn their Dollar Store Kid.

function mint()

As mentioned above, the Dollar Store Kids collection was limited to one mint per account. Most of the logic in the mint method relates to such condition.

The remaining logic relates to the creation of a Dollar Store Kid Capsule NFT.

// Mint the DSK
CAPSULE_MINTER.mintSingleERC20Capsule{value: msg.value}(
    address(capsuleCollection),
    USDC,
    ONE_DOLLAR,
    "",
    _caller
);

A more thorough explanation of the minting of a Capsule NFT can be found here. Note that this method could have included a different token, such as wETH, BAYC (with mintSingleERC721Capsule), or multiple tokens (with mintMultiERC20Capsule or mintMultiERC721Capsule).

Since we supplied the USDC to the Dollar Store Kids contract, there was no need for the user to transfer any tokens to the contract first. This step should be considered when creating your own collection.

function burn()

Quite simply, this method accepts the user's Dollar Store Kid, and burns it for them. There is the ability to add more logic to this method.

CAPSULE_MINTER.burnSingleERC20Capsule(address(capsuleCollection), id_);

The USDC is then transferred back to the user.

Governor Functions

The Governor functions are admin functions used for varying purposes:

  • function sweep(address _token)

Used to withdraw any tokens sent to the Dollar Store Kids contract.

  • function toggleMint()

Used to either start the mint process for the collection, or pause it.

  • function transferCollectionOwnership(address newOwner_)

Used to transfer the ownership of the underlying Capsule NFT Collection.

  • function updateMetamaster(address metamaster_)

Used to transfer metamaster ownership of the Capsule NFT Collection. For more information on metamaster privileges, view Metamaster.

  • function updateBaseURI(string memory baseURI_)

Used to update the baseURI of the collection.

  • function updateRoyaltyConfig(address royaltyReceiver_, uint256 royaltyRate_)

Used to update the royalty config for the base Capsule NFT contract.

This is an example of utilizing the CapsuleNFT Protocol to create your own composable NFT collection. There are a variety of other use cases creatable with CapsuleNFT.

Happy building!

Last updated