I have found the 'system voteproducer' command in cleos. Should I make a raw transaction or something like that?
2 Answers
There is a system contract for voting. It can be found here: https://github.com/EOSIO/eos/blob/master/contracts/eosio.system/voting.cpp
ABI can be found here: https://github.com/EOSIO/eos/blob/master/contracts/eosio.system/eosio.system.abi
You can run a cleos action
command for the system contract:
cleos push action eosio voteproducer '["voter", "proxy", ["producers"]]'
Call voteproducer..
> eos.voteproducer()
CONTRACT
eosio
FUNCTION
voteproducer
PARAMETERS
{
"voter": "account_name",
"proxy": "account_name",
"producers": "account_name[]"
}
EXAMPLE
{
"voter": "",
"proxy": "",
"producers": [
""
]
}
Lookup your account name using your EOS Claim Key.
This is one tool for the job: https://toolkit.genereos.io/tools
voteproducer.js
const {wif} = process.env
// EOS Account
account = 'yourlongacct'
// full list of producers (renew votes and overwrites prior lists)
producers = ['libertyblock']
httpEndpoint = 'https://mainnet.eoscanada.com'
chainId = 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
Eos = require('eosjs')
eos = Eos({httpEndpoint, chainId, keyProvider: wif})
eos.voteproducer(account, proxy = '', producers,
(error, result) => { console.log(error, result) })
If using nodejs, some bash consoles are setup to omit history if you start a command with a space. With this configured a private key can be provided in a way that it will not be cached on disk.
# check it
echo $HISTCONTROL
ignoreboth
# or set it
export HISTCONTROL=ignoreboth
# test it
echo 1
[up arrow]
Setup for the script above:
mkdir eosjs && cd eosjs
npm init --yes && npm i eosjs
vote:
# start with a space to keep wif out of history
wif=yourPrivateWif node voteproducer.js