Giter Site home page Giter Site logo

updatable-nft-metadata's Introduction

Updatable NFT Metadata

Create a NFT drop with updatable metadata.

Setup

To run the project, first clone this repository, and then run one of the following commands to install the dependencies:

npm install
# or
yarn install

Next, you need to create a .env.local file and add the PRIVATE_KEY variable to it with the private key of the wallet you have used to create the NFT drop:

PRIVATE_KEY=...

Now, update the db.json file with the NFT drop's data. Once done, push your code to a repository.

Finally, go to scripts/upload-nfts.mjs and update your drop address and metadata files. The metadata file urls should be in this format: https://my-json-server.typicode.com/<your_username>/<your_repo_name>/nfts/<id>.

How It Works

Using the .fromPrivateKey method from ThirdwebSDK we initialise the sdk:

import { ThirdwebSDK } from "@thirdweb-dev/sdk";
import { config } from "dotenv";

config();

const sdk = ThirdwebSDK.fromPrivateKey(process.env.PRIVATE_KEY, "mumbai");

We then use the .getContract method to get the NFT drop:

const drop = await sdk.getContract("DROP_ADDRESS", "nft-drop");

Finally, we batch upload the NFTs using the centralized metadata files:

try {
  await drop.createBatch([
    "https://my-json-server.typicode.com/thirdweb-dev/updatable-nft-metadata/nfts/0",
    "https://my-json-server.typicode.com/thirdweb-dev/updatable-nft-metadata/nfts/1",
  ]);
  console.log("uploaded all nfts");
} catch (error) {
  console.log(error);
}

Join our Discord!

For any questions, suggestions, join our discord at https://discord.gg/thirdweb.

updatable-nft-metadata's People

Contributors

avneesh0612 avatar jarrodwatts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.