How to transfer SBD or STEEM to multiple accounts? (Batch transfer with steem-python) / 如何向多个账户批量转账

Manual transfer

Some of my friends held some very interesting activities on steemit. Such as 谷哥点名 by @jubi, and 七夕征文大赛by @rivalhw. The activities are very successful, plenty of people did participate and many people won the prize.

But, How to pay bonuses is a bit of a hassle, organizers need to log on to the website and transfer bonuses to each winner.

If there are a large number of winners, We need to do the same thing over and over again.

Batch transfer

Fortunately, we can implement batch transfers using program.
Just installed the official python library for STEEM as I mentioned in my previous article

But, We need Active private key this time, follow the same steps in my previous article but select Active private key, and then import it to our local wallet.

A simplest script maybe like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python
import sys
from steem import Steem

from_account = 'oflyhigh'
to_accounts = ['oflyhigh.test', 'jubi', 'deanliu']
amount = 0.001
asset = 'SBD'
message = 'Test transfer!'

def main(argv=None):
steem=Steem()
for to_account in to_accounts:
steem.transfer(to_account, amount=amount, asset=asset, memo=message, account=from_account)

if __name__ == "__main__":
sys.exit(main())

Now, we can transfer 0.001 SBD to multiple accounts ( @oflyhigh.test, @jubi, @deanliu) by executing the script. A message Test transfer! was added at the same time.

Now, let me check my wallet:

We made it successfully!

For encrypted messaging

steem-python also supports message encryption.

To issue a encrypted message, just plus # prefix for your message.
For example,
message = '#Test transfer!'

And you must import memo private key to your local wallet, otherwise you will get the following error message like this one:
steembase.exceptions.MissingKeyError: Memo key for oflyhigh missing!

There’s a small issue of steem-python for encrypted memo

We get two ‘#’ in the memo, which should be one, but it doesn’t matter.

中文

我的一些朋友在STEEMIT举办了很多有意思的活动,比如 @jubi 的谷哥点名, @rivalhw 的 七夕征文大赛等等。这些活动非常成功,吸引了很多朋友参加并且很多朋友赢得了奖励。

但是,如何发放奖励是很麻烦的事情,组织者要登陆网站给每个获奖者一笔一笔的转账。如果获奖者很多,那么我们就要一次又一次的做相同的事情。

幸运的是,我们可以用程序实现批量转账并附加备注信息,代码参见英文部分。

程序同时支持备注消息加密,在消息前边加个#号就可以了。但是steem-python有点小BUG,转账后的消息里多了一个#号,但是这没啥大影响。


This page is synchronized from the post: How to transfer SBD or STEEM to multiple accounts? (Batch transfer with steem-python) / 如何向多个账户批量转账

How to claim your rewards automatically? / 如何自动收取你的收益

Ways to claim rewards

In my previous article, I had introduced you a simple tool written by me. Using it you can easily check wallet assets and also can accurately calculate the estimated account value.

And I also added a feature to remind the user if there are rewards to be claimed. In such a situation, the page will display a highlighted text: You have rewards to be claimed. When we get this prompt message, we can log in our wallet and click to claim our rewards.

But, Are you tired of this way? Check->Login->Claim or Login->Check->Claim, We do the same thing over and over again. Is there a way to help us do these things automatically? The answer is yes!

There is a operation called claim_reward_balance_operation

Unlike the Steem API, which we can call directly, to initiate this operation you need to fill out this structure, and make a transaction structure from it, sign it with your posting private key, and then broadcast it.

Script with the official python library for STEEM

It’s too complicated for me. 😭
Fortunately, the official python library for STEEM did a lot of work for us, such as to fill out this structure, to make a transaction structure and to sign the translation with your posting private key, and to broadcast it.

All we need to do is call the method claim_reward_balance of Steem Class.

A simplest script maybe like this:

1
2
3
4
#!/usr/bin/env python
from steem import Steem
steem=Steem()
steem.claim_reward_balance(account = 'oflyhigh')

Let me save it as claim_rewards_for_oflyhigh.py.
To run the above script, we MUST do following things first:

  • Install steem-python with pip
    pip install -U steem

  • Get Posting private key
    Get Posting private key from Wallet->Permissions->Show private key

  • Import Posting private key to local wallet
    steempy addkey
    Input private key and set password for local wallet (First time)

  • Set UNLOCK environment variable
    UNLOCK=mysecretpassword

  • chmod u+x claim_rewards_for_oflyhigh.py

Run the script automatically

You can add this script to cron job to let it run automatically at specified intervals.
crontab -e
0 0 * * * /path/claim_rewards_for_oflyhigh.py >>log.txt 2>&1

