You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/blockchain-development-tutorials/native-vrf/commit-reveal-cadence.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,13 +21,13 @@ keywords:
21
21
22
22
Randomness is a critical component in blockchain applications. It allows fair and unpredictable outcomes for use cases like gaming, lotteries, and cryptographic protocols.
23
23
24
-
The most basic approach that you can use to generate a random number on EVM chains is to use block hashes, which combines the block hash with a user-provided seed and hashes them together. You can use the has that results as a pseudo-random generator seed. However, this approach has limitations. A validator that influences the random source used to compute transactions can manipulate the block hash. The block proposer can decide what to include into a block and can iterate through different combinations until they find a favorable random source.
24
+
The most basic approach that you can use to generate a random number on EVM chains is to use block hashes, which combines the block hash with a user-provided seed and hashes them together. You can use the hash that results as a pseudo-random generator seed. However, this approach has limitations. A validator that influences the random source used to compute transactions can manipulate the block hash. The block proposer can decide what to include into a block and can iterate through different combinations until they find a favorable random source.
25
25
26
26
[Chainlink VRF][chainlink-vrf] is a popular tool that improves on this. It provides another approach you can use to generate provably random values on Ethereum and other blockchains. It relies on a decentralized oracle network to deliver cryptographically secure randomness from off-chain sources. However, this dependence on external oracles introduces several weaknesses, such as cost, latency, and scalability concerns.
27
27
28
-
In contrast, Flow offers a simpler and more integrated approach with its native onchain Randomness Beacon at the protocol level, which eliminates reliance on external oracles and sidestepping their associated risks.
28
+
In contrast, Flow offers a simpler and more integrated approach with its native onchain Randomness Beacon at the protocol level, which eliminates reliance on external oracles and the need to sidestep their associated risks.
29
29
30
-
In addition to instant randomness that is available to any transaction (via `revertibleRandom` function), Flow provides a solution to the problem of a user reverting a transaction with an unfavorable outcome. Commit-Reveal schemes on Flow also rely on protocol-native secure randomness and they fix the issue of post-selection by trustless users. Commit-Reveal tools on Flow can be used within both Cadence and Consumer Decentralized Finance (DeFi) contracts. This tutorial focuses on Cadence.
30
+
In addition to instant randomness that is available to any transaction (via `revertibleRandom` function), Flow provides a solution to the problem of a user who reverts a transaction with an unfavorable outcome. Commit-Reveal schemes on Flow also rely on protocol-native secure randomness and they fix the issue of post-selection by trustless users. Commit-Reveal tools on Flow can be used within both Cadence and Consumer Decentralized Finance (DeFi) contracts. This tutorial focuses on Cadence.
31
31
32
32
## Objectives
33
33
@@ -55,7 +55,7 @@ To illustrate this concept, we will build a Coin Toss game on Flow, which demons
55
55
56
56
### What is the Coin Toss Game?
57
57
58
-
The Coin Toss Game is a decentralized betting game that showcases the commit-reveal pattern. Players place bets without knowing the random outcome, which ensures fairness and resistance to manipulation.
58
+
The Coin Toss Game is a decentralized betting game that showcases the commit-reveal pattern. Players place bets and don't know the random outcome, which ensures fairness and resistance to manipulation.
59
59
60
60
The game consists of two distinct phases:
61
61
@@ -80,13 +80,13 @@ In addition, commit-reveal patterns solve the issue of revertible randoms:
80
80
81
81
:::info
82
82
83
-
One of the powers of Cadence transactions is that a developer can set post-conditions that must be true, or the transaction will revert. This is very useful for scenarios such as guaranteeing a user receives their purchase in a complex and multi-step transaction, but it also means that they can set conditions to reject the transaction. In an instant-win lottery, this would allow users to test large numbers of tickets for a win without paying the purchase price.
83
+
One of the powers of Cadence transactions is that a developer can set post-conditions that must be true, or the transaction will revert. This is very useful for scenarios such as to guarantee a user receives their purchase in a complex and multi-step transaction, but it also means that they can set conditions to reject the transaction. In an instant-win lottery, this would allow users to test large numbers of tickets for a win without purchase price payment.
84
84
85
85
:::
86
86
87
87
## Build the Coin Toss contract
88
88
89
-
In this section, we'll walk through how to construct the `CoinToss.cdc` contract, which contains the core logic for the Coin Toss game. To function properly, the contract relies on supporting contracts and a proper deployment setup.
89
+
In this section, we'll walk through how to construct the `CoinToss.cdc` contract, which contains the core logic for the Coin Toss game. To function properly, the contract relies on support contracts and a proper deployment setup.
90
90
91
91
This tutorial will focus specifically on how to write and understand the `CoinToss.cdc` contract, while you can find additional setup details in the [original GitHub repo][github-repo].
92
92
@@ -136,7 +136,7 @@ access(all) fun flipCoin(bet: @{FungibleToken.Vault}): @Receipt {
136
136
137
137
### Step 3: Implement the reveal phase With `revealCoin`
138
138
139
-
Now we implement the reveal phase with the `revealCoin` function. Here, the caller provides the Receipt they recieve at commitment. The contract then "flips a coin" with`_randomCoin()`providing the Receipt's contained Request. The reveal step is possible only when the protocol random source at the committed block height becomes available.
139
+
Now we implement the reveal phase with the `revealCoin` function. Here, the caller provides the Receipt they recieve at commitment. The contract then "flips a coin" and`_randomCoin()`provides the Receipt's contained Request. The reveal step is possible only when the protocol random source at the committed block height becomes available.
140
140
141
141
If result is 1, the user loses, but if it's 0, the user doubles their bet. Note that the caller could condition the revealed transaction, but they've already provided their bet amount, so there's no loss for the contract if they do.
5. Track it: You can take the transaction id to [FlowDiver][flow-diver][.io](https://testnet.flowdiver.io/tx/9c4f5436535d36a82d4ae35467b37fea8971fa0ab2409dd0d5f861f61e463d98) to have a full view of everything that's going on with this `FlipCoin` transaction.
216
+
5. Track it: You can take the transaction id to [FlowDiver][flow-diver][.io] to have a full view of everything about this `FlipCoin` transaction.
217
217
218
218
### Reveal the coin toss result
219
219
220
220
Let's reveal the outcome of your coin toss to see if you've won. This step uses the receipt from your bet, so ensure you use the same account that placed the bet. Here's how to do it:
221
221
222
222
1. Return to your Dev Environment: Open [run.dnz][run-dnz] again.
223
-
2. Enter the Reveal Code: Paste the following Cadence transaction into the editor:
223
+
2. Enter the Reveal Code. Paste the following Cadence transaction into the editor:
224
224
225
225
```cadence
226
226
import FlowToken from 0x7e60df042a9c0868
@@ -249,7 +249,7 @@ transaction {
249
249
}
250
250
```
251
251
252
-
After we run this transaction, we reveal the result of the coin flip and it's 1! It means we haven't won anything this time, but keep trying!
252
+
After we run this transaction, we reveal the result of the coin flip and it's 1! It means we haven't won anything this time, but we'll try again!
253
253
254
254
You can find the full transaction used for this example, with its result and events, at [FlowDiver.io/tx/][flow-diver-tx].
255
255
@@ -276,6 +276,7 @@ When you harness the built-in randomness capabilities on Flow, you can create en
Copy file name to clipboardExpand all lines: docs/blockchain-development-tutorials/use-AI-to-build-on-flow/agents/agentkit-flow-guide.md
+43-29Lines changed: 43 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ sidebar_label: Using AgentKit on Flow
5
5
sidebar_position: 2
6
6
---
7
7
8
-
# Getting Started with AgentKit on Flow
8
+
# Build Custom AI Agents on Flow with AgentKit
9
9
10
10
AgentKit is an ecosystem-agnostic modular developer toolkit that lets you rapidly build, deploy, and iterate on AI agents using pre-configured environments and ready-to-use templates.
11
11
12
12
In this guide, you'll set up your own custom agent that runs on **Flow's EVM-compatible testnet**, powered by **Langchain** and **Anthropic's Claude** LLM.
13
13
14
14
---
15
15
16
-
## Quickstart - Starting From Scratch
16
+
## Quickstart - start from scratch
17
17
18
18
Open your terminal and run:
19
19
@@ -36,7 +36,7 @@ Follow the interactive setup:
36
36
37
37
---
38
38
39
-
## Project Setup
39
+
## Project setup
40
40
41
41
When your scaffold is ready:
42
42
@@ -45,7 +45,7 @@ cd onchain-agent
45
45
npm install
46
46
```
47
47
48
-
Now open the project in your preferred integrated development environment (IDE) (for example, [Cursor](../cursor/index.md).
48
+
Now open the project in your preferred integrated development environment (IDE) (for example, [Cursor].
49
49
50
50
### Environment Configuration
51
51
@@ -56,7 +56,7 @@ Now open the project in your preferred integrated development environment (IDE)
56
56
57
57
### Get Your Anthropic API Key
58
58
59
-
- Head to [Anthropic Console](https://console.anthropic.com/dashboard).
59
+
- Head to [Anthropic Console].
60
60
- Create an account and **purchase credits**.
61
61
- Click **Create Key**, name it, and copy the API key.
62
62
- Add this to your `.env.local`:
@@ -65,10 +65,10 @@ Now open the project in your preferred integrated development environment (IDE)
65
65
ANTHROPIC_API_KEY=your_api_key_here
66
66
```
67
67
68
-
### Wallet Setup with MetaMask
68
+
### Wallet setup with MetaMask
69
69
70
-
1. Add [Flow Testnet](https://developers.flow.com/evm/using) to MetaMask.
71
-
2. Use the [Faucet](https://faucet.flow.com/fund-account) to fund your wallet.
70
+
1. Add [Flow Testnet] to MetaMask.
71
+
2. Use the [Faucet] to fund your wallet.
72
72
3. Get your private key:
73
73
- Click the `...` menu in MetaMask > **Account Details**.
74
74
- Enter your password, copy the private key.
@@ -104,11 +104,11 @@ http://localhost:3000
104
104
105
105
If your agent doesn't respond yet, no worries! You still need to configure your **LLM and client libraries**.
106
106
107
-
### Choose a Model
107
+
### Choose a model
108
108
109
-
Langchain supports many LLMs ([full list here](https://python.langchain.com/docs/integrations/llms/)).
109
+
Langchain supports many LLMs ([full list here]).
110
110
111
-
For this example, we'll use **Anthropic's `claude-3-5-haiku-20241022`**, a lightweight and affordable model. Alternatively, [DeepSeek](https://deepseek.com/) is highly recommended for budget-friendly usage.
111
+
For this example, we'll use **Anthropic's `claude-3-5-haiku-20241022`**, a lightweight and affordable model. Alternatively, [DeepSeek] is highly recommended for budget-friendly usage.
Copy file name to clipboardExpand all lines: docs/blockchain-development-tutorials/use-AI-to-build-on-flow/agents/eliza/build-plugin.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ keywords:
18
18
19
19
Plugins are a powerful way to extend the functionality of your Eliza AI agents. This guide will walk you through the process of how to create custom plugins that can enhance your agent's capabilities, from simple utilities to complex integrations with external services. You'll learn how to leverage the plugin system to create modular and reusable components for your AI agents.
20
20
21
-
## Learning Objectives
21
+
## Learning objectives
22
22
23
23
After you complete this tutorial, you will be able to:
24
24
@@ -33,21 +33,21 @@ After you complete this tutorial, you will be able to:
33
33
34
34
Before you get started with Eliza, make sure you have:
35
35
36
-
-[Node.js 23+] (using [nvm] is recommended)
36
+
-[Node.js 23+] (we recommend that you use [nvm])
37
37
-[pnpm 9+]
38
38
- Git for version control
39
-
- A code editor ([VS Code], [Cursor] or [VSCodium] recommended)
39
+
- A code editor (we recommend [VS Code], [Cursor] or [VSCodium])
40
40
-[Flow-cli] for Flow blockchain interaction.
41
41
42
-
> **Note for Windows Users:**[WSL 2] is required.
42
+
> **Note for Windows users:**[WSL 2] is required.
43
43
44
44
## Quickstart
45
45
46
46
Follow the [Quickstart Guide] to set up your development environment.
47
47
48
-
## Plugin Development
48
+
## Plugin development
49
49
50
-
### Create a Plugin repository from Template
50
+
### Create a plugin repository from Template
51
51
52
52
Visit [Eliza Plugin Template] and click "Use this template" to create a new repository.
### Add Plugin to the `character.json` you want to use
107
+
### Add the plugin to the `character.json` you want to use
108
108
109
-
Let's say you want to add the plugin to the `sample` character which is `characters/sample.character.json`.
109
+
Let's say you want to add the plugin to the `sample` character, which is `characters/sample.character.json`.
110
110
111
111
```json
112
112
{
@@ -119,7 +119,7 @@ Let's say you want to add the plugin to the `sample` character which is `charact
119
119
120
120
:::warning
121
121
122
-
If you use Dependency Injection(`@elizaos-plugins/plugin-di`) in your plugin, remember to add it to the `postProcessors` field. And**`clients` field is deprecated** in the latest version of Eliza, so if you want to add clients, you also need to use `plugins` field.
122
+
If you use Dependency Injection(`@elizaos-plugins/plugin-di`) in your plugin, remember to add it to the `postProcessors` field. The**`clients` field is deprecated** in the latest version of Eliza, so if you want to add clients, you also need to use `plugins` field.
123
123
124
124
:::
125
125
@@ -136,7 +136,7 @@ If you use Dependency Injection(`@elizaos-plugins/plugin-di`) in your plugin, re
0 commit comments