Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (44 sloc) 1.51 KB
/*
*
* Copyright 2018 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {
Account,
Address,
Deadline,
NetworkType,
PlainMessage,
TransactionHttp,
TransferTransaction,
XEM,
} from 'nem2-sdk';
// 01 - Create Transfer Transaction
const recipientAddress = Address.createFromRawAddress('SD5DT3-CH4BLA-BL5HIM-EKP2TA-PUKF4N-Y3L5HR-IR54');
const transferTransaction = TransferTransaction.create(
Deadline.create(),
recipientAddress,
[XEM.createRelative(10)],
PlainMessage.create('Welcome To NEM'),
NetworkType.MIJIN_TEST);
// 02 - Signing the transaction
const privateKey = process.env.PRIVATE_KEY as string;
const account = Account.createFromPrivateKey(privateKey,NetworkType.MIJIN_TEST);
const signedTransaction = account.sign(transferTransaction);
// 03 - Announcing the transaction
const transactionHttp = new TransactionHttp('http://localhost:3000');
transactionHttp
.announce(signedTransaction)
.subscribe(x => console.log(x), err => console.error(err));