Dynamic NFT Metadata on Polybase

HC

Shaki

Mar 24, 2023

dynamic-nft-metadata
dynamic-nft-metadata
dynamic-nft-metadata

With dynamic NFT metadata stored on Polybase, you can build new kinds of utility or gaming NFTs that need faster and cheaper NFT metadata updates. Here’s a step-by-step walkthrough of how you can store your NFT metadata using Polybase.

Create an ERC-721 token

Open a terminal and make a directory for building your ERC-721 token.

directory-terminal

Navigate into the nftMetadata directory, install the following dependencies

install-dependencies

Under the contracts folder, create a new file "myToken.sol" and add the following code to it.

myToken.sol

Update the truffle-config.js file with the following code.

edit-truffle.js

You should store your Mnemonic phrase & Infura API key in the .env file that you need to create in this repository!

Your .env file would look like this.

Your-dotenv-file

Compile and deploy your contracts

compile-smart-contract

Once you have compiled the smart contract we need to migrate it over to the Goerli network! Add a new file 1_deploy_contract.js under the migrations folder and update it with the following script.

migration-script

Now save this code, navigate to the terminal, and type in the following command.

migrate-network

This would deploy your NFT in the Goerli test network. Make sure you recharge your Goerli testnet wallet before migrating it.

Creating a collection in Polybase

Now login to Polybase Explorer & add create a new app. You would be taken to the default boilerplate. Remove that code and paste the code given below. You can find this code in our docs.

polybase-collection-schema

Save the collection. Once you have done this head over to your terminal.

Install Polybase SDK

install-polybase-sdk

Add a mintnft.js file to your directory.

define-values-of-metadata

Navigate to the terminal and run this command.

mint-nft.js

Kudos! You have created your first record in the Polybase database. Here's a video where Shaki walks you through how to store your NFT metadata on Polybase.