Here is how you can programmatically retrieve a Steemit account's last transaction

in #steemit4 years ago (edited)

This simple tutorial teaches you how to programmatically retrieve a Steemit account's last transactions simply pasting a script in any browser window.

NOTES:

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

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://cdn.jsdelivr.net/npm/steem/dist/steem.min.js (SteemJs) 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 and press enter.

Before doing so, if you want, you can change the target account name and the amount of transactions that you want to retrieve (eg. Instead of 'transisto' and 6 you can use 'marcocasario' and 3). Or leave it as it is to first give it a try..

var getLastNTransactions = (user, N) => new Promise((resolve) => {
  steem.api.getAccountHistory(user, -1, 5000, (err, result = []) => {
    if (err) return console.error('>>> ', err);
    const res = [];
    for (let id = 0; id < result.length; id++) {
      if (result[id][1].op[0] === 'transfer') {
        // console.log(JSON.stringify(result[id]))
        res.push(result[id]);
      }
    }
    const last500Transactions = res.reverse();
    resolve(last500Transactions.slice(0, N));
  });
});
getLastNTransactions('transisto', 6)
  .then(res => console.log('OK >> ', JSON.stringify(res)))
  .catch(err => console.error('Oops, something went wrong:', err));



If you then want to execute the script again for a different user, you only need to paste it again, change what you need and press enter again.

Enjoy!! =]

Sort:  

Awesome post! So awesome we resteemed it and gave it a 100% upvote, including our Steemauto fanbase. Follow @theresteemer5000 for a higher chance to be resteemed and upvoted more often.

!DERANGED
!COFFEEA
!shop
$trdo
!BEER
for you

@tipu curate


Hey @gaottantacinque, here is a little bit of BEER from @eii for you. Enjoy it!

Learn how to earn FREE BEER each day by staking.


Questo post è stato condiviso e votato all'interno del discord del team curatori di discovery-it.
This post was shared and voted inside the discord by the curators team of discovery-it


@gaottantacinque, mi aiuti per favore! con chi posso parlare per risolvere il mio problema? io scrivo i miei articoli originali su steemit. ogni giorno e' uno articolo. Ho visto che mack-bot mi fa dislake. Chi potrebbe controlare il mio articolo che io non faccio niente di male. Mi aiuti per piacere. Grazie.

Vai sul profilo @steemflagrewards, apri il link discord e spiega la situazione lì.

Devi postare solo contenuti originali, no tradotti da altri articoli, no riassunti, no foto non tue senza fonte.
Spero tu risolva presto

@marcocasario, grazie per il tuo consiglio

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.031
BTC 68943.86
ETH 3749.76
USDT 1.00
SBD 3.67