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
immortalparameter to thepropsof thecreateSporewhen creating the spore.If a spore's
SporeData.contentTypeincludesimmortal=true, the Immortal extension is activated.
Create Immortal Spores
Ingredients
createSporefunction from@spore-sdk/core.SporeData.contentTypeproperty
Methods
There are two ways to activate the immortal extension when creating a spore.
Specify in the
contentTypeParametersobject 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,
});Use the
setContentTypeParametersfunction
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!
Last updated
Was this helpful?