I'm creating an open source voting app with a Node.JS front end. I'm hoping I can create a smart contract that can use funds allocated to it at creation time, so that participating voters don't have to pay to vote.

Normally transactions with a smart contract that require gas require the transactions to be signed. In the web app context this typically leads to the use of the Metamask plugin when the client app is a browser. I would like to create an app context where each participating voter does not have to sign/fund each vote (i.e. - each transaction).


Originally I assumed the only way to do this is to have a trusted server "proxy" the user's vote and make an Ethernet payable transaction on the user's behalf using the private key of the smart contract creator. But I believe that approach is too awkward to be useful because of the apparent available app implementations:

  • have the contract creator sign each transaction related to each vote as each vote was cast, an awkward idea at best, dead in the water at worst.

  • batch all the votes and have the creator sign a single transaction to execute the votes against he smart contract. This sucks because you wouldn't get to see each vote show up on the blockchain as each vote was cast.

  • store the creators key on the trusted server and proxy-sign on their behalf. This is also a dead approach because it's a security nightmare and no-one is going to accept it.


This is the only reasonable approach I can think of but it depends on one technical detail being possible, that of being able to execute a send() transaction from a view function from one contract against another external contract.

Here is how I see it play out. Two smart contracts are created.

1) The administrative/funding contract. This contract is funded at creation time by the vote creator and contains the funds allocated to facilitate the vote. The funds come from the vote creator when the vote is created. When the vote is closed, any funds left over are sent back to the creator.

2) The voting contract. This contract records votes as they come in and has a function to close the vote.

As a vote is made from a web page that is part of the Node.JS app, the web page uses Web3.js to call a view function in the administrative/funding contract that acts as a proxy for the user's vote. It uses the funds it has on hand to call the vote function in the voting contract.

So my questions are:

1) Is it possible for a view function to execute a send() call on an external contract?

2) Will this technique work?

3) Is there a simpler idea with one smart contract that would work?

4) If the above idea isn't workable, is there any way to accomplish the task of having a voting smart contract(s) where you can eliminate the need for participating voters to fund each vote transaction?

As usual, if you know of any smart contract example/tutorial that does this, please leave a link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.