Beem Tutorials #2 - Beneficiaries

in #utopian-io6 years ago (edited)

Repository of Beem

https://github.com/holgern/beem

Tutorial Content

  • You will learn about the beneficiaries and how to set them via Beem on post creation.

Requirements

  • Python 2.7.x or 3.4+
  • Basic Python knowledge

In the first part of this series, we had a sweet introduction to the library and created a post. One of the options of post() function of Beem is the beneficiaries.

Beneficiaries

With the recent popularity of dapps on top of STEEM, beneficiary option has been known widely. It's basically an option where you can share your author rewards with other accounts on your posts. Currently, all beneficiary rewards are paid on STEEM Power form regardless the post has %50 SBD/%50 SP option enabled or not.

Setting Beneficiaries on Beem

from beem import Steem
steem = Steem(
    keys=["<private_wif>"],
)

beneficiaries = [
    {'account': 'crokkon', 'weight': 1000},
    {'account': 'holger80', 'weight': 1000},
]


resp = steem.post(
    "Benef test with beem",
    "Benef test",
    author="beemtutorials",
    permlink="beemtutorials-test-post-benefs",
    tags="beem test test-post",
    beneficiaries=beneficiaries,
)

print(resp)

This is the same example on the first tutorial except extra beneficiaries. It's a list of python dictionaries where you store account names and their reward weights. (sharing percentages.)

This code will give an output like that:

{
    'expiration': '2018-06-23T16:41:40',
    'ref_block_num': 51293,
    'ref_block_prefix': 1003704839,
    'operations': [
        ['comment', {
            'parent_author': '',
            'parent_permlink': 'post',
            'author': 'beemtutorials',
            'permlink': 'beemtutorials-test-post-benefs',
            'title': 'Benef test with beem',
            'body': 'Benef test',
            'json_metadata': '{"app": "myapp/0.0.1", "tags": ["post", "beem", "test"]}'
        }],
        ['comment_options', {
            'author': 'beemtutorials',
            'permlink': 'beemtutorials-test-post-benefs',
            'max_accepted_payout': '1000000.000 SBD',
            'percent_steem_dollars': 10000,
            'allow_votes': True,
            'allow_curation_rewards': True,
            'extensions': [
                [0, {
                    'beneficiaries': [{
                        'account': 'crokkon',
                        'weight': 1000
                    }, {
                        'account': 'holger80',
                        'weight': 1000
                    }]
                }]
            ]
        }]
    ],
    'extensions': [],
    'signatures': ['1f689b34de1afedb55556dba10fe7f8841396513ea1961da797e3babb732b5e3a22465a23ff3d77d231a563cc7731d224480b67e1d4d0036b4d94214f7ef701683']
}

As you can see from the output, beneficiaries are actually set in the CommentOption operation. We basically push two operations (Comment and CommentOption in one transaction to set beneficiaries.

Note: 'weight': 1000 means that %10 of the author rewards. Steem blockchain uses same weight convention on blockchain code. Just divide by 100 and get the value in percent when you see the weight in any operation.

steemd representation of the post

Limitations

  • You cannot specify more than 8 beneficiaries.
  • Total weight cannot be greater than 10000 (Obviously).
  • Account names must be specified sorted.
  • While it's possible to set beneficiaries after the post creation, it's not possible if the post got a vote or a comment. It's highly suggested to bundle the operations. (Beem already does that.)
  • Once beneficiaries set, there is no way to remove or update them for a particular post.

Curriculum

Sample Codes

Samples

Sort:  

Thanks :) I use these tutorials as my source for code snippets. It is easy to get some working code I can quickly prototype from

Thanks, these comments motivates me to continue :)

I thank you for your contribution. Here are my thoughts;

  • Like @mcfarhat's statement in the previous tutorial of this curriculum, your tutorial has issues with both volume and uniqueness. As the explanation about beneficiaries is rather Steem concept than Beem, the only thing you show is using already well-documented functions. So, I suggest you to diving into more complex themes or changing the main concept of the curriculum. Otherwise, in the voting phase, your next posts (except post 3, because it is already posted) might not be considered.

  • Increasing the number of substantial concepts might increase the volume too. I advise doing so instead of posting little tutorials with one concept alone.


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? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

