Get started with selling subscriptions on Crossmint in 5 minutes
This quickstart walks you through creating and selling your first on-chain subscription collection on Crossmint, in under 5 minutes.
Video walkthrough is here.
This quickstart is written for a technical audience, and primarily uses APIs in combination with the Crossmint console. It is opinionated and uses the base-sepolia chain and JavaScript/Node.js for the examples, but you can use any language and supported chain you like.
production. To get access, reach out using this form and specify your Project ID.
You can find the Project ID near the top right of the console overview page.
With onchain subscriptions, a subscription is recorded as an NFT owned by a user. To check if a user has a valid subscription, you check if they hold a subscription NFT and if it’s expired (encoded on-chain in the NFT’s metadata).
To create a new subscription at Crossmint, the first step is to create a collection, which is just a container for metadata, the price, payout address and other configurations for a collection of NFTs.
A subscription collection is a special extension of a Crossmint collection, which only holds subscription NFTs. Each subscription collection maps to an NFT smart contract (ERC-5643 in EVM chains). Certain features like NFT transferability are not available in subscription collections.
First, you’ll need to obtain the appropriate API keys.
You control these scopes by default in the staging environment.
When working with subscriptions in a production environment, make sure your account and collection are properly verified. Refer to the production launch guide for more information on the verification process.
With your API key ready, you can now proceed to create and manage subscription collections.
You will create your collection via curl requests (recommended), an API client, or whatever code language you wish.
If you are using an API client like Bruno or Postman, make sure you configure your header parameters properly:
Parameter | Value |
---|---|
BASE URL | https://staging.crossmint.com |
API-VERSION | 2022-06-09 |
X-API-KEY | YOUR_API_KEY |
When you copy/paste code examples, make sure you replace the text marked “YOUR_API_KEY”, “YOUR_COLLECTION_ID”, “YOUR_PROJECT_ID”, and “YOUR_WALLET_ADDRESS” with your actual API key, collectionId, projectId, and wallet address.
Notice the isSubscription: true
field in the Response (last tab of code group).
Save the id
from the response for later. We will refer to it as collectionId
later (e.g. fdfd902c-e80a-4828-b884-1554bdaeb54d
in the response above)
In the Crossmint console
Log into the Crossmint Staging Console and navigate to the Token collections tab. You should see your new collection in your list of collections.
Check collection through API (Advanced)
You can use the Get Collection Info API to check if your collection is ready.
You can use the API playground. Alternatively, use the code example below:
When a subscription is issued, your users will receive an NFT that represents it.
This NFT can contain a name, an image, a description, and other fields. You define these values by creating an NFT template that is copied each time a subscription is issued.
Let’s create a template now:
Navigate to the “Token collections” tab and select the collection you created earlier.
In the collection details page, click on the “NFTs” tab.
Click the “Manual Upload” button to create a new template.
Fill in the template details:
Once you’ve filled in all the necessary information, click the “Create NFT” button to add the template to your collection.
Once the template is uploaded, you can select its template ID when issuing a subscription to ensure the correct metadata is set.
Note:
Via API (Advanced)
For programmatic template creation, you can use the Create Template API.
Now it’s time to implement a page where your customers can pay for a subscription.
You can use two of Crossmint’s Checkout modalities for this: embedded checkout and headless. For simplicity, this guide recommends the use of “embedded” which has pre-built UI components.
Clone the Example Repo
Clone the embedded checkout example repo here and follow the instructions in the README.md file. This should get you a working embedded checkout that you can use to test your subscription collection in under 1 minute.
Subscriptions work with embedded and headless checkouts.
Configure Environment Variables
Make sure you change the NEXT_PUBLIC_PROJECT_ID
and NEXT_PUBLIC_COLLECTION_ID
in the demo’s .env.local
file to your subscription collection’s projectId and collectionId.
Troubleshooting is covered in the embedded quickstart guide.
If your embedded checkout is configured properly, you should see your subscription NFT loaded, with a “Subscribe” button on the bottom.
Common errors
NEXT_PUBLIC_PROJECT_ID
and NEXT_PUBLIC_COLLECTION_ID
in the .env.local
file to your subscription collection’s projectId and collectionId.X-API-KEY
in the .env.local
file to your server-side API key.emailInputOptions={{show: true,}}
prop. Using recipient
props will not work.With your newly created embedded checkout, you can now buy your first subscription NFT:
You should see the subscription NFT being minted to your wallet.
After the minting is complete, you will see buttons to view on Opensea, Basescan, and Crossmint. Explore these to see your subscription NFT and its information live on the blockchain.
You will also receive a confirmation email with the details of your subscription. Crossmint automatically creates a wallet for any inputted email address. If you already have Crossmint wallet, it will be sent to your existing wallet.
Once the subscription NFT is successfully minted and delivered, you should receive an email with your transaction details.
Open your Crossmint wallet at https://staging.crossmint.com/user/ for staging, or https://www.crossmint.com/user/ for production, and see your new subscription NFT.
A subscription NFT is active as long as the expiresAt
date is in the future.
The rules are straightforward:
You can check the expiration of your subscription NFT in 2 ways:
Crossmint's APIs (recommended)
Any Crossmint API that returns NFT metadata will include the expiresAt
field.
For this quickstart, Crossmint recommends you use the Get All NFTs API, as it gives an overall view of all NFTs in your subscription collection, including their expiration dates.
(Alternative) Using the API Playground
YOUR_API_KEY
generated in Step 1.YOUR_COLLECTION_ID
from the console1
Block Explorer
To check the expiration of a subscription NFT, you can use a block explorer like Base Sepolia Explorer. Follow these steps:
Congratulations on successfully setting up and testing your subscription collection! Here’s what you can do next:
Go Live: Ready for production? Contact Crossmint sales to enable subscriptions for your account.
Learn More: Explore our full documentation for in-depth information on all Crossmint Checkout products.
Happy building!
Get started with selling subscriptions on Crossmint in 5 minutes
This quickstart walks you through creating and selling your first on-chain subscription collection on Crossmint, in under 5 minutes.
Video walkthrough is here.
This quickstart is written for a technical audience, and primarily uses APIs in combination with the Crossmint console. It is opinionated and uses the base-sepolia chain and JavaScript/Node.js for the examples, but you can use any language and supported chain you like.
production. To get access, reach out using this form and specify your Project ID.
You can find the Project ID near the top right of the console overview page.
With onchain subscriptions, a subscription is recorded as an NFT owned by a user. To check if a user has a valid subscription, you check if they hold a subscription NFT and if it’s expired (encoded on-chain in the NFT’s metadata).
To create a new subscription at Crossmint, the first step is to create a collection, which is just a container for metadata, the price, payout address and other configurations for a collection of NFTs.
A subscription collection is a special extension of a Crossmint collection, which only holds subscription NFTs. Each subscription collection maps to an NFT smart contract (ERC-5643 in EVM chains). Certain features like NFT transferability are not available in subscription collections.
First, you’ll need to obtain the appropriate API keys.
You control these scopes by default in the staging environment.
When working with subscriptions in a production environment, make sure your account and collection are properly verified. Refer to the production launch guide for more information on the verification process.
With your API key ready, you can now proceed to create and manage subscription collections.
You will create your collection via curl requests (recommended), an API client, or whatever code language you wish.
If you are using an API client like Bruno or Postman, make sure you configure your header parameters properly:
Parameter | Value |
---|---|
BASE URL | https://staging.crossmint.com |
API-VERSION | 2022-06-09 |
X-API-KEY | YOUR_API_KEY |
When you copy/paste code examples, make sure you replace the text marked “YOUR_API_KEY”, “YOUR_COLLECTION_ID”, “YOUR_PROJECT_ID”, and “YOUR_WALLET_ADDRESS” with your actual API key, collectionId, projectId, and wallet address.
Notice the isSubscription: true
field in the Response (last tab of code group).
Save the id
from the response for later. We will refer to it as collectionId
later (e.g. fdfd902c-e80a-4828-b884-1554bdaeb54d
in the response above)
In the Crossmint console
Log into the Crossmint Staging Console and navigate to the Token collections tab. You should see your new collection in your list of collections.
Check collection through API (Advanced)
You can use the Get Collection Info API to check if your collection is ready.
You can use the API playground. Alternatively, use the code example below:
When a subscription is issued, your users will receive an NFT that represents it.
This NFT can contain a name, an image, a description, and other fields. You define these values by creating an NFT template that is copied each time a subscription is issued.
Let’s create a template now:
Navigate to the “Token collections” tab and select the collection you created earlier.
In the collection details page, click on the “NFTs” tab.
Click the “Manual Upload” button to create a new template.
Fill in the template details:
Once you’ve filled in all the necessary information, click the “Create NFT” button to add the template to your collection.
Once the template is uploaded, you can select its template ID when issuing a subscription to ensure the correct metadata is set.
Note:
Via API (Advanced)
For programmatic template creation, you can use the Create Template API.
Now it’s time to implement a page where your customers can pay for a subscription.
You can use two of Crossmint’s Checkout modalities for this: embedded checkout and headless. For simplicity, this guide recommends the use of “embedded” which has pre-built UI components.
Clone the Example Repo
Clone the embedded checkout example repo here and follow the instructions in the README.md file. This should get you a working embedded checkout that you can use to test your subscription collection in under 1 minute.
Subscriptions work with embedded and headless checkouts.
Configure Environment Variables
Make sure you change the NEXT_PUBLIC_PROJECT_ID
and NEXT_PUBLIC_COLLECTION_ID
in the demo’s .env.local
file to your subscription collection’s projectId and collectionId.
Troubleshooting is covered in the embedded quickstart guide.
If your embedded checkout is configured properly, you should see your subscription NFT loaded, with a “Subscribe” button on the bottom.
Common errors
NEXT_PUBLIC_PROJECT_ID
and NEXT_PUBLIC_COLLECTION_ID
in the .env.local
file to your subscription collection’s projectId and collectionId.X-API-KEY
in the .env.local
file to your server-side API key.emailInputOptions={{show: true,}}
prop. Using recipient
props will not work.With your newly created embedded checkout, you can now buy your first subscription NFT:
You should see the subscription NFT being minted to your wallet.
After the minting is complete, you will see buttons to view on Opensea, Basescan, and Crossmint. Explore these to see your subscription NFT and its information live on the blockchain.
You will also receive a confirmation email with the details of your subscription. Crossmint automatically creates a wallet for any inputted email address. If you already have Crossmint wallet, it will be sent to your existing wallet.
Once the subscription NFT is successfully minted and delivered, you should receive an email with your transaction details.
Open your Crossmint wallet at https://staging.crossmint.com/user/ for staging, or https://www.crossmint.com/user/ for production, and see your new subscription NFT.
A subscription NFT is active as long as the expiresAt
date is in the future.
The rules are straightforward:
You can check the expiration of your subscription NFT in 2 ways:
Crossmint's APIs (recommended)
Any Crossmint API that returns NFT metadata will include the expiresAt
field.
For this quickstart, Crossmint recommends you use the Get All NFTs API, as it gives an overall view of all NFTs in your subscription collection, including their expiration dates.
(Alternative) Using the API Playground
YOUR_API_KEY
generated in Step 1.YOUR_COLLECTION_ID
from the console1
Block Explorer
To check the expiration of a subscription NFT, you can use a block explorer like Base Sepolia Explorer. Follow these steps:
Congratulations on successfully setting up and testing your subscription collection! Here’s what you can do next:
Go Live: Ready for production? Contact Crossmint sales to enable subscriptions for your account.
Learn More: Explore our full documentation for in-depth information on all Crossmint Checkout products.
Happy building!