Plugins
Transfer Delegate Plugin
Overview
The Transfer Delegate
Plugin is a Owner Managed
plugin that allows the authority of the Transfer Delegate Plugin to transfer the Asset at any time.
The Transfer Plugin will work in areas such as:
- Escrowless sale of the Asset: Transfer NFTs directly to buyers without needing an escrow account
- Gaming scenario where the user swaps/loses their asset based on an event: Automatically transfer assets when game events occur
- Subscription services: Transfer NFTs as part of a subscription service
Warning!
The transfer delegate authority is temporary and will be reset upon asset transfer.
Works With
MPL Core Asset | β |
MPL Core Collection | β |
Arguments
The Transfer Plugin doesn't contain any arguments to pass in.
Functions
Add Transfer Delegate Plugin to an Asset
The addPlugin
command adds the Transfer Delegate Plugin to an Asset. This plugin allows a delegate to transfer the Asset at any time.
Adding a Transfer Plugin to an MPL Core Asset
import { publicKey } from '@metaplex-foundation/umi'
import { addPlugin } from '@metaplex-foundation/mpl-core'
const assetAddress = publicKey('11111111111111111111111111111111')
const delegate = publicKey('22222222222222222222222222222222')
await addPlugin(umi, {
asset: assetAddress,
plugin: {
type: 'TransferDelegate',
authority: { type: 'Address', address: delegate },
},
}).sendAndConfirm(umi)
Delegate the Transfer Authority
The approvePluginAuthority
command delegates the transfer authority to a different address. This allows another address to transfer the Asset while maintaining ownership.
Delegate the Transfer Authority
import { publicKey } from '@metaplex-foundation/umi'
import { approvePluginAuthority } from '@metaplex-foundation/mpl-core'
const asset = publicKey("11111111111111111111111111111111");
const collection = publicKey("22222222222222222222222222222222");
const delegateAddress = publicKey("33333333333333333333333333333333");
await approvePluginAuthority(umi, {
asset: asset,
collection: collection,
plugin: { type: "TransferDelegate" },
newAuthority: { type: "Address", address: delegateAddress },
}).sendAndConfirm(umi);
Transferring an Asset As Delegate
The transfer
instruction transfers an Asset to another address using the transfer delegate authority.
Transfer an MPL Core Asset
import {
fetchAsset,
fetchCollection,
transfer,
} from "@metaplex-foundation/mpl-core";
import { publicKey } from "@metaplex-foundation/umi";
// Asset ID you wish to transfer
const assetId = publicKey("11111111111111111111111111111111");
// Fetch the Asset
const assetItem = await fetchAsset(umi, assetId);
// Fetch collection if Asset is apart of collection
const collectionItem =
assetItem.updateAuthority.type == "Collection" &&
assetItem.updateAuthority.address
? await fetchCollection(umi, assetItem.updateAuthority.address)
: undefined;
// Transfer the Core NFT Asset
const { signature } = await transfer(umi, {
asset: assetItem,
newOwner: publicKey("22222222222222222222222222222222"),
collection: collectionItem,
})
.sendAndConfirm(umi);