Skip to content

NFTs are good and they can exchange the property of an underlying asset, but what if they can become dynamic? What if every NFT could have a story to tell? A concept for future development of digital ownership! Every object has a story, more than ever in the digital metaverse!

Notifications You must be signed in to change notification settings

GianGuaz256/ERC721DynamicExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ERC721DynamicExtension

DynamicNFT

A Smart Contract that allows you to add stories to a given non-fungible token. The tokens developed start from OpenZeppelin code on ERC721 with URIStorage extension and are therefore fully compatible with Opensea and the various marketplaces. Below you can find an explanation of the functions and state variables.

State Variables

When the token is minted the contract creates a state variable that tracks the stories for each tokenId present.

mapping(uint256=>string[]) private dynamicData;

Modifier

Modifier that checks if the msg.sender of the transaction is the owner of that particular tokenId in order to push new dynamicData inside the array.

modifier onlyTokenOwner(uint256 _tokenId){
        require(ownerOf(_tokenId)==msg.sender, "Sender is not the owner of the token");
        _;
}

Functions

Add Dynamic Data

Function that adds a new story or dynamic data to the array of string. It takes the tokenId of the token to be modified and the data string pointing to the IPFS in order to store metadata.

function addDataToDynamicNFT(uint256 _tokenId, string memory _data) public onlyTokenOwner(_tokenId) {
        require(_exists(_tokenId), "ERC721URIStorage: URI set of nonexistent token");
        dynamicData[_tokenId].push(_data);
}

Get Dynamic Data

Function that retrieves data from a particular token. It takes the tokenId and return an array of string pointing to the metadata in the IPFS.

function getDynamiData(uint256 _tokenId) external view returns(string[] memory) {
        require(_exists(_tokenId), "ERC721URIStorage: URI set of nonexistent token");
        return dynamicData[_tokenId];
}

Stay in touch

Author: Guazzo Gianmarco

About

NFTs are good and they can exchange the property of an underlying asset, but what if they can become dynamic? What if every NFT could have a story to tell? A concept for future development of digital ownership! Every object has a story, more than ever in the digital metaverse!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published