Skip to content

Commit b2550af

Browse files
authored
Merge pull request #1532 from onflow/last_forte_doc_edits_cws
Last changes to Forte docs
2 parents cdc0d8b + bd4c778 commit b2550af

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

docs/blockchain-development-tutorials/forte/scheduled-transactions/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ keywords:
1515

1616
# Scheduled Transactions Tutorials
1717

18-
This series covers how to implement scheduled transactions for time-based smart contract execution on Flow, enabling developers to create automated workflows and time-sensitive blockchain applications. These tutorials are part of the Forte network upgrade, which introduces new capabilities to the Flow blockchain.
18+
This series covers how to implement scheduled transactions for time-based smart contract execution on Flow, which allows developers to create automated workflows and time-sensitive blockchain applications. These tutorials are part of the Forte network upgrade, which introduces new capabilities to the Flow blockchain.
1919

2020
## Tutorials
2121

docs/blockchain-development-tutorials/forte/scheduled-transactions/scheduled-transactions-introduction.md

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,44 @@ keywords:
1919

2020
:::warning
2121

22-
Scheduled transactions are a new feature that is under development and is a part of [FLIP 330]. Currently, they only work in the emulator and testnet. The specific implementation is closed to being finished but may change as a part of the development process.
22+
Scheduled transactions are a new feature that is under development and is a part of [FLIP 330]. Currently, they only work in the emulator and testnet. We're close to finishing the specific implementation, but it but may change during the development process.
2323

24-
These tutorials will be updated, but you may need to refactor your code if the implementation changes.
24+
We will update these tutorials, but you may need to refactor your code if the implementation changes.
2525

2626
:::
2727

28-
Flow, EVM, and other blockchains are a form of a **single** shared computer that anyone can use and no one has admin privileges, super user roles, or complete control. For this to work, one of the requirements is that it needs to be impossible for any user to freeze the computer, on purpose or by accident.
28+
# Overview
2929

30-
As a result, most blockchain computers, including EVM and Solana, are not [Turing Complete], because they can't run an unbounded loop. Each transaction must take place within one block, and cannot consume more gas than the limit.
30+
Flow, EVM, and other blockchains are a form of a **single** shared computer that anyone can use, with no admin privileges, super user roles, or complete control. For this to work, it must be impossible for any user to freeze the computer, on purpose or by accident.
31+
32+
As a result, most blockchain computers, including EVM and Solana, aren't [Turing Complete], because they can't run an unbounded loop. Each transaction must occur within one block, and can't consume more gas than the limit.
3133

3234
While this limitation prevents infinite loops, it makes it so that you can't do anything 100% onchain if you need it to happen at a later time or after a trigger. As a result, developers must often build products that involve a fair amount of traditional infrastructure and requires users to give those developers a great amount of trust that their backend will execute the promised task.
3335

34-
Flow fixes this problem with **scheduled transactions**. Scheduled 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.
36+
Flow fixes this problem with _scheduled transactions_. Scheduled Transactions let smart contracts execute code at, or after, a chosen time without an external transaction. You schedule work now and the network executes it later. This allows recurring jobs, deferred actions, and autonomous workflows.
3537

3638
## Learning Objectives
3739

38-
After completing this tutorial, you will be able to:
40+
After you complete this tutorial, you will be able to:
3941

40-
- Understand the concept of scheduled transactions and how they solve blockchain limitations
41-
- Explain the key components of the `FlowTransactionScheduler` system
42-
- Implement a basic scheduled transaction using the provided scaffold
43-
- Analyze the structure and flow of scheduled transaction transactions
44-
- Create custom scheduled transaction contracts and handlers
45-
- Evaluate the benefits and use cases of scheduled transactions in DeFi applications
42+
- Understand the concept of scheduled transactions and how they solve blockchain limitations.
43+
- Explain the key components of the `FlowTransactionScheduler` system.
44+
- Implement a basic scheduled transaction using the provided scaffold.
45+
- Analyze the structure and flow of scheduled transaction transactions.
46+
- Create custom scheduled transaction contracts and handlers.
47+
- Evaluate the benefits and use cases of scheduled transactions in DeFi applications.
4648

4749
# Prerequisites
4850

4951
## Cadence Programming Language
5052

