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
const ledger = LedgerClientFactory.create({
nodeHost: LedgerHostUrls[ledgerType])
}
const {publicKey: senderPublicKey, signPrivateKey: senderPrivateKey} = generateMasterKeys(passphrase)
const feePlanck = Amount.fromSigna(150).getPlanck()
const quantity = ChainValue.create(decimals).setCompound(supply).getAtomic()
const {transaction} = await ledger.asset.issueAsset({
name,
description,
decimals,
mintable,
quantity,
feePlanck,
senderPublicKey,
senderPrivateKey
})
console.info(`Token ${name} successfully created - Token Id: ${transaction}`)
} catch (e) {
handleError(e);
}
}
(async () => {
await issueToken({
ledgerType: 'TestNet',
name: 'INDI2000',
description: 'A 1000 chars description...'
supply: 100,
decimals: 4,
mintable: false,
passphrase: 'YourVerySecretPassphraseWhichCannotBeRevealedHere'
});
})();