Here is how you can easily get balances of a list of Steemit accounts programmatically (+ max values)
STEP 1
Open your favorite browser on any site (I strongly recommend to use Brave browser)
and open the DevTools (
Ctrl + Shift + J
on Linux/Windows and Cmd + Opt + J
on Mac)
STEP 2
Open 2 tabs:
https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js (SteemJs)
https://unpkg.com/[email protected]/dist/dsteem.js (Dsteem.js)
and copy and paste (
Ctrl + A
and Ctrl + C
) the content of both pages into the Browser Console (DevTools).
STEP 3
Copy and paste my script below in the Console:
var USERS_TO_CHECK = ['cribbio', 'gasaeightyfive', 'marcocasario', 'gaottantacinque'];
var results = {};
var maxes = {
balances: {
sp: { user: null, value: 0 },
steem: { user: null, value: 0 },
sbd: { user: null, value: 0 },
},
followers: { user: null, value: 0 }
};
var client = new dsteem.Client('https://api.steemit.com');
var getAccounts = (username) => new Promise((resolve, reject) => {
steem.api.getAccounts([username], (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
var getProps = () => new Promise((res, rej) => {
steem.api.getDynamicGlobalProperties((err, result) => {
if (err) rej(err);
else res(result);
});
});
var getSteemPower = (username) => {
return Promise.all([
getAccounts(username),
getProps(),
]).then(([user, globals]) => {
const totalSteem = Number(globals.total_vesting_fund_steem.split(' ')[0]);
const totalVests = Number(globals.total_vesting_shares.split(' ')[0]);
const userVests = Number(user[0].vesting_shares.split(' ')[0]);
return totalSteem * (userVests / totalVests);
});
};
// const sp = await getSteemPower('cribbio');
var getBalances = (username) => new Promise((resolve, reject) => {
steem.api.getAccounts([username], (err, [{ balance, savings_balance, sbd_balance }]) => {
if (err) reject(err);
else resolve({
steem: +balance.split(' ')[0] + +savings_balance.split(' ')[0],
sbd: +sbd_balance.split(' ')[0],
});
});
});
// getBalances('cribbio').then(console.log);
var getFollowers = targetUser => new Promise((resolve) => {
const options = [
targetUser,
'',
'blog',
1000, // MAX 1000 results :(
];
client.call('follow_api', 'get_followers', options)
.then((result) => {
resolve(result.length);
});
});
// getFollowers('cribbio').then(res => console.log('followers: ', res));
var getInfo = (user) => {
return Promise.all([getSteemPower(user), getBalances(user), getFollowers(user)])
.then(([res1, res2, res3]) => ({
steemPower: res1,
balances: res2,
followers: res3
}));
};
var run = async () => {
for (let id = 0; id < USERS_TO_CHECK.length; id++) {
const currentUser = USERS_TO_CHECK[id];
const currentInfo = await getInfo(currentUser);
results[currentUser] = currentInfo;
const { steemPower, balances: { steem, sbd }, followers } = currentInfo;
if (steemPower > maxes.balances.sp.value) { maxes.balances.sp = { user: currentUser, value: steemPower }; }
if (steem > maxes.balances.steem.value) { maxes.balances.steem = { user: currentUser, value: steem }; }
if (sbd > maxes.balances.sbd.value) { maxes.balances.sbd = { user: currentUser, value: sbd }; }
if (followers > maxes.followers.value) { maxes.followers = { user: currentUser, value: followers }; }
}
console.log({ results, maxes });
};
run();
STEP 4
[Optional] Change the variable at the very top ( USERS_TO_CHECK
) with the users that you would like to check.
STEP 5
Press enter and click on the result to expand the various sections of the response.
If you want to retry with different users simply paste the script again, change the top variable and press enter again.
Enjoy!! =]
NOTE:
This script is completely safe as it does not require any sort of keys to work!
PS. Ah, I forgot to mention. The output will also tell you which user has the highest amount of SP, STEEM, SBD and highest amount of followers (see screenshot).
According to the Bible, Is it sin against God if a law enforcer is forced to take someone's life in the line of duty?
(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)
Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to Thank you, our beloved friend.
Check our Discord Chat
Join our Official Community: https://beta.steemit.com/trending/hive-182074