Attempts a coding contract, returning a reward string on success or empty string on failure.
Attempted solution for the contract.
Filename of the contract.
Optional host: stringHostname of the server containing the contract. Optional. Defaults to current server if not provided.
A reward description string on success, or an empty string on failure.
RAM cost: 10 GB
Attempts to solve the Coding Contract with the provided solution.
const reward = codingcontract.attempt(yourSolution, filename, hostname);
if (reward) {
ns.tprint(`Contract solved successfully! Reward: ${reward}`)
} else ns.tprint("Failed to solve contract.")
Get the type of a coding contract.
Filename of the contract.
Optional host: stringHostname of the server containing the contract. Optional. Defaults to current server if not provided.
Name describing the type of problem posed by the Coding Contract.
RAM cost: 5 GB
Returns a name describing the type of problem posed by the Coding Contract. (e.g. Find Largest Prime Factor, Total Ways to Sum, etc.)
Get the input data.
Filename of the contract.
Optional host: stringHost of the server containing the contract. Optional. Defaults to current server if not provided.
The specified contract’s data, data type depends on contract type.
RAM cost: 5 GB
Get the data associated with the specific Coding Contract. Note that this is not the same as the contract’s description. This is just the data that the contract wants you to act on in order to solve the contract.
Get the description.
Filename of the contract.
Optional host: stringHostname of the server containing the contract. Optional. Defaults to current server if not provided.
Contract’s text description.
RAM cost: 5 GB
Get the full text description for the problem posed by the Coding Contract.
Get the number of attempts remaining.
Filename of the contract.
Optional host: stringHostname of the server containing the contract. Optional. Defaults to current server if not provided.
How many attempts are remaining for the contract.
RAM cost: 2 GB
Get the number of tries remaining on the contract before it self-destructs.
Coding Contract API