快速入门

转移NFT

Last updated March 12, 2025

在Solana上的钱包之间转移NFT所有权。

转移NFT

在以下部分,您可以看到完整的代码示例以及需要更改的参数。有关转移NFT的更多详情,请参阅Core文档

1import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'
2import { transfer } from '@metaplex-foundation/mpl-core'
3import { mplCore } from '@metaplex-foundation/mpl-core'
4import { publicKey } from '@metaplex-foundation/umi'
5
6// Initialize UMI
7const umi = createUmi('https://api.devnet.solana.com')
8 .use(mplCore())
9
10// Transfer an existing NFT asset to a new owner
11const result = await transfer(umi, {
12 asset: publicKey('AssetAddressHere...'),
13 newOwner: publicKey('RecipientAddressHere...'),
14}).sendAndConfirm(umi)
15
16console.log('Asset transferred:', result.signature)

参数

根据您的转移需求自定义以下参数:

参数描述
assetAddress要转移的NFT的公钥
newOwner接收者的钱包地址

工作原理

转移过程涉及3个步骤:

  1. 验证所有权 - 您必须是NFT的当前所有者
  2. 指定接收者 - 提供新所有者的钱包地址
  3. 执行转移 - NFT所有权立即转移

NFT转移

与SPL/同质化代币不同,Core NFT不需要接收者预先创建代币账户。所有权直接记录在NFT上,使转移更简单、更便宜。