Then the script will be executed at 00:00 every day.
More details about crontab can be found by man crontab.

To claim rewards for multiple accounts is just as easy.
Create scripts for each account, and then setup cron job for each file. The benefit is that you can set different intervals for different users.

If you want to claim rewards for multiple account with same same interval, Place users in a list and then iterate through them may be the better way.

中文

每天检查钱包手动收取收益,是不是很累?
有么有啥办法自动完成呢?

答案是有的,steem中定义了一个操作:claim_reward_balance_operation
我们只需填充这个结构,然后生成事务,然后签名事务,然后广播它,就可以了。

听起来很简单,但是其实非常麻烦,总之我是搞不定啦。
幸运的是,STEEM官方Python库可以帮我们完成大部分工作,我们只需要调用claim_reward_balance就可以啦。脚本见英文部分。

为了让脚本能执行,我们还需要安装STEEM官方Python库,导出并导入Posting私钥,设置UNLOCK环境变量,以及修改脚本的执行权限等。

我们的目的是让脚本自动运行,这也没啥,加入到定时任务(Cron job)中就行啦。

如果有多个账户,就写多个脚本设置多个任务好了,这样的好处是可以设置不同的时间间隔。如果多个账户按相同的时间间隔收取呢,那么把用户放入列表然后再遍历是个不错的方法。


This page is synchronized from the post: How to claim your rewards automatically? / 如何自动收取你的收益

或许区块链资产,才真的是你的资产

前段时间,我说过一些QQ号被腾讯冻结了,委屈的是,我并没有用这些QQ号做过什么不法勾当。其中一个7位的QQ号,是当年(大概是十三四年前)混论坛时一个兄弟送的,我已经记不得这个兄弟的论坛ID,也记不得他当时送我QQ号码的缘由。当时在论坛上聊得来的兄弟之间互相送点号码以及网站空间域名什么的,是很普通的事情。我记得我送出去好几个6位的QQ,甚至送出去过一个五位的QQ号,当时论坛上一个福建的兄弟结婚,我把这个号码当贺礼送他了。同样,我已然记不得他的论坛ID了,也记不得这个五位的QQ号的号码。不知道这个号码他是否在用,不知道他偶尔是否会想起我这个兄弟?


原本我在解冻申诉无果后,打算放弃了,毕竟这些号,我平时几乎不用,除了有点纪念意义,似乎也没那么重要。之所以又想起来,是突然想起来我的一个微信公众号挂在这个7位的QQ号码的QQ邮箱上,然后我忘记了公众号的登陆密码,然后想找回密码发现密码被发送到这个被冻结的QQ邮箱中。于是又去申诉,不出意外的又被拒绝。然后打电话给腾讯客服,验证了一堆信息以后,说号码不允许买卖或者共用,等等等一大堆的理由,总之就是说不能返回给我了。(公众号似乎可以通过其它方法重置,我这之后才发现)


不知道你是否有过类似经历,QQ号被冻结或者回收,然后被包装成靓号在腾讯官网上公然卖出。邮箱服务商说关闭就关闭(比如我的大雅虎和hotmail),我的N多好友和同事都一同消失了,其中不乏一些美女同事😭, 还有乱七八糟的网盘,我一哥们和我抱怨,他辛苦收集无数年的各种教育片,尽管他备份至好几个网盘,但是一段时间没关注,统统没了,这真是一个悲伤的故事。如果你有过做淘宝的店主的经历,那么商品被下架或者被删除更是很平常的事情,有时候仅仅是因为放错类目,或者商品描述上用了那些淘宝认为不恰当的关键字。用过Paypal的,我不少朋友遇到过账户连同资产一并冻结的例子,你甚至都不知道自己触犯了哪条规则。诸如此类,数不胜数。

为什么会有这类问题发生,主要因素在于这些服务都存在一个中心机构,或者是腾讯、或者是阿里、或者是邮件服务商、网盘服务商、Paypal公司等等。他们或者是为了所谓维护大多数人的利益,或者是为了自己的私利,宁可错杀也不放过。即便发现是错杀,也会有冠冕堂皇的理由,或者一句对不起,这种情况我们无法受理,足矣。而我们在这些中心化机构的庞然大物面前,好似一粒尘埃,想撼动人家来获得公平合理对话的机会,那是笑谈。如果被错杀,只能打落牙齿望肚子里咽了。

那么是不是一直都会如此下去?区块链的诞生和发展让人看到一丝曙光。区块链的最重要的特点之一,就是去中心化。在区块链世界里,你的ID就是你的ID,只要你不泄露出你的密码(或私钥),那么没有人能回收你的ID。你的资产就是你的资产,只要你不泄露出你的密码(或私钥),那么没有人能随便转移你的资产到其它账户。如果有朝一日,我们的一切资产和行为,都是以区块链为基础,那么想必生活会更加美好吧。