51-
This tutorial assumes you have a modest knowledge of [Cadence]. If you don't, you'll be able to follow along, but you'll get more out of it if you complete our series of [Cadence] tutorials. Most developers find it more pleasant than other blockchain languages and it's not hard to pick up.
53+
This tutorial assumes you have a modest knowledge of [Cadence]. If you don't, you can follow along, but you'll get more out of it if you complete our series of [Cadence] tutorials. Most developers find it more pleasant than other blockchain languages, and it's not hard to pick up.
5254

5355
## Getting Started
5456

55-
Begin by running `flow init` and select `Scheduled Transactions project`. Open the project.
57+
To start, run `flow init` and select `Scheduled Transactions project`. Open the project.
5658

57-
The readme has a robust getting started guide. Complete that to set up and run the demo scheduled transaction. It doesn't seem like much at first. The counter was at `0`, you ran a transaction, now it's at `1`. What's the big deal?
59+
The `readme` file has a robust getting started guide. Complete that to set up and run the demo scheduled transaction. It doesn't seem like much at first. The counter was at `0`, you ran a transaction, now it's at `1`. What's the big deal?
5860

5961
Let's try again to make it clearer what's happening. Open `cadence/transactions/ScheduleIncrementIn.cdc` and look at the arguments for the transaction:
6062

