// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract NFTToken is ERC721URIStorage { uint public _tokenIds; constructor(string memory TokenName, string memory TokenSymbol) ERC721(TokenName, TokenSymbol) { } function mintNewToken(string memory tokenURI) public returns (uint256){ uint256 newItemId = _tokenIds; _mint(msg.sender, newItemId); _setTokenURI(newItemId, tokenURI); _tokenIds++; return newItemId; } } contract NFTTokenFactory { struct CreatedContract { NFTToken token; address creator; string symbol; string name; } CreatedContract[] public createdContracts; uint public createdContractCount; event tokenCreated(address indexed contractAddress, string tokenName, string TokenSymbol); function createToken(string memory TokenName, string memory TokenSymbol) public { NFTToken token = new NFTToken(TokenName, TokenSymbol); CreatedContract memory newContract; newContract.token = token; newContract.creator = msg.sender; newContract.name = TokenName; newContract.symbol = TokenSymbol; createdContracts.push(newContract); createdContractCount++; emit tokenCreated(address(token), TokenName, TokenSymbol); } }
0.4.18