So you have a lot of accounts and want them all to be assigned a single Witness proxy...
There are many people on STEEM that have much more than just one account. Some for businesses, some for projects, some for nefarious purposes. Whatever the reason may be, I have written a script that takes a file of accounts and active_private_keys and mass assigns their Witness proxy as the account you specify.
This can save considerable amounts of time, as well as helping to ensure no accounts SP is wasted when it comes to helping to determine the top Witnesses.
Without further ado... the Script!
#!/usr/bin/env ruby
require 'radiator'
require 'colorize'
class WitnessProxy
attr_reader :logger, :proxy, :bots_file
def initialize(*args)
@logger = Logger.new(STDOUT)
@logger.level = :info
@proxy = args[0]
@bots_file = args[1]
end
def set_bots_proxy
puts "This will set bots in file #{bots_file} to #{proxy} as proxy. Continue? (yes/no)"
response = STDIN.gets.chomp.downcase
if response == 'yes'
puts "Continuing."
@output = []
make_proxy_txs(bots_file).each_slice(100) do |tx_group|
tx_group.each do |tx,wif|
client = Radiator::Transaction.new(url: 'https://steemd.steemit.com', wif: wif)
client.operations = []
client.operations << tx
result = client.process(true)
if result.error
@output << "[Bot - #{tx.payload.last[:account]}] An error happened: #{result.error.message.match(/^(.*?)\.\n/m)[0..1]}".red
else
@output << "[Bot - #{tx.payload.last[:account]}] Success: #{tx.payload.last[:account]} proxy set to #{proxy}".green
end
end
end
logger.info { "\n#{@output.join("\n")}" }
elsif response == 'no'
puts "Aborting. User request."
else
puts "You did not enter yes or no. Please retry and provide only 'yes' or 'no'."
end
end
private
def make_proxy_txs(bots)
txs = []
File.open("#{Dir.pwd}/#{bots_file}").read.each_line do |bot|
txs << [Radiator::Operation.new(
type: :account_witness_proxy,
account: bot.chomp.split(',')[0],
proxy: proxy
), bot.chomp.split(',')[1]] unless bot.chomp.empty?
end
txs
end
def help_text
%Q{#{('*'*50).green}
#{'Dependencies:'.yellow}
gem install radiator
gem install colorize
#{'Bots File:'.yellow}
This file should be in the same directory as the script and be formatted like:
bot_name1,active_private_key1
bot_name2,active_private_key2
bot_name3,active_private_key3
#{'Usage:'.yellow}
./witness_proxy.rb proxy_account bots_file.txt
#{('*'*50).green}}
end
end
witness_proxy = WitnessProxy.new(ARGV[0], ARGV[1])
if ARGV.count != 2 || (ARGV[0] == ('help' || '-h' || '--h'))
puts witness_proxy.send(:help_text)
else
witness_proxy.set_bots_proxy
end
Usage instructions (assumes you have Ruby 1.9+ installed)
- Copy/paste the entire contents above (inside the code block) to a file named something like
proxy.rb
- Save the file
- Install the dependencies the script wants:
gem install colorize
gem install radiator
- Create the accounts file (example format):
account1,active_private_key1,
account2,active_private_key2,
account3,active_private_key3
- Run the script:
ruby proxy.rb proxy_account accounts_file.txt
Results
After everything is finished, you should get a result list of the accounts and their result, either error or success.
Now go vote for @netuoso as Witness with your super powered account
Vote for @netuoso as Witness
- Go to the witness voting page on SteemIt.com
- Scroll to the bottom of the page and locate the vote box (shown below)
- Input my name (netuoso) and hit vote.
- Give yourself a high-five for making such an awesome decision
PSSST:
You could also reverse engineer this script for an example of how to broadcast a transaction via Radiator gem and a Ruby script :)