Skip to main content
Time to complete: 20 minutes In this guide we’ll walk you through how to store media using the Sequence Collections API with Cloudflare Workers, as well as read from the Metadata API to render images This can be accomplished with 8 steps
  1. Obtain a Secret API Key from the Sequence Builder Console
  2. Create Collection from a cURL request one time
  3. Create Token create a token using a tokenID
  4. Create Asset create an assetID
  5. Store an Image process and store an image
  6. Update to Non-private update an asset to be non-private
  7. Publish Collection from a cURL request one time
  8. Render Asset from API from a cURL request one time
First follow this section of the Collectible Minting Service Guide guide to create a cloudflare worker

1. Obtain a Secret API Key (JWT_ACCESS_KEY)

In order to use the backend service, a Secret API Key must be obtained to authenticate requests to your project First start by accessing settings, and selecting the API Keys from the Sequence Builder Console
builder settings access keys
Scroll down and select + Add Admin API Secret Key
builder settings add service account
Then change the access to write and confirm by pressing + Add API Secret Key
builder settings add service account
Finally copy the key and store it in your wrangler.toml as JWT_ACCESS_KEY, as you will not have access to this in the future from the Sequence Builder Console.

2. Create Collection from a cURL Request

As a one time requirement to uploading media to the service, a collection has to be first made. By using the Secret API Key and projectID retrieved from the Builder Console We call the service to retrieve a collectionID
We then set the collectionID from the returned response in the wrangler.toml as COLLECTION_ID

3. Create Token using TokenID

If using a Clouflare worker, ensure to add node_compat = true to your wrangler.toml to allow the window object to be available to the @0xsequence/metadata package
Install the metadata package to use the SequenceCollections with pnpm install @0xsequence/metadata

4. Create Asset using TokenID

In the request, set the metadadaField (assetType) to image, with the other necessary fields completed to return an asset response to be used in the next step

5. Store Image Asset

With the passed in asset.id from the previous jsonCreateAsset object
Where the returned uploadAssetRes.url is the media file url living on Sequence servers

6. Update Non-private Token

Now, we make the token non-private by setting a private boolean to false

7. Publish Collection From A cURL Request

Finally, also as a one time request, we publish the collection based on the projectID and collectionID by running the following command
This would make the collection and all the tokens with the private flag set as false accessible publicly, while others remain hidden until changed

8. Render Asset from API Publicly

You can test your prior work, by calling this cURL request with the updated variables, which will download the file to your local terminal. Or, you can copy and paste into a browser and see the image Where if you used the same code, the <file_name> will be image.png
[cURL]
And if you were using the collection for the baseURI of an ERC721 or ERC1155 you would write to a smart contract setBaseMetadataURI the following URI
And the smart contract will automatically append the tokenID to the end Give it a try
[cURL]
Or in a browser

Render Asset from API Privately

If you decide to keep your assets private (in the token parameter, private: true), you can still view the token image if you provide the jwt_access_key in the header. For this guide, the metadata_field is set to image
[cURL]
Full code for this guide can be found here