Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 1.15 KB

bitburner.hacknet.hashcost.md

File metadata and controls

56 lines (35 loc) · 1.15 KB

Home > bitburner > Hacknet > hashCost

Hacknet.hashCost() method

Get the cost of a hash upgrade.

Signature:

hashCost(upgName: string): number;

Parameters

Parameter Type Description
upgName string Name of the upgrade of Hacknet Node.

Returns:

number

Number of hashes required for the specified upgrade.

Remarks

RAM cost: 0 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 1

// NS1:
var upgradeName = "Sell for Corporation Funds";
if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) {
   hacknet.spendHashes(upgName);
}

Example 2

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