Project ChainVote

Hello @dan-i, I need some guidance on a project I’m working on at school, we’re making a Dapp for a voting system on the blockchain. We have used the courses here to learn how to do everything, and we’re using the Proxy, Function, Storage setup. But when testing everything, I can’t seem to be able to get through the proxy contract, so when I’m deploying the contract in truffle, it does not deploy the proxy contract so I can interact through it. I also tried to use remix to test sending requests through Proxy to the function contract, but the only way is through the lower level interaction of Calldata and that should be hexadecimal.

How can we test that everything is working as it should when Proxy is not being deployed in truffle or ganache?

edit: the reason I ran into this problem, is that when I’m testing with Moralis to store users, I can’t get the address from Proxy to use in the main.js file

1 Like

I hope you don’t mind me replying as well. I just recently also developed a Voting DApp, therefore got curious.
Feel free to have a look at my solution, maybe it is helpful: Voting DApp Repo
Short Demo

hmm, you haven’t used the proxy/function/storage tho, but cool to see your code anyways :blush:

I figured it out! :smiley:

with the following; I got the proxy up and running, and I think there was a problem with it being called “Proxy”

2_deploy_proxy.js:

module.exports = async function (deployer, network, accounts) {
  await deployer.deploy(CaseOne);
  let instanceCase = await CaseOne.deployed();

  await deployer.deploy(Proxey, instanceCase.address);
  await Proxey.deployed();

main.js

sync function login() {
  try {
    user = await Moralis.User.current();
    if (!user) {
      user = await Moralis.Web3.authenticate();
    }

    console.log(user);
    alert("User logged in");
    document.getElementById("login_button").style.display = "none";
    document.getElementById("voting").style.display = "block";
  } catch (error) {
    console.log(error);
  }
}

async function createUser(_region, _userType) {
  alert("Region: " + _region + "\nUserType: " + _userType);
  window.web3 = await Moralis.Web3.enable();
  let contractInstance = new web3.eth.Contract(window.abi, contractAddress);
  contractInstance.methods
    .createUser(_region, _userType)
    .send({ from: ethereum.selectedAddress })
    .on("receipt", function (receipt) {
      console.log(receipt);
    });
}

document.getElementById("login_button").onclick = login;
document.getElementById("create_user").onclick = function () {
  createUser(
    document.getElementById("Region").value,
    document.getElementById("UserType").value
  );
};