//console.log("this is testing");
const NODE = 'https://testnet1.neo.coz.io:443' //testnet
const TIME_CONSTANT = 20000

const sdk = require('../sdk_ts/dist')
const Neon = require("@cityofzion/neon-core") //You will need to install this (^5.0.0-next.16)

async function start() {
	//console.log(SCRIPT_HASH);
tmn = await new sdk.TMN({
    node: NODE,
    scriptHash: "0x10c3d1730b957139e81941d036ef5c6699c320b5"

  });
        await tmn.init()

  const symbol = await tmn.symbol() // => "TMN"
  const decimals = await tmn.decimals() // => 8
  const totalSupply = await tmn.totalSupply() // => {{the total supply}}

  console.log(symbol);
  console.log(decimals);
  console.log(totalSupply);


  const pKey = 'L2x9YtzfxVnuKuu2MSSTG6n6xTdTwh9TEz9hgs4rta1geqsvoJLN'
  const adminWallet = new Neon.wallet.Account(pKey)
 //// console.log(adminWallet)

//  const userAddress = 'NcoF6PfwTzyRCULVpVUN8guoJ4unSUqFot'
  const userAddress = 'NWLMCAmqBQ3mv6Z61ndi3btM8op52y3KYT'
  //const newAccount = new Neon.wallet.Account()
//const address = newAccount.address;
//console.log( address )
  const mintPayload = {
    "address": userAddress,  // example: "NSEQNxueCAf6Qp3QEARj5ztpkhBi1cxayY"
    "amount": 100000000 //number of tokens to mint
  }

  const txid = await tmn.mint(mintPayload, adminWallet)
        console.log(txid)

  await sdk.helpers.sleep(TIME_CONSTANT) // wait for the transaction to persist on-chain before doing anything associated with the minting

  const balance = await tmn.balanceOf(mintPayload.address) // get the balance of the address
  console.log("balance is "+ balance);  
//  const adminbalance = await tmn.balanceOf(pKey) // get the balance of the address
  //console.log("Admin balance is "+ adminbalance);  

}


start();