Intellij IDE Extension Tutorial

Start coding in Move 100% free with PyCharm Community Edition and Pontem Move Intellij Plugin

Pontem’s Intellij plugin for Move is the first tool that allows you to add Move smart contract language to your projects built with various IDEs by JetBrains: PyCharm, CLion, IDEA, Android Studio, RIder, etc. Now you can build dApps for Aptos and other Move-compatible blockchains using the IDEs you are used to.

The plugin is very advanced compared to JetBrains plugins for other smart contract languages like Solidity. It supports syntax highlighting, on-the-go error checks, auto-formatting, symbols, etc. It’s also completely free and really easy to use.

Key Features:

  • Syntax highlighting

  • Code formatting

  • Go-to-definition

  • Rename refactoring

  • Type inference

  • Move.toml and aptos binary integration

In this tutorial, we'll focus on using the Intellij Move plugin with PyCharm. It's also been tested to work with Intellij CLion. Since the installation and use are almost identical, you can use this tutorial for CLion, too, but note that CLion doesn't have a free Community Edition yet.

What is PyCharm Community Edition?

PyCharm is a popular IDE for coding in Python, developed by JetBrains. Most people are familiar with the paid Professional version, but there is also a completely free Community Edition. It works perfectly with Pontem’s Intellij plugin for Move and has all the features you’ll need to start building dApps for Aptos.

In this tutorial, we’ll describe how to install and use the free version with PyCharm Community Edition. See here for the differences between PyCharm Professional and Community Edition. You can also use the Move plugin for free with Intellij IDEA Community Edition, if you are used to the IDEA IDE, as well as with most other JetBrains IDEs, such as CLion. The installation process is almost identical.

Install PyCharm Community Edition

1) Download and run JetBrains Toolbox

Toolbox is an installer utility by JetBrains (around 66 MB). Download the correct file for your OS from the JetBrains Toolbox page.

For Linux, Toolbox comes as a .tar.gz archive; for Windows, it’s an .exe file, and for MacOS, it’s a .dmg app file. If using Linux, extract the .tar.gz to get to the Jetbrains-toolbox installer inside.

2) Run the installer

Locate PyCharm Community on the list → “Install”. The process takes just a couple of minutes.

Install Pontem Intellij Plugin

The easiest way to install our Move plugin is from PyCharm itself.

In PyCharm Community Edition, go to the Plugins tab and search for Move Language. Click Install and accept the third-party plugin terms. Move will be added to your Installed Plugins tab. Make sure to check for updates regularly, as Pontem poften adds new features to the plugin.

Install Aptos CLI

Aptos CLI is a command-line interface that will allow you to write code in Move. We are planning to add a CLI installation button to our Intellij plugin so that you can use it right out of the box, but for now, you’ll need to install it separately. We’ll describe how to do it on MacOS, Linux, and Windows.

Add Aptos CLI to Linux with Terminal

1) Check that you have Python

Most recent Linux distros come with Python, which you’ll need to install the CLI. To check your version, run the command:

$ python3 -version

If you are running an old distro that doesn’t have Python, it makes sense to upgrade the OS.

2) Install the CLI with a single command from Terminal

The easiest way to get Aptos CLI on Linux is an automated install: it takes just one command. See the official Aptos documentation directory for more detailed instructions and alternative ways to install the CLI, such as downloading the binaries manually.

Now execute the following command:

wget -qO- "https://aptos.dev/scripts/install_cli.py" | python3

Run $ aptos info to make sure that everything works. If it doesn’t work straight away, try rebooting the computer.

Wget is a utility for downloading files from the internet. By default, Wget will install Aptos CLI into the folder Home/(username)/.local/bin. To check that it’s really there, go to Home in the file explorer app and click Ctrl+H to display hidden folders, then open /.local/bin – you should find an executable file called “aptos”.

Add Aptos CLI to MacOS with Terminal

The best way to install Aptos CLI (and all sorts of other utilities) on Mac is with Homebrew - an automated software package manager. To download Homebrew, open Terminal from Applications -> Utilities and run the command (you’ll need to enter your admin password):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

During the installation, you may be prompted to also install the Xcode command line developer tools package. After that, the Homebrew installation will finish. Make sure to run the two additional commands that Homebrew will prompt you to execute.

Once Homebrew is installed, update it:

brew update

And finally, install Aptos CLI:

brew install aptos

Run $ aptos help to make sure that everything works.

See the official Aptos documentation directory for more detailed instructions and alternative ways to install the CLI on Mac.

Add Aptos CLI to Windows with Powershell

The recommended way to install Aptos CLI on Windows is with a command in Powershell. To launch Powershell, click on the search icon in the Start menu, type “powershell”, and click Open or Run as Administrator. See here for more ways to open Powershell or here for how to install and open Powershell in earlier versions of Windows.

In Powershell, execute the following command to install Aptos CLI:

