Skip to content

Commit

Permalink
added functions to add and get messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MahithChigurupati committed Jan 25, 2023
1 parent a65fac3 commit 527a9b0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mintNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@ contract MyToken is ERC721, ERC721Enumerable, Ownable {

constructor() ERC721("MyToken", "MTK") {}

struct message{
uint id;
address sneder;
uint nftID;
string sentMessage;
uint timestamp;
}

message[] public messages;

uint public totalMessages = 0;

function addMessage(string memory messageToSend, uint nftID) public returns(bool){
require(ownerOf(nftID) == msg.sender,"you do not own that nft");
messages.push(
message(
totalMessages,
msg.sender,
nftID,
messageToSend,
block.timestamp
)
);
totalMessages += 1;
return true;
}

function getMessage(uint index) public view returns(message memory){
return messages[index];
}

function _baseURI() internal pure override returns (string memory) {
return "google.com";
}
Expand Down

0 comments on commit 527a9b0

Please sign in to comment.