Bitburner: Simple Hacknet Manager

A simple hacknet manager to purchase all the hacknet upgrades for you in an efficient way.


Simply create a .js file and paste the code below
nano nameOfYourFile.js
Note: This script requires 6.1GB of memory available

Script code
export async function main(ns) {
    let delayTime = ns.args[0] || 1000;
    let thresholdMultiplier = ns.args[1] || 1; //Bigger threshold, the less it spends

    while (true) {
        let ownedNodes = ns.hacknet.numNodes();
        let minValue = ns.hacknet.getPurchaseNodeCost();
        let nodeIndex = ownedNodes;
        let upgradeType = -1; //-1 -> purchase, 0 -> level, 1 -> ram, 2 -> core

        for (let i = 0; i < ownedNodes; i++) {
            let upgrades = [
                ns.hacknet.getLevelUpgradeCost(i, 1), 
                ns.hacknet.getRamUpgradeCost(i, 1), 
                ns.hacknet.getCoreUpgradeCost(i, 1)

            let value = Math.min.apply(Math, upgrades);
            if (value < minValue) {
                minValue = value;
                nodeIndex = i;
                upgradeType = upgrades.indexOf(value);

        await waitForMoney(ns, minValue, delayTime, thresholdMultiplier);
        switch (upgradeType) {
            case -1:
            case 0:
                ns.hacknet.upgradeLevel(nodeIndex, 1);
            case 1:
                ns.hacknet.upgradeRam(nodeIndex, 1);
            case 2:
                ns.hacknet.upgradeCore(nodeIndex, 1);

        await ns.sleep(1);

async function waitForMoney(ns, targetMoney, delayTime, thresholdMultiplier) {
    while (ns.getPlayer().money / thresholdMultiplier < targetMoney) {
        await ns.sleep(delayTime);
How it works
The script finds the cheapest upgrade available in one of the hacknet nodes and buys it whenever it has enough money for it.

You can run this script simply by typing
run nameOfYourScript.js

However, you can also pass it two arguments (buy time delay and money threshold multiplier).

run nameOfYourScript.js 5000 2

The command above would try to purchase an upgrade every 5s (5000ms) whenever the player has at least twice the money it would cost to purchase said upgrade.

Note: Passing a money threshold multiplier below 1 will break the script

Thanks to Kirtle for his great guide, all credit to his effort. you can also read the original guide from Steam Community. enjoy the game.

Related Posts:

Post Author: Robins Chew

Leave a Reply

Your email address will not be published. Required fields are marked *