-
Notifications
You must be signed in to change notification settings - Fork 8
Harvester Transaction
Chun Lam edited this page Feb 21, 2024
·
2 revisions
import { Deadline, NetworkType, HarvesterTransaction,
Account, PublicAccount, TransactionHttp } from "tsjs-xpx-chain-sdk";
const API_URL = 'http://localhost:3000';
const networkType = NetworkType.TEST_NET;
const generationHash = "56D112C98F7A7E34D1AEDC4BD01BC06CA2276DD546A93E36690B785E82439CA9"; // from block 1
const transactionHttp = new TransactionHttp(API_URL);
const signerAccount = Account.createFromPrivateKey(
'<your_privateKey>',
networkType, 1);
const harvesterPublicAccount = PublicAccount.createFromPublicKey('<harvesterPublicKey>', networkType);
// add harvester transaction
let addHarvesterTransaction = HarvesterTransaction.createAdd(
Deadline.create(),
harvesterPublicAccount,
networkType
)
let signedAddHarvesterTransaction = signerAccount.preV2Sign(addHarvesterTransaction, generationHash);
console.log("AddHarvesterTxn Hash: ", signedAddHarvesterTransaction.hash);
transactionHttp.announce(signedAddHarvesterTransaction);
// remove harvester transaction
let removeHarvesterTransaction = HarvesterTransaction.createRemove(
Deadline.create(),
harvesterPublicAccount,
networkType
)
let signedRemoveHarvesterTransaction = signerAccount.preV2Sign(removeHarvesterTransaction, generationHash);
console.log("RemoveHarvesterTxn Hash: ", signedRemoveHarvesterTransaction.hash);
transactionHttp.announce(signedRemoveHarvesterTransaction);