Update for steemengine - testnet, stake and unstake support have been added
utopian-io·@holger80·
0.000 HBDUpdate for steemengine - testnet, stake and unstake support have been added
## Repository https://github.com/holgern/steemengine  ## steemengine [steemengine](https://github.com/holgern/steemengine) is a python library for working with [steem-engine.com](https://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 the`set_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](https://github.com/holgern/steemengine/commit/58d9b11e86e3fbecbfa5263019679018182fdcf2) * 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](https://github.com/holgern/steemengine/commit/32883001b4ad9416b2d9a6afeaaabd9c151f8a63) * Allow to change the ssc id ### Release 0.4.5 * [commit b567e61](https://github.com/holgern/steemengine/commit/b567e614b77b47d7f402e38338a91a1238172273) * Propagate the APi object to all steemengine objects ### Release 0.4.4 * [commit 6ca253f](https://github.com/holgern/steemengine/commit/6ca253fd52f88bc7e83453b1eaa59be30ba419af) * Fix URL for RPC object ### Release 0.4.3 * [commit c03c444](https://github.com/holgern/steemengine/commit/c03c4441cca9fe7fff1e93cba4187d8ec602c72e) * Change URL also in RPC ### Release 0.4.2 * [commit 8f806a1](https://github.com/holgern/steemengine/commit/8f806a1b0bef6bfdc72620dcc1fee47a643196cf) * Fix issue #2 - Fix cancel for handling new buy/sell id * URL for steemengine API can be set ## GitHub Account https://github.com/holgern
👍 shahabudin, upgoat, sargoon, lukasmining, wstanley226, linkerstinker, nurah, orbo, steeming-hot, changeangels, robofox, thefunfactory, funanime, qeoddrir, resheep, upcroak, bubbleburst, someonefun, funbox, funlands, funnyfun, dmonia, dodrorth, iedot, themuffinman, funkyfun, goldrym, soundworks, mys, imperfect-one, beleg, hankreirden, dera123, accelerator, sudefteri, akifane, dfen, neokuduk, effofex, ayisigi, literaturk, baycan, rasit, maveraunnehr, reazuliqbal, jpphotography, flugschwein, alitavirgen, steembasicincome, rycharde, sbi2, meowcliver, sbi3, nannetteschluter, melissiamathisen, faustodugan, leonieahlers, laviniacebula, renatewoodrum, jeniceoquin, gretaboan, sidneybarsky, lecialemarr, priscillaclermon, lindseyporco, sbi4, sbi5, sbi6, sbi7, sbi8, jacekw.dev, sbi9, sbi10, abh12345, drorion, carlpei, jordonemmer, jonasalt, voneller, crokkon, espoem, allancovelli, charitacaruso, ilonavandam, bertahessler, hamsa.quality, ascorphat, mops2e, abitcoinskeptic, michealb, qurator, ewkaw, jacekw, holger.random, nerdrepost, lisboa, yadamaniart, emdesan, jlsplatts, smarmy, vividessor, numberjocky, blewitt, barleycorn, amosbastian, tobias-g, jpmay, ulockblock, jaff8, asaj, adamada, rufans, helo, fego, bestofph, skycae, buckydurddle, jinger, codingdefined, kendallron, pinas, steemtank, mirkosche, krnel, make-a-whale, curbot, ew-and-patterns, genuinehuman, techtek, reportup, cryptouno, zeky, maxpatternman, elleok, steemeum, amico, lelon, feedyourminnows, jasonbu, thomasgift, stevescoins, swedishdragon, sashas, backinblackdevil, wherein, brujas, isnochys, warfeed, newhope, vaccinusveritas, reggaemuffin, badham, muscara, devann, mohaaking, swedishdragon76, snwolak, freebornsociety, vaansteam, lauchmelder, zcool, darthgexe, fullnodeupdate, sugarzone, condeas, nerdtopiade, mcfarhat, linuxbot, mytechtrail, satren, linnyplant, raspibot, steem-hilfe, lanzjoseg, dexos2, revisesociology, busy.pay, spero2711, flodor, sternekoechin, msg768, leveragetrading, kmart, commbank, ingdirect, perthmint, unimelb, sbdraffle, swiftbot, thecryptodrive, glitterbooster, kingnosa, abigail-dantes, kamikaze, megadrive, coquiunlimited, paulmoon410, fooblic, ambercookie, michaelizer, verhp11, perepilichnyy, alvinvoo, commonlaw, ikarus56, samantha-w, smjn, nwjordan, marygourmet, indayclara, arsadulislam, steempty, fminerten, shogo, shogo.life, colocolo, istrednepohronie, quekery, sheikhshahin, midun, kgakakillerg, loshcat, greenorange, jarunik, djenny.floro, borislavzlatanov, beggars, wulfgartr, timcliff, partiko, circa, phage93, meedo, alexei83, utopian.trail, techslut, minersean, erikaflynn, jakipatryk, suesa, che-shyr, didic, suesa-random, daan, tykee, silviu93, dakeshi, vishalsingh4997, elear, zoneboy, mcyusuf, gentleshaid, aussieninja, darewealth, dongentle2, jubreal, rollthedice, netizens, jk6276, dssdsds, jayplayco, stem-espanol, ravensavage, mrsbozz, jk6276.mons, jaxson2011, ajayyy, rewarding, vanarchist, carloserp-2000, miguelangel2801, emiliomoron, tomastonyperez, josedelacruz, viannis, erickyoussif, ubaldonet, lupafilotaxia, lorenzor, tsoldovieri, iamphysical, felixrodriguez, azulear, ivymalifred, vjap55, ydavgonzalez, yrmaleza, elvigia, luiscd8a, elpdl, joseangelvs, andrick, yusvelasquez, mary11, fran.frey, jrevilla, giulyfarci52, wilmer14molina, alaiza, lapp, steemtpistia, crassipes, agrovision, psicoluigi, harry-heightz, eliaschess333, dalz, alexs1320, cpufronz, scienceangel, yu-stem, alex-hm, amestyj, geadriana, cyprianj, steem-ua, newsrx, whysteem, carlos84, ennyta, steem-familia, endopediatria, anaestrada12, douglimarbalzan, gaming.yer, evangelista.yova, jenniferjulieth, ajfernandez, ingmarvin, alix96, elimao, yorgermadison, alexjunior, antunez25, haf67, chavas, eglinson, uzcateguiazambra, asmeira, garrillo, pfernandezpetit, mgarrillogonzale, rubenp, jeferc, hirally, emynb, eugenialobo, ballesteroj, jcmontilva, rodriguezr, marbely20, emilycg, moyam, darys, sibaja, balcej, lmanjarres, anaka, benhurg, judisa, juddarivv, mariamo, kimmorales, loraine25, tdre, jjay, ryuna.siege, jeanpi1908, j-p-bs, tensor, jacobyu, pierlave, inertia, themarkymark, yegir, ratticus, utopian-io, tombstone, jga, dicetime, grzesiekb, ashraffarooq, steem-plus, barton26, blockcreate, klye, sanelogsurf, coolthingssite,