1

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.

4

1 回答 1

0

一种常见的设计模式称为工厂。您可以拥有一个部署其他合约的智能合约。这将生成一个对用户可见的事件。请参阅Uniswap 工厂

或者,您可以只使合约构造函数避开发射,并被用户前端捕获。

于 2021-06-24T14:06:53.797 回答