diff --git a/docs/build/getting-started/flow-cli.md b/docs/build/getting-started/flow-cli.md index 62e2f68f75..085c545694 100644 --- a/docs/build/getting-started/flow-cli.md +++ b/docs/build/getting-started/flow-cli.md @@ -160,7 +160,7 @@ You can't deploy the same contract to multiple accounts at the same time with th ::: -## Running Scripts +## Creating Scripts Scripts are used to read data from the Flow blockchain. There is no state modification. In our case, we are going to read a greeting from the `HelloWorld` contract. @@ -170,7 +170,9 @@ If we wanted to generate a new script, we could run: flow generate script ScriptName ``` -But the default project already has a `GetCounter` script for reading the count of the `Counter` contract. Open `cadence/scripts/GetCounter.cdc` in your editor to see the script. +## Running Scripts + +The default project already has a `GetCounter` script for reading the count of the `Counter` contract. Open `cadence/scripts/GetCounter.cdc` in your editor to see the script. To run the script, you can run: diff --git a/docs/tools/flow-cli/boilerplate.md b/docs/tools/flow-cli/boilerplate.md index 1073d8200a..f05fe2e962 100644 --- a/docs/tools/flow-cli/boilerplate.md +++ b/docs/tools/flow-cli/boilerplate.md @@ -7,7 +7,7 @@ sidebar_position: 16 ## Introduction -Flow CLI now includes a feature to automatically generate boilerplate code for contracts, transactions, and scripts. This feature enhances the development experience by simplifying the initial setup of various components in Flow. +Flow CLI includes a feature to automatically generate boilerplate code for contracts, transactions, and scripts. This feature enhances the development experience by simplifying the initial setup of various components in Flow. ```shell > flow generate @@ -23,7 +23,7 @@ Available Commands: transaction Generate a new transaction ``` -## Generate Contract +## Create a Contract To create a new contract with basic structure, use the `contract` command. It creates a new Cadence file with a template contract definition. @@ -45,7 +45,7 @@ access(all) contract HelloWorld { } ``` -## Generate Transaction +## Create a Transaction For initializing a transaction, use the `transaction` command. It sets up a new Cadence file with a template transaction structure. @@ -69,7 +69,9 @@ transaction() { } ``` -## Generate Script +It also adds the new contract to `flow.json`. + +## Create a Script Similarly, to start a new script, the `script` command generates a Cadence file with a basic script structure. @@ -101,4 +103,3 @@ The `--dir` flag is an optional feature in the Flow CLI `generate` commands, all - **Example**: `flow generate contract HelloWorld --dir=custom_contracts` Use the `--dir` flag only if your project requires a different organizational structure than the default. - diff --git a/docs/tools/flow-cli/index.md b/docs/tools/flow-cli/index.md index 583c9679a8..8905131c14 100644 --- a/docs/tools/flow-cli/index.md +++ b/docs/tools/flow-cli/index.md @@ -6,19 +6,69 @@ sidebar_position: 3 The **Flow Command Line Interface (CLI)** is a powerful tool that enables developers to seamlessly interact with the Flow blockchain across various environments, including testnet, mainnet, and local development using the Flow Emulator. Designed for ease of use, the Flow CLI simplifies common blockchain tasks such as managing accounts and contract dependencies, sending transactions, querying chain state, deploying smart contracts, and much more. +## Basic Usage + +The Flow CLI is essential for developers looking to build, test, and maintain decentralized applications on the Flow blockchain efficiently, offering a feature-rich, user-friendly interface for both beginners and experienced blockchain developers. + With Flow CLI, developers can: -- **Initialize Projects**: Quickly set up new Flow projects using the `flow init` command, which creates the necessary files and directories, sets up your project configuration, and installs any core contract dependencies. -- **Manage Contract Dependencies**: Use the [Dependency Manager](dependency-manager.md) to install and manage smart contract dependencies effortlessly, simplifying the integration of external contracts into your project. -- **Manage Accounts**: Create and manage Flow accounts, configure keys, and handle account-related operations. -- **Send Transactions**: Build, sign, and submit transactions to the Flow network, allowing for contract interaction and fund transfers. -- **Query Chain State**: Retrieve data from the Flow blockchain, including account balances, event logs, and the status of specific transactions. -- **Deploy Smart Contracts**: Easily deploy and update Cadence smart contracts on any Flow environment (emulator, testnet, or mainnet). -- **Use the Emulator:** Set up a local Flow blockchain instance with the Flow emulator to test and debug smart contracts in a development environment before deploying them on the network. -- **Interact with the [Flow Access API](/http-api)**: Automate complex workflows using configuration files and command-line scripting, which allows for greater flexibility in continuous integration (CI) or custom development tools. -- **Access Flow’s Tooling Ecosystem**: Integrate Flow CLI with other developer tools like the [Cadence Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=onflow.cadence) to enhance your development experience. +### Initialize Projects -The Flow CLI is essential for developers looking to build, test, and maintain decentralized applications on the Flow blockchain efficiently, offering a feature-rich, user-friendly interface for both beginners and experienced blockchain developers. +Quickly set up new Flow projects using the [`flow init`] command, which creates the necessary files and directories, sets up your project configuration, and installs any core contract dependencies. + +### Manage Contract Dependencies + +Use the [Dependency Manager] to install and manage smart contract dependencies effortlessly, simplifying the integration of external contracts into your project. + +### Manage Accounts + +Create and manage Flow [accounts], configure keys, and handle account-related operations. + +### Send Transactions + +Build, sign, and submit [transactions] to the Flow network, allowing for contract interaction and fund transfers. + +### Query Chain State with Scripts + +Use [scripts] to retrieve data from the Flow blockchain, including account balances, event logs, and the status of specific transactions. + +### Deploy Smart Contracts + +Easily deploy and update Cadence smart contracts on any Flow environment (emulator, testnet, or mainnet). + +### Use the Emulator + +Set up a local Flow blockchain instance with the Flow [emulator] to test and debug smart contracts in a development environment before deploying them on the network. + +### Interact with the Flow Access API + +With the [Flow Access API](/http-api), you can automate complex workflows using configuration files and command-line scripting, which allows for greater flexibility in continuous integration (CI) or custom development tools. + +### Access Flow's Tooling Ecosystem + +Integrate Flow CLI with other developer tools like the [Cadence Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=onflow.cadence) to enhance your development experience. + +### Create Contracts, Transactions, and Scripts + +You can create contract, transaction, and script [boilerplate] stubs with the CLI. Doing so for contracts automatically adds them to `flow.json`. + +```zsh +flow generate contract [ContractName] +flow generate transaction [TransactionName] +flow generate script [ScriptName] +``` + +### Add Existing Contracts + +You can also [manage configuration] to add existing files to `flow.json`. + +```zsh +flow config add [ContractName] +``` + +### Advanced Dependency Management + +Manage both local and remote smart contract dependencies with the [dependency manager]. ## Installation @@ -28,3 +78,15 @@ macOS, Linux, and Windows. ## Create Your First Project To get started with creating your first Flow project and to learn more about how to use the Flow CLI super commands, please refer to the [Super Commands documentation](super-commands.md). These commands simplify the setup and development process, allowing you to focus on building your application without worrying about the underlying configurations. + + + +[`flow init`]: ./super-commands.md#init +[Dependency Manager]: ./dependency-manager.md +[accounts]: ./accounts/get-accounts.md +[transactions]: ./transactions/send-transactions.md +[scripts]: ./scripts/execute-scripts.md +[emulator]: ../emulator/index.md +[boilerplate]: ./boilerplate.md +[manage configuration]: ./flow.json/manage-configuration.md +[dependency manager]: ./dependency-manager.md