Skip to main content

Creators

The Creators extension allows adding a list of creators to an asset, specifying their status (verified or not) and a percentage share. In most cases, this extension is used in combination with Royalties to determine the addresses that should received royalties. There is no limit on how many creators can be added to an asset.

The extension consists of a list of Creators:

Adding Creators

The Creators extension can be created using either the allocate, create or update instructions.

import { allocate, creators } from '@nifty-oss/asset';

const creator1 = publicKey("...");
const creator2 = publicKey("...");

await allocate(umi, {
asset,
payer,
extension: creators([
{ address: creator1, share: 50 },
{ address: creator2, share: 50 }
]),
}).sendAndConfirm(umi);

Fetching Creators

Given an asset account, it is possible to retrieve the creators of an asset. Note that not all assets might have the extension, therefore it is necessary to assert if the extension was found.

import {
ExtensionType,
fetchAsset,
getExtension
} from '@nifty-oss/asset';

const asset = await fetchAsset(umi, address);
const creators = getExtension(asset, ExtensionType.Creators);

if (creators) {
creators.values.forEach(({ address, share }) => {
console.log(address + '=' + share);
});
}