Skip to content

Commit

Permalink
[Documentation] Small cleanups to "Interacting with the Aptos Blockch…
Browse files Browse the repository at this point in the history
…ain"

Closes: aptos-labs#263
  • Loading branch information
JoshLind authored and aptos-bot committed Mar 21, 2022
1 parent 2610535 commit 83d4839
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ slug: "interacting-with-the-aptos-blockchain"

# Interacting with the Aptos Blockchain

The Aptos Blockchain uses the [Move][move_url] for executing operations. While many blockchains implement a set of
native operations, Aptos delegates all operations to Move including aspects like creating accounts, transferring funds,
and publishing Move modules. To support these operations, Blockchains built on top of Move provide a framework akin to
an operating system for a computer, or a minimally viable set of operations for interacting with the blockchain. This
section discusses these operations as they are exposed via the Aptos Framework's `script` functions. This guide in
concert with the [Move module tutorial][your-first-move-module] will unlock the minimal amount of information to start building rich
applicatoins on top of the Aptos Blockchain. Note: the Aptos Framework is under heavy development, this document may not
be up to date, the most recent framework can be found [here][aptos_framework].
The Aptos Blockchain uses the [Move][move_url] virtual machine (VM) for executing operations. While many blockchains implement a set of
native operations, Aptos delegates all operations to Move, including: account creation, fund transfer and publishing Move modules.
To support these operations, blockchains built on top of Move must provide a framework (akin to
an operating system for a computer or a minimal viable set of functions) for interacting with the blockchain. In this section, we discuss
these functions, exposed via the Aptos Framework's `script` functions.

This guide (in concert with the [Move module tutorial][your-first-move-module]) will unlock the minimal amount of information required to start building rich applications on top of the Aptos Blockchain. Note: the Aptos Framework is under heavy development and this document may not
be up to date. The most recent framework can be found in the source code, [here][aptos_framework].

The core functions provided to users within the Aptos Framework include:
* Send and receive `TestCoin`
* Creating accounts
* Publishing new modules
* Sending and receiving `TestCoin`
* Creating a new account
* Publishing a new Move module

This document assumes familiarity with submitting transactions, as demonstrated in the [Your first transaction tutorial][your-first-transaction].
Note: this document assumes readers are already familiar with submitting transactions, as described in the [Your first transaction tutorial][your-first-transaction].

## Sending and Receiving `TestCoin`

`TestCoin` is required for paying gas fees when submitting transactions. `TestCoin` can be obtained by querying the Devnet Faucet. See the [Your first transaction tutorial][your-first-transaction] for an example.
`TestCoin` is required for paying gas fees when submitting and executing transactions. `TestCoin` can be obtained by querying the Devnet Faucet. See the [Your first transaction tutorial][your-first-transaction] for an example.

The payload for instructing the blockchain to perform a transfer is:

Expand All @@ -39,7 +39,8 @@ The payload for instructing the blockchain to perform a transfer is:
}
```

This instructs the VM to execute the `script` `0x1::TestCoin::transfer`. The first argument is the recipient address, `0x737b36c96926043794ed3a0b3eaaceaf`, and the second is the amount to transfer, `1000`.
This instructs the VM to execute the `script` `0x1::TestCoin::transfer`. The first argument is the recipient address, `0x737b36c96926043794ed3a0b3eaaceaf`, and the second is the amount to transfer, `1000`. The sender address is the account
address that sent the transaction calling this `script`.

## Creating a new account

Expand All @@ -57,9 +58,9 @@ The payload for instructing the blockchain to create a new account is:
}
```

This instructs the VM to execute the `script` `0x1::AptosAccount::create_account`. The first argument is the address of the account to create and the second is the authentication key pre-image, which is briefly mentioned in [Accounts][accounts]. For single signer authentication this is the public key concatenated by the by `0` byte or `pubkey_A | 0x00`. This is required to prevent account address land grabbing. The execution of this instruction verifies that the last 16-bytes of the authentication token are the same as the 16-byte account address. We are actively working on improving this API to support taking in a 32-byte account address that would eliminate concerns around land grabbing or account manipulation.
This instructs the Move virtual machine to execute the `script` `0x1::AptosAccount::create_account`. The first argument is the address of the account to create and the second is the authentication key pre-image (which is mentioned in [Accounts][accounts]). For single signer authentication, this is the public key concatenated with the `0` byte (or `pubkey_A | 0x00`). This is required to prevent account address land grabbing. The execution of this instruction verifies that the last 16-bytes of the authentication key are the same as the 16-byte account address. We are actively working on improving this API to support taking in a 32-byte account address that would eliminate concerns around land grabbing or account manipulation.

## Publishing modules
## Publishing a new Move module

The payload for publishing a new module is:

Expand All @@ -72,7 +73,7 @@ The payload for publishing a new module is:

This instructs the VM to publish the module bytecode under the sender's account. For a full length tutorial see [Your first move module][your-first-move-module].

It is important to note, that the Move bytecode must specify the same address as the sender's account, otherwise the transaction will be rejected. For example, assuming account address `0xe110`, the Move module would need to be updated as such `module 0xe110::Message`, `module 0xbar::Message` would be rejected. Alternatively an aliased address could be used, such as `module HelloBlockchain::Message` but the `HelloBlockchain` alias would need to updated to `0xe110` in the `Move.toml` file. We are working with the Move team and planning on incorporating a compiler into our REST interface to mitigate this issue.
It is important to note that the Move bytecode must specify the same address as the sender's account, otherwise the transaction will be rejected. For example, assuming account address `0xe110`, the Move module would need to be updated as such `module 0xe110::Message`, `module 0xbar::Message` would be rejected. Alternatively an aliased address could be used, such as `module HelloBlockchain::Message` but the `HelloBlockchain` alias would need to updated to `0xe110` in the `Move.toml` file. We are working with the Move team and planning on incorporating a compiler into our REST interface to mitigate this issue.

[accounts]: /basics/basics-accounts
[your-first-move-module]: /tutorials/your-first-move-module
Expand Down

0 comments on commit 83d4839

Please sign in to comment.