Hivejs: How to transfer Hive,HBD,EcencyPoints and HiveEngine Token?- Wie transferiert man Hive,HBD Ecencypunkte und HiveEingine Token? #9

avatar

EN

My last post was about additional options for posts and comments.
This time it's about how you send Hive, HBD, Ecency points and HiveEngine tokens with Hivej's

For this we need different functions to do all this.

Transfer Hive and HBD

For Hive and HBD we need the function hive.broadcast.transfer for the Ecency points and HiveEngine tokens the function hive.broadcast.customJson

The function hive.broadcast.transfer is self-explanatory and exceptionally well documented, as you can see on the picture. Actually, I don't have to say anything else, but I'll do it anyway.

  • wif your private active key for the account you are broadcasting from.
    from the account you are sending from.
  • to the account you want to send to
  • amount the amount and which asset you want to send. Must have 3 digits after the decimal point, "1 HBD" will not work, it must be "1,000 HBD".

So you can't really do anything wrong, unless you make a mistake with amount, but for that there is the function [hive.formatter.amount](hive.formatter.amount(amount, asset)).

Just pass as parameter the amount and the asset, i.e. HIVE or HBD and you will get back the correct format.

Transfer Ecency points

To transfer Ecency you have to use the function hive.broadcast.customJson. With this function you can transfer not only ecency points, but a lot more. What else is possible, I will show in another post.

There can only be one transfer per call, if you want to transfer ecency points to more than one user, you have to call the function for each transfer separately.

  • wif the private active key to the account you are transferring from
  • requiredAths With the customJson function it is important that you pass the sender as an array to the function, hence the square brackets. There is probably the possibility to specify more than one for other uses.
  • requiredPostingAuths is not needed here, therefore null
    id "ecency_point_transfer" must be passed, for the transfer of ecency points.
    json is the heart of the function, because in the json string is written what should happen

In line 113-117 you see how the structure of the data must be, which is then passed as Json. It is expected sender, receiver, amount and memo.
Again, ammount must be specified with 3 digits after the comma and with the asset ESTM. Memo may be an empty string.

As mentioned, unfortunately only one transfer can be performed per call. There is also a restriction, so you can't just do 10 transfers at once.

Transfer Hive Engine tokens

You can also transfer the Hive Engine tokens with the function hive.broadcast.customJson. Unlike ecency points, you can send several different tokens with one call and also send them to different users. There will surely be a limit to how many transfers are allowed per call. If I find out, I will add that here.

The transfer differs to the ecency points in the id and the json.

The id must be "ssc-mainnet-hive".

In line 88-98 you can see how the json has to look like.
The contractName must be "tokens", the contractAction "transfer".
The contractPayload consists of the symbol of the token to be transferred, the recipient (to), the amount (quantity) and of course the message (memo). Here it is important to note that quantity must be passed as a string!

If you want to do several transfers at once, you have to do the lines 88-98 several times.

So all in all it is quite simple, you just have to pay attention to a few things. One or the other thing I noticed by writing this post. I hope this helps you and that it was understandable.

You can find the example here, use it only locally, never enter your private active key on jsfiddle!

If you have any questions, feel free to leave a comment. It's best to mention @mein-senf-dazu, so I can see it.

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

DE

In meinem letzten Beitrag ging es um zusätzliche Optionen für Postings und Kommentare.
Dieses Mal geht es darum, wie ihr mit Hivejs Hive, HBD, Ecencypunkte und HiveEngine Token versendet.

Dafür benötigen wir unterschiedliche Funktionen, um das alles machen zu können.

Hive und HBD transferieren

Für Hive und HBD benötigen wir die Funktion hive.broadcast.transfer für die Ecencypunkte und HiveEngine Token die Funktion hive.broadcast.customJson

Die Funktion hive.broadcast.transfer ist selbsterklärend und ausnahmsweise sehr gut dokumentiert, wie ihr auf dem Bild sehen könnt. Eigentlich müsste ich nichts weiter sagen, aber ich mache es dennoch.

  • wif Euer privater Aktiv Schlüssel für den Account von dem ihr versendet.
  • from der Account von dem ihr versendet
  • to der Account an den ihr senden wollt
  • amount der Betrag und welches Asset ihr versenden wollt. Muss 3 Stellen nach dem Komma haben, "1 HBD" funktioniert nicht, es muss "1.000 HBD" lauten.

