user
This module allows you to access both personal information of the node runner. The module is accessed from the global variable user
.
getKeys
Gets the address of all keys stored on the keystore of the node.
Returns
Array<String>
: A list of addresses.
Example
getKey
Gets the private key of a key by its address or keystore index. If the key exists, it will be unlocked using the provided passphrase
. If passphrase
is not provided, an interactive prompt will be launched to ask for it.
Parameters
addrOrIndex
-String|Number
: The address or keystore index of the keypassphrase
-String
: (Optional) The passphrase to use to unlock the key. If not provided, you will be prompted to provide it.
Returns
String
: The base58 encoded private key.
Example
getPublicKey
Gets the public key of a key by its address or keystore index. If the key exists, it will be unlocked using the provided passphrase
. If passphrase
is not provided, an interactive prompt will be launched to ask for it.
Parameters
addrOrIndex
-String|Number
: The address or keystore index of the keypassphrase
-String
: (Optional) The passphrase to use to unlock the key. If not provided, you will be prompted to provide it.
Returns
String
: The base58 encoded public key.
Example
getNonce
Gets the current nonce of a user account.
Parameters
address
-String
: The address of the target user account.height
-String|Number
: (Optional) The block height to query (Default: latest).
Returns
String
: The current nonce.
Example
get
Gets a user account by its address.
Parameters
address
-String
: The address of the target user account.height
-String|Number
: (Optional) The block height to query (Default: latest).
Returns
Object
: The account object balance
- String
: The native coin balance. nonce
- String
: The account nonce. stakes
- Object
: Staked coin information delegatorCommission
- String
: Commission to receive from delegators.
Example
getBalance
Gets the coin balance of a user account.
Parameters
address
-String
: The address of the target user account.height
-String|Number
: (Optional) The block height to query (Default: latest).
Returns
String
: The coin balance.
Example
getStakedBalance
Gets the total amount of the native coin a user account has staked.
Parameters
address
-String
: The address of the target user account.height
-String|Number
: (Optional) The block height to query (Default: latest).
Returns
String
: The coin balance.
Example
getValidator
Gets the node’s validator key.
Parameters
includePrivKey
-Boolean
: When true, the private key is included in the result.
Returns
Object
: The validator key information.
Example
setCommission
Create a transaction that updates the delegator commission percentage of a validator account.
Parameters
txObject
-Object
: The transaction objectcommission
-String
: The percentage of reward to receive from delegators.nonce
-Number|String
: The signing account’s next nonce.fee
-String
: The network fee to be paid by the signing account.timestamp
-String
: (optional) The unix timestamp of the transaction.sig
-String
: (optional) The transaction signature. If not provided, the transaction will be signed using thesigningKey
.
signingKey
-String
: (optional) The private key to use to sign the transaction.payloadOnly
-Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Returns
Object
- The result object
hash
-String
: A 32 bytes transaction hash.
Example
send
Create a transaction that sends coins from the signers account to another account or repository.
Parameters
txObject
-Object
: The transaction objectvalue
-Number|String
: The amount of native coin to be sent.to
-String
: The address of the recipient; A user address or a repository name prefixed withr/
.nonce
-Number|String
: The signing account’s next nonce.fee
-String
: The network fee to be paid by the signing account.timestamp
-String
: (optional) The unix timestamp of the transaction.sig
-String
: (optional) The transaction signature. If not provided, the transaction will be signed using thesigningKey
.
signingKey
-String
: (optional) The private key to use to sign the transaction.payloadOnly
-Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Returns
Object
- The result object
hash
-String
: A 32 bytes transaction hash.
Example
Last updated