功能
委托压缩NFT
Last updated February 24, 2026
Summary
Delegating compressed NFTs allows the owner to authorize another account to perform actions on their behalf. This page covers approving and revoking delegate authorities on individual cNFTs.
- Approve a leaf delegate to transfer, burn, or freeze a cNFT on the owner's behalf
- Revoke a delegate by re-delegating to the owner's own address
- Delegate authority is reset automatically after a transfer
压缩NFT的所有者可以将其委托给另一个账户,同时保持cNFT的所有权。
这允许被委托的账户——我们也称为委托权限——代表所有者执行操作。这些操作是:
这些操作中的每一个都提供了如何使用委托权限执行它们的示例。通常,您只需提供叶子委托人账户作为签名者,而不是叶子所有者账户。 让我们看看如何批准和撤销压缩NFT的委托权限。
批准委托权限
要批准或替换委托权限,所有者必须发送Delegate指令。此指令接受以下参数:
- 叶子所有者:压缩NFT的当前所有者作为签名者。默认为交易的付款人。
- 先前叶子委托人:先前的委托权限(如果有)。否则,应设置为叶子所有者。
- 新叶子委托人:要批准的新委托权限。
此外,由于此指令替换Bubblegum树上的叶子,因此必须提供更多参数来验证压缩NFT的完整性,由于这些参数对于所有改变叶子的指令都是通用的,它们在以下FAQ中有记录。幸运的是,我们可以使用辅助方法,该方法将使用Metaplex DAS API自动为我们获取这些参数。
委托压缩NFT
import { getAssetWithProof, delegate } from '@metaplex-foundation/mpl-bubblegum';
const assetWithProof = await getAssetWithProof(umi, assetId, { truncateCanopy: true });
await delegate(umi, {
...assetWithProof,
leafOwner,
previousLeafDelegate: leafOwner.publicKey,
newLeafDelegate: newDelegate,
}).sendAndConfirm(umi);
撤销委托权限
要撤销现有的委托权限,所有者只需将自己设置为新的委托权限。
撤销压缩NFT的委托权限
import { getAssetWithProof, delegate } from '@metaplex-foundation/mpl-bubblegum';
const assetWithProof = await getAssetWithProof(umi, assetId, {truncateCanopy: true});
await delegate(umi, {
...assetWithProof,
leafOwner,
previousLeafDelegate: currentDelegate,
newLeafDelegate: leafOwner.publicKey,
}).sendAndConfirm(umi);
Notes
- Delegate authority is reset to the new owner after a transfer. The new owner must re-delegate if needed.
- Only one leaf delegate can be active at a time per cNFT. Approving a new delegate replaces the previous one.
- To revoke a delegate, set the new delegate to the owner's own public key.
FAQ
Glossary
| Term | Definition |
|---|---|
| Leaf Delegate | An account authorized by the cNFT owner to perform transfer, burn, and freeze actions |
| Delegate Authority | The approved account that can act on behalf of the cNFT owner |
| Previous Leaf Delegate | The current delegate being replaced, or the owner if no delegate was previously set |
