I trust you are all well.
I’m working on an election dapp using ERC1155 tokens as the votes. I’ve recently transitioned from working on the project as a single contract for a single election to thinking about what I need to do to implement a contract factory and proxy contracts to make it upgradeable. As I don’t have the EVM or Yul knowledge to interact directly with the proxy contracts, I plan on using the Truffle plug-in. I’m at the beginning of my journey in understanding how to use that plug-in.
However, before I go to deep into the proxy contract area, I wanted to share what I think the architecture will be and see if anyone had any thoughts. I’ve copied a diagram below of what I think it will look like.
So, the Dapp will allow users to go through the proxy contract to interact with the election factory. The user will input information about number of offices and candidates and the factory will create a new instance of the election contract. The election contract (the diamond shape) is available to the factory contract. These created contracts will contain the state variables related to the candidates and tokens for that particular election.
Those created contracts will point towards an already implemented logic contract that will control contract state (election not started, started, ended), how tokens (votes) are transferred between accounts, how tokens are minted, and events.
So, as the created elections have finite lifetimes, I don’t need to upgrade those contracts. When the election is over, it’s over. I can upgrade future elections by simply changing the election.sol file that is available to the factory contract. So, I can upgrade the factory contract by simply deploying a new factory contract and having the proxy contract point at it.
I suppose I’m not clear on how I get the created contracts to point at the logic contract. If that’s something that I can easily do when creating them from the factory contract, then I don’t need to upgrade the implemented logic contract, I just need to deploy a new logic contract and upgrade the factory contract to point at it.
Does anyone have any advice or comments on getting created contracts from a factory to point at an already implemented logic contract? Any advice on the architecture in general?
Please feel free to flay me alive and don’t spare my feelings. Thanks in advance for any input. Cheers.