/pallet-move

MoveVM pallet for Substrate-based chains

Primary LanguageMoveMIT LicenseMIT

Move Pallet

A pallet for substrate based blockchains to enable the usage of smart contracts written in the Move-language.

Pallet Move connects the Move language with Substrate

Overview

Smart contracts can directly be implemented and executed as Move scripts or modularized in Move modules. Therefor, the pallet supports publishing of Move modules and the execution of Move scripts to achieve this functionality. In the case of larger projects, the pallet provides the publishing of a bundle (multiple Move modules).

For the execution of Move scripts and the publication of Move modules, the Move source code has to be compiled and serialized into bytecode. For this purpose, the tool smove is provided. The tool also provides further helpful features for developing and working with the Move language and this pallet.

Requirements

Move Example

A basic sample of the Move module and the Move script is shown below.

module DeveloperBob::CarWash {
    /// Buys `count` washing coin(s) for the car wash. Therfor, `COIN_PRICE`*`count` will be withdrawn from the user's account.
    public fun buy_coin(user: &signer, count: u8) acquires Balance {
        // ...
    }
}

More details about the module above in our tutorial. For this example, the module got published and the following script only needs to be executed.

script {
    use DeveloperBob::CarWash;

    fun buy_coin(account: signer, count: u8) {
        CarWash::buy_coin(&account, count);
    }
}

For a general overview and further details of the Move language, have a look at the Move Book.

Tutorial

To dive quickly into the topic, explore our simple tutorial.

Tech Guide

There is a tech-guide available, where you can find advanced topics like pallet configuration, Docker, and benchmarking.

Read the design document to learn more about the pallet API and how it works.

Template Node

Use these instructions to setup the template-node with Move pallet integrated.

Testing

Verify that everything works fine by running the pallet's unit tests with all features enabled:

cargo test --verbose --features build-move-projects-for-test

You can find further details about testing possibilities in the tech-guide.

Important Note

The MoveVM pallet is a good starting point for potential parachains that want to support Move. There are more potential improvements to be made. Still, those are yet to be defined and properly implemented within a future parachain project - since it's hard to predict what exactly the parachain might need or not need. The current solution is general and parachain-agnostic. The MoveVM is taken from the Move language repository - any possible safety issues are inherited from that repo. Therefore, the Substrate MoveVM fork (substrate-move) should get all upstream changes from that repository. The first parachain adapters should do additional testing to ensure the robustness of the solution.

See also

  • move-stdlib - Provides elementary Move functions in Move smart contracts.
  • substrate-move - A modified MoveVM fork for the use of MoveVM in the pallet-move repo.
  • smove - Handles the gas estimation, the serialization of script and module transactions, and the inspection of the module's ABIs.
  • substrate-stdlib- Provides elementary Substrate functions in Move smart contracts.

License

MIT License.

About Eiger

We are engineers. We contribute to various ecosystems by building low level implementations and core components. We believe in Move and in Polkadot and wanted to bring them together. Read more about this project on our blog.

Contact us at hello@eiger.co Follow us on X/Twitter