steem-python for dummies #4 - Private memos

Hello,

This is the 4. post of "steem-python for dummies" series. If you didn't read the older ones, take your time and have a look.

  1. steem-python for dummies #1 - Introduction and Basic Operations
  2. steem-python for dummies #2 - Playing with account data
  3. steem-python for dummies #3 - Coding an upvote bot

In this post, we will learn about private memos.

Private memos

All steem transfer operations are public. Everyone can see it. But if you want to attach a private message between sender and receiver, you have an option to encrpypt the message and send it like this.

Steemit interface already supports this functionality. Only thing you should do is just adding a "#" char to the start of the message.

# This is secret. Nobody should see this.

Using private memos in steem-python

It's dead simple. Just add # to the beginning of the memo.

s = Steem(keys=["PRIVATE_MEMO_KEY"])
s.commit.transfer(
    "emrebeyler", 
    0.001, 
    "SBD", 
    memo="#test message", 
    account="sender_account"
)

Tip: Currently steem-python package has a little bug when sending private memos. It add one extra "#" char to the beginning of the memo. It doesn't break the functionality but if you want to get rid of that, you can apply this patch:
remove double "#" char in private memos

Also, note that, private memo key is required to encrypt/decrpty memo keys.

Here is my private message's string representation on the network

Reading private memos

Steem-python's Memo class has a helper do decode memos. All you need is just passing memo private key and the encoded string. It will return the encoded message.

from steembase import memo as Memo
from steembase.account import PrivateKey
print(Memo.decode_memo(
    PrivateKey("MEMO_PRIVATE_KEY"),
    "#Jj3eUdmGhs9dbee5crcPTA7hXybBw6TvkEG7NvLVsxTTnb4AHmLeYmQ58r4K4GTLGHZX8BcESDSP6reVz7toZF7xYT88eytJxuS1ChCsKHRKJY3MUyShcJhy36wGX1W31",
))

Use cases

  • Private messages (Only sender and receiver can decode it.)
  • 3rd party applications can make use of it. Like If I want to see balance on my minnowbooster account, minnowbooster can send the amount with a private memo.

That's all for this post. Feel free to ask questions or request topics about steem-python for the incoming posts.



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
15 Comments