Utilities

Members

(static, constant) STACKS_NETWORK :StacksNetwork

Source:
default Stacks network to connect to
Type:
  • StacksNetwork

(static, constant) USTX :integer

Source:
used to convert uSTX to STX and reverse
Type:
  • integer

Methods

(inner) cancelPrompt(prompt)

Source:
Catches a cancel event in prompts, sets the message, and exits the AutoMiner
Parameters:
Name Type Description
prompt Array.<Object> An object that contains the current prompt displayed to the user

(async, inner) canClaimMiningReward(contractAddress, contractName, address, blockHeight) → {bool}

Source:
Returns true if the user can claim a reward for a given block height
Parameters:
Name Type Description
contractAddress string
contractName string
address string
blockHeight integer
Returns:
Type
bool

(inner) exitWithError(message)

Source:
Prints an error message and exits the running script
Parameters:
Name Type Description
message string

(inner) exitWithSuccess(message)

Source:
Prints a final message and exits the running script
Parameters:
Name Type Description
message string

(async, inner) getAccountTxs(address) → {Array.<Array>}

Source:
Returns all account transactions for a given address or contract identifier
Parameters:
Name Type Description
address string STX address to query
Returns:
Type
Array.<Array>

(async, inner) getBlockAvg(userConfig) → {integer}

Source:
Returns the average block commit for strategyDistance blocks in the past/future
Parameters:
Name Type Description
userConfig Array.<Object> An object that contains the user configuration
Returns:
Type
integer

(async, inner) getBlockCommit(userConfig, miningStrategy) → {integer}

Source:
Returns a target block commit based on provided user config and mining strategy
Parameters:
Name Type Description
userConfig Array.<Object> An object that contains the user configuration
miningStrategy Array.<Object> An object that contains properties for automatically calculating a commit
Returns:
Type
integer

(async, inner) getBlockHeight() → {integer}

Source:
Returns the current Stacks block height
Returns:
Type
integer

(async, inner) getMiningStatsAtBlock(contractAddress, contractName, blockHeight) → {integer}

Source:
Returns the total amount of STX sent for a given block height in the specified contracts
Parameters:
Name Type Description
contractAddress string STX address of the contract deployer
contractName string Name of the contract
blockHeight integer Block height to query
Returns:
Type
integer

(async, inner) getNonce(address) → {integer}

Source:
Returns the current nonce for the given address
Parameters:
Name Type Description
address string STX address to query
Returns:
Type
integer

(async, inner) getOptimalFee(multiplier, checkAllTxopt) → {integer}

Source:
Averages the fees for the first 200 transactions in the mempool, or optionally all transactions, and applies a multiplier
Parameters:
Name Type Attributes Default Description
multiplier integer Mulitiplier for mempool average
checkAllTx boolean <optional>
false Boolean to check all transactions in mempool
Returns:
Optimal fee in uSTX
Type
integer

(async, inner) getRewardCycle(contractAddress, contractName, blockHeight) → {integer}

Source:
Returns the reward cycle for a given block height
Parameters:
Name Type Description
contractAddress string STX address of the contract deployer
contractName string Name of the contract
blockHeight integer Block height to query
Returns:
Type
integer

(async, inner) getStackerAtCycleOrDefault(contractAddress, contractName, cycleId, userId) → {Array.<Object>}

Source:
Returns the amount stacked and amount to return for a given cycle and user
Parameters:
Name Type Description
contractAddress string STX address of the contract deployer
contractName string Name of the contract
cycleId integer Reward cycle to query
userId integer User ID to query
Returns:
Type
Array.<Object>

(async, inner) getStackingReward(contractAddress, contractName, cycleId, userId) → {integer}

Source:
Returns the amount of STX a user can claim in a given reward cycle in uSTX.
Parameters:
Name Type Description
contractAddress string STX address of the contract deployer
contractName string Name of the contract
cycleId integer Reward cycle to query
userId integer User ID to query
Returns:
Type
integer

(async, inner) getStxBalance(address) → {integer}

Source:
Returns the current STX balance of a given address
Parameters:
Name Type Description
address string STX address to query
Returns:
Type
integer

(async, inner) getTotalMempoolTx() → {integer}

Source:
Returns the total number of transactions in the mempool
Returns:
Type
integer

(async, inner) getUserId(contractAddress, contractName, address) → {integer}

Source:
Returns the userId in the CityCoin contract for a given address
Parameters:
Name Type Description
contractAddress string STX address of the contract deployer
contractName string Name of the contract
address string Stacks address to query
Returns:
Type
integer

(inner) printDivider()

Source:
Prints a consistent divider used for logging

(inner) printTimeStamp()

Source:
Prints a consistent timestamp used for logging

(async, inner) processTx(broadcastedResult, tx) → {integer}

Source:
Monitors a transaction and returns the block height it succeeds at
Parameters:
Name Type Description
broadcastedResult TxBroadcastResult result from broadcastTransaction() in @stacks/transactions
tx string the txid of the transaction
Returns:
Type
integer

(async, inner) safeFetch(url) → {Array.<Object>}

Source:
Returns the JSON content from the specified URL
Parameters:
Name Type Description
url string URL to fetch JSON content from
Returns:
JSON object
Type
Array.<Object>

(async, inner) timer(ms)

Source:
Sleeps for the given amount of milliseconds
Parameters:
Name Type Description
ms integer number of milliseconds

(async, inner) waitUntilBlock(userConfig) → {boolean}

Source:
Parameters:
Name Type Description
userConfig Array.<Object> An object that contains the user configuration
Returns:
Type
boolean