# 2. How to Use Mina IDE

## 1. Write a contract

After entering the project, you can click on the "preview" option at the top right corner of the readme.md file in the folder to preview it.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FGVAhunula3dfXwGqnINH%2Fimage.png?alt=media&#x26;token=96a2b837-3b56-4130-aa63-9fff9bbda02f" alt=""><figcaption></figcaption></figure>

In the Explorer panel, you can create new files (or folders), refresh the directory, and download files. You can also directly click on the files that come with the template.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FgnpVxTl4gZ6h3PkaeTi6%2Fimage.png?alt=media&#x26;token=5ef73343-12f4-4dce-b229-9a8c8f2f4e7d" alt=""><figcaption></figcaption></figure>

Click on a contract file to edit the code.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FNWCtLKBGP5JfFeb5btFp%2Fimage.png?alt=media&#x26;token=53368a6d-c7c2-45a1-a74a-ecdee9563168" alt=""><figcaption></figcaption></figure>

## 2. Compile a contract

On the right-hand menu bar, under the Compiler section, select "Module Package Path", and then click on "Compile" to start compiling the contract.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FMDb5pq8JKmgbEe9IpTuk%2Fimage.png?alt=media&#x26;token=dbc6191e-ba09-4fc5-9341-293856710157" alt=""><figcaption></figcaption></figure>

After successful compilation, a 'build' folder will be generated in the current directory.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FMD17S9QY3GXmUqXQGzQE%2Fimage.png?alt=media&#x26;token=6c0eb46a-ab73-435d-a9f2-516acc828017" alt=""><figcaption></figcaption></figure>

## 3. Deploy a contract

Click on the "Deploy & Interaction" button on the right side, which will take you to the deployment and interaction page. Select "Module Package Path", and then click on "Config" to start zk config.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FNAE89T8mmPrxfh5X3QjS%2Fimage.png?alt=media&#x26;token=9c6b9e3b-abbf-4eb3-a8b1-09323b8051c4" alt=""><figcaption></figcaption></figure>

For example (Testnet):

* Deploy alias name: `devnet`

  This tutorial uses `devnet`, but the deploy alias name can be anything and does not have to match the network name.
* Target network kind: `Testnet`
* Mina GraphQL API URL: `https://api.minascan.io/node/devnet/v1/graphql`
* Transaction fee to use when deploying (in MINA): `0.1`
* Use a different account (select to see options): `Create a new fee payer key pair`

For example (Mainnet):

* Deploy alias name: `mainnet`

  This tutorial uses `devnet`, but the deploy alias name can be anything and does not have to match the network name.
* Target network kind: `Mainnet`
* Mina GraphQL API URL: `https://api.minascan.io/node/mainnet/v1/graphql`
* Transaction fee to use when deploying (in MINA): `0.1`
* Use a different account (select to see options): `Create a new fee payer key pair`

After completing the configuration, click on the faucet link in the Sandbox to obtain test tokens.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2F2R18vjbHVoaukeEx9XSN%2Fimage.png?alt=media&#x26;token=478d0569-9dad-4eb7-8564-8461c0734ab8" alt=""><figcaption></figcaption></figure>

After successfully obtaining the test tokens, click on Deploy and select the appropriate Deploy Alias for deployment.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FXat9ho3MwYS6zR4dSIyD%2Fimage.png?alt=media&#x26;token=0b5cb641-e20e-4a9f-9c7a-146eec3bc11f" alt=""><figcaption></figcaption></figure>

Wait for a moment, and the sandbox will display the deployment link. Click on that link to confirm that the deployment transaction has been successfully added to the chain.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2Fw5y8WnazvOxLDsA1zAg6%2Fimage.png?alt=media&#x26;token=3871fcb8-7cf6-4075-81ed-e0cb4b5a82a3" alt=""><figcaption></figcaption></figure>

## 4. Contract interaction

After a successful contract deployment, you can interact with the contract. Select the corresponding parameters and click on Interact to initiate the interaction.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FTgzhKzD9MWPRjQvzNb6m%2Fimage.png?alt=media&#x26;token=edc98b10-6290-4123-a5a6-01b72e824fb7" alt=""><figcaption></figcaption></figure>

## 5. Mina Sandbox

If you prefer using the command line for development, you can open the Mina Sandbox, which comes pre-loaded with [zkApp CLI](https://www.npmjs.com/package/zkapp-cli), [Git](https://git-scm.com/) and [Node.js V20](https://nodejs.org/en)。

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FG6hhBXx9qxxrilmIiZfC%2Fimage.png?alt=media&#x26;token=b46e402f-cc5e-43ae-9a3e-8bf556631b6a" alt=""><figcaption></figcaption></figure>

If you've started a process on a port in the Sandbox and wish to access that port, please refer to [ChainIDE - Port Forwarding](https://chainide.gitbook.io/chainide-english-1/port-forwarding).
