Arguments in JSON Tutorial

Package info

This section references the CliArgs example package, which contains the following manifest:

[package]
name = "CliArgs"
version = "0.1.0"
upgrade_policy = "compatible"

[addresses]
test_account = "_"

[dependencies.EndlessFramework]
local = "../../framework/endless-framework"

Here, the package is deployed under the named address test_account.

Set your working directory to endless-move/move-examples/cli_args to follow along:

cd <endless-core-parent-directory>/endless-core/endless-move/move-examples/cli_args

Deploying the package

Start by mining a vanity address for Ace, who will deploy the package:

The exact account address should vary for each run, though the vanity prefix should not.

Store Ace's address in a shell variable, so you can call it inline later on:

Fund Ace's account with the faucet (either devnet or testnet):

Now publish the package under Ace's account:

Entry functions

The only module in the package, cli_args.move, defines a simple Holder resource with fields of various data types:

A public entry function with multi-nested vectors can be used to set the fields:

After the package has been published, endless move run can be used to call set_vals():

To pass vectors (including nested vectors) as arguments from the command line, use JSON syntax escaped with quotes!

The function ID, type arguments, and arguments can alternatively be specified in a JSON file: move-examples/cli_args/entry_function_arguments.json

Here, the call to endless move run looks like:

If you are trying to run the example yourself don't forget to substitute Ace's actual address for <test_account> in entry_function_arguments.json!

View functions

Once the values in a Holder have been set, the reveal() view function can be used to check the first three fields, and to compare type arguments against the last two fields:

This view function can be called with arguments specified either from the CLI or from a JSON file:

If you are trying to run the example yourself don't forget to substitute Ace's actual address for <test_account> in view_function_arguments.json (twice)!

Output:

Script functions

The package also contains a script, set_vals.move, which is a wrapper for the setter function:

First compile the package (this will compile the script):

Next, run endless move run-script Arguments via CLI

Arguments via JSON file

script_function_arguments.json

Both such script function invocations result in the following reveal() view function output:

Output:

As of the time of this writing, the endless CLI only supports script function arguments for vectors of type u8, and only up to a vector depth of 1. Hence vector<address> and vector<vector<u8>> are invalid script function argument types.

Last updated