Skip to main content

Manager

For use cases where the asset needs to be controlled (managed) by a third-party address, Nifty Asset allows the creation of "managed" assets. These assets have the Manager extension enabled, which defines a delegate address with customizable permissions.

The delegate can perform any of the actions specified on the roles field. Therefore, when the Manager extension is present on an asset, the ownership of the asset is shared — both the owner and the delegate will be able to transfer, lock and burn the asset.

Since the presence of the Manager extension significantly changes the nature of the asset, the extension can only be added to assets with the Standard set to Managed.

info

The Manager extension must be specified at the point of creation of the asset. It is not possible to add or remove the extension after its creation. It is possible, however, to update the address and the roles enabled.

Using a Manager

The Manager extension is used to create Managed assets. The extension can be added using either the allocate or create instruction.

import { DelegateRole, Standard, create, manager } from '@nifty-oss/asset';

await create(umi, {
asset,
owner,
name: 'Managed Asset',
standard: Standard.Managed,
payer,
extension: manager(delegate, [DelegateRole.Transfer]),
}).sendAndConfirm(umi);

Fetching a Manager

Given an asset account, it is possible to retrieve the manager information 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 manager = getExtension(asset, ExtensionType.Manager);

if (manager) {
console.log("Delegate: " + manager.address);
console.log("Roles: " + manager.roles);
}