Development
...
Dispatch Transactions
Issue Token
1 min
an almost unique feature of signum is the native token engine, which does not require any smart contract this makes tokenization efficient, secure and cheap issuing a token costs 150 signa you can define its name (up to ten alphanumeric characters), the divisibility (between zero and eight decimals) and if a token should have a fixed supply, or being mintable once you know how to sign transactions with signumjs, it is pretty straightforward to issue a new token const {ledgerclientfactory} = require("@signumjs/core"); const {chainvalue, amount} = require("@signumjs/util"); const {generatemasterkeys} = require("@signumjs/crypto"); const ledgerhosturls = { testnet 'http //localhost 6876', mainnet 'https //europe signum network', } async function issuetoken(args) { try { const {ledgertype, name, description, supply, mintable, decimals, 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) // issuing a token costs 150 signa const feeplanck = amount fromsigna(150) getplanck() // 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(supply) 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 issueasset({ name, description, decimals, mintable, quantity, feeplanck, senderpublickey, senderprivatekey }) // now, some final nice message console info(`token ${name} successfully created token 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', name 'indi2000', description 'a 1000 chars description ' supply 100, decimals 4, mintable false, passphrase 'yourverysecretpassphrasewhichcannotberevealedhere' }); })();