Privex Golos Python documentation¶
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¶
Download and install from PyPi using pip (recommended)¶
pip3 install golos-python
(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 Python Library (golos-python) - Developed by Privex Inc. |
|
This is the main module for the GOLOS library, containing the class |
|
Contains |
|
Various Python exceptions which may be used throughout this GOLOS library. |
|
Contains the attribute |
|
|
|
Contains various GOLOS type classes which are used within |
|
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
|
-
class
tests.
GolosKeyTests
(methodName='runTest')[source]¶
-
class
tests.
GolosTestCase
(methodName='runTest')[source]¶ -
-
test_find_tx
()[source]¶ Test Api.find_op_transaction returns the correct transaction from an operation
-
test_find_tx_no_exist
()[source]¶ Test Api.find_op_transaction raises TransactionNotFound with a non-existent operation
-
test_get_account_history
()[source]¶ Testing Api.get_account_history returns a non-empty list containing valid history items
-
test_get_transaction
()[source]¶ Test Api.get_transaction returns the correct transaction from a TXID
-
test_get_transaction_id
()[source]¶ Test Api.get_transaction_id generates the correct TXID from a transaction
dict
-