create account

Node.js - Kirim SBD ke Upvoter #5 by binjeeclick

View this thread on: hive.blogpeakd.comecency.com
· @binjeeclick · (edited)
$0.46
Node.js - Kirim SBD ke Upvoter #5
Hello Steemians,.
apa kabarnya hari ini, semoga selalu dalam lindungannya, pada artikel kali ini kita akan melanjutkan pembahasan yang tertunda, yaitu tentang mengirim SBD hadiah (Gift), artikel yang pertama ada pada link ini [Kirim SBD ke User atau ke Upvoter](https://steemit.com/indonesia/@binjeeclick/node-js-kirim-sbd-ke-user-atau-ke-upvoter-4-2017924t122947711z).

### Intro
Script yang akan kita kembangkan hari ini adalah Script untuk mengirim SBD ke semua Upvoter dalam satu post, misalnya [post saya yang ini](https://steemit.com/indonesia/@binjeeclick/node-js-kirim-sbd-ke-user-atau-ke-upvoter-4-2017924t122947711z) saya mendapatkan 38 Votes, jadi SBD yang akan kita kirim kepada ke 38 Upvoter tersebut dengan nominal yang sama.

Yang kita butuhkan untuk menjalankan script ini adalah:
1. Pengirim, contoh `binjeeclick`
2. Active Key/Owner Key, contohnya `5JTTbNDXcbAG5hRA497mJHU6ZT79piFFqchczp8C7q4Sznz1at9`
3. Permlink URL atau link post, contoh `https://steemit.com/indonesia/@binjeeclick/node-js-kirim-sbd-ke-user-atau-ke-upvoter-4-2017924t122947711z` yang kita ambil hanya `node-js-kirim-sbd-ke-user-atau-ke-upvoter-4-2017924t122947711z`.
4. Jumlah SBD yang akan kita kirim, contohnya `0.001`.

### Code Kirim SBD ke Upvoter
1. Bukalah Notepad++ atau text editor lain yang familiar dengan anda, ketikkan kode berikut:
```javascript
<html>
<head>
<meta charset="UTF-8">
    <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#btnSendSBD").click(function () {
                var url = $("#txtSBDURL").val();
                var permlink = url.substring(url.lastIndexOf("/")).replace("/","");
                var authorStartIndex = url.lastIndexOf("@");
                var authorEndIndex = url.lastIndexOf("/");
                var author = url.substring(authorStartIndex + 1, authorEndIndex);
                var from = $("#txtUser").val();
                var wif = $("#txtActiveKey").val();
                var ul = document.getElementById('result');
                var amt = parseFloat($("#txtSBDAmount").val()).toFixed(3) + " SBD";
                    steem.api.getContent(author, permlink, function (err, result) {
                        console.log(err, result);
                    if (err != null)
                        { alert(err); }
                    else {
                    result.active_votes.map(function (active_vote) {
                var to = active_vote.voter;
                    steem.broadcast.transfer(wif, from, to, amt, "", function (sendError, sendResult){
                        console.log(sendError, sendResult);
                    if (sendError != null){
                        console.log(sendError);
            //alert(sendError);
                var li = document.createElement('li');
                    li.innerHTML = active_vote.voter + ' ' + active_vote.percent/100 + '% Send SBD Error';
                    ul.appendChild(li);
                        }
                    else {
                var li = document.createElement('li');
                    li.innerHTML = active_vote.voter + ' ' + active_vote.percent/100 + '% Send SBD Done ';
                    ul.appendChild(li);
                        }
            });
        });
      }
     });
    });
});
</script>
</head>
<body>
    <TABLE>
        <TR>
            <TD>Pengirim</TD>
            <TD><input type="text" id="txtFromUser" value="" style="width: 500px;" /></TD>
        </TR>
        <TR>
            <TD>Private Active/Owner Key</TD>
            <TD><input type="password" id="txtActiveKey"   value="" style="width: 500px;" /></TD>
        </TR>
        <TR>
            <TD>URL POST</TD>
            <TD><input type="text" id="txtSBDURL" value="" style="width: 500px;" /></TD>
        </TR>
        <TR>
            <TD>Jumlah SBD</TD>
            <TD><input type="text" id="txtSBDAmount"  style="width: 200px;" /></TD>
        </TR>
    </TABLE>
    <p><input id="btnSendSBD" type="button" value="Send SBD To ALL Voters" /></p>
    <hr />
    <ul id="result">
    </ul>
   </body>
</html>
```
Lihat lebih jelas di [pastebin.com](https://pastebin.com/d7UQSkQc)
2. Simpan document tersebut dengan Extensi `.html` beri nama apa saja, misalnya `sebdsbdbyurl.html`
3. Buka file tersebut degan browser, anda akan melihat tampilan seperti ini:
<div><center><img src="https://image.prntscr.com/image/tMZE8yr_SHKAI93L6jwGBQ.png" /><br/><em>Credit: @binjeeclick</em></center></div><p><hr>
4. Selamat anda telah berhasil membuat tools untuk send SBD ke Upvoter.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorbinjeeclick
permlinknode-js-kirim-sbd-ke-upvoter-5
categoryindonesia
json_metadata{"tags":["indonesia","steemdev","nsc","nodejs","tutorial"],"users":["binjeeclick"],"image":["https://image.prntscr.com/image/tMZE8yr_SHKAI93L6jwGBQ.png"],"links":["https://steemit.com/indonesia/@binjeeclick/node-js-kirim-sbd-ke-user-atau-ke-upvoter-4-2017924t122947711z","https://pastebin.com/d7UQSkQc"],"app":"steemit/0.1","format":"markdown"}
created2017-09-25 02:12:21
last_update2017-09-25 04:30:27
depth0
children4
last_payout2017-10-02 02:12:21
cashout_time1969-12-31 23:59:59
total_payout_value0.378 HBD
curator_payout_value0.083 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,678
author_reputation2,553,417,069,149
root_title"Node.js - Kirim SBD ke Upvoter #5"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id15,843,706
net_rshares129,676,790,207
author_curate_reward""
vote details (35)
@bukhairidin ·
sepertinya postingan ini untuk menambah upvote, tetapi saya belum mengetahui bagaimana cara menjalankan seperti perintah dari postingan ini.
apakah sudikiranya untuk memandu saya melakukan seperti postingan anda?
properties (22)
authorbukhairidin
permlinkre-binjeeclick-node-js-kirim-sbd-ke-upvoter-5-20170925t032301231z
categoryindonesia
json_metadata{"tags":["indonesia"],"app":"steemit/0.1"}
created2017-09-25 03:23:00
last_update2017-09-25 03:23:00
depth1
children1
last_payout2017-10-02 03:23:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length212
author_reputation2,167,681,459,353
root_title"Node.js - Kirim SBD ke Upvoter #5"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id15,847,177
net_rshares0
@binjeeclick ·
$0.37
intinya saya cuma sharing ilmu tentang pemakaian steem.js dalam membuat website app,..
bila anda ikuti seperti yang telah saya uraikan, semua akan berjalan dengan baik, hanya perlu copas script nya aja,..
👍  , , , , , , , , , , ,
properties (23)
authorbinjeeclick
permlinkre-bukhairidin-2017925t112743523z
categoryindonesia
json_metadata{"tags":"indonesia","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-09-25 04:27:48
last_update2017-09-25 04:27:48
depth2
children0
last_payout2017-10-02 04:27:48
cashout_time1969-12-31 23:59:59
total_payout_value0.361 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length204
author_reputation2,553,417,069,149
root_title"Node.js - Kirim SBD ke Upvoter #5"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id15,850,201
net_rshares109,693,292,698
author_curate_reward""
vote details (12)
@jufni ·
Mantaf men......makasih ilmunya, akan  ana coba. Semoga bermamfaat!!
properties (22)
authorjufni
permlinkre-binjeeclick-node-js-kirim-sbd-ke-upvoter-5-20170927t095335346z
categoryindonesia
json_metadata{"tags":["indonesia"],"app":"steemit/0.1"}
created2017-09-27 09:53:42
last_update2017-09-27 09:53:42
depth1
children0
last_payout2017-10-04 09:53:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length68
author_reputation38,022,962,008
root_title"Node.js - Kirim SBD ke Upvoter #5"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id16,066,292
net_rshares0
@kyawhlaing ·
a good post! thanks for sharing knowledge.
properties (22)
authorkyawhlaing
permlinkre-binjeeclick-node-js-kirim-sbd-ke-upvoter-5-20170927t095357843z
categoryindonesia
json_metadata{"tags":["indonesia"],"app":"steemit/0.1"}
created2017-09-27 09:54:03
last_update2017-09-27 09:54:03
depth1
children0
last_payout2017-10-04 09:54:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length42
author_reputation6,006,644,313,880
root_title"Node.js - Kirim SBD ke Upvoter #5"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id16,066,323
net_rshares0