Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Require the Helix libraries
  2. const Helix = require("@helixnetwork/core");
  3. const Converter = require("@helixnetwork/converter");
  4.  
  5. // Create a new instance of the Helix object
  6. // Use the provider field to specify which node to connect to
  7. const helix = Helix.composeAPI({
  8.   provider: "http://hlxtest.net:8085"
  9. });
  10.  
  11. // Sender
  12. const senderSeed =
  13.   "d2ebccb3cff4ea6a6c7ba4d2528cf60c14e0f4d1af762bdda9442efb94cdc857";
  14. const senderAddress =
  15.   "d3bb5bf8b306647ea5ca7e53b3497716e9daa99443a67c17f64cccda572821965477bc51";
  16.  
  17. // Receiver
  18. const receiverSeed =
  19.   "4de4fc4ef7432cb3aaa6e7c8d1d858d52ba935e038746722ffd5da3104aff75e";
  20. const receiverAddress1 =
  21.   "9a8dfc66b22223bf90157a50b00e1628ab49b74617ebcdd605409a7a69c806a8423862b1";
  22.  
  23. // Store the TxBytes that are returned from prepareTransfers function
  24. var storedTxBytes;
  25.  
  26. var transfer = {
  27.   address: receiverAddress1,
  28.   value: 1,
  29.   message: Converter.asciiToTxHex("abcd"),
  30.   tag: Converter.asciiToTxHex("abcd")
  31. };
  32.  
  33. // Create bundle and return the TxBytes of the prepared TXs
  34. helix
  35.   .prepareTransfers(senderSeed, [transfer])
  36.   .then(function(TxBytes) {
  37.     storedTxBytes = TxBytes;
  38.     // Finalize and broadcast the bundle to the node
  39.     return helix.sendTransactionStrings(
  40.       storedTxBytes,
  41.       5 /*depth*/,
  42.       2 /*minimum weight magnitude*/
  43.     );
  44.   })
  45.   .then(results => console.log(results))
  46.   .catch(err => {
  47.     console.log(err);
  48.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement