Compiler & Toolset
We've developed a toolchain for the Move VM and language which allows for:
  • Compiling Move code into bytecode.
  • Testing Move code with tests and formal verifications.
  • Viewing Move resources (stored data) from remote blockchain nodes.
  • Disassembling Move binary and even reading human readable results.
The toolchain is implemented by the Dove tool and several separate binaries, which you can install following this tutorial.

Installation

All tools are stored in our Move-Tools Github repository.
You can download all tools for your operating system from releases page.
After downloading, rename tool(s) by removing version and os and moving binary to /usr/local/bin/.
For example, for dove on linux:
1
mv ./dove-1.3.2-linux-x86_64 ./dove
2
chmod +x ./dove
3
mv ./dove /usr/local/bin/dove
Copied!
For Windows:
  1. 1.
    Go to "Program Files" directory.
  2. 2.
    Create there "dove" directory.
  3. 3.
    Rename the downloaded file to "dove" and put it into "dove" directory.
  4. 4.
    Open "cmd" and run next command:
1
setx path "%path%;%ProgramFiles%\dove"
Copied!
  1. 1.
    Restart "cmd".
Now dove is available from "cmd".
To build tools from sources see README.

Dove

Dove is a Move compiler and package manager. Using Dove you can create your own Move smart contract applications.
Let's create your first project:
1
dove new first_project --dialect pont --address <address>
Copied!
  • Replace <address> with your address.
Navigate to first_project folder and examine what's automatically generated inside:
1
cd ./first_project
2
ls -la
Copied!
  • Dove.toml - configuration file.
  • modules - place modules here.
  • scripts - place scripts here.
  • tests - place tests here.
Let's examine what is contained in Dove.toml:
1
[package]
2
name = "first_project1"
3
account_address = "<your address>"
4
dialect = "pont"
5
6
dependencies = [
7
{ git = "https://github.com/pontem-network/move-stdlib", tag = "v0.3.0"}
8
]
Copied!
  • name - name of project.
  • account_address - address of your account, used during compilation.
  • dialect - can be diem, or pont (SS58 Polkadot addresses).
  • dependencies - list of dependencies, git (tag or branch also supported) or local folder (use path).
Let's create an empty script and build it:
1
touch ./scripts/test.move
Copied!
Insert Move code:
1
script {
2
fun test() {
3
4
}
5
}
Copied!
Build your empty project in one of two ways:
  1. 1.
    Without arguments:
1
dove build # Build script without providing arguments which can't be used in Substrate Pallet.
Copied!
  1. 1.
    With arguments:
1
dove tx 'test()' # Build script with arguments.
Copied!
Difference between the build and tx commands:
  • If you want to just build your scripts, use build. However, this command is mainly used for building modules (modules are similar to smart contracts in Move).
  • if you want to simply send transactions to the Pontem node, use tx and provide arguments.
Use the tx command only for scripts and use build for modules
For more information use the help function:
1
dove tx --help
Copied!
See your built artifacts in ./artifacts folder:
1
ls -la ./artifacts/scripts # Just built script
2
ls -la ./artifacts/transactions # Script with arguments for pallet.
Copied!

Script Transaction

Command tx allows you to create transactions for Polkadot or Kusama based chains with the Move Pallet.
tx takes a script identifier, type parameters, and arguments to create a transaction file as an artifact of work:
Example:
1
dove tx 'store_u64(60)'
Copied!
This command searches for the script named 'store_u64' in the script directory. Then it compiles it and creates a transaction file.
This command will fail if:
  • There is no script with the name 'store_u64'.
  • There is more than one script with the name 'store_64'.
  • The passed parameters or type parameters do not match the script parameters.
  • There are syntax errors in the script.
  • You can use type parameters in the move language.
Example:
1
dove tx 'create_account<0x01::PONT::PONT>()'
Copied!
You're allowed to use SS58 address format and other types:
1
dove tx 'create_account<gkQ5K6EnLRgZkwozG8GiBAEnJyM6FxzbSaSmVhKJ2w8FcK7ih::MyToken::Token>()'
2
dove tx 'create_account(gkQ5K6EnLRgZkwozG8GiBAEnJyM6FxzbSaSmVhKJ2w8FcK7ih, 10, true, [10, 20, 30, 40])'
Copied!
Supported types:
Numbers (u8, u64, u128):
1
dove tx 'my_script(255, 18446744073709551615, 340282366920938463463374607431768211455)'
Copied!
Boolean:
1
dove tx 'my_script(true, false)'
Copied!
Addresses:
1
dove tx 'my_script(5GcFHawZJHgwymsu9X2F5Lt5sSX89TxxFgHAMJ7TnoUJKqJD, 0x1CF326C5AAA5AF9F0E2791E66310FE8F044FAADAF12567EAA0976959D1F7731F)'
Copied!
Vectors:
1
dove tx 'my_script([10, 20, 1024])' // Vector u64
2
dove tx 'my_script([5GcFHawZJHgwymsu9X2F5Lt5sSX89TxxFgHAMJ7TnoUJKqJD, 0x1CF326C5AAA5AF9F0E2791E66310FE8F044FAADAF12567EAA0976959D1F7731F, 0x01])' // Vector addresses.
Copied!

