Update for steemengine - testnet, stake and unstake support have been added

Repository

https://github.com/holgern/steemengine

image.png

steemengine

steemengine is a python library for working with steem-engine.com tokens.

I released version 0.5.0 which can be installed by

1
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.

1
2
3
4
5
6
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.

1
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:

1
2
3
api = Api("https://testapi.steem-engine.com/")
w = Wallet(..., api=api)
w.set_id("ssc-00000000000000000002")

For the Market class:

1
2
3
api = Api("https://testapi.steem-engine.com/")
m = Market(..., api=api)
m.set_id("ssc-00000000000000000002")

For the Tokenobject class:

1
2
api = Api("https://testapi.steem-engine.com/")
t = Token(..., api=api)

For the Tokens class:

1
2
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.

1
steemengine stake -a holger80 1 DRAGON

broadcasts a custom_json
image.png
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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.

1
2
3
4
5
6
7
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.

1
2
3
4
5
6
7
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.

1
2
3
4
5
6
7
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:

1
2
3
4
5
6
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:

1
wallet.unstake(1, "MYTOKEN")

Unstaking takes some time. The process can be canceled by:

1
wallet.stake("cf39ecb8b846f1efffb8db526fada21a5fcf41c3")

where cf39ecb8b846f1efffb8db526fada21a5fcf41c3 is the transaction id of the unstake operation.

Info shows the amount of staked token

1
steemengine info holger80

or

1
2
3
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