Skip to content

k0yote/migrate-metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Migrate Metadata

クラウドストレージにあるNFTメタデータを分散ストレージへ移行

Prerequisites

マイグレーションを行う。

  1. メタ情報とイメージをローカルにダウンロードする (メタデータ中に定義されているimageのURLからダウンロード)
{
  "description": "Friendly OpenSea Creature that enjoys long swims in the ocean.", 
  "external_url": "https://openseacreatures.io/3", 
  "image": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png", 
  "name": "Dave Starbelly",
  "attributes": [ ... ]
}
  1. ダウンロードしたイメージをIPFSストレージにアップロードする ※今回はthirdwebが提供している以下の2つライブラリーを用いて行いました。
  • https://www.npmjs.com/package/thirdweb
  • go get github.com/thirdweb-dev/go-sdk/v2/thirdweb

Help

./bin/meta-converter -h                                                                                                                                
flag needs an argument: -h
Usage of ./bin/meta-converter:
  -eTokenID int
    	finish to NFT TokenID (default 1)
  -h string
    	Metadata API Base URL (default "https://metadata.baseUrl/xxxxx/")
  -image-outdir string
    	Images output folder name (default "images")
  -meta-outdir string
    	Metadata output folder name (default "metadata")
  -sTokenID int
    	start from NFT TokenID (default 1)

実行

  1. npm install

  2. 以下を実行し、メタデータとイメージをダウンロードする

    ./bin/meta-converter -h {メタが取れるAPIベースURL} -sTokenID 開始トークンID -eTokenID 終了トークンID
    ## 実行ログからipfsのcid確認ができる
    ipfs response : {Image:ipfs://jiorjoiiojgojdfogjdf/0}
    ipfs response : {Image:ipfs://jiorjoiiojgojdfogjdf/0}
    ipfs response : {Image:ipfs://jiorjoiiojgojdfogjdf/0}
    ipfs response : {Image:ipfs://jiorjoiiojgojdfogjdf/0}
    ipfs response : {Image:ipfs://jiorjoiiojgojdfogjdf/0}
  3. 1.を実行するとmetadata / imagesフォルダにそれぞれメタデータjsonファイルと画像がダウンロードされていてる

  4. メタデータのimageが既にipfsのURLに書きかわってる

  5. 最後メタデータをアップロードする

    ## thirdwebのAPIシークレットキーを要求されるので事前にAPIキーを生成しておく
    npx thirdweb@latest upload metadata
    ## 正常に実行された例
    ✔ Successfully uploaded directory to IPFS
    ✔ Files stored at the following IPFS URI: ipfs://joewiurefdjasf
    ✔ Open this link to view your upload: https://{client-id}.ipfscdn.io/ipfs/joewiurefdjasf/
  6. 4.取得したURLだとthirdweb側の制限があるのでパブリックでは確認できないため、public gatewayに変更してhttps://ipfs.io/ipfs/joewiurefdjasf/をスマートコントラクトのベーストークンURIを更新

About

Migrate from a centralized nft metadata distribution to an ipfs with thirdweb library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published