Created
January 19, 2021 15:02
-
-
Save daoka/ff995973957762793c396c92aa2b77ec to your computer and use it in GitHub Desktop.
UnlinkVotingKey
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 { Account, Deadline, LinkAction, NetworkType, RepositoryFactoryHttp, TransactionService, VotingKeyLinkTransaction } from 'symbol-sdk'; | |
const apiGatewayUrl = 'http://api-01.ap-northeast-1.testnet.symboldev.network:3000'; | |
const networkType = NetworkType.TEST_NET; | |
const generationHash = '45FBCF2F0EA36EFA7923C9BC923D6503169651F7FA4EFC46A8EAF5AE09057EBD'; | |
const epochAdjustment = 1573430400; | |
const repoFactory = new RepositoryFactoryHttp(apiGatewayUrl, { | |
networkType, | |
generationHash | |
}); | |
const accountKey = 'YOUR_MAIN_KEY'; | |
const account = Account.createFromPrivateKey(accountKey, networkType); | |
const votingPublicKey = 'YOUR_VOTING_PUBLIC_KEY' | |
const tx = VotingKeyLinkTransaction.create( | |
Deadline.create(epochAdjustment), | |
votingPublicKey, | |
1, | |
26280, | |
LinkAction.Unlink, | |
networkType, | |
1 | |
).setMaxFee(1000) | |
const signedTx = account.sign(tx, generationHash); | |
const transactionRepo = repoFactory.createTransactionRepository(); | |
const receiptRepo = repoFactory.createReceiptRepository(); | |
const transactionService = new TransactionService(transactionRepo, receiptRepo); | |
const listener = repoFactory.createListener(); | |
listener.open().then(() => { | |
transactionService.announce(signedTx, listener).subscribe((x) => { | |
console.log(x); | |
listener.close(); | |
}, (err) => { | |
console.error(err); | |
listener.close(); | |
}) | |
}).catch((err) => { | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment