Files
bitburner-src/markdown/bitburner.codingcontract.getcontract.md
Michael Ficocelli 6073964768 DARKNET: Darkweb Expansion Project & Bitnode (#2139)
This is BN15. It is a really big change; see the PR for all the details.
2026-02-03 03:40:36 -08:00

1.5 KiB

Home > bitburner > CodingContract > getContract

CodingContract.getContract() method

Get various data about a specific contract.

Signature:

getContract(filename: string, host?: string): CodingContractObject;

Parameters

Parameter

Type

Description

filename

string

Filename of the contract.

host

string

(Optional) Hostname/IP of the server containing the contract. Optional. Default to the current server if not provided.

Returns:

CodingContractObject

An object containing various data about the contract specified.

Remarks

RAM cost: 15 GB

The returned object includes the type, data, description as well as methods for getting the number of tries remaining and submitting your answer. Depending on the type of the contract, the data is typed differently. Using type-narrowing, you can get the correct type of the data:

Example

const contract = ns.codingcontract.getContract(fileName, hostName);
if (contract.type === ns.enums.CodingContractName.FindLargestPrimeFactor) {
  const data = contract.data;
  // ^? data: number
}