Man kann also eigentlich nichts falsch machen, außer man macht bei amount einen Fehler, aber dafür gibt es die Funktion [hive.formatter.amount](hive.formatter.amount(amount, asset)).

Einfach als Parameter den Betrag und das Asset, also HIVE oder HBD übergeben und man erhält das korrekte Format zurück.

Ecencypunkte transferieren

Zum transferieren von Ecency muss die Funktion hive.broadcast.customJson verwendet werden. Mit dieser Funktion kann man nicht nur Ecencypunkte transferieren, sondern noch einiges. Was noch möglich ist, werde ich noch in einem weiteren Beitrag zeigen.

Es kann immer nur ein Transfer pro Aufruf erfolgen, möchte man Ecencypunkte an mehrere Nutzer transferieren, so muss man für jeden Transfer die Funktion einzeln aufrufen.

  • wif der private Aktiv-Schlüssel zum Account von dem ihr versendet
  • requiredAths Bei der Funktion customJson ist es wichtig, dass ihr den Absender als Array an die Funktion übergebt, daher die eckigen Klammern. Es gibt wohl die Möglichkeit mehrere anzugeben für andere Anwedungsmöglichkeiten.
  • requiredPostingAuths wird hier nicht benötigt, daher null
  • id "ecency_point_transfer" muss übergeben werden, für den transfer von Ecencypunkten.
  • json ist sozusagen das Herzstück der Funktion, denn in dem Json-String steht drin, was passieren soll

In Zeile 113-117 seht ihr wie der Aufbau der Daten sein muss, was dann als Json übergeben wird. Es wird sender, receiver, amount und memo erwartet.
Dabei muss auch hier ammount mit 3 Stellen hinter dem Komma und mit dem Asset ESTM angegeben werden. Memo darf ein leerer String sein.

Wie erwähnt, kann man leider pro Aufruf nur ein Transfer durchführen. Zudem gibt es eine Beschränkung, sodass man nicht einfach 10 Transfers auf mal nacheinander machen kann.

Hive Engine Token transferieren

Auch die Hive Engine Token transferiert man mit der Funktion hive.broadcast.customJson. Anders als bei den Ecencypunkten kann man mehrere unterschiedliche Token mit einem Aufruf versenden und auch an unterschiedliche Nutzer senden. Es wird sicherlich ein Limit geben, wie viele Transfers pro Aufruf erlaubt sind. Sollte ich das herausfinden, werde ich das hier ergänzen.

Der Transfer unterscheidet sich zu den Ecencypunkten in der id und dem Json.

Als id muss hier "ssc-mainnet-hive" übvergeben werden.

In Zeile 88-98 seht ihr wie das Json auszusehen hat.
als contractName muss "tokens" angegeben werde, als contractAction "transfer".
Der contractPayload besteht aus Symbol des Token, der transferiert werden soll, der Empfänger (to), der Betrag (quantity) und natürlich die Nachricht (memo). Hier ist wichtig anzumerken, dass quantity als String übergeben werden muss!

Möchtet ihr auf einmal mehrere Transfers durchführen, so müsst ihr die Zeilen 88-98 mehrfach durchführen.

Also alles in allem doch recht simpel, man muss nur paar Sachen beachten. Das eine oder andere ist mir durch das Schreiben dieses Beitrages erst aufgefallen. Hoffe Euch hilft das weiter und dass es soweit verständlich war.

Das Beispiel findet ihr hier, nutzt diesen nur Lokal, gebt nie euren privaten Aktiv-Schlüssel auf jsfiddle ein!

Wer Fragen hat, kann gern ein Kommentar da lassen. Am besten @mein-senf-dazu erwähnen, damit ich es mitbekomme.



0
0
0.000
7 comments
avatar

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

You received more than 700 upvotes.
Your next target is to reach 800 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 the last post from @hivebuzz:

CBRS Hive Infographic Contest - Get your badge and win 1000 HIVE
Our Hive Power Delegations to the October PUM Winners
Support the HiveBuzz project. Vote for our proposal!
0
0
0.000
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

Thanks for this step to step written piece on ways to transfer Hive, HBD and Ecency points.

0
0
0.000
avatar

You quite did a nice lecture on the topic on transfers keep up the good work 👍

0
0
0.000