LightHive - A light Python client for HIVE blockchain

in HiveDevs15 days ago (edited)


lighthive is a light python client to interact with the HIVE blockchain. It’s simple and stupid. It doesn’t interfere with the process between the developer and the HIVE node.

It's forked from the Lightsteem project. You can just install w/ the traditional PIP: (Requires Python3.6+)

$ (sudo) pip install lighthive

Examples


Get Dynamic Global Properties

props = client.get_dynamic_global_properties()

print(props)

Get Current Reserve Ratio

ratio = c('witness_api').get_reserve_ratio()

print(ratio)

Get @emrebeyler’s account history

history = c.get_account_history("emrebeyler", 1000, 10)

for op in history:
    print(op)
Get top 100 witness list

witness_list = client.get_witnesses_by_vote(None, 100)

print(witness_list)

Broadcasting transactions


Account Witness Vote

from lighthive.client import Client
from lighthive.datastructures import Operation

c = Client(
    keys=["<private_key>",])

op = Operation('account_witness_vote', {
        'account': '<your_account>',
        'witness': 'emrebeyler',
        'approve': True,
    })

c.broadcast(op)

Voting

This will vote with a %1. Percent / 100 = Weight. If you want to downvote, use negative weight.

from lighthive.client import Client
from lighthive.datastructures import Operation

client = Client(
    keys=["<private_key>"]
)

op = Operation('vote', {
    "voter": "emrebeyler",
    "author": "emrebeyler",
    "permlink": "re-hitenkmr-actifit-ios-app-development-contribution-20180816t105311829z",
    "weight": 100,
})

client.broadcast(op)

More examples can be found at the documentation.

Enjoy!

Vote for my witness


If you didn't vote for my witness already, consider casting a witness vote.

Sort:  

Cool, thanks for that... nice little port.

i love it ! :DDDD imma try this out

deleted because i found my question was stupid

Nice! There are still some "STEEM" words in documentation and more important in project description on GitHub.

Thanks!

Yeah, this will be addressed later. The first priority is having the library functional.

i see in the preview that some multiplying asterix dont show up, but they are there

global client
client=Client(keys)
def sellop(steem,exp):
op=Operation("limit_order_create",{"owner":"maxsieg","orderid":str(randint(0,10000)),"amount_to_sell":json.dumps({"amount":str(int(steem1000)),"precision":"3","nai":"@@000000021"}),"amount_to_recieve":json.dumps({"amount":str(int(steem1000*sellrate())),"precision":"3","nai":"@@000000013"}),"fill_or_kill": "false","expiration":(datetime.utcnow()+timedelta(seconds=exp)).strftime("%Y-%m-%dT%H:%M:%S")})
client.broadcast(op)

I was not sure about boolean values i tried both "false" and False. Because of the following error message i tried converting all integers into string but it still gives me this message.

RPCNodeException: Parse Error:Couldn't parse int64_t

I converted it to string so should be no integer in there? do strings have to be encoded in a certain way? python3 should be utf-8...

First question: why do you use json.dumps in the fields? I'll try to check broadcasting a limit_order_create, today.

For boolean values, use Python's false. False. with no "" or ''.

usin json.dumps cuz u use json.dumps to solve dictionaries in dictionaries when you write a "post" or "comment on none" operation in the docs. i would not know how to deal with dictionaries in dictionaries otherwise.