I have create a Voting Dapp using web3j and ganache, but their is a small problem. I decide to deploy a voting contract every time a new election begin, and there will be a administrator who control the deploy of the contract and the begin and end of the election. So when the voting contract is deployed, only can the administrator get the contract contract address. how can I send the address to normal citizens so they can call the smart contract. I thought of storing the contract address in a normal database, but if the database is hacked or destroyed, the whole dapp would crash. Is there any function in web3j that I can store a string in the blockchain itself? ps. I saw the web3j.dbputString function but I have no idea how to use it.
private String deployContract(Web3j web3j, Credentials credentials) throws Exception {
return Election.deploy(web3j, credentials,GAS_PRICE,GAS_LIMIT).send().getContractAddress();
}
here is the contract deployed segment.
A common design pattern is called Factory. You can have a smart contract that deploys other contracts. This will generate an event that is visible to the user. See Uniswap Factory.
Alternative you can just make the contract constructor to evit an emit and that is caught by the user frontend.