Skip to content

Commit 606ca7a

Browse files
authored
Generate Readme.md (#1762)
1 parent c63a3d5 commit 606ca7a

File tree

7 files changed

+852
-13
lines changed

7 files changed

+852
-13
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Flow CLI
3+
*
4+
* Copyright Flow Foundation
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package generator
20+
21+
import (
22+
"github.com/onflow/flowkit/v2"
23+
)
24+
25+
// FileTemplate is a template for raw
26+
type FileTemplate struct {
27+
TemplatePath string
28+
TargetPath string
29+
Data map[string]interface{}
30+
}
31+
32+
func NewFileTemplate(
33+
templatePath string,
34+
targetPath string,
35+
data map[string]interface{},
36+
) FileTemplate {
37+
return FileTemplate{
38+
TemplatePath: templatePath,
39+
TargetPath: targetPath,
40+
Data: data,
41+
}
42+
}
43+
44+
var _ TemplateItem = FileTemplate{}
45+
46+
// GetType returns the type of the contract
47+
func (c FileTemplate) GetType() string {
48+
return "file"
49+
}
50+
51+
func (c FileTemplate) GetTemplatePath() string {
52+
return c.TemplatePath
53+
}
54+
55+
// GetData returns the data of the contract
56+
func (c FileTemplate) GetData() map[string]interface{} {
57+
return c.Data
58+
}
59+
60+
func (c FileTemplate) GetTargetPath() string {
61+
return c.TargetPath
62+
}
63+
64+
func (c FileTemplate) UpdateState(state *flowkit.State) error {
65+
return nil
66+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
## 👋 Welcome Flow Developer!
2+
3+
Welcome to your new Flow project. This project is a starting point for you to develop smart contracts on the Flow Blockchain. It comes with example contracts, scripts, transactions, and tests to help you get started.
4+
5+
## 🔨 Getting Started
6+
7+
Here are some essential resources to help you hit the ground running:
8+
9+
- **[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.
10+
- **[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.
11+
- **[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.
12+
- **[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.
13+
- **[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.
14+
15+
## 📦 Project Structure
16+
17+
Your project has been set up with the following structure:
18+
19+
- `flow.json` - This is the configuration file for your project (analogous to a `package.json` file for NPM). It has been initialized with a basic configuration to get started.
20+
- `/cadence` - This is where your Cadence smart contracts code lives
21+
22+
Inside the `cadence` folder you will find:
23+
- `/contracts` - This folder contains your Cadence contracts (these are deployed to the network and contain the business logic for your application)
24+
- `ExampleContract.cdc`
25+
- `/scripts` - This folder contains your Cadence scripts (read-only operations)
26+
- `ExampleScript.cdc`
27+
- `/transactions` - This folder contains your Cadence transactions (state-changing operations)
28+
- `ExampleTransaction.cdc`
29+
- `/tests` - This folder contains your Cadence tests (integration tests for your contracts, scripts, and transactions to verify they behave as expected)
30+
- `ExampleTest.cdc`
31+
32+
## 👨‍💻 Start Developing
33+
34+
### Creating a New Contract
35+
36+
To add a new contract to your project, run the following command:
37+
38+
```shell
39+
flow generate contract
40+
```
41+
42+
This command will create a new contract file and add it to the `flow.json` configuration file.
43+
44+
### Creating a New Script
45+
46+
To add a new script to your project, run the following command:
47+
48+
```shell
49+
flow generate script
50+
```
51+
52+
This 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).
53+
54+
You can import any of your own contracts or installed dependencies in your script file using the `import` keyword. For example:
55+
56+
```cadence
57+
import "Counter"
58+
```
59+
60+
### Creating a New Transaction
61+
62+
To add a new transaction to your project you can use the following command:
63+
64+
```shell
65+
flow generate transaction
66+
```
67+
68+
This 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).
69+
70+
You can import any dependencies as you would in a script file.
71+
72+
### Creating a New Test
73+
74+
To add a new test to your project you can use the following command:
75+
76+
```shell
77+
flow generate test
78+
```
79+
80+
This command will create a new test file. Tests are used to verify that your contracts, scripts, and transactions are working as expected.
81+
82+
### Installing External Dependencies
83+
84+
If 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).
85+
86+
For example, to install the NonFungibleToken contract you can use the following command:
87+
88+
```shell
89+
flow deps add mainnet://1d7e57aa55817448.NonFungibleToken
90+
```
91+
92+
Contracts can be found using [ContractBrowser](https://contractbrowser.com/), but be sure to verify the authenticity before using third-party contracts in your project.
93+
94+
## 🧪 Testing
95+
96+
To verify that your project is working as expected you can run the tests using the following command:
97+
98+
```shell
99+
flow test
100+
```
101+
102+
This 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).
103+
104+
To learn more about testing in Cadence, check out the [Cadence Test Framework Documentation](https://cadence-lang.org/docs/testing-framework).
105+
106+
## 🚀 Deploying Your Project
107+
108+
To 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.
109+
110+
You can create a new Flow account using the following command:
111+
112+
```shell
113+
flow accounts create
114+
```
115+
116+
Learn more about setting up deployment targets in the [Flow CLI documentation](https://developers.flow.com/tools/flow-cli/deployment/project-contracts).
117+
118+
### Deploying to the Flow Emulator
119+
120+
To deploy your project to the Flow Emulator, start the emulator using the following command:
121+
122+
```shell
123+
flow emulator --start
124+
```
125+
126+
To deploy your project, run the following command:
127+
128+
```shell
129+
flow project deploy --network=emulator
130+
```
131+
132+
This 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).
133+
134+
### Deploying to Flow Testnet
135+
136+
To deploy your project to Flow Testnet you can use the following command:
137+
138+
```shell
139+
flow project deploy --network=testnet
140+
```
141+
142+
This command will deploy your project to Flow Testnet. You can now interact with your project on this network using the Flow CLI or any other Flow client.
143+
144+
### Deploying to Flow Mainnet
145+
146+
To deploy your project to Flow Mainnet you can use the following command:
147+
148+
```shell
149+
flow project deploy --network=mainnet
150+
```
151+
152+
This command will deploy your project to Flow Mainnet. You can now interact with your project using the Flow CLI or alternate [client](https://developers.flow.com/tools/clients).
153+
154+
## 📚 Other Resources
155+
156+
- [Cadence Design Patterns](https://cadence-lang.org/docs/design-patterns)
157+
- [Cadence Anti-Patterns](https://cadence-lang.org/docs/anti-patterns)
158+
- [Flow Core Contracts](https://developers.flow.com/build/core-contracts)
159+
160+
## 🤝 Community
161+
- [Flow Community Forum](https://forum.onflow.org/)
162+
- [Flow Discord](https://discord.gg/flow)
163+
- [Flow Twitter](https://x.com/flow_blockchain)
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
## 👋 Welcome Flow Developer!
2+
3+
Welcome to your new Flow project. This project is a starting point for you to develop smart contracts on the Flow Blockchain. It comes with example contracts, scripts, transactions, and tests to help you get started.
4+
5+
## 🔨 Getting Started
6+
7+
Here are some essential resources to help you hit the ground running:
8+
9+
- **[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.
10+
- **[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.
11+
- **[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.
12+
- **[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.
13+
- **[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.
14+
15+
## 📦 Project Structure
16+
17+
Your project has been set up with the following structure:
18+
19+
- `flow.json` - This is the configuration file for your project (analogous to a `package.json` file for NPM). It has been initialized with a basic configuration and your selected Core Contract dependencies to get started.
20+
21+
Your project has also been configured with the following dependencies. You can add more dependencies using the `flow deps add` command:
22+
- `FlowToken`
23+
- `FungibleToken`
24+
25+
- `/cadence` - This is where your Cadence smart contracts code lives
26+
27+
Inside the `cadence` folder you will find:
28+
- `/contracts` - This folder contains your Cadence contracts (these are deployed to the network and contain the business logic for your application)
29+
- `ExampleContract.cdc`
30+
- `/scripts` - This folder contains your Cadence scripts (read-only operations)
31+
- `ExampleScript.cdc`
32+
- `/transactions` - This folder contains your Cadence transactions (state-changing operations)
33+
- `ExampleTransaction.cdc`
34+
- `/tests` - This folder contains your Cadence tests (integration tests for your contracts, scripts, and transactions to verify they behave as expected)
35+
- `ExampleTest.cdc`
36+
37+
## 👨‍💻 Start Developing
38+
39+
### Creating a New Contract
40+
41+
To add a new contract to your project, run the following command:
42+
43+
```shell
44+
flow generate contract
45+
```
46+
47+
This command will create a new contract file and add it to the `flow.json` configuration file.
48+
49+
### Creating a New Script
50+
51+
To add a new script to your project, run the following command:
52+
53+
```shell
54+
flow generate script
55+
```
56+
57+
This 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).
58+
59+
You can import any of your own contracts or installed dependencies in your script file using the `import` keyword. For example:
60+
61+
```cadence
62+
import "Counter"
63+
```
64+
65+
### Creating a New Transaction
66+
67+
To add a new transaction to your project you can use the following command:
68+
69+
```shell
70+
flow generate transaction
71+
```
72+
73+
This 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).
74+
75+
You can import any dependencies as you would in a script file.
76+
77+
### Creating a New Test
78+
79+
To add a new test to your project you can use the following command:
80+
81+
```shell
82+
flow generate test
83+
```
84+
85+
This command will create a new test file. Tests are used to verify that your contracts, scripts, and transactions are working as expected.
86+
87+
### Installing External Dependencies
88+
89+
If 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).
90+
91+
For example, to install the NonFungibleToken contract you can use the following command:
92+
93+
```shell
94+
flow deps add mainnet://1d7e57aa55817448.NonFungibleToken
95+
```
96+
97+
Contracts can be found using [ContractBrowser](https://contractbrowser.com/), but be sure to verify the authenticity before using third-party contracts in your project.
98+
99+
## 🧪 Testing
100+
101+
To verify that your project is working as expected you can run the tests using the following command:
102+
103+
```shell
104+
flow test
105+
```
106+
107+
This 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).
108+
109+
To learn more about testing in Cadence, check out the [Cadence Test Framework Documentation](https://cadence-lang.org/docs/testing-framework).
110+
111+
## 🚀 Deploying Your Project
112+
113+
To 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.
114+
115+
You can create a new Flow account using the following command:
116+
117+
```shell
118+
flow accounts create
119+
```
120+
121+
Learn more about setting up deployment targets in the [Flow CLI documentation](https://developers.flow.com/tools/flow-cli/deployment/project-contracts).
122+
123+
### Deploying to the Flow Emulator
124+
125+
To deploy your project to the Flow Emulator, start the emulator using the following command:
126+
127+
```shell
128+
flow emulator --start
129+
```
130+
131+
To deploy your project, run the following command:
132+
133+
```shell
134+
flow project deploy --network=emulator
135+
```
136+
137+
This 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).
138+
139+
### Deploying to Flow Testnet
140+
141+
To deploy your project to Flow Testnet you can use the following command:
142+
143+
```shell
144+
flow project deploy --network=testnet
145+
```
146+
147+
This command will deploy your project to Flow Testnet. You can now interact with your project on this network using the Flow CLI or any other Flow client.
148+
149+
### Deploying to Flow Mainnet
150+
151+
To deploy your project to Flow Mainnet you can use the following command:
152+
153+
```shell
154+
flow project deploy --network=mainnet
155+
```
156+
157+
This command will deploy your project to Flow Mainnet. You can now interact with your project using the Flow CLI or alternate [client](https://developers.flow.com/tools/clients).
158+
159+
## 📚 Other Resources
160+
161+
- [Cadence Design Patterns](https://cadence-lang.org/docs/design-patterns)
162+
- [Cadence Anti-Patterns](https://cadence-lang.org/docs/anti-patterns)
163+
- [Flow Core Contracts](https://developers.flow.com/build/core-contracts)
164+
165+
## 🤝 Community
166+
- [Flow Community Forum](https://forum.onflow.org/)
167+
- [Flow Discord](https://discord.gg/flow)
168+
- [Flow Twitter](https://x.com/flow_blockchain)

0 commit comments

Comments
 (0)