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:
- airdrops
- claimdrops
- comments
- crittermanager
- dice
- distribution
- hivepegged
- inflation
- market
- marketmaker
- marketpools
- mining
- nft
- nftairdrops
- nftauction
- nftmarket
- packmanager
- sscstore
- tokenfunds
- tokens
- 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:
- airdrops
- claimdrops
- comments
- crittermanager
- dice
- distribution
- hivepegged
- inflation
- market
- marketmaker
- marketpools
- mining
- nft
- nftairdrops
- nftauction
- nftmarket
- packmanager
- sscstore
- tokenfunds
- tokens
- 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)
Leave hive-engine: How to retrieve data - Wie Daten abrufen to:
Read more #hive-169321 posts
Best Posts From hive-coding
We have not curated any of hive-coding's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From hive-coding
- Google VS ChatGPT (Plesk), and the winner is
- HiveSQL: Time of posts / Uhrzeit der Posts
- HiveSQL: Unused Hivepower - Ungenutze Hivepower
- HiveSQL: Age of active accounts
- HiveSQL: Monthly Active Users / User Registrations / Monthly Posts & Comments
- beneficiaries from DHF- begünstigte vom DHF
- HiveSQL: Top 100 HBD holders HiveSQL: Top 100 HBD Besitzer
- Which frontend ist used for Posting - Welches Frontend wird fürs Posten genutzt?
- KE with hive.min.js not possible - KE mit hive.min.js nicht möglich
- Get KE in HiveSQL - KE mit HiveSQL abfragen
- SPlex.gg Attack-Hide and Sort -Update
- SPlex.gg Attack-Hide and Sort
- hive-engine: How to retrieve data - Wie Daten abrufen
- Hivekeychain: how to send a comment - Wie sendet man ein Kommentar
- Keychain: How to sell your Dust Token - Wie verkauft man seine Staub-Token #19
- Hive-Engine: How to sell your Dust Token - Wie verkauft man seine Staub-Token
- HSBI API: Show Sponsor with HSBI unit and Date - Sponsoren anzeigen mit der HSBI Anzahl und dem Datum
- HiveJS: How to get current Voting Power ? - Wie erhält man die aktuelle Voting Power? #17
- HiveJS: get info and vote for witness - Informationen erhalten und für Witness voten #16
- Hivejs: How to delegtae hivepower - Wie delegiert man Hivepower? # 15