aptos
binary, which consists of:aptos move
namespace has everything related to the Move language:aptos key
allows you to generate a new private keyaptos init
allows you to initialize your Aptos project in order to:$PATH
.Plugins
on the left, then Marketplace
and search for the Move language
.sources/
- directory where you put your modules.
Move.toml
- manifest file for the package. Here, you define the package metadata, dependencies and addresses used in the code.Sender
and value 0x42
under [addresses]
. We're going to store all our modules in that address in the Aptos blockchain.move init
command automatically adds a dependency to the AptosFramework
package. It also transitively adds a MoveStdlib
dependency. Let's compile that empty package to make the Aptos CLI fetch the dependencies and inspect them.aptos-core
repo from Github.build/
directory at the package root.MoveStdlib
- standard library of the Move language consisting of modules that are indispensable such as functions to work with vectors and signers.AptosFramework
- a set of modules specific to the Aptos blockchain, like the Coin
module for an ERC20-like fungible token, and Account
for the account metadata.has key
ability after the name of the struct.&signer
argument in scope and call the move_to
function. The &signer
data type in the Move language represents the sender account of the current transaction, and is used mostly for resource store and access restrictions in modules. Developers can extract the address of the transaction sender using Signer::address_of(&signer)
function.acquires ResourceName
after the return type.UserProfile
resource struct where we're going to store our username in a field of type String
. Resources in Move are marked with the has key
ability.vector<u8>
objects or sequences of bytes. To use them more easily, the byte string literal was introduced, i.e. b"MyUser", b"MyString"
.ASCII
module was added to the standard library, which provides a String
struct that wraps vector<u8>
and ensures that it contains only ASCII characters. In our usernames, we're going to use those.username
:UserProfile
object from the user global storage. For that, we will use the borrow_global()
method which needs the address of the user store as a parameter. This also allows us to fetch the username of any other user.acquires UserProfile
which was explained earlier.UserProfile
in the global storage, we need to create one with the correct usernameUserInfo
&signer
here, as we want to only allow users themselves to change their profile.tests/{$MODULE_NAME}Tests.move
module.tests/
directory to the root of the package, and add UserInfoTests.move
there. Test functions are marked with the #[test]
attribute, this way Move knows it's a test and can apply special treatment. We also mark the module itself with a #[test_only]
attribute to remove it from the public namespace.aptos init
command.UserInfo
module publication..aptos/config.yaml
in the root of the project. Don't share your private key with anyone! If you want to change the configuration or account, just run aptos init
again and the configuration will be overwritten.0x7EBD304E2E7E7C2147D14A605072480473256B75D5CC7A9A794C0C5BC2F1E17B
(don't forget to add 0x
prefix to the start of the address), and replace the Sender
address in Move.toml
.aptos move publish
command:UserInfo
module we can send a transaction to the Aptos blockchain which will call the UserInfo::set_username
function and set the username for our account.set_username
script we need to utilize the aptos move run
command. In this example we will use the username AptosDev
as the username for our account which has to be provided as an argument. Also, function-id
should contain a path to the deployed contract and function name. In your case the path will be different because you are using your own account.