想象着,我们无需再使用QQ、微信之类的工具来聊天;不用在使用中国移动和中国联通的服务来接打电话;不用再使用淘宝支付宝之类的服务来购物和支付;甚至我们不需要去银行填一堆表格来开卡;不需要去券商那又填表又拍照的来开户;甚至将来汽车不用上牌了,居民也不要身份证了,出国啥的也不用护照了;那将会是多么美好的事情啊!


哎,又在白日做梦了,看来被腾讯气得不轻。


This page is synchronized from the post: 或许区块链资产,才真的是你的资产

A simple tool to check estimated account value. / 检查账户估值的小工具

I have written two articles to explain how to calculate estimated account value.

Although in fact that it is very simple, but it seems too technical for new users. So, in this article, I’d like to introduce a simple tool written by me. Using it, you can easily check wallet assets and also can accurately calculate the estimated account value for any account, you or your friends.

The URL & Interface

Like all the other tools I’ve written, I’m not good at UI design, so it looks as ugly as ever.
http://steemit.serviceuptime.net/check_eav.php

Just input the account name you want to check, then press Return or click Check Button, you will get the results.

The Results Filed

This tool will read all assets of the input account, report them, and then give a summarize.
The assets include following items:

  • STEEM
  • SBD
  • STEEM Power
  • STEEM in SAVINGS
  • SBD in SAVINGS
  • STEEM in Market
  • SBD in Market
  • STEEM(Rewards)
  • SBD(Rewards)
  • STEEM Power(Rewards)
  • SBD in Conversion

For example, the results of my account:

Using steemit, You can not obtain the items in the red box for other accounts, but my tool can.

I also added a feature to remind the user if there are rewards to be claimed. In such a situation, the page will display a highlighted text: You have rewards to be claimed.

For example, the check results of LAODR Tea House public account: laodr


Are you curious about your estimated account value? Or, curious about estimated account value of your friends? Or, you want to see if you have rewards to be claimed? Check it Now!

中文

之前用了两篇文章讲述如何计算账户估值,尽管其实很简单,但是新用户往往一头雾水。所以做了个小工具,来检查账户估值,一方面可以让大家用用,另一方面也是验证一下自己前边文章的结论。

贴图中红框内的部分,都是你查别人查不到的内容哦。

为了方便大家,我还特意加了个收益提醒功能,当有收益需要收取时,会显示一条高亮文本: You have rewards to be claimed.

想知道自己或朋友的账户估值?或者想看看自己有没有收益需要收取?快来查查吧


This page is synchronized from the post: A simple tool to check estimated account value. / 检查账户估值的小工具

How to calculate estimated account value: Part Two / 如何计算账户估值:第二部分

In my previous article, we concluded that:
To calculate estimated account value, we need to get items from these four parts:
1) The assets in wallet( And in SAVINGS)
2) The assets in internal market
3) The assets(SBD) in conversion processes
4) The assets(rewards) to be claimed

I will explain how to get them in this article.

The assets in wallet( And in SAVINGS)

The following assets need to be fetched.

  • STEEM
  • STEEM POWER
  • STEEM DOLLARS
  • STEEM in SAVINGS
  • STEEM DOLLARS in SAVINGS

There is a API named get_accounts will retrieve the account information which contained the above items.
vector< extended_account > get_accounts( vector< string > names ) const;

To retrieve them we need to put the account name into list, and then call API with this list as arguments. We can read the item value from the result using the corresponding key.

Item Key
STEEM balance
STEEM POWER vesting_shares
STEEM DOLLARS sbd_balance
STEEM in SAVINGS savings_balance
STEEM DOLLARS in SAVINGS savings_sbd_balance




An additional note, STEEM POWER was expressed in the form of VESTS, we need to convert it to equivalent STEEM.

The assets in internal market

To simplify the problem, In order to simplify the problem, we define two type of operations: BUY and SELL.

  • BUY: We pay SBD, and want to receive STEEM
  • SELL: We pay STEEM, and want to receive SBD

So, We get the following correspondence

Asset How to calculate
STEEM in internal market Remaining STEEM in all opening SELL order
STEEM DOLLARS in internal market Remaining SBD in all opening BUY order

There is a API named get_open_orders, will return all open orders in internal market for specified account.
vector<extended_limit_order> get_open_orders( string owner )const;

The example return information for my account.

We can draw the results from above information: we have 0.586 STEEM and 2 SBD in internal market.

The assets(SBD) in conversion processes

