Command line for GOLOS blockchain. A short tutorial.
This will be in English as my Russian is not still good enough. Feel free to translate to Russian and drop me a link.
This tutorial was checked on Ubuntu Linux 14.04 LTS and 16.04 LTS. Should also work on any distribution that supports Python 3.
Installation
Clean 'socialenv' virtualenv for Python3 + forked python-steemlib and conservatorio for GOLOS blokchain.
virtualenv -p python3 socialclienv
. socialclienv/bin/activate
pip install steemtools
pip install --upgrade --force-reinstall git+git://github.com/GolosChain/conservatorio.git@master
pip install --upgrade --force-reinstall git+git://github.com/GolosChain/python-steemlib@master
pip install --upgrade --force-reinstall git+git://github.com/GolosChain/python-graphenelib@master
pip install --upgrade --force-reinstall git+git://github.com/oblalex/gnuplot.py-py3k.git@master
Activating virtualenv and GOLOS specific Node setup
08:44:52 /sandbox/cli$ . socialclienv/bin/activate
(socialclienv) 08:45:02 /sandbox/cli$
(socialclienv) 08:45:02 /sandbox/cli$
(socialclienv) 08:45:02 /sandbox/cli$ python
Python 3.4.3 (default, Sep 14 2016, 12:36:27)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from piston import steem
>>> node = steem.Steem("wss://node.golos.ws")
>>> from steemtools.node import Node
>>> Node._default = node
After you override _Node.default with GOLOS node you can use all the goodies against GOLOS blockchain!
Account
>>> from steemtools.base import Account
>>> a = Account("kiwi")
Examples:
Account properties
>>> a.get_props()
{'active': {'account_auths': [],
'key_auths': [['GLS7rhzdS5FCbbAjup18MXoBb8sxpapYmzepLXuEbeU2JtxapSiPb',
1]],
'weight_threshold': 1},
'active_challenged': False,
'average_bandwidth': 901777248,
'average_market_bandwidth': 0,
'balance': '0.000 GOLOS',
'blog_category': {},
'can_vote': True,
'comment_count': 0,
'created': '2016-10-18T14:41:09',
'curation_rewards': 0,
'id': '2.2.9207',
'json_metadata': '{"ico_address":"17TTTh4qTx9LQ1cz5HezwvMBVyYwNAkKPk"}',
'last_account_recovery': '1970-01-01T00:00:00',
'last_account_update': '1970-01-01T00:00:00',
'last_active_proved': '1970-01-01T00:00:00',
'last_bandwidth_update': '2016-10-26T00:28:18',
'last_market_bandwidth_update': '1970-01-01T00:00:00',
'last_owner_proved': '1970-01-01T00:00:00',
'last_owner_update': '1970-01-01T00:00:00',
'last_post': '2016-10-24T22:20:06',
'last_root_post': '2016-10-24T10:51:27',
'last_vote_time': '2016-10-25T18:17:00',
'lifetime_bandwidth': '19495000000',
'lifetime_vote_count': 0,
'market_history': [],
'memo_key': 'GLS5W1ovRyHbYTCSwbHNevZ4oaYLus8Qu4c6wvJ9K45JwKLP6cjBf',
'mined': False,
'name': 'kiwi',
'next_vesting_withdrawal': '1969-12-31T23:59:59',
'other_history': [],
'owner': {'account_auths': [],
'key_auths': [['GLS7UG9jzyhvgHqUu2aWNFxdeBNTpgnT77GQRa2wHDnamKJVXDCZ3',
1]],
'weight_threshold': 1},
'owner_challenged': False,
'pending_reset_authority': {'account_auths': [],
'key_auths': [],
'weight_threshold': 0},
'post_bandwidth': 10000,
'post_count': 10,
'post_history': [],
'posting': {'account_auths': [],
'key_auths': [['GLS6dHviBDjW1fNqsqx4ZDcSJ432oSZ47RtniTSrGe9FhcdtKmW8h',
1]],
'weight_threshold': 1},
'posting_rewards': 0,
'proxied_vsf_votes': [0, 0, 0, 0],
'proxy': '',
'recovery_account': 'golos',
'reputation': '618055343750',
'reset_account': 'null',
'reset_request_time': '1969-12-31T23:59:59',
'savings_balance': '0.000 GOLOS',
'savings_sbd_balance': '0.000 GBG',
'savings_sbd_last_interest_payment': '1970-01-01T00:00:00',
'savings_sbd_seconds': '0',
'savings_sbd_seconds_last_update': '1970-01-01T00:00:00',
'savings_withdraw_requests': 0,
'sbd_balance': '0.000 GBG',
'sbd_last_interest_payment': '1970-01-01T00:00:00',
'sbd_seconds': '0',
'sbd_seconds_last_update': '1970-01-01T00:00:00',
'to_withdraw': 0,
'transfer_history': [],
'vesting_balance': '0.000 GOLOS',
'vesting_shares': '8509616.613634 GESTS',
'vesting_withdraw_rate': '0.000000 GESTS',
'vote_history': [],
'voting_power': 9950,
'withdraw_routes': 0,
'withdrawn': 0,
'witness_votes': ['hipster', 'kiwi', 'litvintech', 'on0tole', 'vitaly-lvov'],
'witnesses_voted_for': 5}
Curation statistics
>>> a.curation_stats()
{'7d': 0.0, '24hr': 0.0, 'avg': 0.0}
Full account history
>>> history = a.history()
>>> for item in history:
... print item
{'op_type': 'account_create', 'timestamp': '2016-10-18T14:41:09', ...
{'op_type': 'witness_update', 'timestamp': '2016-10-18T15:58:21', ...
Blockchain access
>>> from steemtools.blockchain import Blockchain
>>> b = Blockchain()
Current block number
>>> b.get_current_block()
225358
Block mint time
>>> b.get_block_time(225358, True)
Block 225358 was minted on: 2016-10-26T07:21:36
1477466496.0
Posts access
>>> from steemtools.base import Post
>>> p = Post("@kiwi/golosuite-za-kiwi-delegata")
Get votes
>>> p.get_votes()
[{'percent': 10000,
'reputation': '10854623437',
'rshares': 250000000,
'time': '2016-10-19T07:31:03',
'time_elapsed': 1047,
'voter': 'steem-id',
'weight': '669370401281820'},
{'percent': 10000,
'reputation': '129279260937',
'rshares': 210000000,
'time': '2016-10-19T09:35:33',
'time_elapsed': 8517,
'voter': 'ausbitbank',
'weight': '966459713569212'},
{'percent': 10000,
'reputation': 9687500,
'rshares': 175000000,
'time': '2016-10-19T09:27:42',
'time_elapsed': 8046,
'voter': 'stereolubov',
'weight': '805460538321132'},
{'percent': 10000,
'reputation': 4081877820,
'rshares': 250000000,
'time': '2016-10-19T07:17:06',
'time_elapsed': 210,
'voter': 'cryptomental',
'weight': '134274441796339'},
{'percent': 10000,
'reputation': '1547236591405',
'rshares': 195000000,
'time': '2016-10-19T07:15:09',
'time_elapsed': 93,
'voter': 'panther',
'weight': '46387384571690'},
{'percent': 10000,
'reputation': '618055343750',
'rshares': 3150000000,
'time': '2016-10-19T07:14:15',
'time_elapsed': 39,
'voter': 'kiwi',
'weight': '314499902084777'}]
Post metadata
>>> p.get_metadata()
{'rshares': 4230000000,
'time_elapsed': 606944.3903486729,
'weight': 19486824540995747}
These are just a few examples. But you can see how powerful it is.
Many functions in steemtools are hardcoded for STEEM blockchain. We can make a separate fork for GOLOS. I am thinking of making a generic fork though that will support both STEEM, GOLOS and new (if any) social media blockchains based on steem in the future.