Calculate the cost of upgrading hacknet node cache.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of times to upgrade cache. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
Cost of upgrading the specified Hacknet Node's cache.
RAM cost: 0 GB
This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
Returns the cost of upgrading the cache level of the specified Hacknet Server by n.
If an invalid value for n is provided, then this function returns 0. If the specified Hacknet Node is already at max level, then Infinity is returned.
Calculate the cost of upgrading hacknet node cores.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of times to upgrade cores. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
Cost of upgrading the specified Hacknet Node's number of cores.
RAM cost: 0 GB
Returns the cost of upgrading the number of cores of the specified Hacknet Node by n.
If an invalid value for n is provided, then this function returns 0. If the specified Hacknet Node is already at max level, then Infinity is returned.
Get the list of hash upgrades
An array containing the available upgrades
RAM cost: 0 GB
This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
Returns the list of all available hash upgrades that can be used in the spendHashes function.
const upgrades = ns.hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
Calculate the cost of upgrading hacknet node levels.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of levels to upgrade. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
Cost of upgrading the specified Hacknet Node.
RAM cost: 0 GB
Returns the cost of upgrading the specified Hacknet Node by n levels.
If an invalid value for n is provided, then this function returns 0. If the specified Hacknet Node is already at max level, then Infinity is returned.
Get the stats of a hacknet node.
Index/Identifier of Hacknet Node
Object containing a variety of stats about the specified Hacknet Node.
RAM cost: 0 GB
Returns an object containing a variety of stats about the specified Hacknet Node.
Note that for Hacknet Nodes, production refers to the amount of money the node generates. For Hacknet Servers (the upgraded version of Hacknet Nodes), production refers to the amount of hashes the node generates.
Calculate the cost of upgrading hacknet node RAM.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of times to upgrade RAM. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
Cost of upgrading the specified Hacknet Node's RAM.
RAM cost: 0 GB
Returns the cost of upgrading the RAM of the specified Hacknet Node n times.
If an invalid value for n is provided, then this function returns 0. If the specified Hacknet Node already has max RAM, then Infinity is returned.
Get the cost of a hash upgrade.
Name of the upgrade of Hacknet Node.
Optional count: numberNumber of upgrades to buy at once. Defaults to 1 if not specified.
Number of hashes required for the specified upgrade.
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.
const upgradeName = "Sell for Corporation Funds";
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
ns.hacknet.spendHashes(upgradeName);
}
Purchase a new hacknet node.
The index of the Hacknet Node or if the player cannot afford to purchase a new Hacknet Node the function will return -1.
RAM cost: 0 GB
Purchases a new Hacknet Node. Returns a number with the index of the
Hacknet Node. This index is equivalent to the number at the end of
the Hacknet Node’s name (e.g. The Hacknet Node named hacknet-node-4
will have an index of 4).
If the player cannot afford to purchase a new Hacknet Node then the function will return -1.
Purchase a hash upgrade.
Name of the upgrade of Hacknet Node.
Optional upgTarget: stringObject to which upgrade applies. Required for certain upgrades.
Optional count: numberNumber of upgrades to buy at once. Defaults to 1 if not specified. For compatibility reasons, upgTarget must be specified, even if it is not used, in order to specify count.
True if the upgrade is successfully purchased, and false otherwise.
RAM cost: 0 GB
This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
Spend the hashes generated by your Hacknet Servers on an upgrade. Returns a boolean value - true if the upgrade is successfully purchased, and false otherwise.
The name of the upgrade must be an exact match.
The upgTarget argument is used for upgrades such as Reduce Minimum Security, which applies to a specific server.
In this case, the upgTarget argument must be the hostname of the server.
// For upgrades where no target is required
ns.hacknet.spendHashes("Sell for Corporation Funds");
// For upgrades requiring a target
ns.hacknet.spendHashes("Increase Maximum Money", "foodnstuff");
Upgrade the cache of a hacknet node.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of cache levels to purchase. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
True if the Hacknet Node’s cache level is successfully upgraded, false otherwise.
RAM cost: 0 GB
This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
Tries to upgrade the specified Hacknet Server’s cache n times.
Returns true if it successfully upgrades the Server’s cache n times, or if it purchases some positive amount and the Server reaches its max cache level.
Returns false otherwise.
Upgrade the core of a hacknet node.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of cores to purchase. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
True if the Hacknet Node’s cores are successfully purchased, false otherwise.
RAM cost: 0 GB
Tries to purchase n cores for the specified Hacknet Node.
Returns true if it successfully purchases n cores for the Hacknet Node or if it purchases some positive amount and the Node reaches its max number of cores.
Returns false otherwise.
Upgrade the level of a hacknet node.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of levels to purchase. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
True if the Hacknet Node’s level is successfully upgraded, false otherwise.
RAM cost: 0 GB
Tries to upgrade the level of the specified Hacknet Node by n.
Returns true if the Hacknet Node’s level is successfully upgraded by n or if it is upgraded by some positive amount and the Node reaches its max level.
Returns false otherwise.
Upgrade the RAM of a hacknet node.
Index/Identifier of Hacknet Node.
Optional n: numberNumber of times to upgrade RAM. Must be positive. Will be rounded to the nearest integer. Defaults to 1 if not specified.
True if the Hacknet Node’s RAM is successfully upgraded, false otherwise.
RAM cost: 0 GB
Tries to upgrade the specified Hacknet Node’s RAM n times. Note that each upgrade doubles the Node’s RAM. So this is equivalent to multiplying the Node’s RAM by 2 n.
Returns true if the Hacknet Node’s RAM is successfully upgraded n times or if it is upgraded some positive number of times and the Node reaches its max RAM.
Returns false otherwise.
Hacknet API
Remarks
Not all these functions are immediately available.