Created
November 30, 2019 13:07
-
-
Save joeneldeasis/00deae4d0a7bf34c898014d1a0ec6163 to your computer and use it in GitHub Desktop.
Mosaic Transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For javascript: