Privex Golos Python documentation

Privex Logo

Welcome to the documentation for Privex’s Golos Python Library - an open source Python 3 library designed for interacting with the GOLOS Classic and potentially the GOLOS network.

This documentation is automatically kept up to date by ReadTheDocs, as it is automatically re-built each time a new commit is pushed to the Github Project

QuickStart

To install golos-python - simply download it using pip, just like any other package :)

pip3 install golos-python

For alternative installation methods, see Installation

Below are some common examples for using the library:

from golos import Api

# The ``nodes`` parameter is optional. By default it will use the node list specified in ``golos.storage.nodes``
golos = Api(nodes=['wss://golosd.privex.io', 'wss://api.golos.blckchnd.com/ws'])

###
# Get account information + balances
###

accounts = golos.get_accounts(['someguy123'])
acc = accounts[0]
print(acc['owner'])
# 'someguy123'

print('GOLOS:', acc['GOLOS'], 'GBG:', acc['GBG'])
# GOLOS: 157560.231 GBG: 6420.916

###
# Get witness information
###

witness = golos.get_witness_by_account(account='someguy123')
print(witness['url'])
# 'https://golos.io/ru--delegaty/@someguy123/delegat-someguy123'

###
# Get account history
###

history = golos.get_account_history(account='someguy123')

print(history[0])
# {'account': 'huso', 'witness': 'someguy123', 'approve': False, 'number': 127286, 'block': 30494335,
#  'timestamp': '2019-09-17T14:20:21', 'type_op': 'account_witness_vote'}

###
# Transfer GOLOS / GBG to another account
#
# WARNING: To reduce the risk of rounding errors, pass the amount as either a string or a Decimal() - avoid float's!
###

tf = golos.transfer(
    to='ksantoprotein', amount='0.1', asset='GOLOS', from_account='someguy123',
    wif='5Jq19TeeVmGrBFnu32oxfxQMiipnSCKmwW7fZGUVLAoqsKJ9JwP', memo='this is an example transfer'
)

print('TXID:', tf['id'], 'Block:', tf['block_num'])
# TXID: c901c52daf57b60242d9d7be67f790e023cf2780 Block: 30895436

Contents

Installation

(Alternative) Manual install from Git

Option 1 - Use pip to install straight from Github

pip3 install git+https://github.com/Privex/golos-python

Option 2 - Clone and install manually

# Clone the repository from Github
git clone https://github.com/Privex/golos-python
cd golos-python

# RECOMMENDED MANUAL INSTALL METHOD
# Use pip to install the source code
pip3 install .

# ALTERNATIVE MANUAL INSTALL METHOD
# If you don't have pip, or have issues with installing using it, then you can use setuptools instead.
python3 setup.py install

Code / API Documentation

golos

Golos Python Library (golos-python) - Developed by Privex Inc.

golos.api

This is the main module for the GOLOS library, containing the class Api which is the high-level class to be used when interacting with python-golos.

golos.base58

Contains Base58 and various helper functions for working with Base58 public/private keys used on blockchains such as GOLOS and STEEM.

golos.broadcast

golos.exceptions

Various Python exceptions which may be used throughout this GOLOS library.

golos.key

golos.operations

Contains the attribute type_op which maps each transaction operation to a list of arguments and their types.

golos.storage

golos.storage contains various configuration options which are used throughout the library.

golos.types

Contains various GOLOS type classes which are used within operations for specifying operation arguments and their types.

golos.ws_client

Copyright.

Unit Tests

Privex Golos-Python Unit Tests

To run these tests:

pip3 install -r requirements.txt
pytest -v tests.py

Enabling extra logging output:

If you want to see the logging output of the library, use the DEBUG environment variable, and execute tests.py directly (not via pytest, as pytest will filter out the log messages):

DEBUG=true ./tests.py -vv

Copyright:

+===================================================+
|                 © 2019 Privex Inc.                |
|               https://www.privex.io               |
+===================================================+
|                                                   |
|        Privex's Golos Library                     |
|        License: X11/MIT                           |
|                                                   |
|        Core Developer(s):                         |
|                                                   |
|          (+)  Chris (@someguy123) [Privex]        |
|                                                   |
+===================================================+

Privex's Golos Python Library
Copyright (c) 2019    Privex Inc. ( https://www.privex.io )

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Classes

GolosTestCase([methodName])

class tests.GolosKeyTests(methodName='runTest')[source]
test_account_keys()[source]

Test Key.get_keys correctly generates account public/private keys

test_compare_keys()[source]

Test that Key.is_key correctly verifies a public key matches a private key

test_get_public()[source]

Test Key.get_public_from_private returns the correct public key

class tests.GolosTestCase(methodName='runTest')[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_get_account()[source]

Testing Api.get_accounts returns valid account dictionaries

test_get_account_history()[source]

Testing Api.get_account_history returns a non-empty list containing valid history items

test_get_witness()[source]

Testing Api.get_witness returns a valid witness info dictionary

Indices and tables