はじめに
NFTを更新する
Last updated March 12, 2025
更新権限者として、NFTの名前とメタデータを更新します。
NFTを更新する
以下のセクションでは、完全なコード例と変更が必要なパラメータを確認できます。NFTの更新の詳細については、Coreドキュメントをご覧ください。
1import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'
2import { update } from '@metaplex-foundation/mpl-core'
3import { mplCore } from '@metaplex-foundation/mpl-core'
4import { publicKey } from '@metaplex-foundation/umi'
5
6const umi = createUmi('https://api.devnet.solana.com').use(mplCore())
7const assetAddress = publicKey('AssetAddressHere...')
8
9// Update an existing NFT asset's metadata
10const result = await update(umi, {
11 asset: assetAddress,
12 name: 'Updated NFT Name',
13 uri: 'https://updated-example.com/metadata.json',
14}).sendAndConfirm(umi)
15
16console.log('Asset updated successfully')
1# Update an NFT using the Metaplex CLI
2
3# Update name and URI
4mplx core asset update <assetId> --name "Updated NFT" --uri "https://example.com/new-metadata.json"
5
6# Update with new image
7mplx core asset update <assetId> --image "./new-image.png"
8
9# Update with JSON metadata file
10mplx core asset update <assetId> --json "./metadata.json"
11
12# Update with both JSON and image
13mplx core asset update <assetId> --json "./metadata.json" --image "./new-image.png"
パラメータ
更新に合わせて以下のパラメータをカスタマイズしてください:
| パラメータ | 説明 |
|---|---|
assetAddress | 更新するNFTの公開鍵 |
name | NFTの新しい名前(オプション) |
uri | 新しいメタデータURI(オプション) |
仕組み
更新プロセスには3つの手順が含まれます:
- NFTを取得 -
fetchAssetを使用して現在のNFTデータを取得 - 更新を準備 - 変更したい新しい名前またはURIを指定
- 更新を送信 - 更新トランザクションを実行
NFTの更新権限者のみがNFTを変更できます。NFTがコレクションの一部でコレクション権限を使用している場合、コレクションの更新権限者である必要があります。