your tutorial has issues with both volume and uniqueness

Can you please post the other tutorial or well-documented page about beneficiaries on Beem. I couldn't find anything before writing this. (Except a couple of pull requests and bug-reports)

the explanation about beneficiaries is rather Steem concept than Beem

Interesting. Beem is a library to interact with Steem. Of course concepts will be about both technologies. Otherwise it doesn't make any sense.

Otherwise, in the voting phase, your next posts (except post 3, because it is already posted) might not be considered.

This doesn't make any sense either. If any of my tutorials doesn't deserve to get a vote, then it shouldn't. (Including this one, or the next one.)

So, I suggest you to diving into more complex themes or changing the main concept of the curriculum

Thanks for the suggestion. I will not post these series into Utopian anymore, because I don't want to read any more review comments like this.

The quality of moderation is very poor in tutorials category. Yes it is better NOT to post, rather than getting it reviewed by some one who hasnt written a single tutorial about programming in his entire life.

I thank you for your review about my moderation process. I would be happy if you can directly give examples or show what is wrong. Otherwise, I don't think I can help you on this matter as what you tell is rather subjective than rational and objective.

Hey @emrebeyler,
You not posting on utopian is NOT what we are wanting to happen ! :)
The general idea that @yokunjon is trying to convey is to come up with some more innovative and useful examples of utilizing beem functionality. I just checked quickly and was able to stumble upon well-documented beneficiaries uses by crokkon here and here
Your posts are getting scored, and I personally learnt some aspects via reading your post.
Our advise is around coming up with something more innovative and useful to utilize those beem functions, make it more exciting !

These links are irrelevant. These are bug reports and pull requests. They’re nowhere near being a documentian or tutorial.

This is a series from zero to hero. You cannot explain advanced things without giving the basics.

Anyways, I dont see any point to continue discussing this because my series looks like incompatible with tutorials category.

Edit: no offence to any team members, I just dont share the same feelings. I had a similar steem-python tutorials (15 posts) and I still get good feedback from people after months

Speaking with my author hat, this review just frustruted me because you think that the content is not enough to be rewarded while I get good feedbacks from the readers.

Loading...

thank you. it was hard for me but after this tutorial its fine thank you

Is there anything beam can't do that steem-python can?

This got irrelevant as I read can and not can't in your comment. Sorry :facepalm:

I copy pasted this out of the readme of beem ;)

Advantages over the official steem-python library

  • High unit test coverage
  • Support for websocket nodes
  • Native support for new Appbase calls
  • Node error handling and automatic node switching
  • Usage of pycryptodomex instead of the outdated pycrypto
  • Complete documentation of beempy and all classes including all functions
  • steemconnect integration
  • Works on read-only systems
  • Own BlockchainObject class with cache
  • Contains all broadcast operations
  • Estimation of virtual account operation index from date or block number
  • the command line tool beempy uses click and has more commands
  • SteemNodeRPC can be used to excecute even not implemented RPC-Calls
  • More complete implemention

I hope this helped :D

Any cons you know of?

I don't think so. At least none that steem-python has as well :)

Thanks, I'll give it a try with one of my bots.

Works nice for mine using "multiprocessing" library for discord (rewrite branch) and telegram interfaces.
As a web-interface I simply use web.py for now. It all works with latest Python 3.6

but I see you are more in this than me....

But the question was different :)

Oh god I can't read. Shame on me D:

I started using steem-python and piston and had major trouble with incompatibilities to latest steem API as well als Python 3.6. Had to patch lot to make it run. Even within 3rd party libraries.
Then discovered beem and work went smooth. It just works!
There is no reason at all using the old stuff.
As a newcomer to Python I do not like to learn deprecated language and library functions. So for me I think it even was a good Idea to use latest Python.
btw. everything works quite nice within Anaconda environment.

How does it handle failover and node failures? Steem-python sucks for this.

None I can think of. However, I have recently switched to Beem, maybe people with more experience may give a better answer.

Hey @emrebeyler
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!