Skip to content

Instantly share code, notes, and snippets.

@joeneldeasis
Created November 30, 2019 13:07
Show Gist options
  • Save joeneldeasis/00deae4d0a7bf34c898014d1a0ec6163 to your computer and use it in GitHub Desktop.
Save joeneldeasis/00deae4d0a7bf34c898014d1a0ec6163 to your computer and use it in GitHub Desktop.

Revisions

  1. joeneldeasis created this gist Nov 30, 2019.
    38 changes: 38 additions & 0 deletions mosaicTransfer.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import {
    MosaicId,
    UInt64,
    Address,
    TransferTransaction,
    Deadline,
    Account,
    NetworkType,
    Mosaic,
    TransactionHttp,
    PlainMessage,
    } from "tsjs-xpx-chain-sdk";

    const amount = 100;
    const privateKey = "private-key-here" //put your private key here
    const toAddress = "VBHYO3-4QPRVF-QI4DVA-BWWEHK-BK2GWZ-RBOCFH-CFBJ" //put your address here

    const networkGenerationHash = "56D112C98F7A7E34D1AEDC4BD01BC06CA2276DD546A93E36690B785E82439CA9";
    const httpNode = "https://bctestnet3.brimstone.xpxsirius.io";

    const transactionHttp = new TransactionHttp(httpNode);

    const sender = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);
    const recipient = Address.createFromRawAddress(toAddress);

    const transferTransaction = TransferTransaction.create(
    Deadline.create(),
    recipient,
    [new Mosaic(new MosaicId("25446640478c3b84"), UInt64.fromUint(amount))],
    PlainMessage.create("mosaic transfer"),
    NetworkType.TEST_NET
    );

    const signedTransaction = sender.sign(transferTransaction, networkGenerationHash);

    transactionHttp.announce(signedTransaction);

    console.log("tx: ", signedTransaction);