{"id":47920572,"url":"https://github.com/onflow/scheduledtransactions-scaffold","last_synced_at":"2026-04-04T05:57:08.825Z","repository":{"id":309722616,"uuid":"1036255521","full_name":"onflow/scheduledtransactions-scaffold","owner":"onflow","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-30T12:47:01.000Z","size":205,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T05:56:36.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Cadence","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-11T19:48:50.000Z","updated_at":"2025-12-29T23:58:48.000Z","dependencies_parsed_at":"2025-09-18T19:14:31.782Z","dependency_job_id":"cd1a07eb-34da-4000-90ba-e142fe0b2a31","html_url":"https://github.com/onflow/scheduledtransactions-scaffold","commit_stats":null,"previous_names":["onflow/scheduledcallbacks-scaffold","onflow/scheduledtransactions-scaffold"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/onflow/scheduledtransactions-scaffold","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fscheduledtransactions-scaffold","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fscheduledtransactions-scaffold/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fscheduledtransactions-scaffold/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fscheduledtransactions-scaffold/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onflow","download_url":"https://codeload.github.com/onflow/scheduledtransactions-scaffold/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fscheduledtransactions-scaffold/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31389392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T05:57:08.225Z","updated_at":"2026-04-04T05:57:08.819Z","avatar_url":"https://github.com/onflow.png","language":"Cadence","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 👋 Welcome to the Scheduled Transactions Scaffold\n\nThis project is a starting point for you to test out Scheduled Transactions on the Flow Blockchain. It comes with example contracts, scripts, transactions, and tests to help you get started.\n\n## What are Scheduled Transactions?\n\nScheduled Transactions let smart contracts execute code at (or after) a chosen time without an external transaction. You schedule work now; the network executes it later. This enables recurring jobs, deferred actions, and autonomous workflows.\n\nCore pieces:\n\n- Capability to a handler implementing `FlowTransactionScheduler.TransactionHandler`\n- Parameters: `timestamp`, `priority`, `executionEffort`, `fees`, optional `transactionData`\n- Estimate first (`FlowTransactionScheduler.estimate`), then schedule using the scheduler manager\n- The scheduler manager (`FlowTransactionSchedulerUtils.Manager`) helps track and manage scheduled transactions\n\n## 🔨 Getting Started\n\nHere are some essential resources to help you hit the ground running:\n\n- **[Flow Documentation](https://developers.flow.com/)** - The official Flow Documentation is a great starting point to start learning about about [building](https://developers.flow.com/build/flow) on Flow.\n- **[Cadence Documentation](https://cadence-lang.org/docs/language)** - Cadence is the native language for the Flow Blockchain. It is a resource-oriented programming language that is designed for developing smart contracts. The documentation is a great place to start learning about the language.\n- **[Visual Studio Code](https://code.visualstudio.com/)** and the **[Cadence Extension](https://marketplace.visualstudio.com/items?itemName=onflow.cadence)** - It is recommended to use the Visual Studio Code IDE with the Cadence extension installed. This will provide syntax highlighting, code completion, and other features to support Cadence development.\n- **[Flow Clients](https://developers.flow.com/tools/clients)** - There are clients available in multiple languages to interact with the Flow Blockchain. You can use these clients to interact with your smart contracts, run transactions, and query data from the network.\n- **[Block Explorers](https://developers.flow.com/ecosystem/block-explorers)** - Block explorers are tools that allow you to explore on-chain data. You can use them to view transactions, accounts, events, and other information. [Flowser](https://flowser.dev/) is a powerful block explorer for local development on the Flow Emulator.\n\n## ▶️ Quick Start (Scheduled Transactions Example)\n\nFollow this to run the demo that schedules a transaction to increment the `Counter`.\n\n1. Ensure flow-cli 2.7.2\n\n```bash\nflow version\n# If older than 2.7.2, update first: https://developers.flow.com/tools/flow-cli/install\n```\n\n2. Create `emulator-account.pkey`\n\n- Generate a key pair and copy the private key hex\n\n```bash\nflow keys generate\n# Copy the \"Private Key\" value from the output (hex string)\n```\n\n- Save the private key to `emulator-account.pkey` in the project root\n\n```bash\nprintf \"\u003cPASTE_PRIVATE_KEY_HEX_HERE\u003e\" \u003e emulator-account.pkey\n```\n\n3. Install deps and start emulator\n\n```bash\nflow deps install\nflow emulator --block-time 1s\n```\n\n4. In a new terminal, deploy, init, schedule, verify\n\n```bash\nflow project deploy --network emulator\n\n# Initialize handler (scheduler manager will be created automatically)\nflow transactions send cadence/transactions/InitCounterTransactionHandler.cdc \\\n  --network emulator --signer emulator-account\n\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n\n# Schedule increment (creates manager if needed)\nflow transactions send cadence/transactions/ScheduleIncrementIn.cdc \\\n  --network emulator --signer emulator-account \\\n  --args-json '[\n    {\"type\":\"UFix64\",\"value\":\"2.0\"},\n    {\"type\":\"UInt8\",\"value\":\"1\"},\n    {\"type\":\"UInt64\",\"value\":\"1000\"},\n    {\"type\":\"Optional\",\"value\":null}\n  ]'\n\n# after ~3s\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n```\n\nFor full details see `EXAMPLE.md`. For the continuous loop variant, see `EXAMPLE-LOOP.md`.\n\nNote: The scheduler manager is automatically created when you schedule your first transaction, or you can initialize it separately using `InitSchedulerManager.cdc`.\n\n## ▶️ Quick Start (Scheduled Transactions Loop Example)\n\nFollow this to run the demo that continuously increments the `Counter` by rescheduling on each transaction execution.\n\nRepeat steps 1–3 above, then in a new terminal run:\n\n```bash\nflow project deploy --network emulator\n\nflow transactions send cadence/transactions/InitCounterLoopTransactionHandler.cdc \\\n  --network emulator --signer emulator-account\n\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n\nflow transactions send cadence/transactions/ScheduleIncrementInLoop.cdc \\\n  --network emulator --signer emulator-account \\\n  --args-json '[\n    {\"type\":\"UFix64\",\"value\":\"2.0\"},\n    {\"type\":\"UInt8\",\"value\":\"1\"},\n    {\"type\":\"UInt64\",\"value\":\"1000\"},\n    {\"type\":\"Optional\",\"value\":null}\n  ]'\n\n# after ~3s, the transaction runs and schedules the next one automatically\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n```\n\nFor full details and troubleshooting, see `EXAMPLE-LOOP.md`.\n\n## ▶️ Quick Start (Scheduled Transactions Cron Example)\n\nFollow this to run the demo that increments the `Counter` at precise intervals using cron-like scheduling (prevents drift).\n\nRepeat steps 1–3 above, then in a new terminal run:\n\n```bash\nflow project deploy --network emulator\n\nflow transactions send cadence/transactions/InitCounterCronTransactionHandler.cdc \\\n  --network emulator --signer emulator-account\n\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n\nflow transactions send cadence/transactions/ScheduleIncrementInCron.cdc \\\n  --network emulator --signer emulator-account \\\n  --args-json '[\n    {\"type\":\"UFix64\",\"value\":\"3.0\"},\n    {\"type\":\"UInt8\",\"value\":\"1\"},\n    {\"type\":\"UInt64\",\"value\":\"1000\"},\n    {\"type\":\"Optional\",\"value\":{\"type\":\"UInt64\",\"value\":\"3\"}},\n    {\"type\":\"Optional\",\"value\":null}\n  ]'\n\n# after ~12s, check that it ran exactly 3 times at precise 3-second intervals\nflow scripts execute cadence/scripts/GetCounter.cdc --network emulator\n```\n\nFor full details and troubleshooting, see `EXAMPLE-CRON.md`.\n\n## 📦 Project Structure\n\nYour project has been set up with the following structure:\n\n- `flow.json` – Project configuration and dependency aliases (string-imports)\n- `/cadence` – Your Cadence code\n- `/.cursor/rules/scheduledtransactions` – Local documentation and agent guidance.\n\nInside the `cadence` folder you will find:\n\n- `/contracts` - This folder contains your Cadence contracts (these are deployed to the network and contain the business logic for your application)\n  - `Counter.cdc`\n  - `CounterTransactionHandler.cdc`\n  - `CounterLoopTransactionHandler.cdc`\n  - `CounterCronTransactionHandler.cdc`\n- `/scripts` - This folder contains your Cadence scripts (read-only operations)\n  - `GetCounter.cdc`\n- `/transactions` - This folder contains your Cadence transactions (state-changing operations)\n  - `IncrementCounter.cdc`\n  - `InitSchedulerManager.cdc` - Initialize the scheduler manager\n  - `InitCounterTransactionHandler.cdc`\n  - `InitCounterLoopTransactionHandler.cdc`\n  - `InitCounterCronTransactionHandler.cdc`\n  - `ScheduleIncrementIn.cdc` - Schedule single increment\n  - `ScheduleIncrementInLoop.cdc` - Schedule looping increment\n  - `ScheduleIncrementInCron.cdc` - Schedule cron-like increment\n- `/tests` - This folder contains your Cadence tests (integration tests for your contracts, scripts, and transactions to verify they behave as expected)\n  - `Counter_test.cdc`\n\nDocs and rules live under `/.cursor/rules/scheduledtransactions`:\n\n- `index.md` – Navigation and references\n- `agent-rules.mdc` – Agent guidance for composing safe transaction transactions\n- `quick-checklist.md` – Essential checklist\n- `flip.md` – FLIP-330: Scheduled Transactions\n\nOther folders/files:\n\n- `EXAMPLE.md` – Step-by-step walkthrough to run the scheduled transactions demo\n- `EXAMPLE-LOOP.md` – Step-by-step walkthrough for the continuous loop scheduled transactions demo\n- `EXAMPLE-CRON.md` – Step-by-step walkthrough for the cron-like scheduled transactions demo (precise intervals)\n\n## 👨‍💻 Start Developing\n\n### Create `emulator-account.pkey` (required)\n\nIf your `flow.json` references a key file for the `emulator-account`, create one and run the emulator with that same key so signing matches the service account. This is required; starting the emulator without the same private key will cause deploys/signing to fail.\n\n1. Generate a key pair and copy the private key hex\n\n```bash\nflow keys generate --sig-algo ECDSA_P256 --hash-algo SHA3_256\n# Copy the \"Private Key\" value from the output (hex string)\n```\n\n2. Save the private key to `emulator-account.pkey` in the project root\n\n```bash\nprintf \"\u003cPASTE_PRIVATE_KEY_HEX_HERE\u003e\" \u003e emulator-account.pkey\n```\n\n### Creating a New Contract\n\nTo add a new contract to your project, run the following command:\n\n```shell\nflow generate contract\n```\n\nThis command will create a new contract file and add it to the `flow.json` configuration file.\n\n### Creating a New Script\n\nTo add a new script to your project, run the following command:\n\n```shell\nflow generate script\n```\n\nThis command will create a new script file. Scripts are used to read data from the blockchain and do not modify state (i.e. get the current balance of an account, get a user's NFTs, etc).\n\nYou can import any of your own contracts or installed dependencies in your script file using the `import` keyword. For example:\n\n```cadence\nimport \"Counter\"\n```\n\n### Creating a New Transaction\n\nTo add a new transaction to your project you can use the following command:\n\n```shell\nflow generate transaction\n```\n\nThis command will create a new transaction file. Transactions are used to modify the state of the blockchain (i.e purchase an NFT, transfer tokens, etc).\n\nYou can import any dependencies as you would in a script file.\n\n## ⏰ Scheduled Transactions – Quick Reference\n\n- Imports (string imports): `import \"FlowTransactionScheduler\"`, `import \"FlowTransactionSchedulerUtils\"`, `import \"FlowToken\"`, `import \"FungibleToken\"`\n- Required params when scheduling:\n  - `timestamp: UFix64` (must be in the future; on emulator prefer `getCurrentBlock().timestamp + smallDelta`)\n  - `priority: UInt8` (0 = High, 1 = Medium, 2 = Low)\n  - `executionEffort: UInt64` (minimum 10)\n  - `handlerCap: Capability\u003cauth(FlowTransactionScheduler.Execute) \u0026{FlowTransactionScheduler.TransactionHandler}\u003e`\n  - `transactionData: AnyStruct?`\n- Flow: Initialize/borrow manager → Estimate → withdraw fees → schedule through manager\n\nMinimal scheduling skeleton with manager:\n\n```cadence\nimport \"FlowToken\"\nimport \"FungibleToken\"\nimport \"FlowTransactionScheduler\"\nimport \"FlowTransactionSchedulerUtils\"\n\ntransaction(\n    timestamp: UFix64,\n    priority: UInt8,\n    executionEffort: UInt64,\n    handlerStoragePath: StoragePath,\n    transactionData: AnyStruct?\n) {\n    prepare(signer: auth(BorrowValue, IssueStorageCapabilityController, SaveValue) \u0026Account) {\n        let p = priority == 0\n            ? FlowTransactionScheduler.Priority.High\n            : priority == 1\n                ? FlowTransactionScheduler.Priority.Medium\n                : FlowTransactionScheduler.Priority.Low\n\n        // Get handler capability\n        let handlerCap = signer.capabilities.storage\n            .issue\u003cauth(FlowTransactionScheduler.Execute) \u0026{FlowTransactionScheduler.TransactionHandler}\u003e(handlerStoragePath)\n\n        // Initialize manager if needed\n        if signer.storage.borrow\u003c\u0026AnyResource\u003e(from: FlowTransactionSchedulerUtils.managerStoragePath) == nil {\n            let manager \u003c- FlowTransactionSchedulerUtils.createManager()\n            signer.storage.save(\u003c-manager, to: FlowTransactionSchedulerUtils.managerStoragePath)\n        }\n\n        // Borrow manager\n        let manager = signer.storage.borrow\u003cauth(FlowTransactionSchedulerUtils.Owner) \u0026{FlowTransactionSchedulerUtils.Manager}\u003e(\n            from: FlowTransactionSchedulerUtils.managerStoragePath\n        ) ?? panic(\"Could not borrow Manager\")\n\n        let est = FlowTransactionScheduler.estimate(\n            data: transactionData,\n            timestamp: timestamp,\n            priority: p,\n            executionEffort: executionEffort\n        )\n\n        assert(\n            est.timestamp != nil || p == FlowTransactionScheduler.Priority.Low,\n            message: est.error ?? \"estimation failed\"\n        )\n\n        let vaultRef = signer.storage\n            .borrow\u003cauth(FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n            ?? panic(\"missing FlowToken vault\")\n        let fees \u003c- vaultRef.withdraw(amount: est.flowFee ?? 0.0) as! @FlowToken.Vault\n\n        // Schedule through manager\n        let transactionId = manager.schedule(\n            handlerCap: handlerCap,\n            data: transactionData,\n            timestamp: timestamp,\n            priority: p,\n            executionEffort: executionEffort,\n            fees: \u003c-fees\n        )\n\n        log(\"Scheduled transaction id: \".concat(transactionId.toString()))\n    }\n}\n```\n\n### 📦 Installing External Dependencies\n\nIf you want to use external contract dependencies (such as NonFungibleToken, FlowToken, FungibleToken, etc.) you can install them using [Flow CLI Dependency Manager](https://developers.flow.com/tools/flow-cli/dependency-manager).\n\nFor example, to install the NonFungibleToken contract you can use the following command:\n\n```shell\nflow deps add mainnet://1d7e57aa55817448.NonFungibleToken\n```\n\nContracts can be found using [ContractBrowser](https://contractbrowser.com/), but be sure to verify the authenticity before using third-party contracts in your project.\n\n## 🧪 Testing\n\nTo verify that your project is working as expected you can run the tests using the following command:\n\n```shell\nflow test\n```\n\nThis command will run all tests with the `_test.cdc` suffix (these can be found in the `cadence/tests` folder). You can add more tests here using the `flow generate test` command (or by creating them manually).\n\nTo learn more about testing in Cadence, check out the [Cadence Test Framework Documentation](https://cadence-lang.org/docs/testing-framework).\n\n## 🚀 Deploying Your Project\n\nTo deploy your project to the Flow network, you must first have a Flow account and have configured your deployment targets in the `flow.json` configuration file.\n\nYou can create a new Flow account using the following command:\n\n```shell\nflow accounts create\n```\n\nLearn more about setting up deployment targets in the [Flow CLI documentation](https://developers.flow.com/tools/flow-cli/deployment/project-contracts).\n\n### Deploying to the Flow Emulator\n\nTo deploy your project to the Flow Emulator, start the emulator with Scheduled Transactions enabled:\n\n```shell\nflow emulator --block-time 1s\n```\n\nTo deploy your project, run the following command:\n\n```shell\nflow project deploy --network=emulator\n```\n\nThis command will start the Flow Emulator and deploy your project to it. You can now interact with your project using the Flow CLI or alternate [client](https://developers.flow.com/tools/clients).\n\n## 📚 Other Resources\n\n- [Cadence Design Patterns](https://cadence-lang.org/docs/design-patterns)\n- [Cadence Anti-Patterns](https://cadence-lang.org/docs/anti-patterns)\n\n## 🤝 Community\n\n- [Flow Community Forum](https://forum.flow.com/)\n- [Flow Discord](https://discord.gg/flow)\n- [Flow Twitter](https://x.com/flow_blockchain)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fscheduledtransactions-scaffold","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonflow%2Fscheduledtransactions-scaffold","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fscheduledtransactions-scaffold/lists"}