Skip to main content

Debugging locally

All local logs and events will output to your terminal where you run goldsky compose start. Output is formatted and colored to make scanning the output as easy as possible.

Chain forking

For testing against live on-chain state without spending gas, start your app with the --fork-chains flag:
goldsky compose start --fork-chains
This creates in-memory forks of all chains you interact with, powered by TEVM. All wallets are automatically funded with test ETH, so you can freely test contract interactions. Your task code stays exactly the same as in production — no special dev code needed. See Environments for more details.

Testing individual tasks

You can trigger any task directly using callTask:
goldsky compose callTask my_task '{"key": "value"}'

Debugging a Deployed Compose App

There are two key methods of debugging your app when running in the cloud, 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

import { TaskContext } from "compose";

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

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

    const wallet = await evm.wallet();
    const { hash } = await wallet.writeContract(
      evm.chains.polygon,
      "0x1234567890abcdef1234567890abcdef12345678" as `0x${string}`,
      "reportPayouts(bytes32,uint256[])",
      [resultId, payouts]
    );

    return { hash };
  } 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

Deploying your App

Learn about deploying your app to the cloud for production use cases.

Full CLI Reference

View the full CLI command reference