Interact with a Package

Create and deploy your first move module.

Interacting with your module

The hello_blockchain module stores a string at an account within the MessageHolder resource of the calling account that can later be retrieved. To try interacting with the contract we will:

  1. Call set_message to store a string on-chain

  2. Call get_message to view the stored message on-chain

1

Store a string/message on-chain

Replace the place holder values denoted by <> with your account address before executing the commands.

replace & execute me!
supra move tool run --function-id '<hello_blockchain>::message::set_message' --args string:"Hello world!" --rpc-url https://rpc-testnet.supra.com
2

View the string/message stored on-chain

replace & execute me!
supra move tool view --function-id '<hello_blockchain>::message::get_message' --args address:<hello_blockchain> --rpc-url https://rpc-testnet.supra.com
3

Final step: Join our Discord!

Commands used to interact with modules

Calling a view function: supra move tool view

The view command is used to call view functions, which do not change the state of the VM in any way. View functions are denoted with #[view] above the function declaration.

Expects the two following arguments: --function-id which designates the function to be called. The format is as follows: MODULE_ADR::MODULE_NAME::FUNCTION_NAME

--args which designates the arguments to be passed to the function. If multiple parameters must be passed, they are separated by spaces. The format is as follows: TYPE:VALUE

Execute the following command to better understand the arguments of the command.

supra move tool view --help
Executing an entry function: supra move tool run

The run command is used to call entry functions, which result in some transaction. Entry functions are your gateway to interacting with modules. We are unable to call functions without the entry declaration.

Expects the two following arguments: --function-id which designates the function to be called. The format is as follows: MODULE_ADR::MODULE_NAME::FUNCTION_NAME

--args which designates the arguments to be passed to the function. If multiple parameters must be passed, they are separated by spaces. The format is as follows: TYPE:VALUE

Execute the following command to better understand the arguments of the command.

supra move tool run --help

Last updated