[steemit] How to migrate your DAPPS to Hive - Script 2: WHERE IS MY HONEY?? {dsteemJS}

in #hive5 years ago (edited)

Here is how you can check you balance on https://hive.blog using dsteemJS:

NOTE:
This script does not requires a pre-existing Steemit account or any private key so it's very safe to use.

If you're the paranoid type feel free to log out, use a different browser, use incognito, etc. This script does not require authentication.

STEP 1


Open your favorite browser on any site (I strongly recommend using Brave browser for its speed and security)
and open the DevTools (Ctrl + Shift + J on Linux/Windows and Cmd + Opt + J on Mac)

STEP 2


Open https://unpkg.com/[email protected]/dist/dsteem.js(dsteemJs) and copy & paste (Ctrl + A and Ctrl + C) the javascript code displayed on the page into the Browser Console (DevTools) that you opened in the first tab.

STEP 3

  • Copy & paste my script below in the Console
  • Change the value of targetAccount (first line of the script) with your account name
  • Press enter.
var targetAccount = 'gaottantacinque';

var opts = { addressPrefix: 'STM' };
var client = new dsteem.Client('https://api.hive.blog');

var getAccountInfo = async () => {
  const account = await client.database.call(
    'get_accounts',
    [[targetAccount]],
  );
  const { balance, savings_balance, sbd_balance } = account[0];
  console.log(JSON.stringify({
    balance, savings_balance, sbd_balance,
  }));
};
getAccountInfo();

// OUTPUT:
// {"balance":"13.709 HIVE","savings_balance":"0.000 HIVE","sbd_balance":"1.136 HBD"}



Enjoy & HIVE ON!!   =]

Sort:  

You prefer running this as a nodeJs script?


Here are the steps:

  • Download NodeJs on your machine
  • Create a new folder for your project via terminal - eg. mkdir hello-hive
  • Navigate into the newly created folder - eg. cd hello-hive
  • Initialize npm: npm init and (to keep it simple) keep pressing enter until you get back control of the terminal
  • Create a file named index.js, copy my code snippet above and add this 1 line at the top: const dsteem = require('dsteem');
  • Execute: npm install --save dsteem

You can now execute the script running: node index.js

Upvoted and resteemed

You prefer running this as a nodeJs script?


Here are the steps:

  • Download NodeJs on your machine
  • Create a new folder for your project via terminal - eg. mkdir hello-hive
  • Navigate into the newly created folder - eg. cd hello-hive
  • Initialize npm: npm init and (to keep it simple) keep pressing enter until you get back control of the terminal
  • Create a file named index.js, copy my code snippet above and add this 1 line at the top: const dsteem = require('dsteem');
  • Execute: npm install --save dsteem

You can now execute the script running: node index.js😎

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.038
BTC 96907.08
ETH 3380.66
USDT 1.00
SBD 3.23