RE: 10 SBD SteemJS Programming Question
The post in question ’30-sbd-webgl-screen-capture-contest’ has 119 reblogs.
Full results as json in this gist.
Node.js example tested and working using SteemSQL database (you will need a user/pass see below)
const sql = require('mssql');
const config = {
user: 'username',
password: 'password',
server: 'vip.steemsql.com',
database: 'DBSteem',
}
sql.connect(config).then(pool => {
return pool.request()
.query("SELECT dbo.Reblogs.* FROM dbo.Reblogs WHERE permlink = '30-sbd-webgl-screen-capture-contest'")
}).then(result => {
console.dir(result)
})
sql.on('error', err => {
})
Result will contain an array with all of the accounts who reblogged you and the timestamp of the reblog.
Explanation
Unfortunately Re-blogs are not stored on the post that has been re-blogged :(. I'm not sure why but you're right reblogged_by
will always be empty. I know, it seems a bit ridiculous.
Reblogs are created as custom json and broadcast to the network like so -
let ACCOUNT_NAME = ‘’
let ACCOUNT_KEY = ‘’
const json = JSON.stringify(['reblog', {
account: ACCOUNT_NAME,
author: ‘money-dreamer’,
permlink: '10-sbd-steemjs-programming-question'
}]);
steem.broadcast.customJson( ACCOUNT_KEY, [], [ACCOUNT_NAME], 'follow', json, function(err, result) {
console.log(err, result);
});
Unfortunately like you’ve found there is almost zero information about reblog on the steem-js library. You can not get reblog directly from the API but there is still hope.
The options
a) Create your own record of transactions. Stream block operations as they come in and database them. You can then search where there is a custom json transaction that matches your name/permlink. You’ll need to retrospectively go through each Steem block and database the transactions to get a complete set of data.
b) Use a third party set of data. Steemsql and steemdata are two that I know of. The bad news is that steemdata looks like it’s currently down (just tried connecting to the db, no good and the web api is not responding). Steemsql is now a subscription service costing 10SBD a month or 1SBD a day. https://sql.steemhelpers.com/ was exactly what you needed but is also currently down :(.
Results/What I did
I signed up to the SteemSQL service on the 1day plan to test my theory for you. I used Navicat SQL explorer at first to explore the SQL Databse and there is a helpful reblog table setup to save having to search through all json transactions.
The example I created uses mssql npm package to connect to the sql server. You’ll need a username and password by subscribing to steemsql for a day or month.
p.s thanks to @arcange who runs SteemSQL and helped me get the Database setup when I couldn't connect.
Thanks. I sent the 10 SBD. I still would like the code to read directly from the blockchain as you stated in option a. Do you know of any code examples that do that? I'm only going back 7 days and it will only be run periodically (say, once per day) so that shouldn't be too bad. Or, I could just start a listener and collect new transactions as they come in right when the contest post is created. Thanks!
Sorry if I'm late to the party. I am doing the inverse of what you're looking for.
https://github.com/r351574nc3/steem-bot-examples/blob/0f2867fd3f80c0c30f0271c05071d5c41363408a/auto-reply-steem-bot/app/helpers/bot/reply.js#L118
My example uses
getDiscussionsByBlog
to retrieve blog entries. I only wanted my unique entries, but the results were returning resteems.I ended up writing this to filter out resteems
https://github.com/r351574nc3/steem-bot-examples/blob/0f2867fd3f80c0c30f0271c05071d5c41363408a/auto-reply-steem-bot/app/helpers/bot/reply.js#L41
If
results.id == 0
, that means it's a resteem. I used the inverted condition to filter those out. Hope this helps. You can run this periodically.Thank you for the reward @money-dreamer, I had not done this before and enjoyed investigating and finding a solution. I've not seen any examples of Option A code it's been on my to "make tutorial" list but I've not got around to it just yet. If I would be helpful to you I will do that next and try to get it online asap?
Yes. That would be great. I want to learn how to read all the data directly from each block - maybe getMostRecentBlock and getBlockNumber.
Also, if there is some way to listen to new transactions being broadcast to the blockchain from within Node, that would be useful.
yes It's possible with those functions, have been super busy. Aiming to get a demo/tutorial online tomorrow.
For anyone interested that tutorial is now here -https://steemit.com/utopian-io/@sambillingham/tutorial-reblog-contest-building-with-steem-js-10
I see that SteemWorld uses wss://rpc.buildteam.io/ to fetch the data: {id: 317, method: "call", params: [5, "get_reblogged_by", ["money-dreamer",...
I'm looking at your tutorial using buildteam.io:
https://utopian.io/utopian-io/@sambillingham/tutorial-beginner-friendly-build-your-first-steem-bot-in-javascript-30minutes
Does that information contain the
get_reblogged_by
?I was only using buildteam.io while the default steem-js endpoint was down and before the library was updated. I'm not sure they have any different data running but I'll look into it. Good thinking to look into what SteemWorld uses.
@sambillingham
An offbeat question. What tool do you use on MAC to connect to MSSQL server. I couldn't find a decent mssql client for Macos.