Your First Move Module
Your First Move Module
This tutorial details how to compile, test, publish and interact with Move modules on the Endless blockchain. The steps in summary are:
Install the precompiled binary for the Endless CLI.
Create an account on the Endless blockchain and fund it.
Compile and test a Move module.
Publish a Move module to the Endless blockchain.
Interact with a Move module.
Step 1: Install the CLI
Install the precompiled binary for the Endlesss CLI.
Step 2: Create an account and fund it
After installing the CLI binary, create and fund an account on the Endless blockchain.
Start a new terminal and run the following command to initialize a new local account:
You will see output asking to choose a network:
Press return to accept the default devnet network or specify the network of your choosing:
See and respond to the prompt for your private key by accepting the default to create a new or by entering an existing key:
Assuming you elected to create a new, you will see:
The account address in the above output a345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a
is your new account and is aliased as the profile default
. This account address will be different for you as it is generated randomly. From now on, either default
or 0xa345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a
are used interchangeably in this document. Of course, substitute your own address as needed.
Now fund this account by running this command:
You will see output resembling:
input yes
to send fund transaction, and console output:
Step 3: Compile and test the module
Run the below command to compile the hello_blockchain
module:
You will see output resembling:
To test the module run:
And receive output like:
To prepare the module for the account created in the previous step, we specify that the named address hello_blockchain
is set to our account address, using the default
profile alias.
Step 4: Publish the Move module
After the code is compiled and tested, we can publish the module to the account created for this tutorial with the command:
You will see the output similar to:
At this point, the module is now stored on the account in the Endless blockchain.
Step 5: Interact with the Move module
Move modules expose access points, known as entry functions. These entry functions can be called via transactions. The Endless CLI allows for seamless access to these entry functions. The example Move module hello_blockchain
exposes a set_message
entry function that takes in a string
. This can be called via the CLI:
Upon success, the CLI will print out the following:
The set_message
function modifies the hello_blockchain
MessageHolder
resource. A resource is a data structure that is stored in global storage. The resource can be read by querying the following REST API:
After the first execution, this should contain:
Notice that the message
field contains hello, blockchain
.
Supporting documentation
Last updated