|
| 1 | +<br /> |
| 2 | +<p align="center"> |
| 3 | + <a href="https://docs.onflow.org/flow-cli/install/"> |
| 4 | + <img src="https://raw.githubusercontent.com/onflow/flow-cli/tmp/cli-dev/quick.svg" alt="Logo" width="470" height="auto"> |
| 5 | + </a> |
| 6 | + |
| 7 | + <p align="center"> |
| 8 | + <i>Flow Quickstart will help you develop your first project without breaking a sweat.</i> |
| 9 | + <br /> |
| 10 | + <a href="https://docs.onflow.org/flow-cli/install/"><strong>Read on docs »</strong></a> |
| 11 | + <br /> |
| 12 | + <br /> |
| 13 | + <a href="https://github.com/onflow/flow-cli/issues">Development Guidelines</a> |
| 14 | + · |
| 15 | + <a href="https://github.com/onflow/flow-cli/blob/master/CONTRIBUTING.md">Contribute</a> |
| 16 | + </p> |
| 17 | +</p> |
| 18 | +<br /> |
| 19 | +<br /> |
| 20 | + |
| 21 | +### 👋 Welcome Flow Developer! |
| 22 | +You've come to the right place. We will help you develop your first Flow application. |
| 23 | + |
| 24 | +### 🔨 Getting started |
| 25 | +Starting your project is very simple. |
| 26 | + |
| 27 | +1. Run flow setup command `flow setup` |
| 28 | +2. Run flow development command `flow dev` |
| 29 | +3. Start writing your contracts, we will take care of the rest |
| 30 | + |
| 31 | +### 💿 Flow Setup |
| 32 | +Flow setup is the initial command you run to start your new Flow project. |
| 33 | +```shell |
| 34 | +> flow setup |
| 35 | +``` |
| 36 | +The command will generate standard Flow proejct structure with the following resources: |
| 37 | + |
| 38 | +- **/contracts** all your contract source code goes in this folder, you can read more about Cadence contracts here. |
| 39 | +- **/scripts** all your scripts goes here, you can read more about Cadence scripts here. |
| 40 | +- **/transactions** all the transactions goes in this folder, you can read more about Cadence transactions here. |
| 41 | +- **flow.json** this is a configuration file for your project, but you don't need to worry about it, we will configure everything for you as you go. |
| 42 | + |
| 43 | + |
| 44 | +### 📦 Flow Develop |
| 45 | +Flow develop command can be run after you created the project using the above flow setup command. You can run it like so: |
| 46 | +```shell |
| 47 | +> flow dev |
| 48 | +``` |
| 49 | +Running this command will start up a local emulator, which behaves similar to the real Flow network so you can use it during testing. It will then automatically watch your project files and make sure to automatically sync all the contracts on the network. |
| 50 | + |
| 51 | +You should see something similar to: |
| 52 | +```shell |
| 53 | +Development environment activated, we will keep an eye on any new contracts |
| 54 | +you crate inside the contract folders and automatically deploy them for you. |
| 55 | +If you create a folder inside the contract folder we will automatically |
| 56 | +create an account with that name and deploy the contract in that account. |
| 57 | + |
| 58 | + |
| 59 | +[15:53:38] Syncing all the contracts... |
| 60 | + |
| 61 | +😎 bob |
| 62 | + |- Test contracts/bob/test.cdc |
| 63 | + |
| 64 | +😜 charlie |
| 65 | + |- Goo contracts/charlie/Goo.cdc |
| 66 | + |- Loo contracts/charlie/Loo.cdc |
| 67 | + |
| 68 | +😏 emulator-account |
| 69 | + |- Taa contracts/Taa.cdc |
| 70 | + |- Koo contracts/Koo.cdc |
| 71 | + |- Xoo contracts/Xoo.cdc |
| 72 | + |- Moo contracts/Moo.cdc |
| 73 | +``` |
| 74 | + |
| 75 | +When you want to import the contract you just created you can simply do by writing the import statement: |
| 76 | +``` |
| 77 | +import Foo |
| 78 | +``` |
| 79 | +We will automatically find your contract named `Foo` and make sure it's deployed and imported ready to be used. |
| 80 | +If you want to deploy a contract to a specific account you can just create a folder inside the contracts folder and we will create the account for you which will have the same name as the folder you created. All the contracts inside this folder will be deployed automatically to that account. |
| 81 | + |
| 82 | +Example deploying to charlie account: |
| 83 | + |
| 84 | +_folder structure_ |
| 85 | +``` |
| 86 | +/contracts |
| 87 | + Bar.cdc |
| 88 | + /charlie |
| 89 | + Foo.cdc |
| 90 | +``` |
| 91 | + |
| 92 | +You can then import the `Foo` contract in `Bar` contract like so: |
| 93 | +``` |
| 94 | +import Foo from "charlie" |
| 95 | +``` |
| 96 | + |
| 97 | + |
| 98 | +### 🚀 Flow Execute |
| 99 | + |
| 100 | +This command can be used to send transactions or scripts easily by using the following command: |
| 101 | +```shell |
| 102 | +flow exec sendToken |
| 103 | +``` |
| 104 | +The command will automatically search for that file in scripts and contracts and will execute it for you. |
| 105 | + |
| 106 | + |
| 107 | +### 🎉 Flow Migrate |
| 108 | +After you finish writing your project and you are ready to move on to testnet or mainnet we got you covered ther as well. |
| 109 | + |
| 110 | +You can easily migrate your just created project by running: |
| 111 | + |
| 112 | +```shell |
| 113 | +> flow migrate |
| 114 | + |
| 115 | +❓ Where do you want to migrate your project to? |
| 116 | + > 'TESTNET' < |
| 117 | + 'MAINNET' |
| 118 | + |
| 119 | +Looks like you are missing some of the accounts on the TESTNET: |
| 120 | + - 'charlie' |
| 121 | + - 'bob' |
| 122 | + |
| 123 | +❓ Do you want to create those accounts automatically? |
| 124 | + > 'YES' < |
| 125 | + 'NO' |
| 126 | + |
| 127 | +❗ This command will perform the following: |
| 128 | + - Generate a new ECDSA P-256 public and private key pair. |
| 129 | + - Create a new account on Local Emulator paired with the public key. |
| 130 | + - Save the newly-created account to flow.json and the keys to keys.json. |
| 131 | + |
| 132 | + |
| 133 | +✨ Project successfully migrated to 'TESTNET' |
| 134 | + |
| 135 | +😎 bob (0xf8d6e0586b0a20c7) |
| 136 | + |- Test contracts/bob/test.cdc |
| 137 | + |
| 138 | +😏 charlie (0xb446e0586b0a20133) |
| 139 | + |- Goo contracts/charlie/Goo.cdc |
| 140 | + |- Loo contracts/charlie/Loo.cdc |
| 141 | + |
| 142 | +``` |
0 commit comments