Create Immortal Spore

In this recipe, we'll show you how to use the Spore SDK to create immortal spores that are indestructible and can live on-chain indefinitely.

What is an Immortal Spore?

The Immortal extension enhances the properties of spores, making them indestructible and live on the blockchain indefinitely. Here's what you need to know:

  • To create an immortal spore, we need to add the immortal parameter to the props of the createSpore when creating the spore.

  • If a spore's SporeData.contentType includes immortal=true, the Immortal extension is activated.

Create Immortal Spores

Ingredients

  • createSpore function from @spore-sdk/core.

  • SporeData.contentType property

Methods

There are two ways to activate the immortal extension when creating a spore.

  1. Specify in the contentTypeParameters object as follows

import { createSpore } from '@spore-sdk/core';

let { txSkeleton } = await createSpore({
  data: {
    content: JPEG_AS_BYTES,
    contentType: 'image/jpeg',
    contentTypeParameters: {
      immortal: true, // enabling the immortal extension
    },
  },
  fromInfos: [WALLET_ADDRESS],
  toLock: WALLET_LOCK_SCRIPT,
});
  1. Use the setContentTypeParameters function

import { createSpore, setContentTypeParameters } from '@spore-sdk/core';

let { txSkeleton } = await createSpore({
  data: {
    content: JPEG_AS_BYTES,
    contentType: setContentTypeParameters(
      'image/jpeg', 
      {
        immortal: true, // enabling the immortal extension
      }
    ),
  },
  fromInfos: [WALLET_ADDRESS],
  toLock: WALLET_LOCK_SCRIPT,
});

In both methods, we pass the immortal: true parameter as part of the contentTypeParameters when creating the spore. This activates the Immortal extension, ensuring that your spore remains indestructible and lives forever on-chain.

What's Next?

Now that you’ve mastered creating Immortal Spores using the Spore SDK, explore further and experiment with different parameters and functions offered by the Spore SDK to enhance your creations!

Your Feedback Matters!

Get in touch by:

Last updated