Write a Module
Create and deploy your first move module.
If you have not already, open your newly initiatlized project within your code editor of choice on your host machine. Remember, the container configs
directory is bound to the supra_configs
directory on your host machine. Any changes made to these files on the host machine will be reflected within the container.
If you are using VS Code, we highly recommend that you install the Supra Move extension.
Create a new move file within the sources
directory.
sources
directory.In the previous step, we set the named address of @exampleAddress
to that of your own account. Notice how the name of this module is exampleAddress::transfer
. Modules are defined with the following format: ADDRESS::MODULE_NAME
In Move, global storage is a forest with trees rooted at an account address. Accounts can store both resource data and module code. Modules are deployed to an account, rather than a unique address being generated at deployment as you may be custom to with other VMs.
At compilation, exampleAddress
will be replaced with the value you set in the named addresses within the Move.toml
file. Upon publishing the module, it will be published at that designated account.
The sources directory holds the move modules that you will be working on within your project. Within the sources
directory, create the example.move
file with the following code.
The two_by_two
function provided has four parameters. The signer, amount to be transferred, and two destination addresses. The function will transfer the passed amount to both destination addresses.
Last updated