Skip to content

Latest commit

 

History

History
93 lines (57 loc) · 4.91 KB

README.md

File metadata and controls

93 lines (57 loc) · 4.91 KB

Minting Mutable NFTs #onPolygon with Tableland

This repo goes along with an EthMexico 2022 workshop by the same name

Technology intros

Intro to Polygon

Polygon is the leading Ethereum scaling solution. We'll use Polygon PoS on the Polygon Mumbai testnet to deploy smart contracts and Tableland tables. Switch to the Polygon Mumbai network in Metamask, create a new test account, and send yourself some Matic from a faucet.

Intro to Tableland

Tableland is a network and relational metadata protocol for EVM chains like Ethereum. We'll use Tableland to store, query, and update NFT metadata on two tables. Here are some things you can do with Tableland.

  • Use tables to store mutable NFT metadata governed by immutable rules.
  • Use tables to attach in-app or in-game metadata to existing NFTs.
  • Control table write access with token or address-based rules.
  • Use tables to build fully decentralized apps and games that require complex relational data models.

LFB: Let's Build! ;)

Get started building fast. Clone this repo, then create a .env file and add the following as environment variables from Alchemy, Polyscan, and Metamask. CREATE A NEW TEST ACCOUNT ON METAMASK. DO NOT USE AN ACCOUNT WITH REAL ASSETS.

touch .env

Add the following to your .env file

  • ALCHEMY_POLYGON_MUMBAI_API_KEY=your_polygon_mumbai_alchemy_api_key
  • POLYGONSCAN_API_KEY=your_polygonscan_api_key
  • PRIVATE_KEY=your_new_dev_only_account_metamask_private_key_with_no_real_assets

then install dependencies and deploy the smart contract!

npm i
npx hardhat run scripts/deployTequilaTables.js --network "polygon-mumbai"

After you've deployed, read the contractAddress and 2 Tableland table names logged in the CLI. Update constants accordingly on lines 2-7 of scripts/constants.js

Optional -- mint more NFTs

npx hardhat run scripts/mintNFT.js --network polygon-mumbai

Updating Metadata

Modify code inside of scripts/updateMetadata.js, then run the script to update metadata. One callout -- by default only the contract creator can update metadata. If you want the owner to be able to update their NFT's metadata, look into Using a TablelandController

 npx hardhat run scripts/updateMetadata.js --network polygon-mumbai

Smart contract: TequilaTablesNFT

Tableland tables

Main Tableland Table: table_nft_main_80001_962

Attributes Tableland Table: table_nft_attributes_80001_963

TokenURI

Images

Drink img assets -- already uploaded to Storj (decentralized file storage) and pinned on IPFS

Shoutout to Tableland's dev rel team!