eigerco / pallet-move

MoveVM pallet for Substrate-based chains

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License

MIT License.

About

MoveVM pallet for Substrate-based chains

License:MIT License


Languages

Language:Move 70.4%Language:Rust 28.6%Language:Shell 0.8%Language:Dockerfile 0.2%