Intellij IDE Extension

Intellij Move IDE Tutorial

IDE Screen 1
Move Language is a plugin for the Intellij IDE platform that enables developers to write smart contracts using the Move language in editors/IDEs based on the Intellij platform therefore also compatible with other IDEs like Pycharm and Clion for projects that require multi-language development within one IDE.
Key Features:
  • Syntax highlighting
  • Code formatting
  • Go-to-definition
  • Rename refactoring
  • Type inference
  • Move.toml and aptos binary integration

1. Install Aptos CLI

The Aptos CLI is required for the Move Language plugin to work correctly.

2. Install Intellij IDE and Move plugin

To work with Move you need an IDE based on the Intellij platform, it can be PyCharm, CLion or any other Jetbrains IDE. Note that the current version of the plugin tested well only on PyCharm and CLion, so we recommend using these mentioned platforms until future updates.
The community edition of the IDEs work well with the plugins.
Use the following links to download IDEs:
After you installed one of the recommended IDE’s, open the following link to install the plugin:
Open your IDE and click on “Install” button to download it, otherwise you can install plugin directly from IDE.

3. Create and build your first Move Project

  • In Main Menu choose “File” → “New Project”.
  • Choose “Move” in the left Menu.
  • Choose a name for your project, for example “MyFirstMoveProject”.
  • Put path to Aptos CLI if needed. To get path of Aptos CLI in your local system just open Console/Terminal and run which aptos.
  • Click on “Create”.
IDE Screen 2
  • In the new project, first open the Move.toml file.
  • Open terminal in IDE and run the following command: aptos init.
  • Just skip all steps Aptos is asking you (this means press “Enter” each time to use the default configuration).
  • Copy the address of the new generated account during aptos init to Move.toml, under the addresses section (see screenshot below for example): Sender = “0xFFA7F40F44B93B24202E010E9E2BE0CB443FD964B27519EA68BE04BF3A00C3A1”
IDE Screen 3
  • Now create a new Move module file, let’s call it Math:
    • Right Click on the “sources” folder.
    • “New” → “Move File”.
    • Choose the name (”Math”) and the type of file (”Module”).
IDE Screen 4
  • Put the following code into your module:
1
module Sender::Math {
2
public fun add(a: u128, b: u128): u128 {
3
a + b
4
}
5
}
Copied!
  • Build your project by clicking on the “Run” button (it depends on each IDE, but it’s generally always on the top right or left corner).
IDE Screen 5
  • See the newly built artifacts in the build folder and in the output of the IDE console.
IDE Screen 6
  • If there are errors in your code, you can see it in the “Problems” console:
IDE Screen 7
Configure Aptos CLI manually
In the case that you opened an existing project Aptos project, you will still have to configure the Aptos CLI. Just search for Move Language in the “Preferences” settings.
If you want to spare the search bot, follow these steps:
  • Open “Preferences” menu in the IDE Main Menu.
  • Navigate to “Languages & Frameworks”.
  • Choose “Move Language”.
  • Put path to Aptos CLI in your local system.
  • Click “Apply” and save configuration.

4. Deploy modules

  • Open file containing module, e.g. Math.move.
  • Right click on the name of the module on the top bar to open a context menu as in the screen below:
IDE Screen 8
  • Click on Run ‘Publish Math’
IDE Screen 9
  • Module should now be deployed. You can validate this in your console.
  • Another option: you can use the gutter button (the arrow icon) instead of opening the context menu.
IDE Screen 10

5. Write tests

  • Create the “tests” directory in the root of the project.
  • Create a new test file: In top bar click “New” → “Move”, choose a name (”MathTest”) and choose type “Test”.
  • Put the following code in the new test file:
1
#[test_only]
2
module Sender::MathTest {
3
use Sender::Math;
4
5
#[test]
6
fun test_add() {
7
let a = 20;
8
let b = 30;
9
10
let r = Math::add(a, b);
11
assert!(r == (a+b), 1);
12
}
13
}
Copied!
  • Run a test on the whole module or test individual lines in the gutter with the green Run buttons:
IDE Screen 11
  • Or just right click on the “tests” folder and run all tests.
IDE Screen 12

Troubleshooting

No build configuration available

If you see there is no build configuration e.g. the ”Run” button is disabled, like this:
IDE Screen 13
Fix it easily by adding a build configuration to your project:
  • Click on “Add Configuration”.
  • Click on the “Plus” button.
IDE Screen 14
  • Choose “Move”.
IDE Screen 15
  • Fill the fields:
    • Name: “Build”.
    • Command: “move compile”.
    • Working directory - your current directory.
IDE Screen 16
  • Click “Apply” and close the window.
  • “Run” build.
IDE Screen 17

Executable is not specified

If you get an error like this:
IDE Screen 18
  • Open “Preferences” menu.
  • Navigate to “Languages & Frameworks”.
  • Choose “Move Language”:
    • Put path to Aptos CLI in your local system.
    • Click on “Apply” and close window.
IDE Screen 19