Transaction class

class Transaction()

An object of Transaction() class is created with factory static method new_transaction() and contains all necessary transaction parameters.

Static methods

new_transaction(networkType, transactionType, addressToHex, amount, fee, nonce, timestamp, dataHex, gas, gasPrice)
Arguments:
  • networkType (NetworkType) – A type of network.
  • transactionType (TransactionType) – A type of transaction.
  • addressToHex (string) – Semux-address in string hexadecimal form.
  • amount (string) – Amount of payment (integer value in nanosem).
  • fee (string) – Amount of fee (integer value in nanosem).
  • nonce (string) – A Nonce (unique and sequential for the sender).
  • timestamp (string) – A timestamp of the transaction (in milliseconds).
  • dataHex (string) – Some arbitrary text data in string hexadecimal form.
  • gas (string) – Amount of gas.
  • gasPrice (string) – Gas price (integer value in nanosem).
Returns:

object of Transaction() class.

Factory method for creating of Transaction() class object.
Example:
var d = new Date();
var network_type = Module.UnoSemuxNetworkType.TESTNET;
var transaction_type = Module.UnoSemuxTransactionType.TRANSFER;
var to = "0x82c38263217817de2ef28937c7747716eb1e7228";
var data = "0x756E6F2D6C616273206C696768742077616C6C65742064656D6F"; // "uno-labs light wallet demo" in hex form
var value = "100000000"; // nanosem
var fee = "5000000";     // nanosem
var nonce = "533";       // Actually, you have to get it from Node API
var gas = "0";
var gas_price = "0";     // nanosem

var transaction = GetRes(Module.UnoSemuxTransaction.new_transaction(
      network_type,
      transaction_type,
      String(to),
      String(value),
      String(fee),
      String(nonce),
      String(d.getTime()),
      String(data),
      String(gas),
      String(gas_price)
));

var transaction_sign = GetRes(hdAddr.sign_transaction(transaction));

var transaction_hash = GetRes(transaction_sign.hash());
console.log("Transaction hash '" + transaction_hash + "'");

var transaction_sign_hex_encoded = GetRes(transaction_sign.encode());
console.log("Transaction sign hex str '" + transaction_sign_hex_encoded + "'");

Class methods

encode()
Returns:An encoded string of Transaction() object.
Method to get an encoded representation of itself.

Getters

There are also some “getters” methods in the class:

  • network_type()
  • transaction_type()
  • address_to()
  • value()
  • fee()
  • nonce()
  • timestamp()
  • data()
  • gas()
  • gas_price()