@@ -69,10 +71,10 @@ transaction(
6971

7072
The first parameter is the delay in seconds for the scheduled transaction. Let's try running it again. You'll need to be quick on the keyboard, so feel free to use a higher number of `delaySeconds` if you need to. You're going to:
7173

72-
1. Call the script to view the counter
73-
2. Call the transaction to schedule the counter to increment after 10 seconds
74-
3. Call the script to view the counter again and verify that it hasn't changed yet
75-
4. Wait 10 seconds, call it again, and confirm the counter incremented
74+
1. Call the script to view the counter.
75+
2. Call the transaction to schedule the counter to increment after 10 seconds.
76+
3. Call the script to view the counter again and verify that it hasn't changed yet.
77+
4. Wait 10 seconds, call it again, and confirm the counter incremented.
7678

7779
For your convenience, the updated transaction call is:
7880

@@ -137,7 +139,7 @@ Result: 3
137139

138140
### Review of the Existing Contract and Transactions
139141

140-
If you're not familiar with it, review `cadence/contracts/Counter.cdc`. This is the standard contract created by default when you run `flow init`. It's very simple, with a counter and public functions to increment or decrement it.
142+
If you're not familiar with `cadence/contracts/Counter.cdc` review it. This is the standard contract created by default when you run `flow init`. It's very simple, with a counter and public functions to increment or decrement it.
141143

142144
### Transaction Handler
143145

@@ -180,13 +182,13 @@ access(all) contract CounterTransactionHandler {
180182
}
181183
```
182184

183-
This contract is simple. It contains a [resource] that has a function with the `FlowTransactionScheduler.Execute` [entitlement]. This function contains the code that will be called by the scheduled transaction. It:
185+
This contract is simple. It contains a [resource] that has a function with the `FlowTransactionScheduler.Execute` [entitlement]. This function contains the code that the scheduled transaction calls. It:
184186

185-
1. Calls the `increment` function in the `Counter` contract
186-
2. Fetches the current value in the counter
187-
3. Logs that value to the console **for the emulator**
187+
1. Calls the `increment` function in the `Counter` contract.
188+
2. Fetches the current value in the counter.
189+
3. Logs that value to the console **for the emulator**.
188190

189-
It also contains functions to get metadata about the handler and a function, `createHandler`, which creates and returns an instance of the `Handler` resource. There are other metadata views that could be good to include in your Handler, but we are sticking to the basic ones for now.
191+
It also contains functions to get metadata about the handler and a function, `createHandler`, which creates and returns an instance of the `Handler` resource. There are other metadata views that could be good to include in your Handler, but we're sticking to the basic ones for now.
190192

191193
### Initializing the Transaction Handler
192194

@@ -237,9 +239,9 @@ manager.schedule(
237239

238240
It calls the `schedule` function from the `FlowTransactionSchedulerUtils.Manager` contract. This function has parameters for:
239241

240-
- `handlerCap`: The handler [capability] for the code that should be executed.
242+
- `handlerCap`: The handler [capability] for the code that should execute.
241243

242-
This was created above as a part of the previous transaction with:
244+
This was created above during the previous transaction with:
243245

244246
```cadence
245247
let handlerCap = signer.capabilities.storage
@@ -279,7 +281,7 @@ The transaction call has an argument for `delaySeconds`, which is then converted
279281
let future = getCurrentBlock().timestamp + delaySeconds
280282
```
281283

282-
- `priority`: The priority this transaction will be given in the event of network congestion. A higher priority means a higher fee for higher precedence.
284+
- `priority`: The priority this transaction is given in the event of network congestion. A higher priority means a higher fee for higher precedence.
283285

284286
The `priority` argument is supplied in the transaction as a `UInt8` for convenience, then converted into the appropriate [enum] type:
285287

@@ -291,11 +293,11 @@ let pr = priority == 0
291293
: FlowTransactionScheduler.Priority.Low
292294
```
293295

294-
The `executionEffort` is also supplied as an argument in the transaction. This represents the gas limit for your transaction and is used to prepare the estimate for the gas fees that must be paid for the transaction, and directly in the call to `schedule()` the transaction.
296+
The `executionEffort` is also supplied as an argument in the transaction. This represents the gas limit for your transaction and used to prepare the estimate for the gas fees that must be paid for the transaction, and directly in the call to `schedule()` the transaction.
295297

296298
- `fees`: A [vault] containing the appropriate amount of gas fees needed to pay for the execution of the scheduled transaction.
297299

298-
To create the vault, the `estimate()` function is first used to calculate the amount needed:
300+
To create the vault, the `estimate()` function calculates the amount needed:
299301

300302
```cadence
301303
let est = FlowTransactionScheduler.estimate(
@@ -306,7 +308,7 @@ let est = FlowTransactionScheduler.estimate(
306308
)
307309
```
308310

309-
Then, an [authorized reference] to the signer's vault is created and used to `withdraw()` the needed funds and [move] them into the `fees` variable which is then sent in the `schedule()` function call.
311+
Then, an [authorized reference] to the signer's vault is created and used to `withdraw()` the needed funds and [move] them into the `fees` variable, which is then sent in the `schedule()` function call.
310312

311313
Finally, we also `assert` that some minimums are met to ensure the transaction will be called:
312314

@@ -321,9 +323,9 @@ assert(
321323

322324
The `FlowTransactionSchedulerUtils.Manager` resource provides a safer and more convenient way to manage scheduled transactions. Instead of directly calling the `FlowTransactionScheduler` contract,
323325
you can use the Manager resource that manages all your scheduled transactions from a single place and handles many of the common patterns to reduce boilerplate code.
324-
It also provides many convenient functions to get detailed information about all the transactions you have scheduled by timestamp, handler, etc.
326+
It also provides many convenient functions to get detailed information about all the transactions you have scheduled by timestamp, handler, and so on.
325327
When setting up a manager, you also publish a capability for it so it is easy for scripts
326-
to query your account and also see what transactions you have scheduled!
328+
to query your account and also see what transactions are scheduled!
327329

328330
### Setting Up the Manager
329331

@@ -365,26 +367,26 @@ manager.schedule(
365367

366368
The Manager also provides utility methods for:
367369

368-
- Scheduling another transaction with a previously used handler
369-
- Getting scheduled transaction information in many different ways
370-
- Canceling scheduled transactions
371-
- Managing transaction handlers
372-
- Querying transaction status
370+
- Scheduling another transaction with a previously used handler.
371+
- Getting scheduled transaction information in many different ways.
372+
- Canceling scheduled transactions.
373+
- Managing transaction handlers.
374+
- Querying transaction status.
373375

374376
## Writing a New Scheduled Transaction
375377

376378
With this knowledge, we can create our own scheduled transaction. For this demo, we'll simply display a hello from an old friend in the emulator's console logs.
377379

378380
### Creating the Contracts
379381

380-
Start by using the [Flow CLI] to create a new contract called `RickRoll.cdc` and one called `RickRollTransactionHandler.cdc`:
382+
To start, use the [Flow CLI] to create a new contract called `RickRoll.cdc` and one called `RickRollTransactionHandler.cdc`:
381383

382384
```zsh
383385
flow generate contract RickRoll
384386
flow generate contract RickRollTransactionHandler
385387
```
386388

387-
Open the `RickRoll` contract, and add functions to log a fun message to the emulator console, and a variable to track which message to call:
389+
Open the `RickRoll` contract and add functions to log a fun message to the emulator console, and a variable to track which message to call:
388390

389391
```cadence
390392
access(all)
@@ -418,7 +420,7 @@ contract RickRoll {
418420
}
419421
```
420422

421-
Next, open `RickRollTransactionHandler.cdc`. Start by importing the `RickRoll` contract, `FlowToken`, `FungibleToken`, and `FlowTransactionScheduler`, and stubbing out the `Handler` and factory:
423+
Next, open `RickRollTransactionHandler.cdc`. Import the `RickRoll` contract, `FlowToken`, `FungibleToken`, and `FlowTransactionScheduler`, and stub out the `Handler` and factory:
422424

423425
```cadence
424426
import "FlowTransactionScheduler"
@@ -476,7 +478,7 @@ access(all) resource Handler: FlowTransactionScheduler.TransactionHandler {
476478
}
477479
```
478480

479-
We could move forward with this, but it would be more fun to have each transaction schedule the follow transaction to share the next message. You can do this by moving most of the code found in the transaction to the handler. Start with configuring the `delay`, `future`, `priority`, and `executionEffort`. We'll hardcode these for simplicity:
481+
We could move forward with this, but it would be more fun to have each transaction schedule the follow transaction to share the next message. To do this, move most of the code found in the transaction to the handler. Start with configuring the `delay`, `future`, `priority`, and `executionEffort`. We'll hardcode these for simplicity:
480482

481483
```cadence
482484
var delay: UFix64 = 5.0
@@ -679,7 +681,7 @@ transaction(
679681

680682
### Deployment and Testing
681683

682-
It's now time to deploy and test the new scheduled transaction!: First, add the new contracts to the emulator account in `flow.json` (other contracts may be present):
684+
It's now time to deploy and test the new scheduled transaction! First, add the new contracts to the emulator account in `flow.json` (other contracts may be present):
683685

684686
```json
685687
"deployments": {
@@ -698,14 +700,14 @@ Then, deploy the contracts to the emulator:
698700
flow project deploy --network emulator
699701
```
700702

701-
And execute the transaction to initialize the new scheduled transaction handler:
703+
Next, execute the transaction to initialize the new scheduled transaction handler:
702704

703705
```zsh
704706
flow transactions send cadence/transactions/InitRickRollHandler.cdc \
705707
--network emulator --signer emulator-account
706708
```
707709

708-
Finally, **get ready to quickly switch to the emulator console** and call the transaction to schedule the transaction!:
710+
Finally, **get ready to quickly switch to the emulator console** and call the transaction to schedule the transaction:
709711

710712
```zsh
711713
flow transactions send cadence/transactions/ScheduleRickRoll.cdc \
@@ -718,7 +720,7 @@ flow transactions send cadence/transactions/ScheduleRickRoll.cdc \
718720
]'
719721
```
720722

721-
In the logs, you'll see similar to:
723+
In the logs, you'll see content similar to:
722724

723725
```zsh
724726
11:40AM INF LOG: "[system.process_transactions] processing transactions"
@@ -757,13 +759,13 @@ In this tutorial, you learned about scheduled transactions, a powerful feature t
757759

758760
Now that you have completed this tutorial, you should be able to:
759761

760-
- Understand the concept of scheduled transactions and how they solve blockchain limitations
761-
- Explain the key components of the FlowTransactionScheduler system
762-
- Understand the benefits of the Transaction Scheduler Manager
763-
- Implement a basic scheduled transaction using the provided scaffold
764-
- Analyze the structure and flow of scheduled transaction transactions
765-
- Create custom scheduled transaction contracts and handlers
766-
- Evaluate the benefits and use cases of scheduled transactions in DeFi applications
762+
- Understand the concept of scheduled transactions and how they solve blockchain limitations.
763+
- Explain the key components of the FlowTransactionScheduler system.
764+
- Understand the benefits of the Transaction Scheduler Manager.
765+
- Implement a basic scheduled transaction using the provided scaffold.
766+
- Analyze the structure and flow of scheduled transaction transactions.
767+
- Create custom scheduled transaction contracts and handlers.
768+
- Evaluate the benefits and use cases of scheduled transactions in DeFi applications.
767769

768770
Scheduled transactions open up new possibilities for DeFi applications, enabling recurring jobs, deferred actions, and autonomous workflows that were previously impossible on blockchain. This feature represents a significant step forward in making blockchain more practical for real-world applications that require time-based execution.
769771

0 commit comments

Comments
 (0)