bitburner-src/markdown/bitburner.hacknet.hashcost.md
Olivier Gagnon f4ac7344c4 doc
2022-01-08 13:25:06 -05:00

57 lines
1.1 KiB
Markdown

<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Hacknet](./bitburner.hacknet.md) &gt; [hashCost](./bitburner.hacknet.hashcost.md)
## Hacknet.hashCost() method
Get the cost of a hash upgrade.
<b>Signature:</b>
```typescript
hashCost(upgName: string): number;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| upgName | string | Name of the upgrade of Hacknet Node. |
<b>Returns:</b>
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
```ts
// NS1:
var upgradeName = "Sell for Corporation Funds";
if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) {
hacknet.spendHashes(upgName);
}
```
## Example 2
```ts
// NS2:
const upgradeName = "Sell for Corporation Funds";
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
ns.hacknet.spendHashes(upgName);
}
```