forked from hedera-dev/hedera-code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.js
44 lines (36 loc) · 1.36 KB
/
delete.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {
Client,
AccountId,
PrivateKey,
TokenDeleteTransaction,
} from '@hashgraph/sdk';
import dotenv from 'dotenv';
dotenv.config();
// ensure required environment variables are available
if (!process.env.OPERATOR_ID ||
!process.env.OPERATOR_KEY ||
!process.env.HTS_FT_ID) {
throw new Error('Must set required keys in .env');
}
// configure client using environment variables
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const client = Client.forTestnet().setOperator(operatorId, operatorKey);
// entry point for execution of this example (called at the bottom of the file)
async function main() {
// delete the fungible token
const ftDeleteTx = await new TokenDeleteTransaction()
.setTokenId(process.env.HTS_FT_ID)
.freezeWith(client);
const ftDeleteTxSigned = await ftDeleteTx.sign(operatorKey);
const ftDeleteTxSubmitted = await ftDeleteTxSigned.execute(client);
const ftDeleteTxRecord = await ftDeleteTxSubmitted.getRecord(client);
console.log('ftDeleteTxRecord', transactionHashscanUrl(ftDeleteTxRecord));
// force exit
process.exit(0);
}
function transactionHashscanUrl(txRecord) {
const txId = txRecord.transactionId.toString();
return `https://hashscan.io/testnet/transaction/${txId}`;
}
main();