A set of methods to interact with the process in which the Oracle Program is running.

Methods

  • Gets all the input arguments from the Data Request First argument (index: 0) is the Oracle Program ID Second argument (index: 1) is the input of the Data Request

    Returns string[]

    An array of input arguments

    Example

    const args = Process.args();
    
  • Gets all the environment variables as a Map

    Returns Map<string, string>

    key, value pair with all environment variables

    Example

    const env = Process.env();

    const vmMode = env.get('VM_MODE');
  • Exits the process with a bytes encoded result. This sets Data Request execution result to the bytes

    Parameters

    • result: Bytes

      Bytes encoded result, which will be sent back to the contract

    • Optional code: number = POSIX_ERROR_CODE

      code Exit code, defaults to 1 (POSIX compatible, 0 is success, >= 1 is error)

    Returns void

    Example

    const error = "Failed to fetch data from https://example.com";

    Process.error(Bytes.fromUtf8String(error));
  • Exits the process (no result set)

    Parameters

    • code: number

      Exit code (POSIX compatible, 0 is success, >= 1 is error)

    Returns void

    Example

    Process.exit(0);
    
  • Gets the data request / tally inputs

    Returns Bytes

    bytes encoded inputs

    Example

    const inputs = Process.getInputs();
    const inputAsString = inputs.toUtf8String();

    console.log(inputAsString);
  • Gets the mode of the VM instance.

    Returns string

    The mode of the VM, either 'dr' or 'tally'.

  • Returns true when the VM instance is in 'dr' mode.

    Returns boolean

  • Returns true when the VM instance is in 'tally' mode.

    Returns boolean

  • Exits the process with a bytes encoded result. This sets Data Request execution result to the bytes

    Parameters

    • result: Bytes

      Bytes encoded result, which will be sent back to the contract

    Returns void

    Example

    const result = "{\"price\": \"10.23\"}";

    Process.success(Bytes.fromUtf8String(result));