-
Holger Nahrstaedt authored
Account * Example forget SimilarAccountNames added * Example for history and history_reverse improved Amount * Example is tested with doctest Block * Example is tested with doctest Price * Fix example Profile * Fix example Steem * Example is tested by doctest Transactionbuilder * Example is tested by doctest Vote * datetime.now() changed to datetime.utcnow() * Example is tested by doctest Witness * datetime.now() changed to datetime.utcnow() * Example is tested by doctest Docs * Installation instruction improved * Quickstart created * Discord channel added to support
Holger Nahrstaedt authoredAccount * Example forget SimilarAccountNames added * Example for history and history_reverse improved Amount * Example is tested with doctest Block * Example is tested with doctest Price * Fix example Profile * Fix example Steem * Example is tested by doctest Transactionbuilder * Example is tested by doctest Vote * datetime.now() changed to datetime.utcnow() * Example is tested by doctest Witness * datetime.now() changed to datetime.utcnow() * Example is tested by doctest Docs * Installation instruction improved * Quickstart created * Discord channel added to support
Quickstart
Steem
The steem object is the connection to the Steem blockchain. By creating this object different options can be set.
Note
All init methods of beem classes can be given
the steem_instance=
parameter to assure that
all objects use the same steem object. When the
steem_instance=
parameter is not used, the
steem object is taken from get_shared_steem_instance().
get_shared_steem_instance()
returns a global instance of steem.
It can be set by set_shared_steem_instance
otherwise it is created
on the first call.
from beem import Steem
stm = Steem()
account = Account("test", steem_instance=stm)
from beem import Steem
from beem.instance import set_shared_steem_instance
stm = Steem()
set_shared_steem_instance(stm)
account = Account("test")
Wallet and Keys
Each account has a: * Posting key (allows accounts to post, vote, edit, resteem and follow/mute) * Active key (allows accounts to transfer, power up/down, voting for witness, ...) * Memo key (Can be used to encrypt/decrypt memos) * Owner key (The most important key, should not be used with beem)
Outgoing operation, which will be stored in the steem blockchain, have to be signed by a private key. E.g. Comment or Vote operation need to be signed by the posting key of the author or upvoter. Private keys can be provided to beem temporary or can be stored encrypted in a sql-database (wallet).
Note
Before using the wallet the first time, it has to be created and a password has to set. The wallet content is available to beempy and all python scripts, which have access to the sql database file.
Creating a wallet
steem.wallet.wipe(True)
is only necessary when there was already an wallet created.
.. code-block:: python
from beem import Steem steem = Steem() steem.wallet.wipe(True) steem.wallet.create("wallet-passphrase")
Adding keys to the wallet
from beem import Steem
steem = Steem()
steem.wallet.unlock("wallet-passphrase")
steem.wallet.addPrivateKey("xxxxxxx")
steem.wallet.addPrivateKey("xxxxxxx")
Using the keys in the wallet
from beem import Steem
steem = Steem()
steem.wallet.unlock("wallet-passphrase")
account = Account("test", steem_instance=steem)
account.transfer("<to>", "<amount>", "<asset>", "<memo>")
Private keys can also set temporary
from beem import Steem
steem = Steem(keys=["xxxxxxxxx"])
account = Account("test", steem_instance=steem)
account.transfer("<to>", "<amount>", "<asset>", "<memo>")
Receiving information about blocks, accounts, votes, comments, market and witness
from beem.blockchain import Blockchain
blockchain = Blockchain()
for op in Blockchain.ops():
print(op)
from beem.block import Block
print(Block(1))
from beem.account import Account
account = Account("test")
print(account.balances)
for h in account.history():
print(h)
from beem.vote import Vote
vote = Vote(u"@gtg/ffdhu-gtg-witness-log|gandalf")
print(vote.json())
from beem.comment import Comment
comment = Comment("@gtg/ffdhu-gtg-witness-log")
print(comment["active_votes"])
from beem.market import Market
market = Market("SBD:STEEM")
print(market.ticker())
from beem.witness import Witness
witness = Witness("gtg")
print(witness.is_active)
from beem.market import Market
market = Market("SBD:STEEM")
print(market.ticker())
market.steem.wallet.unlock("wallet-passphrase")
print(market.sell(300, 100) # sell 100 STEEM for 300 STEEM/SBD