Members
(static, constant) STACKS_NETWORK :StacksNetwork
default Stacks network to connect to
Type:
- StacksNetwork
(static, constant) USTX :integer
used to convert uSTX to STX and reverse
Type:
- integer
Methods
(inner) cancelPrompt(prompt)
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}
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)
Prints an error message and exits the running script
Parameters:
Name | Type | Description |
---|---|---|
message |
string |
(inner) exitWithSuccess(message)
Prints a final message and exits the running script
Parameters:
Name | Type | Description |
---|---|---|
message |
string |
(async, inner) getAccountTxs(address) → {Array.<Array>}
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}
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}
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}
Returns the current Stacks block height
Returns:
- Type
- integer
(async, inner) getMiningStatsAtBlock(contractAddress, contractName, blockHeight) → {integer}
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}
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}
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}
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>}
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}
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}
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}
Returns the total number of transactions in the mempool
Returns:
- Type
- integer
(async, inner) getUserId(contractAddress, contractName, address) → {integer}
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()
Prints a consistent divider used for logging
(inner) printTimeStamp()
Prints a consistent timestamp used for logging
(async, inner) processTx(broadcastedResult, tx) → {integer}
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>}
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)
Sleeps for the given amount of milliseconds
Parameters:
Name | Type | Description |
---|---|---|
ms |
integer | number of milliseconds |
(async, inner) waitUntilBlock(userConfig) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
userConfig |
Array.<Object> | An object that contains the user configuration |
Returns:
- Type
- boolean