I'm playing around with programmatically forming DAOs. Essentially I want to create a frontend users can come to, type in a name, click a button and deploy a smart contract. I'd like to display a list of smart contracts that user has previously deployed so I'll need some way to query for contracts owned by that user's wallet address.
Is there a way to relate smart contracts to a wallet address in a way that's queryable?
Example:
contract CoolDAO {
string name;
address public owner;
constructor(string _name) payable {
name = _name;
owner = msg.sender;
}
function getName() public view returns (string memory) {
return name;
}
}
Users should be able to:
- Deploy this contract with a particular name
- See a list of all the contracts they've previously deployed.
My first thought is that I would create an NFT collection representing ownership of the contracts - then when the user deploys a contract, I'd mint an NFT for them with an attribute that points to that contract's address. Then if I wanted to know what contracts that user owned, I could query for any NFTs they own from that collection. (Essentially I'd be using an NFT as a many-to-many table)
Is there a more straightforward approach to handle this?