Skip to content
Home » Blockchain » Full Guide to Move | Smart Contract Programming Language

Full Guide to Move | Smart Contract Programming Language

move programming language logo

The web3 space is filled with languages. Some grow a lot more popular, while some don’t. However, each language has an interesting story. The Move programming language also has one. 

In this detailed guide, I will be delving into the history of Move, why Facebook developed it, its design language and structure, and how you, as a developer, can leverage it. 

So, let’s get right into it, shall we?

🚨 New Course: Learn to Create a Fungible Token with Sui Move

What is Move?

The Move programming language is open-source tool for web3 developers to write blockchain applications. It is one of the more recent programming languages, with an executable bytecode language for smart contracts and custom transactions.

Why did Facebook develop Move?

One of the most exciting and important things about the Move programming language is that it was developed by Facebook. Just like Go was developed by Google itself. 

All of this started in 2019 when one of the biggest social media giants, Facebook, came up with the idea of Libra, a stablecoin. Move was first introduced as a native language to Libra. Then in 2020, Libra became Diem due to some regulatory challenges. In 2022, it was eventually sold to Silvergate Capital Corporation because Diem was practically dead. Facebook’s stablecoin project did not work. 

However, what remained was the Move programming language that was specifically designed for the Diem (then Libra blockchain).

What exactly are stablecoins? 

Stablecoins are an equally investible but less volatile alternative to popular cryptocurrencies such as BTC, ETH, etc. They were first introduced in 2014. As of June 2020, there are some 200 stablecoins. There are two types of stablecoins; fiat-backed stablecoins and algorithmic stablecoins. 

🌱 Check this guide: How to create a crypto coin

1. Fiat-backed stablecoins

These stablecoins are backed by a reserve of fiat currency, such as USD. For example, if there are USD 100,000 Coin (USDC) tokens in circulation, then there must also be USD 100,000 held in reserve. This way, the coins remain stable.

2. Algorithmic stablecoins

There is no currency backing involved here. In algorithmic stablecoins, there are algorithms that maintain the value of a stablecoin by minting and burning tokens. For example, if the price of a stablecoin starts to go up, the algorithm may automatically mint more tokens, which will increase the supply and drive the price down.

Facebook’s rationale and motive behind Libra

Launched as something that was expected to revolutionize and transform the global economy, Facebook wanted Libra to serve as an intermediary for transferring traditional currencies. It was also connected to WhatsApp and Facebook Messenger.

How it would have worked, had it not failed, is that users would convert their currencies to Libra and send it to anyone with a Libra-compatible wallet, Calibra (changed to Novi, later on). Libra initially served as a bridge between cryptocurrency and fiat currency. However, fate had some other plans and it did not work out.

Which blockchains use Move the most currently?

Blockchains that have been using the Move programming language frequently are Aptos and the Sui blockchain. Starcoin is also yet another project that uses Move. All three blockchains are L1s with an emphasis on writing smart contracts for DeFi, GameFi, and other blockchain applications.

How is Move different from other blockchain languages?

Move’s two big competitors are Solidity and Vyper. And there are some ways in which the Move programming is different from them and other blockchain programming languages.

FactorsMove Others (Solidity, Vyper, etc.)
How it is typedStatically typed and strongly typed which means there is generally less room for errors and the code is more readableDynamically typed which means the compiler tries to figure out the type of a variable or expression based on how it is used.
Performance optimizationHas techniques such as inlining functions and avoiding unnecessary memory allocations, to optimize the performance of various blockchain applications such as smart contractsDo not have such techniques to optimize the performance of blockchain applications
Type systemUses a linear type system meaning no one variable can be used for two different purposesUse a non-linear type system meaning that one variable can be used for two different purposes
Digital assetsHas an in-built type that represents digital assetsDo not have an in-built to represent digital assets

What are the critical design goals undertaken by Move?

As a smart contract programming language, Move has undertaken a number of design goals with time. These design goals specifically help Move to grow and develop an infrastructure that could help further help establish efficient and secure blockchains.

1. First-class resources

The thing with blockchain languages is that they deal with virtual assets, unlike traditional assets that tend to be tangible. Now, digital assets have two important qualities; they tend to be scarce and they have access control, meaning only certain people can modify them. For programming languages, it is important that the developers are able to express these qualities. This is exactly what the first-class resources of the Move programming language do. They make it easier to write digital assets that are scarce in nature and have access control.

2. Flexibility

The Move programming language has modules that allow one to compose code with flexibility. Move is not an object-oriented programming language. However, its components – modules, procedures, resources, and the relationship between them – is similar to the components in an object-oriented language. Move also allows for declaring multiple resource types which makes it more expressive and flexible as a language. 

3. Verifiability

The Move programming language is known for being capable enough to ensure on-chain verification for all the safety traits. But given that blockchains are utilized frequently, verification of all the safety traits will not be possible. This is why Move has off-chain static verification tools as well. Thus, the complexities with on-chain verification are addressed easily on Move and this is made possible by the three designs which include:

4. Lack of dynamic dispatch

This particular design helps Move easily identify the effects of a procedure call without diving into complexities.

