Files
bitburner-src/markdown/bitburner.hacknet.hashcost.md

1.3 KiB

Home > bitburner > Hacknet > hashCost

Hacknet.hashCost() method

Get the cost of a hash upgrade.

Signature:

hashCost(upgName: HacknetServerHashUpgrade, count?: number): number;

Parameters

Parameter

Type

Description

upgName

HacknetServerHashUpgrade

Name of the upgrade using hash of Hacknet Server.

count

number

(Optional) Number of upgrades to buy at once. Defaults to 1 if not specified.

Returns:

number

Number of hashes required for the specified upgrade.

Remarks

RAM cost: 0.5 GB

This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).

Returns the number of hashes required for the specified upgrade. The name of the upgrade must be an exact match.

Example

const upgradeName = "Sell for Corporation Funds";
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
  ns.hacknet.spendHashes(upgradeName);
}