As I mentioned in previous article, if we try to convert some amount SBD to STEEM, it will disappear from the wallet. So to accurately calculate the estimated account value, we need to get this part of SBD.

Fortunately, there is a API called get_conversion_requests.
vector<convert_request_api_obj> get_conversion_requests( const string& account_name )const;

The result should like this one, We can work out the total amount of SBD easily.

The assets(rewards) to be claimed

And after HF18, users need to claim their rewards manually, so to accurately calculate the estimated account value, we need to add this part: Rewards to be claim.

The good news is we can retrieval them directly from user info, with same API get_accounts and the same way.

Item Key
STEEM Reward to be claimed reward_steem_balance
STEEM DOLLARS to be claimed reward_sbd_balance
STEEM POWER to be claimed reward_vesting_balance / reward_vesting_steem


For STEEM POWER to be claimed, we can obtain it from reward_vesting_balance or reward_vesting_steem, but the previous one need to be converted, so the later one is better.

For detailed usage of APIs, Please refer to the steem source code on Github.

中文

上篇文章中我们得出结论,精确计算账户估值,我们需要读取:

  • 钱包资产(包括存款账户)
  • 内部市场资产
  • 转换中的资产
  • 待收取的资产

我们可以使用:
get_accounts读回钱包资产(包括存款账户)
get_open_orders读回并计算出内部市场资产
get_conversion_requests读回并计算出 转换中的资产
get_accounts读回待收取的资产

API的详细用法,请参考Github上的steem源码


This page is synchronized from the post: How to calculate estimated account value: Part Two / 如何计算账户估值:第二部分

How to calculate estimated account value: Part One / 如何计算账户估值:第一部分

Are you curious about your estimated account value? Or, curious about estimated account value of your friends?

Get estimated account value in wallet page

You can check your estimated account value in your wallet after your logged in steemit.com, and you can check your friend’s wallet by visit https://steemit.com/@yourfriendid/transfers without login. But, Have you noticed that there are some differences between them?

Take my account for example:

✅️Check my wallet after logged-in


❌️Check my wallet without logged-in

Pay attention to where I marked it, the estimated account value after logged-in in is more than without logged-in. Why? ⚠️Because the assets in internal market are not counted in estimated account value if this account is not logged in.

So, if your friends have a lot of assets in internal market, you will get a completely wrong value.

How to solve this problem?

There is a API get_open_orders, will return all open orders in internal market of the specified account, and then we can calculate the assets in internal market of this account.

Is it enough? No!
After we got account’s assets in internal market by script, we need to manually add them to the values we got from web page(wallet), This is very annoying thing. A better way is to read the user’s wallet information by script too, and then add the corresponding information together.

What we need to get?

To read the user’s wallet information, we need to get the following information:

  • STEEM
  • STEEM POWER
  • STEEM DOLLARS
  • STEEM in SAVINGS
  • STEEM DOLLARS in SAVINGS

Is it enough now? No!

There a function in wallet called Convert to Steem, if you use it to convert SBD to STEEM, your SBD will disappear from the wallet, until it be converted successfully.

So, It should be better if we can obtain the assets(SBD) to be converted.
Fortunately, there is a API called get_conversion_requests. We can use it to calculate the amount of assets(SBD).

And after HF18, users need to claim their rewards manually, so to accurately calculate the estimated account value, we need to add this part: Rewards to be claim

Conclusions

Estimated account value contains four parts:

1) The assets in wallet( And in SAVINGS)
2) The assets in internal market
3) The assets(SBD) in conversion processes
4) The assets(rewards) to be claimed

To calculate estimated account value, we need to get following items:

  • STEEM
  • STEEM POWER
  • STEEM DOLLARS
  • STEEM in SAVINGS
  • STEEM DOLLARS in SAVINGS
  • STEEM in internal market
  • STEEM DOLLARS in internal market
  • STEEM DOLLARS in conversion requests
  • STEEM Reward to be claimed
  • STEEM POWER to be claimed
  • STEEM DOLLARS to be claimed

I’ll explain how to get these items in my next article.
Thank you for reading.

中文

登陆查看用户账户估值,和不登录查看,结果会有一些区别。
如果没有登陆,或者ID A登录查看ID B的钱包, 在内部市场的资产不被显示。

除此之外,转换中的资产, 以及待收取的收益,也没有计算在内。
所以要精确计算账户估值,我们需要读取

  • 钱包资产(保护存款账户)
  • 内部市场资产
  • 转换中的资产
  • 待收取的资产

我将在下篇文章中介绍如何获得这些内容,感谢阅读。


This page is synchronized from the post: How to calculate estimated account value: Part One / 如何计算账户估值:第一部分

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×