Join our
Discord!
LogoLogo
SupraScan ExplorerStarKey WalletDiscord
MoveVM
  • Network
  • Oracles
  • Automation
  • SupraNova
  • Guides
MoveVM
  • Overview
  • Getting Started
    • Install Supra CLI with Docker
    • Create a Supra Account
    • Create a Move Package
      • Initialize a Package
      • Write a Module
      • Compile and Publish
      • Interact with a Package
    • Create a dApp with StarKey
  • Network Information
  • Token Standards
  • Learn Move 101
    • Getting Started with Move
    • Unsigned Integers in Move
    • Math Operations in Move
    • Using Vectors in Move
    • Reading Resource Data with borrow_global
    • Passing Data in Move: Value vs. Reference
    • Adding Elements with vector::push_back
    • Emitting Events with event::emit
  • Move Book
    • Getting Started
      • Modules and Scripts
      • Move Tutorial
    • Primitive Types
      • Integers
      • Bool
      • Address
      • Vector
      • Signer
      • References
      • Tuples and Unit
    • Basic Concepts
      • Local Variables and Scope
      • Equality
      • Abort and Assert
      • Conditionals
      • While, For, and Loop
      • Functions
      • Structs and Resources
      • Constants
      • Generics
      • Type Abilities
      • Uses and Aliases
      • Friends
      • Packages
      • Package Upgrades
      • Unit Tests
    • Global Storage
      • Structure
      • Operators
    • Reference
      • Standard Library
      • Coding Conventions
  • TypeScript SDK
    • Guides
      • Create Supra Accounts
      • Publish a Package
    • Documentation
    • Repository
  • Rest API
    • Mainnet
      • Accounts
      • Faucet
      • Transactions
      • Block
      • View
      • Consensus
      • Events
      • Tables
    • Testnet
      • Accounts
      • Faucet
      • Transactions
      • Block
      • View
      • Events
      • Tables
  • Developer Resources
    • Supra Dapp Templates
    • Supra Move VS Code Extension
  • Links
    • Supra DevHub
    • SupraScan Block Explorer
    • StarKey Wallet
    • Live Data Feeds
    • Whitepapers
    • Security Audits
    • Supra's Official GitHub
Powered by GitBook
On this page
  • Commands used to interact with modules
  • Interacting with your module
Edit on GitHub
  1. Getting Started
  2. Create a Move Package

Interact with a Package

Create and deploy your first move module.

PreviousCompile and PublishNextCreate a dApp with StarKey

Last updated 18 days ago

Commands used to interact with modules

1

Calling a view function

Command: 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.

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

supra move tool view --help
2

Executing an entry function

Command: 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.

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

supra move tool run --help

Both commands expect the argument --function-id which designates the function to be called. The format is as follows: MODULE_ADR::MODULE_NAME::FUNCTION_NAME

Function parameters are passed with the argument --args. If multiple parameters must be passed, they are separated by spaces. The format is as follows: TYPE:VALUE

Example command
supra move tool view --function-id '0xCAF3::transfer::view_balance' --args address:0xCAF3 --rpc-url https://rpc-testnet.supra.com

Interacting with your module

The example module will transfer tokens from the calling account to the two destination accounts. To gain experience with interacting with a package, we will:

  1. Check the balance of your account with the view_balance function

  2. Transfer tokens to the destination addresses with the two_by_two function

  3. Check the balance of your account with the view_balance function

We should observe that the balance returned in step 3 is less than the balance returned in step 1 due to the tokens being transferred in step 2.

1

Check the initial balance

In this example, the module was deployed to the named address @exampleAddress that we set in the move.toml file. Replace the place holder values denoted with <> below to execute the command.

Our example module included a view function view_balance. For our first interaction, lets check the balance of your account.

As we have deployed the module to the same account that you will be calling the function from, both the module address and the address argument will be the same.

replace & execute me!
supra move tool view --function-id '<exampleAddress>::transfer::view_balance' --args address:<ADDRESS_TO_CHECK> --rpc-url https://rpc-testnet.supra.com
2

Call the deployed two_by_two entry function

Replace the place holder values denoted with <> below to execute the command. Following the execution of this command, repeat step 1 to observe the new balance(s).

replace & execute me!
supra move tool run --function-id '<exampleAddress>::transfer::two_by_two' --args u64:10000000 address:<FIRST_ADR> address:<SECOND_ADR> --rpc-url https://rpc-testnet.supra.com
3

Repeat step 1 to check the updated balance

You should now observe that the balance of your account is less than it was when first observed in step 1. Feel free to play around with this more to get a feel for the commands.

4

Final step: !

Join our Discord