Addr class

class Addr()

This class is designed to work with a specific key pair (not with an HD wallet).

Static methods

sImportPrivateKeyStrHex(hexPrivate)
Arguments:
  • hexPrivate (string) – A HEX form of an importing private key.
Returns:

An object of Addr() class.

Imports a private key.
sGenerateNew()
Returns:An object of Addr() class.
Generates a new key pair.

Class methods

addrStrHex()
Returns:A string containing a Semux-address (without leading ‘0x’).
Method to get a HEX representation of itself (aka Semux-address).
Example:
// Get address as str hex
var addr_str_hex_rs = next_hd_addr.addrStrHex();

if (typeof addr_str_hex_rs.error != "undefined") {
    console.log(addr_str_hex_rs.error);
} else {
    var addr_str_hex = addr_str_hex_rs.res;
    console.log("HEX address: " + "0x" + addr_str_hex);
}
sign1(transaction)
Arguments:
Returns:

An object of TransactionSign() class.

Performs a signature of a Transaction() object.
Example:
var sign_rs = next_hd_addr.sign1(transaction);

if (typeof sign_rs.error != "undefined") {
    console.log(sign_rs.error);
} else {
    var sign = sign_rs.res;
}
nonce()
Returns:A string containing the current Nonce (string representation of SINT64 - max value is 9,223,372,036,854,775,807).
Method to get the current Nonce, which was set by setNonce() method or was incremented by incNonce() method.
setNonce(nonce)
Arguments:
  • nonce (string) – A string representation of Nonce to set.
Returns:

void.

Set the Nonce for this Address.
incNonce()
Returns:A string containing the incremented Nonce.
Method to increment the current Nonce.