1. Aptos IDE Usage Process
This tutorial provides a detailed description of how to use Aptos IDE to create a smart contract, compile it, wallet configuration, and deploy it on the Aptos blockchain.
Once you click the "Try Now" button, a window like shown below will appear and you need to click on the "New Project" button.
New Project Creation using Aptos IDE
Clicking the "New Project" button will display all the supported blockchains and built-in templates integrated with ChainIDE, you may choose any blockchain of your interest that you want to use to deploy your smart contract. For this tutorial, we are creating an application to deploy on Aptos Blockchain, so we will use Aptos IDE.
Built-in templates for Aptos IDE
ChainIDE has prepared several official Move sample project templates for the Aptos blockchain, including basic Move types and a Basic Coin template. We'll use the "HelloBlockchain" built-in template for this tutorial, click the "HelloBlockchain" built-in template and enter the project workspace.
The workspace is as shown below. When opening the project for the first time, the readme of the template project (including the basic introduction of the template) will be opened by default.
Aptos IDE Workspace Overview
In the lower right corner of the workspace, is the development network wallet built into Aptos IDE. Based on Aptos' development network, we implemented a basic wallet to manage development accounts. When a user enters the Aptos Move project for the first time, an Aptos development network account will be created by default.
Click to open the wallet, you can see that the current account token balance is 0. In order to facilitate subsequent module release, interaction, etc., we click the "Fund from Faucet" to get some test coins for deploying a smart contract to the Aptos Blockchain and make interaction to the deployed smart contract.
In the Explorer panel on the left side of the workspace, you can see the files of the current project. A basic Move package should contain at least a Move.toml file and a sources folder, under which is the move file.
You can open the HelloBlockchain smart contract, view it in the editor panel, and make changes to it according to your requirements.
Click the first icon on the far right of the workspace to open the Move Package compilation panel. We can see that the compiler will automatically read the relevant information of the current project to obtain Move.toml, module name, etc.
After you finished writing up the contract, you can click the "Compile" button to compile the Move Package. The compilation will call the Terminal Sandbox service of ChainIDE (we built an Aptos CLI Sandbox to compile the Move). The compilation result will be output in the "Terminal" panel.
When we compiled the code shown in the above image, an error is reported, and to resolve that issue, we need to configure the address for HelloBlockchain. Open the wallet and copy the address of the current wallet; then open the Move.toml file and configure this address for HelloBlockchain in the addresses item.
After configuring the address for the module, click compile again, you can see that the compilation is successful and you can see the module id in the Terminal output.
After the project is compiled successfully, the module can be published. Click the second icon from the far right of the workspace to open the Publishing Interaction panel. There are three form items in the publish panel:
- 1.Publish Way: The publishing method, currently only supports the scripting method for publishing and interacting with the development network, so it cannot be changed
- 2.TOML Config Path: Move.toml configuration file path. There may be multiple Move Packages in a project. Use this option to select the package to be published
- 3.Compiled Module Path: The compiled module file path. The path of the compiled module mv file of the current package
We select the Message module mv file and click Publish. The conference calls the built-in script to interact with the Aptos development network and publishes the Message module to the current account.
After the module is published successfully, the information of the published module will be saved, and the quick interactive content (calling the method of the published module) will be generated in the module interaction panel.
The Message module published above has a set_message method that adds a MessageHolder Resource to the account. We enter any character in arg-1 and click call.
The module is published to the account, and the Resource is generated after the module method is called, we can view it in the next section on the account resource on the chain.
Click the third icon on the far right of the workspace to open the Account Module Resources panel.
Enter the current account address in the account module form item, enter the module name "message", and click Query to view the Message module published on the current account.
Enter the current account address in the account resource form item, enter the resource name "MessageHolder", and click Query to see that the MessageHolder value added to the account above is hello.