hive-engine: How to retrieve data - Wie Daten abrufen

Mein letzter Beitrag ist leider schon fast einen Monat her, in dem ich erklärt habe, wie man mithilfe der Hivekeychain einen Kommentar an die Blockchain sendet.

Hive-Engine

Wer die Hive-Engine nicht kennt, der muss neu bei Hive sein. Ok, vielleicht nutzen manche von euch Tribaldex, ich nutze aus Gewohnheit Hive-engine.

Wer Daten abrufen will, kann dies ganz einfach mit sscjs machen. Am einfachsten ist es, indem man einfach die Dateien einbindet:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sscjs@latest/dist/ssc.min.js"></script>
<script>
    const ssc = new SSC('https://api.hive-engine.com/rpc');
</script>

Find

find(contract, table, query, limit = 1000, offset = 0, indexes = [], callback = null) 

Mit der find-Methode kann man Daten abrufen, dafür benötigt man zunächst contract und table.

Contract

Aber was kann man als contract angeben?

Welche contracts es gibt, findet ihr hier. Der Name jeder js-Datei kann verwendet werden.

Zu diesem Zeitpunkt sind es folgende Contracts:

  1. airdrops
  2. claimdrops
  3. comments
  4. crittermanager
  5. dice
  6. distribution
  7. hivepegged
  8. inflation
  9. market
  10. marketmaker
  11. marketpools
  12. mining
  13. nft
  14. nftairdrops
  15. nftauction
  16. nftmarket
  17. packmanager
  18. sscstore
  19. tokenfunds
  20. tokens
  21. witnesses

Da frage ich mich gerade, wo kann man denn NFT versteigern bzw. ersteigern? Da dort nur wenige Auktionen drin sind, scheint es noch recht neu zu sein.

Tables

Nun benötigen wir noch die Tabellen der Contracts. Diese können wir mit der Funktion getContractInfo abrufen.

getContractInfo(contract, callback  =  null)

Mit der Funktion erhalten wir neben dem Code des contractes auch die Tabellennamen. Diese beginnen immer mit dem Contractnamen und einem Unterstrich, jedoch müssen diese ohne diesem in der find-Methode angegeben werden.

Contract hat somit die Tabellen balances, contractsBalances, delegations, params, pendingundelegations, pendingunstakes und tokens als Tabellen.

Um die Kontostände abzurufen, nutzen wir somit die find-Methode wie folgt:

ssc.find('tokens', 'balances', { }, 1000, 0, [], (err, result) => {
console.log(err, result);
});

Hier findet ihr ein kleines Beispiel auf jsFiddle. Ihr könnt in dem Beispiel die Contracts auswählen und dann eine der Tabellen des Contracts. Es wird dann ein Datensatz aus der Tabelle ausgegeben.

EN

My last post was unfortunately almost a month ago, in which I explained how to send a comment to the blockchain using the Hivekeychain.

Hive engine

If you don't know about the Hive Engine, you must be new to Hive. Ok, maybe some of you use Tribaldex, I use Hive-engine out of habit.

If you want to retrieve data, you can do it easily with sscjs. The easiest way is to simply include the files:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sscjs@latest/dist/ssc.min.js"></script>
<script>
    const ssc = new SSC('https://api.hive-engine.com/rpc');
</script>

Find

find(contract, table, query, limit = 1000, offset = 0, indexes = [], callback = null) 

The find method can be used to retrieve data, for which you first need contract and table.

Contract

But what can you specify as a contract?

You can find out which contracts are available here. The name of each js file can be used.

At this time, the following contracts are available:

  1. airdrops
  2. claimdrops
  3. comments
  4. crittermanager
  5. dice
  6. distribution
  7. hivepegged
  8. inflation
  9. market
  10. marketmaker
  11. marketpools
  12. mining
  13. nft
  14. nftairdrops
  15. nftauction
  16. nftmarket
  17. packmanager
  18. sscstore
  19. tokenfunds
  20. tokens
  21. witnesses

I was just wondering, where can NFT be auctioned off? Since there are only a few auctions there, it seems to be quite new.

Tables

Now we need the tables of the contracts. We can get them with the function getContractInfo.

getContractInfo(contract, callback = null)

With this function we get the code of the contract as well as the table names. These always start with the contract name and an underscore, but they have to be given without it in the find method.

Contract thus has the tables balances, contractsBalances, delegations, params, pendingundelegations, pendingunstakes and tokens as tables.

To retrieve the account balances, we thus use the find method as follows:

ssc.find('tokens', 'balances', { }, 1000, 0, [], (err, result) => {
console.log(err, result);
});

Here you can find a small example on jsFiddle. You can select the contracts in the example and then one of the tables of the contract. A record from the table is then output.

Translated with www.DeepL.com/Translator (free version)

Sort:  

Congratulations @hive-coding! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You distributed more than 1500 upvotes.
Your next target is to reach 1750 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

The Hive Gamification Proposal
Support the HiveBuzz project. Vote for our proposal!

Yay! 🤗
Your content has been boosted with Ecency Points, by @hive-coding.
Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for new Proposal
Delegate HP and earn more

!LOL

Testen ob Stake nötig oder auch Holding wirklich auslangt.

What do you say when someone you dislike dies suddenly?
I don't bereave it!

Credit: reddit
@hive-coding, I sent you an $LOLZ on behalf of mein-senf-dazu

(1/6)

PLAY & EARN $DOOM

PIZZA!

$PIZZA slices delivered:
@mein-senf-dazu(1/5) tipped @hive-coding