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

46 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

<!-- 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.
**Signature:**
```typescript
hashCost(upgName: string, count?: number): number;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| upgName | string | Name of the upgrade of Hacknet Node. |
| 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 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.
2023-04-28 20:19:30 +02:00
## Example
2023-04-28 20:19:30 +02:00
```js
const upgradeName = "Sell for Corporation Funds";
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
2023-04-28 20:19:30 +02:00
ns.hacknet.spendHashes(upgradeName);
}
```