iwr "https://aptos.dev/scripts/install_cli.py" -useb | Select-Object -ExpandProperty Content | python3

See the official Aptos documentation directory for more detailed instructions and alternative ways to install the CLI on Windows, including from source code.

Create your first Move project

  1. In the main PyCharm menu, choose “File” → “New Project”.

  1. Choose “Move” in the menu on the left. Enter a name for your project - for example “MyFirstMoveProject”.

  1. A path to Aptos CLI should be inserted already. If it’s not, open the Terminal/Console and run which aptos, then navigate to that directory in PyCharm’s Aptos CLI field.

If you installed Aptos CLI using Terminal/Console/Powershell, it can be located in a hidden folder like .local/bin. Make sure to click the “Show Hidden Files and Directories” icon (the eye icon) in the navigation popup.

  1. Click on “Create”. In the new project, the Move.toml file should open automatically. If it doesn’t, unroll the dropdown under the project’s name on the left and click on Move.toml.

  1. Open the Terminal emulator in PyCharm by pressing Alt+F12. Alternatively, you can launch Terminal from PyCharm’s main sandwich menu (top left corner) -> View -> Tool Windows -> Terminal.

  1. In the Terminal, run the following command: aptos init. When prompted to choose a network, press Enter to choose devnet (the default option), then Enter again to generate a new Aptos private key - unless you want to use an existing private key (0x…), in which case paste it in.

  2. The Pontem Move plugin will generate a new Aptos account and fund it with 100,000,000 testnet octas. This is equivalent to 1 APT. Note that testnet APT doesn’t have any real value and can’t be bridged to the mainnet.

  3. Copy the address of the newly generated account. In the Move.toml, file, locate the “addresses” line. Go to the next line and enter: Sender = “(your account address)” (see the screenshot).

  1. Create a new Move module file: right-click on the “Sources” folder -> New -> Move FIle. Choose a name (we’ll call it “Math”) and Module as file type. Press Enter.

10. In the Math.move module, copy the following code into the brackets after “module Sender: Math”:

public fun add(a: u128, b: u128): u128 { a + b }

11. Open the Run Build display tool: click on the main sandwich menu in the top left -> View -> Tool Windows -> Run.

  1. Check if you have an active build configuration: if you do, you’ll see a Run Move button. If you don’t, you’ll see something like Add Configuration or Current File.

You need an active build configuration to be able to build the project. To create one, either press Alt+Shift+F10 -> Edit Configurations or click on the Build button in the top right to go to the Edit Configurations dialogue. Click on Add New Run Configuration or the + icon in the corner -> Aptos -> Any command.

Make sure that the move compile command is selected and that the directory path to the project is correct. Give your configuration a name (like Run Move). Click Run to build your Move project.

The results will be displayed in the Run console at the bottom. You’ll also see a new build folder in the list of the project’s folders on the left.

If there are any errors in your code, you'll see them in the Problems console.

Deploy modules

  1. Open the file containing a module - in our case, Math.move. You’ll find it in the sources folder on the left.

  2. Check that the Run console is displayed - or call it through the main sandwich menu -> View -> Tool Windows -> Run. When prompted, agree to the transaction fee (just type yes).

  3. Press Alt+Shift+F10 or click on Run Move -> Edit Configurations. Create a new configuration (click on the + sign -> Aptos -> any command, name it Publish Math, and enter move publish as command -> OK.

  1. Run Publish Math on Math.move.

5. When prompted in the console, enter yes to agree to pay the gas fee by typing in yes. Publishing a module is a transaction on the blockchain that incurs a network fee. You should get a transaction hash once the deployment operation is finalized.

Write and run tests

  1. The project directory should already have a folder called “tests”. If it doesn’t, right-click the project’s name in the menu on the left -> New -> Directory. Name the new folder “tests”.

  1. Navigate to the project’s folder in your computer’s file explorer and create a new folder within it, naming it Tests.

  2. Right-click the tests folder -> New -> Move File -> Test Module. Name the new file “MathTest” and choose Test Module as Type.

  3. Insert the following code in the new test file between the brackets after Sender: :MathTest. Be careful not to leave dangling brackets.

#[test_only]
module Sender::MathTest {
    use Sender::Math;

    #[test]
    fun test_add() {
        let a = 20;
        let b = 30;

        let r = Math::add(a, b);
        assert!(r == (a+b), 1);
    }
}

5. Right-click the MathTest file -> Test MathTest. If this run configuration isn’t available, create one through the Edit Configurations dialogue, using the move test command. You’ll see the results in the console.

Apart from running the test on the whole module, you can test individual lines in the gutter using green Run buttons:

Alternatively, just right click on the “tests” folder and run all tests.

Troubleshooting

"Error running "Build": Executable is not specified"

Open the “Preferences” menu -> Languages & Frameworks -> Move Language. Insert the path to the Aptos CLI in your local system, click on “Apply”, and close the window.

Last updated