# CLI Cheatsheet

This guide shows the commands you need to initialise, build, and deploy a instance using Blockflow CLI.

#### Step 1:  **Install the Blockflow CLI**

To install the CLI extension on your local machine,  you can use the following command:

> ```shell
> npm i -g @blockflow-labs/cli
> ```

**Step 2:  Authenticate CLI**

Authenticate Blockflow CLI with your [credentials](https://app.blockflow.network/) by running this command.&#x20;

> ```shell
> blockflow configure
> ```

**Step 3: Initialise Blockflow Project**&#x20;

To create a new project, navigate to the directory where you want to store your project and run the following command *(make sure the folder is empty):*

> ```shell
> blockflow init
> ```

The CLI will prompt you to select various options for your project. Fill in the details, and the CLI will populate your directory with the necessary files for indexing.

**Step 4: Configure YAML**

After you have written your trigger configuration in **blockflow\.yaml**, you can run this command:&#x20;

> ```shell
> blockflow codegen
> ```

The CLI will generate boilerplate code for handler functions.

**Step 5: Setup Database Schema**

Once project initialised. Write your database schema in **studio.schema.ts** file, after writing run this command:&#x20;

> ```shell
> blockflow typegen
> ```

This will generate schema.ts file in src/types folder. It contain autogenerated interfaces and classes.

**Step 6: Testing Instance**

After you have written your handler logic. You can test your instance locally by using this command:

> ```shell
> blockflow instance-test --rpc "paste-your-rpc-url-here"
> ```

This need a local mongo running. Once completed. Check your local mongoDB.

**Step 7: Deploying Instance**

Once tested we are ready for deployment. Make sure you have blockflow credentials in studio.yaml file.

> ```shell
> blockflow instance-deploy
> ```

You can check your deployed instance in your blockflow account. And query the database in graphql playground.
