# 2. How to use Sui IDE

{% embed url="<https://www.youtube.com/watch?v=5Pq_r5geNl0>" %}

## 1. Write a contract

Upon entering the project, the README.md file included in the folder will be automatically previewed.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FQqpCWAxwStq5rsycqTZ2%2Fimage.png?alt=media&#x26;token=8443c039-e6e9-47c0-b75b-7f092862c238" 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%2FB1PBvJj3FWfztIVSAcFf%2Fimage.png?alt=media&#x26;token=e6e81116-b384-4b57-b63c-e6e23925705a" 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%2FrhImquBz4eMGlBgw3T3U%2Fimage.png?alt=media&#x26;token=8f97c28a-dbdd-4809-9cfa-91b05d767052" alt=""><figcaption></figcaption></figure>

## 2. Test a contract

Once your contract code is written, click on the "Compiler" button in the right-side menu to open the compilation module. After selecting the Module Package Path, click on "Test."

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FpQ8lJYRLpcn7LOZ6uAMd%2Fimage.png?alt=media&#x26;token=d15adff8-8c0c-49a8-87b6-9c3c4e1b57fb" alt=""><figcaption></figcaption></figure>

After a successful test, the test results will be displayed in the console.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2F5Ci8zVF1yVnCh4aU3TEx%2Fimage.png?alt=media&#x26;token=5efc8a55-37b8-4925-b14d-50ee89b62aa8" alt=""><figcaption></figcaption></figure>

## 3. Compile a contract

On the right-hand menu bar, under the Compiler section, click on "Build" 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%2Fojl12oQQbflieWeB3Wpr%2Fimage.png?alt=media&#x26;token=220ba044-666f-4fba-b8ca-88d877710174" alt=""><figcaption></figcaption></figure>

After a successful compilation, a "build.json" file 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%2FioSqZeIrcpmwWCq2i7xs%2Fimage.png?alt=media&#x26;token=270313ae-6cbd-41e9-86a9-8305dfce4391" alt=""><figcaption></figcaption></figure>

## 4. Connect to Sui

Before deploying the contract, you need to click on "Connect Wallet" on the upper right corner. Choose from one of the available wallets to connect it to ChainIDE.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FLRDUS0fUpXWQTUmVejfI%2Fimage.png?alt=media&#x26;token=45b5d67c-af94-4b6c-a25a-ab1646bf865a" alt=""><figcaption></figcaption></figure>

## 5. Deploy a contract

Click the "Deploy & Interaction" button on the right-hand side, which will bring up the deployment and interaction pages. Select the compiled contract and click "Deploy" to initiate the deployment (then confirm in Wallet). After successful contract deployment, the console will display the contract deployment result and relevant information.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2F5En3liEAEyEUsGvKrsgw%2Fimage.png?alt=media&#x26;token=69e0842b-a733-4dd4-9b94-a0506329ac9f" alt=""><figcaption></figcaption></figure>

In addition, you can click "Import Deployed Contract" to import a contract that has already been deployed for contract interactions.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2F9ojU3klrfTiMX05Ra1yp%2Fimage.png?alt=media&#x26;token=4451ccdc-dd25-4b27-8bdc-5d0eb9e7fc5b" alt=""><figcaption></figcaption></figure>

## 6. Contract interaction

After a successful contract deployment, you can interact with the contract. Click on the deployed contract, choose the corresponding interface, and click on "Execute" to initiate the write interaction.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FH12ei8B0VYlOw0Fqcz7e%2Fimage.png?alt=media&#x26;token=c7895ee6-825e-48e6-8960-f7b8dc611b7d" alt=""><figcaption></figcaption></figure>

## 7. Package & Object Query

Click on "Account Objects" and enter the corresponding fields to query the relevant information.

<figure><img src="https://3745657014-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYy-lqJKjq1m0yBAX4r%2Fuploads%2FoS5GNUCLwyKzowLmZsxy%2Fimage.png?alt=media&#x26;token=2428d70d-4045-4a1c-a828-29444a050bd4" alt=""><figcaption></figcaption></figure>

## 8. Sui Sandbox

If you prefer using the command line for development, you can open the Sui Sandbox, which comes pre-loaded with [Sui Cli](https://docs.sui.io/references/cli), [Git](https://git-scm.com/) and [Node.js V16](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%2FkyMXdtRypBpe40AxbBK9%2Fimage.png?alt=media&#x26;token=76fe970c-cad1-4390-8469-62672b6a9971" 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).
