try { // !! KEY PLACE const functionId = "0x2fe27a8d6a04d57583172cdda79df0e9::MyCounter::init_counter"; // !! KEY PLACE const strTypeArgs = [];
const tyArgs = utils.tx.encodeStructTypeTags(strTypeArgs); const sendAmount = parseFloat(amount, 10); if (!(sendAmount > 0)) { window.alert("Invalid sendAmount: should be a number!"); return false; } const BIG_NUMBER_NANO_STC_MULTIPLIER = new BigNumber("1000000000"); const sendAmountSTC = new BigNumber(String(sendAmount), 10); const sendAmountNanoSTC = sendAmountSTC.times( BIG_NUMBER_NANO_STC_MULTIPLIER ); const sendAmountHex = `0x${sendAmountNanoSTC.toString(16)}`; // Multiple BcsSerializers should be used in different closures, otherwise, the latter will be contaminated by the former. const amountSCSHex = (function () { const se = new bcs.BcsSerializer(); // eslint-disable-next-line no-undef se.serializeU128(BigInt(sendAmountNanoSTC.toString(10))); return hexlify(se.getBytes()); })();