I am trying to make a token generator, I have made two contracts the following way:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Token is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_mint(msg.sender, 1000);
}
}
TokenGenerator contract:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./ERC20.sol";
contract TokenGenerator{
function generateToken(string memory name, string memory symbol) public returns(address){
Token token = new Token(name, symbol);
address myAddress = address(token);
return myAddress;
}
}
However, I am struggling to understand how to use it in the frontend side. The way I generally do is that I deploy the contract and use that abi to generate more token, in which case the token holder is the deployed contract address and not the account that is generating the token. How do I generate a token whereupon every time the user clicks generate a new smart contract of the token is made on the go, and the token holder is the user account address?