Skip to content
Thyme Docs

Quickstart

This walkthrough first runs an inert task, then connects it to a cloud executable. You need the CLI and Deno, a Flow workspace and project, and access to your deployment's console.

1. Create and run a task

thyme init my-flow-project
cd my-flow-project
npm install
thyme new heartbeat
cp .env.example .env

Set SIMULATE_ACCOUNT in .env to your intended execution address. For this read-free example you do not need an RPC endpoint. Replace functions/heartbeat/index.ts with:

import { defineTask, z } from '@thyme-labs/sdk'
 
export default defineTask({
  schema: z.object({}),
  async run(ctx) {
    const runs = Number(ctx.storage.runs ?? 0) + 1
    ctx.storage.runs = runs
    ctx.logger.info(`Heartbeat ${runs} from ${ctx.account}`)
    return { canExec: false, message: 'Heartbeat recorded; no transaction needed' }
  },
})

Replace functions/heartbeat/args.json with {}.

thyme run heartbeat --persist
thyme run heartbeat --persist

The counter increases in storage.json. canExec: false is a normal skip: the run can log and persist state without submitting a transaction.

2. Declare permissions, select the deployment, and upload

After the local runs, add functions/heartbeat/permissions.json to declare that this task requires no contract calls:

{ "calls": [] }

CLI 0.10.0 has a known local manifest-loading bug, so this walkthrough creates the manifest after local checks. Upload still includes and validates it.

export THYME_API_URL='https://YOUR_FLOW_API_HOST/http'
thyme login
thyme upload heartbeat --tag v1

Replace the placeholder host with your API base URL. Select the workspace and project in the prompts. Upload creates an immutable release; it does not create or start an executable.

3. Create a profile and executable

In the same project, open Profiles and complete an available profile's setup. For new Roles profiles, review the allowed contract targets and selectors and finish on-chain verification; see profile setup.

Then choose Executables → Create:

  1. Select heartbeat@v1 and use {} for args.
  2. Choose an interval, such as one minute.
  3. Leave secrets unbound because this task does not use any.
  4. Select your active profile, supported gas mode, and an available sandbox runtime.

Provisioning prepares the bundle, then the executable becomes active. Use Execute now and open the execution logs to see the heartbeat. Cloud storage starts separately from your local storage.json.

The management CLI and HTTP API can also create and operate executables after workspace management consent.

4. Add contract calls deliberately

Follow authoring a task to read a contract, return a call, and declare its permission. Update the profile's scope with the owner's approval, upload a new tag, and follow release management to switch the executable.

For execution outcomes and troubleshooting, see monitoring.