diff --git a/docs/quick-start/hello-world/index.md b/docs/quick-start/hello-world/index.md index b088064..2f1b5ae 100644 --- a/docs/quick-start/hello-world/index.md +++ b/docs/quick-start/hello-world/index.md @@ -15,11 +15,11 @@ This guide provides step-by-step instructions to set up your local development e ### Install Required Packages -* [Install dotnet](https://dotnet.microsoft.com/en-us/download) +* [Install dotnet](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) * Install aelf contract templates ```bash -dotnet new install AELF.ContractTemplates +dotnet new --install AELF.ContractTemplates ``` AELF.ContractTemplates contains various predefined templates for the ease of developing smart contracts on the aelf blockchain. @@ -38,10 +38,8 @@ Please remember to export PATH after installing aelf.deploy. * [Install Node.js](https://nodejs.org/en) * Install aelf-command -### Install aelf-command - ```bash -npm i -g aelf-command +sudo npm i -g aelf-command ``` aelf-command is a CLI tool for interacting with the aelf blockchain, enabling tasks like creating wallets and managing transactions. @@ -74,13 +72,15 @@ curl -O --output-dir $ACS_DIR https://raw.githubusercontent.com/AElfProject/AElf ### Adding Your Smart Contract Code -Now that we have a template hello world project, we can customize the template to incorporate our own contract logic. +Now that we have a template hello world project, we can customise the template to incorporate our own contract logic. Lets start by implementing methods to provide basic functionality for updating and reading a message stored persistently in the contract state. ```bash cd src ``` +The implementation of file `src/HelloWorldState.cs` is as follows: + ```csharp using AElf.Sdk.CSharp.State; @@ -142,21 +142,74 @@ dotnet build #### Create A Wallet -import CreateWallet from '@site/docs/_create-wallet.md'; +To send transactions on the aelf blockchain, you must have a wallet. + +Run this command to create aelf wallet. - +```bash title="Terminal" +aelf-command create +``` + +![result](/img/create_wallet_output.png) #### Acquire Testnet Tokens for Development -import GetTestnetToken from '@site/docs/_get-testnet-token.md'; +To deploy smart contracts or execute on-chain transactions on aelf, you'll require testnet ELF tokens. + +**Get ELF Tokens** + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +Run the following command to get testnet ELF tokens from faucet. Remember to either export your wallet address and wallet password or replace $WALLET_ADDRESS and $WALLET_ADDRESS with your wallet address and wallet password respectively. + +```bash title="Terminal" +export WALLET_ADDRESS="YOUR_WALLET_ADDRESS" +curl -X POST "https://faucet.aelf.dev/api/claim?walletAddress=$WALLET_ADDRESS" -H "accept: application/json" -d "" +``` +To check your wallet's current ELF balance: +```bash title="Terminal" +export WALLET_PASSWORD="YOUR_WALLET_PASSWORD" +aelf-command call ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io GetBalance +``` +You will be prompted for the following: + +```sh +Enter the required param : **ELF** +Enter the required param : **$WALLET_ADDRESS** +``` + +You should see the Result displaying your wallet's ELF balance. + + + + +Go to this url [https://faucet-ui.aelf.dev](https://faucet-ui.aelf.dev). Enter your address and click `Get Tokens`. - +![result](/img/get-token-ui.png) + + + ### Deploy Your Smart Contract -import DeploySmartContract from '@site/docs/_deploy-smart-contract.md'; +The smart contract needs to be deployed on the chain before users can interact with it. + +Run the following command to deploy a contract. Remember to export the path of HelloWorld.dll.patched to CONTRACT_PATH. +Remember to export CONTRACT_FILE equals to HelloWorld. + +```bash title="Terminal" +export CONTRACT_PATH="SRC_DIRECTORY_PATH" + /bin/Debug/net6.0 +export CONTRACT_FILE=HelloWorld +aelf-deploy -a $WALLET_ADDRESS -p $WALLET_PASSWORD -c $CONTRACT_PATH/$CONTRACT_FILE.dll.patched -e https://tdvw-test-node.aelf.io/ +``` + +Please wait for approximately 1 to 2 minutes. If the deployment is successful, it will provide you with the contract address. - +![result](/img/deploy-result.png) ## 4. Interact with Your Deployed Smart Contract @@ -164,6 +217,7 @@ Lets try to call methods on your newly-deployed smart contract using `aelf-comma Firstly, we will set a message using the `Update` method. Run the following command, and enter the message argument as `test`. This will set `test` into the Message contract state. +Remember to export CONTRACT_ADDRESS equals to your deployed contract address. ```bash aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Update