5. Modularity

Move allows the isolation of modules for the sake of functional verification. This means that the code outside of the modules specified by Move can not violate the types of a module. In the long run, the modular design could also enable comprehensive functional verification for crucial module invariants by reviewing isolated modules.

6. Limitated mutability

Limited mutability in the Move programming language means that values can only be mutated through references. This means that there can only be one mutable reference to a value at any given time. This helps to prevent errors that can occur when multiple mutable references to a value are used.

☀️ Read more: What does immutable mean?

7. Safety

One more goal undertaken by the Move programming language is safety. Move language focuses on the on-chain checking of bytecode for memory safety, resource, and type. After the checking process, the bytecode goes for execution directly through a bytecode interpreter. As a result, Move could enable safety privileges that are commonly related to a specific source language.

Common concepts in the Move Programming Language

Data types

Like every programming language, each value that you see on Move belongs to a certain data type. This helps the language to determine which value is specified to which data type. 

  1. Boolean: the boolean type has only two values. It can either be true or false.
  2. Unsigned integers: integers that can only hold non-negative values
  3. Fixed-size byte arrays: arrays of bytes that have a fixed length
  4. Address: unique identifiers that are used to refer to resources in the Move programming language
  5. Struct: a data type that can be used to group together related data
    a) Kind – determines how a struct can be used
    b) Unrestricted -procedures that can be called from any module

Procedures

Procedures in Move are methods that could be classified into public and and internal. Although they are similar to other functions within a programming language, they have some differences. Procedures are always named, can have parameters, and can return values.

  1. Public procedures: accessible to all other modules in the system. They can be called from any other module, and their results can be used by any other module.
  2. Internal procedures: only accessible to the module in which they are defined. They cannot be called from other modules, and their results cannot be used by other modules.

👀 Also see: Clarity Smart Contract Language 2023 Guide

Bytecode verifier

The bytecode verifier in Move is a tool that ensures that Move bytecode is valid and safe to execute. The bytecode verifier performs a number of checks on the bytecode, including:

  1. Type checking: checks that the types of values are correct
  2. Stack balance checking: checks that the stack is balanced at all times
  3. Reference checking: checks that references are used correctly
  4. Control graph development: develops the control graph of the bytecode
  5. Reference linking: links references together
  6. Resource checking: checks that resources are used correctly
move bytcode verifier process how it works
Source: Aptos

Benefits of Move programming language

As a programming language designed specifically for blockchain development, most of its features are developer-centric. Some of its features are testament to the claim that it is a developer-centric language are like preventing security vulnerabilities, ensuring reliability, making it easy to learn and use, etc. These features are enabled by the following characteristics of the language:

1. Strongly-typed

Move is a strongly-typed language. This means that it greatly helps in preventing errors because a strongly-typed language must have the variable declared explicitly. Once the compiler agrees that the variable is uses correctly, it will help catch errors during the development process.

2. Resource-oriented programming

Unlike most of its counterparts, Move is not an object-oriented language. It is resource-oriented instead. This means that the security vulnerabilities in the Move programming language are easily preventable. This is because resources have a limited life, they can’t be copied and neither can they be dropped.

3. Verification

Move code can be verified, which means that it can be proven that the code will behave as intended. This is done using a formal verification tool, which checks the code for errors. Verification also ensures the safety and reliability of a code.

Move tools and libraries for development

1. Libraries

In programming, libraries greatly help to optimize a developer’s coding. Libraries have pre-written codes that developers can put into use.

  • Move Std: a collection of standard modules that are used by many Move smart contracts.
  • Move Account Library: helps in managing accounts on the Move blockchain
  • Move Transaction Library: helps in managing transactions on the Move blockchain

2. Tools

In programming, tools help you provide an environment, help you streamline your instructions, and test and implement the program.

  • Move Prover: used to check the correctness of the codes
  • Move Compiler: used to compile a code into bytecode
  • Move Playground: web-based IDE that is used to write, compile and debug Move code
Move playground by pontem IDE
Source: Pontem

📰 Also see: Solana Unveils Solang to Woo Ethereum Devs

How to write a smart contract in the Move programming language

Writing a simple smart contract in the Move programming language does not take much. All you have to do is follow these few simple steps mentioned below and you will have created a smart contract using Move.

1. Create a brand new file

Name it Counter.move

2. Define a module called Counter

It will be called Counter, like this. 👇🏼

module Counter {

3. Define two public procedures called increment and get

public fun increment(counter: &mut Counter): u64 {
// Increment the counter value.
counter.value = counter.value + 1;

// Return the new counter value.
return counter.value;
}

public fun get(counter: &Counter): u64 {
// Return the current counter value.
return counter.value;
}
}

4. Finally, compile the code

Use command movec Counter.move

In conclusion,

Move is a strongly-typed, resource-oriented and simple smart contract programming language. A number of features make it a developer-centric language. Once used as a native language to Diem blockchain, Move is mostly used to code in Sui blockchain. This guide contains the features and important components of the Move programming language, its syntax, how to write a simple smart contract using the language, and its goals and what it aims to achieve.