steemengine - a python library for steem-engine.com

in utopian-io •  21 days ago

Repository

https://github.com/holgern/steemengine

image.png

Steem Engine

The python library uses a rpc client to communicate with the steem-engine.com json RPC server. All descripted methods at https://github.com/harpagon210/steemsmartcontracts/wiki/JSON-RPC-server have been implemented.

Furthermore a website api call for receiving account transfer history is supported.

Technology Stack

The library uses a rpc client based on the requests library for receiving data from the steem-engine.com JSON RPC server.

Any function call from the RPC class is translated into a RPC JSON call

rpc.find({"contract": contract_name, "table": table_name, "query": query,
                             "limit": limit, "offset": offset, "indexes": indexes}, endpoint="contracts")

will be converted to:

{
    "jsonrpc": "2.0",
    "method": "find",
    "params": {
        "contract": "contract_name",
        "table": "table_name",
        "query": query,
        "limit": limit,
    "offset": offset,
    "indexes":indexes}
    },
    "id": 1
}

with the RPC JSON server url:
https://api.steem-engine.com/rpc/contracts"

All possible calls have been collected in the Api class.

Installation

The python package can be installed by:

pip install steemengine

Usage

Get the latest block of the sidechain

from steemengine.api import Api
api = Api()
print(api.getLatestBlockInfo())

Get the block with the specified block number of the sidechain

from steemengine.api import Api
api = Api()
print(api.getBlockInfo(1910))

Retrieve the specified transaction info of the sidechain

from steemengine.api import Api
api = Api()
print(api.getTransactionInfo("e6c7f351b3743d1ed3d66eb9c6f2c102020aaa5d"))

Get the contract specified from the database

from steemengine.api import Api
api = Api()
print(api.getContract("tokens"))

Get an array of objects that match the query from the table of the specified contract

from steemengine.api import Api
api = Api()
print(api.find("tokens", "tokens"))

Get the object that matches the query from the table of the specified contract

from steemengine.api import Api
api = Api()
print(api.findOne("tokens", "tokens"))

Get the transaction history for an account and a token

from steemengine.api import Api
api = Api()
print(api.get_history("holger80", "NINJA"))

Roadmap

The next step will be using the beem library for sending token.
I'm planing also a command line tool for viewing token balances and sending token.

How to contribute?

Please use the issue tracker for bug reports and feature wishes. Pull requests are also welcome.

GitHub Account

https://github.com/holgern

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hi there @holger80!

The client library looks great. Library looks like a read-only library at the moment. It's nice that you plan to add support broadcasting like transferring, issueing tokens, etc.

I have a couple of minor code review comments :)

  • Method names don't follow the PEP8 conventions. We have get_history, and getLatestBlockInfo. I would prefer following PEP8's convention.

  • Regarding findOne, I would expect a single object here. If there are multiple objects returns, an exception might be raised. (Ex: Django ORM's objects.get works like that.)

  • It would be clear to check response status with response.status_code != 200 instead of str(response) != '<Response [200]>'.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

·

Thanks for fast review and the good suggestions.

Yes, broadcasting is on my list for the next update.

·

Thank you for your review, @emrebeyler! Keep up the good work!

Thank you very much for your work :)
!tipuvote 10

This post is supported by $4.53 @tipU upvote funded by @cardboard :)
@tipU voting service guide | For investors.

Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Interesting to read about this. Steemengine

Hi, @holger80!

You just got a 2.81% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

working on getting you some ENG tokens for this! Very cool and extremely helpful.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.

Hey, @holger80!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!