How to set beneficiaries with steem-python

in #steemdev7 years ago (edited)

It only took me 22 days to figure out ...

This was my issue:

https://github.com/steemit/steem-python/issues/9

In the commit.py it says:

For example, if we would like to split rewards between account1 and account2:

    beneficiaries = [
                     {'account': 'account1', 'weight': 5000},
                     {'account': 'account2', 'weight': 5000}
                    ]

And that doesn't work and it was driving me crazy.

This worked:

beneficiaries = [
                 OrderedDict('account': 'account1', 'weight': 5000),
                 OrderedDict('account': 'account2', 'weight': 5000)
                ]

( You need from collections import OrderedDict )

Now you can make a post with the beneficiaries argument.

I almost put a 100 SBD bounty on solving this issue.

For my report with @deutschbot, I use it like this:

bene_list = []
bene_weight = 10000 // len(mentioned_authors)
bene_rest = 10000 - (bene_weight * len(mentioned_authors))

for author in mentioned_authors:

    bene_dict = OrderedDict()
    bene_dict['account'] = author
    bene_dict['weight'] = bene_weight

    if author == report_author:
        
        bene_dict['weight'] = bene_weight + bene_rest

    bene_list.append(bene_dict)

Now you can

steem.post(
      title = 'My funky title', 
      body = beautiful_post, 
      author = 'beststeemitaccountever111', 
      tags = ['such', 'code', 'much', 'win']
      beneficiaries = bene_list) 

Sort:  

Ugh, I've run into headaches like this in the past, and they can be frustrating!

Hopefully steem-python will get first-class support for that at some point.

Great work!
I still have not gained experience in programming the steemit API but I think it's really time to start...

Versteh leider nur Bahnhof, bin halt kein Programmierer, dir scheints aber zu taugen :-D

You say you are not an advanced developer, I disagree! :]

Nah, I'm a noob.

I loved this notes and your profile picture, I also wanted to play like that with the default image, very inspiring!

I'm kinda proud of my profile picture :D

great going!!

Wo kann ein Programmnixkapierer nachlesen, was hier gemeint ist?

Ich wüsste nicht wo ...

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63050.55
ETH 2622.66
USDT 1.00
SBD 2.71