0

I am working on a voting smart contract. I know I can set the owner for a smart contract. But I assumed that "role" was for the programmer of the smart contract so he can maintain control over important data structures (e.g. - preventing the improper deletion of certain users or user assets, etc.)

My current belief is that I would create and publish/migrate a new instance of my voting smart contract for each separate vote (e.g. - each new election, etc.), is that correct? If so, what is the normal best practice for assigning an administrator to the contract, someone that is not the smart contract programmer (myself) but the person who should be acting administrator for the current vote (i.e. - a particular instance of the smart contract that is managing one particular vote)? Should I make them the current owner of the smart contract instance when I create the new smart contract instance for the new vote?

3

There are a number of questions here:

that "role" was for the programmer of the smart contract so he can maintain control over important data structures

not to sound flippant, but the owner (role) is going to depend on how the contract has been implemented.

In this example (from the solidity docs) the owner is called "chairperson" and is the address that created the contract. enter link description here The role of the chairperson is to grant the right to vote to whichever addresses they choose.

(e.g. - preventing the improper deletion of certain users or user assets, etc.)

typically, this sort of functionality is not part of a voting smart contract, or else the trust imbued by an on-chain voting contract would be lost.

a new instance of my voting smart contract for each separate vote (e.g. - each new election, etc.), is that correct?

typically this is how voting smart contracts are implemented.

If so, what is the normal best practice for assigning an administrator to the contract

this goes back to the answer/comment above

Should I make them the current owner of the smart contract instance when I create the new smart contract instance for the new vote?

Again, owner is dependent upon the contract implementation.

One approach that is possible is this:

  • the creation address has one, and only one, ability: to identify the "chairperson"
  • once the "chairperson"-ship has been granted, the creation address has no more privileges.
  • optionally: the "chairperson" could can designate a new "chairperson" but the creation address would not be involved.
1

Usually the deployer of the contract becomes the owner. It's easy and safe to use in the constructor the address of the deployer.

Define the owner in the contract

address public owner;

In the constructor function it's easy and safe to set the owner

function SmartContract() {
    owner = msg.sender;
}

It's probably a good idea to be able to set multiple administrators of the contract with specific, limited permissions if you want the owner to have other specific permissions.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.