Powering up
Powering up is a process on steem blockchain where you convert your liquid STEEMs to Steem Power. Every time an account powers up, it broadcast a "transfer_to_vesting" operation to the network.
@sndbox and some other organizations have weekly power-up challenges. And I was lucky to win a couple of them. Today I was curious how much I have powered up in the last month. (I did powered-up a lot.)
Filtering "transfer_to_vesting" ops with steem-python
Out script's main flow should be like this:
- Get an input with username, start_date, and end_date
- Filter all "transfer_to_vesting" operations between start_date and end_date
- Sum all powered-up amount in corresponding transactions.
And we have the number.
Basic example to filter specific operations:
from steem import Steem
from steem.account import Account
s = Steem(nodes=["https://api.steemit.com"])
acc = Account('emrebeyler', steemd_instance=s)
for op in acc.history_reverse(filter_by=["transfer_to_vesting"]):
print(op)
This script will filter all "transfer_to_vesting" operations in your entire account history and prints them.
The Calculator script
from steem import Steem
from steem.account import Account
from steem.amount import Amount
from dateutil.parser import parse
from datetime import datetime
import tableprint as tp
def calculate_powerup(username, start_date, end_date):
s = Steem(nodes=["https://api.steemit.com"])
account = Account(username, steemd_instance=s)
data = []
total = 0
for op in account.history_reverse(filter_by=["transfer_to_vesting"]):
ts = parse(op["timestamp"])
if ts > end_date:
continue
if ts < start_date:
break
total += Amount(op["amount"]).amount
data.append((op["amount"], op["timestamp"]))
data.append(("Total: %s STEEM" % round(total, 2), "-"))
return data, total
if __name__ == '__main__':
data, total = calculate_powerup(
'emrebeyler',
datetime(2018, 2, 1),
datetime(2018, 3, 1),
)
tp.table(data, ['Amount', 'Timestamp'], width=32)
Example output
You can play with other accounts and timeframes by changing start_date and end_date. Make sure you have steem-python and tableprint libraries installed on your local environment.
Have fun.
This is awesome! Do you know if there's something similar in Steem.js? I couldn't find a way to target the power up transactions specifically, so when I made the power up calcuator for sndbox I ended up having to just make an API call for a big slice of a user's transactions and then filter out the ones that were power ups.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Actually, this is the same w/ python. It's a syntactic sugar that just filters while browsing all type of transactions.
I remember a feature request at Github asking if filtering can be done on the steem daemon itself but it's not there yet.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ah ok, yeah I found a feature request for Steem.js about that feature too. Super cool what you did here though! I keep getting more curious about Python :P
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That's my pythonman 😎
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Grazie, Zorto.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
woah nice one
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
did you start learning python?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yeah I started you are my idol thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you put out some awesome stuff man. thanks for everything you do! :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Whoa, creativity.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yeah nice guys
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This post has received gratitude of 5.80% from @appreciator courtesy of @emrebeyler!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You should add a check for your account, it isn't common but you can power up another account and they will show up as
transfer_to_vesting
so your script will factor them in as local power-ups.It's kind of an edge case but I use it a lot.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
True! I did that a couple of times actually. Thanks for the heads up.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit