Repository
https://github.com/holgern/steemengine
steemengine
steemengine is a python library for working with steem-engine.com tokens.
I released version 0.5.0 which can be installed by
pip install steemengine
New features
steem-engine testnet is supported
It is possible to set the url in the Api
class and input the Api
object to each steemengine class.
This allows it to use the steem-engine testnet.
from steemengine.api import Api
from steemengine.wallet import Wallet
api = Api("https://testapi.steem-engine.com/")
w = Wallet("holger80", api=api)
w.set_id("ssc-00000000000000000002")
print(w.get_token("SSC"))
The url of the testnet api is https://testapi.steem-engine.com/
. When set the url in the API class and set the api parameter in all steemengine classes, e.g. Wallet("holger80", api=api)
, all API calls are done to the testnet. When operation as transfers should be performed ih the testnet, the id has to be changed, by using theset_id
function. The id of the mainnet is ssc-mainnet1
and the testnet id is: ssc-00000000000000000002
.
w.set_id("ssc-00000000000000000002")
sets the id to the testnet id.
Using the testnet
When the testnet should be used, the following has to be done:
For the Wallet class:
api = Api("https://testapi.steem-engine.com/")
w = Wallet(..., api=api)
w.set_id("ssc-00000000000000000002")
For the Market class:
api = Api("https://testapi.steem-engine.com/")
m = Market(..., api=api)
m.set_id("ssc-00000000000000000002")
For the Tokenobject class:
api = Api("https://testapi.steem-engine.com/")
t = Token(..., api=api)
For the Tokens class:
api = Api("https://testapi.steem-engine.com/")
t = Tokens(api=api)
staking and unstaking of tokens
At the last update of steem-engine staking of token was activated. Three new functions were added to the command line tool and the wallet class in order to support staking.
steemengine stake -a holger80 1 DRAGON
broadcasts a custom_json
with stake
as contractAction.
As it can be seen here, the transaction was accepted. As staking was not enabled at the DRAGON token, the transaction had no effect.
steemengine info 2bf97f544b1fc86fbbe5ef4c43b8e622b6aad388
Transaction Id: 2bf97f544b1fc86fbbe5ef4c43b8e622b6aad388
+---------------------+------------------------------------------+
| Key | Value |
+---------------------+------------------------------------------+
| blockNumber | 137651 |
| action | stake |
| contract | tokens |
| logs | { |
| | "errors": [ |
| | "staking not enabled" |
| | ] |
| | } |
| payload | { |
| | "symbol": "DRAGON", |
| | "quantity": "1.0000000", |
| | "isSignedWithActiveKey": true |
| | } |
| refSteemBlockNumber | 32722564 |
| sender | holger80 |
| transactionId | 2bf97f544b1fc86fbbe5ef4c43b8e622b6aad388 |
+---------------------+------------------------------------------+
Syntax of the new commands:
This command stakes an AMOUNT of unstaked token TOKEN. The account on which the staking should happen must be given by the -a options.
Usage: steemengine stake [OPTIONS] AMOUNT TOKEN
stake a token
Options:
-a, --account TEXT Transfer from this account
--help Show this message and exit.
This command unstakes an AMOUNT of staked token TOKEN. The account on which the staking should happen must be given by the -a options.
Usage: steemengine unstake [OPTIONS] AMOUNT TOKEN
unstake a token
Options:
-a, --account TEXT Transfer from this account
--help Show this message and exit.
This command cancel an ongoing unstake operation with the transaction id TRX_ID. The account on which the staking should happen must be given by the -a options.
Usage: steemengine cancel-unstake [OPTIONS] TRX_ID
unstake a token
Options:
-a, --account TEXT Transfer from this account
--help Show this message and exit.
New function at the wallet class
A token MYTOKEN can be staked with the stake function:
from steemengine.wallet import Wallet
from beem import Steem
active_wif = "5xxxx"
stm = Steem(keys=[active_wif])
wallet = Wallet("test", steem_instance=stm)
wallet.stake(1, "MYTOKEN")
The staked token can then be unstaked by:
wallet.unstake(1, "MYTOKEN")
Unstaking takes some time. The process can be canceled by:
wallet.stake("cf39ecb8b846f1efffb8db526fada21a5fcf41c3")
where cf39ecb8b846f1efffb8db526fada21a5fcf41c3
is the transaction id of the unstake operation.
Info shows the amount of staked token
steemengine info holger80
or
from steemengine.wallet import Wallet
wallet = Wallet("holger80")
print(wallet)
Shows the amount of staked token. Token on which staking is not enabled, has only a balance key.
All tokens on which staking is activated have a stake
and pendingUnstake
field. The info
command shows the content of these fields are prints a -
when staking was not activated for a token.
Commits
Release 0.5.0
- commit 58d9b11
- Add stake, unstake, cancel_unstake to Wallet class
- Add stake, unstake, cancel_unstake to the command line tool
- Add stake and pendingUnstake to info from the commandline tool
Release 0.4.6
- commit 3288300
- Allow to change the ssc id
Release 0.4.5
- commit b567e61
- Propagate the APi object to all steemengine objects
Release 0.4.4
- commit 6ca253f
- Fix URL for RPC object
Release 0.4.3
- commit c03c444
- Change URL also in RPC
Release 0.4.2
- commit 8f806a1
- Fix issue #2 - Fix cancel for handling new buy/sell id
- URL for steemengine API can be set
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]
Thank you for your review, @helo! Keep up the good work!
This is awesome, simple to use library!
You received an automatic upvote, because I believe in you and I love what you create! 😉
A huge hug from @amico! 🤗
😍 I love promoting @steembasicincome, even with #sbi-skip! 😜
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!
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
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!
Hi, @holger80!
You just got a 3.15% 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.
Congratulations @holger80! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!