4

The goal is to have a new account permission called 'vote' that I can use for voting. If my key for that permission gets compromised I can simply replace it using my active permission. In the meantime all the adversary can do is to vote on my behalf.

I did the digging on this question to implement this on my own account. Thought it would be useful to share the steps here in a self-answered question.

5

There are basically two steps you need to do. First you create a new account permission and then you give it the authority to use voteproducer action on eosio contract. As a prerequisite for this instruction I expect that your account's active key is stored in a cleos wallet and the wallet is unlocked.

1. Create new account permission

For the new permission you will need a new key pair. Let's create that using cleos.

cleos wallet create_key -n your_wallet_name

Output of the command should be like this:

Created new private key with a public key of: "EOSPUBLICKEY"

Next, we create the new 'vote' permission on your account. It will use the newly generated key pair.

In the following command replace account_name with your own account name and EOSPUBLICKEY with the value you got from create_key command output in the previous step.

Parameter 'vote' is the name of the new permission. You can use a different name if you wish but remember to use the same value in following commands, too. The last parameter is the parent permission name for the new permission. The default 'active' is fine for this use case.

cleos -u https://api.main.alohaeos.com set account permission account_name vote EOSPUBLICKEY active

2. Authorize the new permission to vote

Now that we have just created the new permission it doesn't have authority to do anything yet. We need to give it the authority to use the voteproducer action in the eosio system contract. This can be achieved with the following command in cleos. Again, replace account_name with your own account name.

cleos -u https://api.main.alohaeos.com set action permission account_name eosio voteproducer vote

Now you are all set up and can start voting with your_account@vote permission!

Notes

Please note that the vote commands in cleos currently ignore the -p option because the account permission is hardcoded to 'active'. You need to use the command 'cleos push action' as a workaround. That command reacts to the -p option properly. For more info see https://github.com/EOSIO/eos/issues/4216. This issue affects only cleos and not other wallets.

For example, if you'd like to delegate your votes to my proxy account ottomagiceos you would issue the following command. Replace account_name with your account name both in the action parameters and in the -p option.

cleos -u https://api.main.alohaeos.com push action eosio voteproducer '{"voter":"account_name","proxy":"ottomagiceos","producers":[]}' -p account_name@vote

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.