<img src="https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drxhdemuq4r4ezSCFC6xhAknvQspB_1680x8400"> #### Calculating witness rewards *** Every time a witness produces a block, steem blockchain rewards the witness with a **producer_reward** operation in the blockchain. This is a virtul operation - don't exactly bounded to a transaction, therefore it doesn't have a transaction ID. It is possible to go through the account history and calculate how much a witness made by being a witness. :) Some of the properties of a producer_reward operation: { 'producer': 'emrebeyler', 'vesting_shares': '1980.464769 VESTS', 'block': 20633599, 'timestamp': '2018-03-13T07:48:27', } #### Main Flow of the script *** - Go through the account history - Filter "producer_reward" operations - Sum all rewarded VESTS and convert to Steam Power <center><img src="http://i.hizliresim.com/YgaNn2.png"></center> <center><sup>My witness earnings so far. I am rich!</sup></center> #### Script *** ``` from steem import Steem from steem.account import Account from steem.amount import Amount from steem.converter import Converter import logging logger = logging.getLogger('producer rewards') logger.setLevel(logging.INFO) logging.basicConfig() def calculate_producer_rewards(steemd_instance, witness_account): account = Account(witness_account,steemd_instance=steemd_instance) total_vests = 0 for producer_reward in account.history_reverse(filter_by=["producer_reward"]): total_vests += Amount(producer_reward["vesting_shares"]).amount converter = Converter(steemd_instance=s) total_sp = converter.vests_to_sp(total_vests) return total_vests, total_sp if __name__ == '__main__': s = Steem(nodes=["https://api.steemit.com"]) witness_account = 'emrebeyler' vests, sp = calculate_producer_rewards(s, witness_account) print("Account: %s, Total Vests: %s, Total SP: %s" % ( witness_account, round(vests, 2), round(sp, 2))) ``` See the script nicely formatted at [Github Gists](https://gist.github.com/emre/ffb0c8e895b0e4d9506f3f587664dd2b). #### Notes *** - This script scans all operation history. Execution time may take forever for old witnesses. - Conversion to the SP is done with the current VESTS to SP rate. This is a dynamic variable and may differ from time to time. #### Requirements *** You need to have **steem-python** library installed in your local environment. Have fun.
author | emrebeyler |
---|---|
permlink | steam-python-tips-5-calculating-witness-rewards |
category | steem-python |
json_metadata | {"community":"busy","app":"steemit/0.1","format":"markdown","tags":["steem-python","python","witness","sndbox","busy"],"links":["https://gist.github.com/emre/ffb0c8e895b0e4d9506f3f587664dd2b"],"image":["https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drxhdemuq4r4ezSCFC6xhAknvQspB_1680x8400","http://i.hizliresim.com/YgaNn2.png"]} |
created | 2018-03-14 17:39:54 |
last_update | 2018-03-14 19:23:51 |
depth | 0 |
children | 9 |
last_payout | 2018-03-21 17:39:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 15.575 HBD |
curator_payout_value | 2.833 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,472 |
author_reputation | 448,535,049,068,622 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,419,941 |
net_rshares | 5,694,147,232,301 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
chitty | 0 | 230,254,507,351 | 50% | ||
olegn | 0 | 1,981,236,239 | 100% | ||
lgm-1 | 0 | 1,728,910,684 | 25% | ||
kiddarko | 0 | 497,754,879 | 0.5% | ||
mindfreak | 0 | 23,466,299,711 | 12.5% | ||
dadview | 0 | 223,500,033 | 0.5% | ||
jamzed | 0 | 21,076,332,198 | 100% | ||
hansikhouse | 0 | 94,336,943,676 | 12.5% | ||
voronoi | 0 | 195,995,933,024 | 25% | ||
adventureevryday | 0 | 548,633,244 | 1% | ||
busy.org | 0 | 44,124,167,644 | 0.06% | ||
teamhumble | 0 | 1,799,230,655 | 6% | ||
alfarisi | 0 | 156,454,817 | 25% | ||
elizacheng | 0 | 942,637,201 | 5% | ||
heriafriadiaka | 0 | 300,583,830 | 25% | ||
buzzbeergeek | 0 | 734,523,126 | 1% | ||
damla | 0 | 4,348,882,881 | 20% | ||
erb | 0 | 10,134,815,911 | 25% | ||
oendertuerk | 0 | 36,288,400,581 | 20% | ||
dbzfan4awhile | 0 | 3,522,684,146 | 3.75% | ||
cryptastic | 0 | 5,774,228,898 | 30% | ||
world-travel-pro | 0 | 1,212,395,945 | 1.25% | ||
walnut1 | 0 | 1,475,639,118 | 1.25% | ||
derrick829 | 0 | 14,156,327,557 | 1% | ||
lastozgur | 0 | 426,556,435 | 100% | ||
hendrix22 | 0 | 23,471,659,420 | 10% | ||
sndbox | 0 | 3,929,810,314,892 | 25% | ||
buy-bitcoin | 0 | 612,562,856 | 100% | ||
kofspades | 0 | 132,358,956 | 12.5% | ||
leotrap | 0 | 5,987,797,779 | 12.5% | ||
nettybot | 0 | 9,773,802,281 | 20% | ||
matrixonsteem | 0 | 464,341,260 | 100% | ||
somethingburger | 0 | 1,780,453,093 | 25% | ||
steemliberator | 0 | 586,658,925 | 100% | ||
bleyker | 0 | 104,160,881 | 25% | ||
djlethalskillz | 0 | 1,849,266,333 | 5% | ||
dodybireuen | 0 | 740,168,878 | 100% | ||
msp3k | 0 | 4,589,334,804 | 100% | ||
make-a-whale | 0 | 100,843,515,891 | 15% | ||
witnessstats | 0 | 463,972,907 | 100% | ||
boontjie | 0 | 43,076,010,380 | 100% | ||
crokkon | 0 | 11,840,264,800 | 50% | ||
osm0sis | 0 | 711,621,919 | 1% | ||
kriptonoob | 0 | 357,456,402 | 0.1% | ||
espoem | 0 | 27,527,629,217 | 50% | ||
playitforward | 0 | 7,188,231,497 | 7.5% | ||
mrblinddraw | 0 | 4,219,991,155 | 10% | ||
r2steem2 | 0 | 477,666,524 | 100% | ||
steemcreate | 0 | 496,323,850 | 100% | ||
omersurer | 0 | 982,233,027 | 5% | ||
curationstreet | 0 | 484,248,894 | 5% | ||
emrebeyler | 0 | 711,933,968,002 | 100% | ||
kamuhuzuru | 0 | 117,603,610 | 10% | ||
turbot | 0 | 339,895,724 | 75% | ||
dangerux | 0 | 156,371,939 | 20% | ||
ethemkibar | 0 | 2,173,352,874 | 10% | ||
jeffbernst | 0 | 2,049,154,771 | 12.5% | ||
evilest-fiend | 0 | 1,220,283,919 | 50% | ||
thashadowbrokers | 0 | 59,211,385 | 100% | ||
richardoccas | 0 | 150,062,396 | 40% | ||
gokos | 0 | 499,140,692 | 93% | ||
matematikciemre | 0 | 219,670,416 | 5% | ||
muhammetcan | 0 | 529,175,200 | 89% | ||
geekpowered | 0 | 21,047,787,499 | 100% | ||
aydant | 0 | 575,772,972 | 100% | ||
intelligencer | 0 | 3,870,097,392 | 100% | ||
lextenebris | 0 | 5,077,196,546 | 20% | ||
irfandogan | 0 | 264,846,714 | 10% | ||
biriki3 | 0 | 174,830,627 | 10% | ||
brotato | 0 | 270,887,007 | 100% | ||
pizaz | 0 | 270,324,907 | 100% | ||
triplethreat | 0 | 59,179,130 | 100% | ||
dootdoot | 0 | 50,201,672 | 100% | ||
wewt | 0 | 5,266,300,518 | 20% | ||
conflaxus | 0 | 59,149,580 | 100% | ||
tittilatey | 0 | 57,965,483 | 100% | ||
cajun | 0 | 270,803,294 | 100% | ||
coonass | 0 | 276,529,095 | 100% | ||
squirrelnuts | 0 | 270,397,839 | 100% | ||
iwanderela | 0 | 1,180,237,871 | 1% | ||
luoq | 0 | 2,250,364,297 | 12.5% | ||
ewq | 0 | 1,470,328,705 | 6% | ||
steemdevs | 0 | 270,183,423 | 100% | ||
jeezy | 0 | 59,124,306 | 100% | ||
test.with.dots | 0 | 59,125,468 | 100% | ||
pi-pi | 0 | 57,864,537 | 100% | ||
listentosteem | 0 | 57,861,415 | 100% | ||
thornaci | 0 | 80,223,924 | 100% | ||
gravy | 0 | 57,844,235 | 100% | ||
sauronbey | 0 | 297,859,327 | 12% | ||
yucealiosman | 0 | 501,110,900 | 84% | ||
onursa | 0 | 504,185,200 | 91% | ||
osmania | 0 | 1,848,940,023 | 100% | ||
selamtux | 0 | 467,020,000 | 78% | ||
ucmuharfli | 0 | 537,408,680 | 16% | ||
shankstaicho | 0 | 3,920,845,871 | 100% | ||
patricklancaster | 0 | 76,731,063 | 0.5% | ||
embesilikat | 0 | 80,306,496 | 10% | ||
fotobot | 0 | 57,272,313 | 10% | ||
gokhan83kurt | 0 | 1,858,095,981 | 5% | ||
deejee | 0 | 76,609,386 | 12.5% | ||
e-babil | 0 | 221,353,036 | 6% | ||
wisewoof | 0 | 1,098,410,846 | 5% | ||
gulumserunver | 0 | 98,012,022 | 16% | ||
neokuduk | 0 | 98,376,638 | 10% | ||
eshapunver | 0 | 140,996,421 | 20% | ||
muhittinabi | 0 | 61,249,957 | 10% | ||
debruyne844 | 0 | 67,419,046 | 12.5% | ||
queqtra | 0 | 56,124,416 | 7.6% | ||
bybrawe | 0 | 319,813,415 | 20% | ||
ahmetmertugrul | 0 | 553,375,532 | 100% | ||
samedb | 0 | 572,627,825 | 95% | ||
iluvatar100 | 0 | 899,210,810 | 10% | ||
evansbankx | 0 | 141,291,018 | 100% | ||
jbeguna04 | 0 | 237,680,848 | 25% | ||
myus | 0 | 74,134,752 | 12.5% | ||
flugschwein | 0 | 597,154,553 | 100% | ||
steem-rocks | 0 | 590,662,516 | 99% | ||
omarkhayyam | 0 | 519,334,221 | 100% | ||
synergysteem | 0 | 1,199,604,426 | 100% | ||
ornitorenk | 0 | 2,068,206,448 | 10% | ||
properfraction | 0 | 613,608,410 | 100% | ||
chukuibijenny | 0 | 55,175,051 | 12.5% | ||
lavinas | 0 | 61,249,020 | 10% | ||
menggugat | 0 | 70,736,149 | 12.5% | ||
jacek-w | 0 | 413,862,934 | 100% | ||
peri | 0 | 1,249,327,883 | 10% | ||
hakancelik | 0 | 4,144,832,989 | 75% | ||
ahmetchef | 0 | 581,905,069 | 100% | ||
tgksalin | 0 | 592,959,556 | 100% | ||
privacybydesign | 0 | 613,230,869 | 100% | ||
misbahjuli | 0 | 381,654,924 | 100% | ||
ogergami | 0 | 614,502,373 | 100% | ||
firster78 | 0 | 171,616,379 | 28% | ||
ayoade96 | 0 | 52,249,834 | 12.5% | ||
blockmountain | 0 | 564,142,511 | 12.5% | ||
trupvote | 0 | 615,349,248 | 100% | ||
jumbot | 0 | 22,815,702,171 | 40% | ||
esme-svh | 0 | 471,637,166 | 100% | ||
keybordjp | 0 | 73,903,556 | 12.5% | ||
testorz | 0 | 418,325,646 | 96% | ||
a-dnmz | 0 | 609,415,643 | 100% | ||
lightshield | 0 | 153,159,118 | 100% | ||
qotd | 0 | 386,534,293 | 88% | ||
senseofhumor | 0 | 613,404,229 | 100% | ||
aksapphires | 0 | 55,304,908 | 12.5% | ||
sahinadm | 0 | 560,676,944 | 100% | ||
crpytoanalyzer | 0 | 109,067,418 | 91% | ||
tooche | 0 | 309,328,035 | 100% |
This is a very useful script for witnesses!
author | chitty |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180318t190833123z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-18 19:08:24 |
last_update | 2018-03-18 19:08:24 |
depth | 1 |
children | 0 |
last_payout | 2018-03-25 19:08:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.040 HBD |
curator_payout_value | 0.013 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 43 |
author_reputation | 86,901,300,608,582 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 45,194,315 |
net_rshares | 16,413,078,190 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
emrebeyler | 0 | 16,413,078,190 | 2% |
informasi sangat beemanfaat, kamu telah melakukan pekerjaan yang mulia, terimakasih telah berbagi..good luck
author | fadil94 |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180315t085232943z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-15 08:52:39 |
last_update | 2018-03-15 08:52:39 |
depth | 1 |
children | 0 |
last_payout | 2018-03-22 08:52:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 108 |
author_reputation | 803,879,722,663 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,551,839 |
net_rshares | 0 |
I don't think you want to have **_steam_** python tips in your title ;)
author | flugschwein |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180314t191906021z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-14 19:19:06 |
last_update | 2018-03-14 19:19:06 |
depth | 1 |
children | 2 |
last_payout | 2018-03-21 19:19:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 71 |
author_reputation | 11,950,112,708,339 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,437,481 |
net_rshares | 0 |
fixed. thanks!
author | emrebeyler |
---|---|
permlink | re-flugschwein-re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180314t192409218z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-14 19:24:09 |
last_update | 2018-03-14 19:24:09 |
depth | 2 |
children | 1 |
last_payout | 2018-03-21 19:24:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 14 |
author_reputation | 448,535,049,068,622 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,438,303 |
net_rshares | 0 |
You're welcome. I'm glad I could help.
author | flugschwein |
---|---|
permlink | re-emrebeyler-re-flugschwein-re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180314t193721307z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-14 19:37:24 |
last_update | 2018-03-14 19:37:24 |
depth | 3 |
children | 0 |
last_payout | 2018-03-21 19:37:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 38 |
author_reputation | 11,950,112,708,339 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,440,380 |
net_rshares | 0 |
Cool little script. Might be useful for a dashboard or site or something.
author | geekpowered |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180319t042612952z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-19 04:26:12 |
last_update | 2018-03-19 04:26:12 |
depth | 1 |
children | 1 |
last_payout | 2018-03-26 04:26:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.040 HBD |
curator_payout_value | 0.011 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 73 |
author_reputation | 99,319,261,112,097 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 45,264,803 |
net_rshares | 16,413,078,190 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
emrebeyler | 0 | 16,413,078,190 | 2% |
That's actually a good idea - I will do a leaderboard for the top100 witnesses :)
author | emrebeyler |
---|---|
permlink | re-geekpowered-re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180319t065836032z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-19 06:58:36 |
last_update | 2018-03-19 06:58:36 |
depth | 2 |
children | 0 |
last_payout | 2018-03-26 06:58:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 81 |
author_reputation | 448,535,049,068,622 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 45,284,086 |
net_rshares | 3,310,197,232 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
geekpowered | 0 | 3,310,197,232 | 16% |
Great informative update news...thank you so much...i like it...
author | sumanbiswas |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180314t180252068z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-14 18:02:57 |
last_update | 2018-03-14 18:02:57 |
depth | 1 |
children | 0 |
last_payout | 2018-03-21 18:02:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 64 |
author_reputation | 425,351,397,895 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,424,111 |
net_rshares | 0 |
İyiymiş bu sistem teşekkürler 😊
author | tooche |
---|---|
permlink | re-emrebeyler-steam-python-tips-5-calculating-witness-rewards-20180314t174254096z |
category | steem-python |
json_metadata | {"tags":["steem-python"],"app":"steemit/0.1"} |
created | 2018-03-14 17:42:57 |
last_update | 2018-03-14 17:42:57 |
depth | 1 |
children | 0 |
last_payout | 2018-03-21 17:42:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 31 |
author_reputation | 3,291,365,132 |
root_title | "steem-python tips #5 - Calculating witness rewards" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,420,481 |
net_rshares | 0 |