Skip to main content

Debugging

There are two key methods of debugging, viewing logs and inspecting task run records. Both of these can be done in the UI of our web app on your compose app details page at https://app.goldsky.com/dashboard/compose/{appName}. By default all context function calls are captured as task run events and are logged. You can also add your own custom events and logging with the logEvent context function and the standard typescript console.

Examples

/// <reference types="../../.compose/types.d.ts" />

export async function main(
  { fetch, logEvent }: TaskContext,
  params: { payouts: string, resultId: string }
) {
  try {
    const { payouts, resultId } = params;

    console.log("Reporting payouts", payouts, resultId);

    const response = await writeContract(
      chain,
      config.resolver as Address,
      "reportPayouts(bytes32,uint256[])",
      [resultId, payouts],
      {
        max_attempts: 2,
        initial_interval_ms: 500,
        backoff_factor: 1,
      }
    );
  } catch (error) {
    if (error instanceof Error && error.message.includes("payout denominator already set")) {
      await logEvent({
        code: "PAYOUT_DENOMINATOR_ALREADY_SET",
        message: `Payout denominator already set, marking as resolved`,
        data: JSON.stringify(error),
      });
    } else {
      console.error("Error reporting payout", error);
      throw error;
    }
  }
}

Next Steps