|
| 1 | +--- |
| 2 | +title: Scheduled Transactions |
| 3 | +description: Manage scheduled transactions on Flow with the CLI |
| 4 | +sidebar_position: 7 |
| 5 | +--- |
| 6 | + |
| 7 | +The Flow CLI provides commands to manage scheduled transactions. These commands allow you to set up a Manager resource, list scheduled transactions, get transaction details, and cancel transactions. |
| 8 | + |
| 9 | +## What are Scheduled Transactions? |
| 10 | + |
| 11 | +Scheduled transactions enable smart contracts to schedule autonomous execution in the future without external triggers. This allows for use cases like recurring payments, automated arbitrage, and time-based contract logic. |
| 12 | + |
| 13 | +The scheduled transactions system uses priorities (High, Medium, Low) with different execution guarantees and fee multipliers to ensure predictable performance while enabling novel autonomous blockchain patterns. |
| 14 | + |
| 15 | +📖 **[Learn more about scheduled transactions](../../../blockchain-development-tutorials/forte/scheduled-transactions/scheduled-transactions-introduction.md)** |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +Before using the scheduled transactions commands, you must initialize a Manager resource in your account storage. The Manager resource is provided by the **FlowTransactionSchedulerUtils** core contract and provides a convenient way to group, schedule, cancel, and query scheduled transactions through a single resource. |
| 20 | + |
| 21 | +## Why Use the Manager? |
| 22 | + |
| 23 | +While it's possible to schedule transactions directly, **using the Manager resource is essential for proper tooling integration**. The Manager provides a standardized interface that allows CLI commands, block explorers, and other developer tools to discover and interact with your scheduled transactions. |
| 24 | + |
| 25 | +**Key benefits of using the Manager:** |
| 26 | +- **Tooling Integration**: CLI commands and other tools can automatically discover and manage your scheduled transactions |
| 27 | +- **Centralized Management**: All your scheduled transactions are organized in one place for easy tracking |
| 28 | +- **Enhanced Querying**: Query transactions by handler type, timestamp, or status through standardized interfaces |
| 29 | +- **Metadata Access**: Tools can resolve handler views and metadata to provide richer information about your scheduled transactions |
| 30 | + |
| 31 | +Without the Manager, your scheduled transactions exist but cannot be easily discovered or managed through tooling, requiring manual tracking and interaction. |
| 32 | + |
| 33 | +## Commands |
| 34 | + |
| 35 | +### Setup Manager Resource |
| 36 | + |
| 37 | +Initialize a Manager resource in your account storage to start managing scheduled transactions. |
| 38 | + |
| 39 | +```shell |
| 40 | +flow schedule setup |
| 41 | +``` |
| 42 | + |
| 43 | +This command creates and stores a Manager resource at the standard storage path, allowing you to manage scheduled transactions for your account. |
| 44 | + |
| 45 | +#### Example Usage |
| 46 | + |
| 47 | +```shell |
| 48 | +flow schedule setup --network testnet --signer my-account |
| 49 | +``` |
| 50 | + |
| 51 | +#### Flags |
| 52 | + |
| 53 | +- `--signer` - The account that will own the Manager resource |
| 54 | +- `--network` / `-n` - Network to execute on (emulator, testnet, mainnet) |
| 55 | +- `--host` - Access API hostname |
| 56 | +- `--config-path` / `-f` - Path to flow.json configuration file |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### List Scheduled Transactions |
| 61 | + |
| 62 | +List all scheduled transactions for a given account that has a Manager resource. |
| 63 | + |
| 64 | +```shell |
| 65 | +flow schedule list <account> |
| 66 | +``` |
| 67 | + |
| 68 | +#### Arguments |
| 69 | + |
| 70 | +**Account** |
| 71 | +- Name: `account` |
| 72 | +- Valid inputs: Flow account address (with or without `0x` prefix) or account name from flow.json |
| 73 | + |
| 74 | +The account address or name that has scheduled transactions to list. |
| 75 | + |
| 76 | +#### Example Usage |
| 77 | + |
| 78 | +```shell |
| 79 | +flow schedule list 0x01cf0e2f2f715450 --network testnet |
| 80 | +``` |
| 81 | + |
| 82 | +#### Flags |
| 83 | + |
| 84 | +- `--network` / `-n` - Network to query (emulator, testnet, mainnet) |
| 85 | +- `--host` - Access API hostname |
| 86 | +- `--output` / `-o` - Output format (`json`, `inline`) |
| 87 | +- `--filter` / `-x` - Filter output by property name |
| 88 | +- `--save` / `-s` - Save output to file |
| 89 | +- `--config-path` / `-f` - Path to flow.json configuration file |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +### Get Transaction Details |
| 94 | + |
| 95 | +Get detailed information about a specific scheduled transaction by its ID. |
| 96 | + |
| 97 | +```shell |
| 98 | +flow schedule get <transaction-id> |
| 99 | +``` |
| 100 | + |
| 101 | +#### Arguments |
| 102 | + |
| 103 | +**Transaction ID** |
| 104 | +- Name: `transaction-id` |
| 105 | +- Valid inputs: Unsigned integer (UInt64) |
| 106 | + |
| 107 | +The unique identifier of the scheduled transaction to retrieve. |
| 108 | + |
| 109 | +#### Example Usage |
| 110 | + |
| 111 | +```shell |
| 112 | +flow schedule get 123 --network testnet |
| 113 | +``` |
| 114 | + |
| 115 | +#### Flags |
| 116 | + |
| 117 | +- `--network` / `-n` - Network to query (emulator, testnet, mainnet) |
| 118 | +- `--host` - Access API hostname |
| 119 | +- `--output` / `-o` - Output format (`json`, `inline`) |
| 120 | +- `--filter` / `-x` - Filter output by property name |
| 121 | +- `--save` / `-s` - Save output to file |
| 122 | +- `--config-path` / `-f` - Path to flow.json configuration file |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +### Cancel Scheduled Transaction |
| 127 | + |
| 128 | +Cancel a scheduled transaction and receive a partial fee refund. |
| 129 | + |
| 130 | +```shell |
| 131 | +flow schedule cancel <transaction-id> |
| 132 | +``` |
| 133 | + |
| 134 | +When you cancel a scheduled transaction, a portion of the fees paid will be refunded based on the configured refund multiplier. The transaction must be in a scheduled state (not already executed or canceled). |
| 135 | + |
| 136 | +#### Arguments |
| 137 | + |
| 138 | +**Transaction ID** |
| 139 | +- Name: `transaction-id` |
| 140 | +- Valid inputs: Unsigned integer (UInt64) |
| 141 | + |
| 142 | +The unique identifier of the scheduled transaction to cancel. |
| 143 | + |
| 144 | +#### Example Usage |
| 145 | + |
| 146 | +```shell |
| 147 | +flow schedule cancel 123 --network testnet --signer my-account |
| 148 | +``` |
| 149 | + |
| 150 | +#### Flags |
| 151 | + |
| 152 | +- `--signer` - Account that owns the Manager resource containing the transaction |
| 153 | +- `--network` / `-n` - Network to execute on (emulator, testnet, mainnet) |
| 154 | +- `--host` - Access API hostname |
| 155 | +- `--output` / `-o` - Output format (`json`, `inline`) |
| 156 | +- `--config-path` / `-f` - Path to flow.json configuration file |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## Common Flags |
| 161 | + |
| 162 | +These flags are available across all scheduled transactions commands: |
| 163 | + |
| 164 | +### Network |
| 165 | + |
| 166 | +- Flag: `--network` |
| 167 | +- Short Flag: `-n` |
| 168 | +- Valid inputs: the name of a network defined in the configuration (`flow.json`) |
| 169 | +- Default: `emulator` |
| 170 | + |
| 171 | +Specify which network you want the command to use for execution. |
| 172 | + |
| 173 | +### Host |
| 174 | + |
| 175 | +- Flag: `--host` |
| 176 | +- Valid inputs: an IP address or hostname |
| 177 | +- Default: `127.0.0.1:3569` (Flow Emulator) |
| 178 | + |
| 179 | +Specify the hostname of the Access API that will be used to execute the commands. This flag overrides any host defined by the `--network` flag. |
| 180 | + |
| 181 | +### Network Key |
| 182 | + |
| 183 | +- Flag: `--network-key` |
| 184 | +- Valid inputs: A valid network public key of the host in hex string format |
| 185 | + |
| 186 | +Specify the network public key of the Access API that will be used to create a secure GRPC client when executing the command. |
| 187 | + |
| 188 | +### Configuration |
| 189 | + |
| 190 | +- Flag: `--config-path` |
| 191 | +- Short Flag: `-f` |
| 192 | +- Valid inputs: a path in the current filesystem |
| 193 | +- Default: `flow.json` |
| 194 | + |
| 195 | +Specify the path to the `flow.json` configuration file. You can use the `-f` flag multiple times to merge several configuration files. |
| 196 | + |
| 197 | +### Output |
| 198 | + |
| 199 | +- Flag: `--output` |
| 200 | +- Short Flag: `-o` |
| 201 | +- Valid inputs: `json`, `inline` |
| 202 | + |
| 203 | +Specify the format of the command results. |
| 204 | + |
| 205 | +### Filter |
| 206 | + |
| 207 | +- Flag: `--filter` |
| 208 | +- Short Flag: `-x` |
| 209 | +- Valid inputs: a case-sensitive name of the result property |
| 210 | + |
| 211 | +Specify any property name from the result you want to return as the only value. |
| 212 | + |
| 213 | +### Save |
| 214 | + |
| 215 | +- Flag: `--save` |
| 216 | +- Short Flag: `-s` |
| 217 | +- Valid inputs: a path in the current filesystem |
| 218 | + |
| 219 | +Specify the filename where you want the result to be saved. |
| 220 | + |
| 221 | +### Log |
| 222 | + |
| 223 | +- Flag: `--log` |
| 224 | +- Short Flag: `-l` |
| 225 | +- Valid inputs: `none`, `error`, `debug` |
| 226 | +- Default: `info` |
| 227 | + |
| 228 | +Specify the log level. Control how much output you want to see during command execution. |
| 229 | + |
| 230 | +### Version Check |
| 231 | + |
| 232 | +- Flag: `--skip-version-check` |
| 233 | +- Default: `false` |
| 234 | + |
| 235 | +Skip version check during start up to speed up process for slow connections. |
0 commit comments