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.
cd <endless-core-parent-directory>/endless-core/endless-move/move-examples/cli_argsDeploying the package
Start by mining a vanity address for Ace, who will deploy the package:
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():
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:
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:
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:
Last updated