Development
...
Dispatch Transactions
Burn Token
1 min
burning a token or even signa is very easy actually, it is just sending the desired quantity to the burn address 0 but signumjs also provides a slightly more comfortable method const {ledgerclientfactory} = require("@signumjs/core"); const {chainvalue} = require("@signumjs/util"); const {generatemasterkeys} = require("@signumjs/crypto"); const ledgerhosturls = { testnet 'http //localhost 6876', mainnet 'https //europe signum network', } async function minttoken(args) { try { const {ledgertype, tokenid, toburn, passphrase} = args // we create our client depending on the parameter const ledger = ledgerclientfactory create({ nodehost ledgerhosturls\[ledgertype]) } // before we can send we need to get the private signing key from the user const {publickey senderpublickey, signprivatekey senderprivatekey} = generatemasterkeys(passphrase) // now, we check the token for existance, but also fetching its decimals // such we can compute the quantity to be minted console info("checking token ") const {decimals, name} = await ledger asset getasset({assetid tokenid}) // the token quantity is being determined by the given supply and decimals it's similar to the concept of signa vs planck, // but with dynamic decimals (0 8) the formula to calculate the quantity is qnt = amount (10^decimals) // to simplify the devs life we can use the value object `chainvalue` which allows us to convert from and to quantity // instead of using the name planck/signa the name atomic/compound is used const quantity = chainvalue create(decimals) setcompound(toburn) getatomic() // now, we execute the transaction // within the method the local signing flow is being executed, i e // the private key is used only locally for signinh, but never sent over the network const {transaction} = await ledger asset burnasset({ asset tokenid, quantity, feeplanck, senderpublickey, senderprivatekey }) // now, some final nice message console info(`burnt ${amount} coins of token ${name} transaction id ${transaction}`) } catch (e) { // if the api returns an exception, // the return error object is of type httperror handleerror(e); } } // // our entry point has to be async, as our subsequent calls are // // this pattern keeps your app running until all async calls are executed (async () => { await issuetoken({ ledgertype 'testnet', tokenid '1234', toburn 100, passphrase 'yourverysecretpassphrasewhichcannotberevealedhere' }); })();