Executor

Executor allows you to execute scripts without sending transactions to the chain.
See help:
1
dove run --help
Copied!
  1. 1.
    Insert the following code inside modules/Store.move:
1
address {{sender}} {
2
module Store {
3
struct Store<T: store> has key {
4
value: T
5
}
6
7
public fun store<T: store>(account: &signer, value: T) {
8
move_to(account, Store<T> {
9
value
10
});
11
}
12
13
public fun destroy<T: store>(account: address): T acquires Store {
14
let Store { value } = move_from<Store<T>>(account);
15
value
16
}
17
}
18
}
Copied!
  1. 1.
    Insert the following code inside scripts/store.move:
1
script {
2
use {{sender}}::Store;
3
use 0x1::Signer;
4
5
fun store_u64(acc: signer, a: u64) {
6
Store::store(&acc, a);
7
Store::destroy<u64>(Signer::address_of(&acc));
8
}
9
}
Copied!
Run the following command to put a number into storage with the run command:
1
dove run 'store_u64(<account>, 100)' # Store number 100 in storage.
Copied!
Replace <account> with your address.
The Dove run command will publish provided modules and execute scripts with arguments. The data generated by a script will be stored into ./artifacts/storage/ folder.

Tests

You can run tests on your smart contracts using Dove.
Let's demo this using the same module and script from the executor section.
  1. 1.
    Create a new test file:
1
touch ./tests/store_test.move
Copied!
  1. 1.
    Put the following code inside:
1
address {{sender}} {
2
module StoreTest {
3
use 0x1::Signer;
4
use {{sender}}::Store;
5
6
#[test(
7
account = @5GcFHawZJHgwymsu9X2F5Lt5sSX89TxxFgHAMJ7TnoUJKqJD,
8
)]
9
fun test_store(account: &signer) {
10
let value: u64 = 100;
11
Store::store(account, value); // Successful store value.
12
let stored_value = Store::destroy<u64>(Signer::address_of(account)); // Successful destroy value.
13
14
assert(stored_value == value, 101); // Throw error.
15
}
16
}
17
}
Copied!
The provided code implements a test for the Store module and looks very similar to the script we already implemented, yet it allows us to test our code.
See macro test, which allows you to provide a list of transaction signers that will be passed to the test function during execution.
Run tests:
1
dove test
Copied!
See result of test execution output, e.g.:
1
[ PASS ] 0xbeffe738f774f699ca7624bd45e8207f590cafb48bdca72fce02125480e7e116::StoreTest::test_store
2
Test result: OK. Total tests: 1; passed: 1; failed: 0
Copied!
See other test options:
1
dove test --help
Copied!
See more examples in Bridge repository.

Signers

Usually you have scripts that contains only one signer. A signer is an account where a signed transaction contains a script. When Diem builds a transaction using the tx command it adds information about signers to the transaction, so you shouldn't worry about these arguments.

Root and Treasury signers

As Diem is a permissioned network, often some functions of the Diem Standard Library require signatures from the Diem Treasury and Diem Root accounts.
If we compare Pontem to Diem, Pontem is a permissionless network, so Pontem disables parts of functions that require Treasury and Root signatures, and at the same time provides a way to get Treasury and Root signatures immediately.
So, using Dove you can build a transaction using Treasury and Root signature by using tr and dr literals as arguments:
1
dove tx 'my_script(dr, tr, ...the rest of arguments)'
Copied!

More

To learn more about these commands see help:
1
dove --help
Copied!
To continue with Dove and create your first scripts and modules read our Move VM pallet documentation.

Language Server

Language server is currently out of date and currently in process of migration in a separate project.

Resource viewer

Resource viewer is currently out of date and pending migration inside Dove in future versions.

Disassembler

Allows you to disassemble compiled .mv (modules/scripts) files.
See help:
1
decompiler --help
Copied!
Try to decompile .mv file:
1
decompiler --input <path to compiled module or script>
Copied!
Last modified 9d ago