-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathburn-all-tokens.js
47 lines (37 loc) · 1.33 KB
/
burn-all-tokens.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
45
46
47
/*
An example for burning tokens with this library.
*/
const SlpWallet = require('../index')
async function burnTokens () {
try {
// Replace the values for the constants below to customize for your use.
const MNEMONIC =
'essence appear intact casino neck scatter search post cube fit door margin'
// bitcoincash:qzl40sfyyqlmgc44y6rqjsarpyr3j9alnqyuqcwjc5
const TOKENID =
'6201f3efe486c577433622817b99645e1d473cd3882378f9a0efc128ab839a82'
// Instantiate the wallet library.
const slpWallet = new SlpWallet(MNEMONIC)
// Wait for the wallet to be created.
await slpWallet.walletInfoPromise
console.log(`wallet info: ${JSON.stringify(slpWallet.walletInfo, null, 2)}`)
// console.log('slpWallet.utxos.utxoStore: ', slpWallet.utxos.utxoStore)
// Get the balance of the wallet.
const balance = await slpWallet.getBalance()
console.log(`balance: ${balance} satoshis`)
// Exit if the wallet has no balance.
if (balance === 0) {
console.log(
`The balance of your wallet is zero. Send BCH to ${
slpWallet.walletInfo.address
} to run this example.`
)
return
}
const txid = await slpWallet.burnAll(TOKENID)
console.log(`Success! Tokens burnt with TXID: ${txid}`)
} catch (err) {
console.error('Error: ', err)
}
}
burnTokens()