This article will get you started with AElf's Boilerplate project. You will learn the following items:
setting up the basic environment for developing contracts and dApps.
downloading AElf Boilerplate's code and setting up Visual Studio Code.
To successfully complete this tutorial you first need to install the following dependencies, please refer to your platforms installation guide:
Git for version control, follow these instructions.
Dotnet core sdk for building and testing, you can download it here.
Mac users also need to install Homebrew.
Strictly speaking you don't need an IDE for this tutorial but it is highly recommended. If you don't already have one we recommend you try Visual Studio Code (vscode) with the C# extension:
Open a terminal in your system and clone the tutorial with the following command:
git clone https://github.com/AElfProject/aelf-boilerplate
This command will create a aelf-boilerplate folder with the code inside it.
If not already done open vscode and open the aelf-boilerplate folder.
If asked to add some "required assets" say yes. There may also be some dependencies to restore: for all of them choose Restore.
Open vscode's Integrated Terminal and build the project with the following command. Note: you can find out more about vscode's terminal here.
If you don't already have protobuf installed, run the following script:
On Mac or Linux:
On Windows: Windows is slightly more complex. You need to open a PowerShell console as administrator. Enter your clone directory so your PowerShell is currently in the root of aelf-boilerplate clone. Run the following:
Note: if you prefer or have problems, you can refer to the following guide to manually install protobuf on your system.
cd chain/src/AElf.Boilerplate.Launcher/dotnet build
To actually run the node, use the following command.
dotnet run bin/Debug/netcoreapp2.2/AElf.Boilerplate.Launcher
At this point the smart contract has been deployed and is ready to use. You should see the node's logs. You can now stop the node by killing the process (usually control-c or ctrl-c in the terminal).
If you want to run the tests, simply navigate to the HelloWorldContract.Test folder. From here run:
cd ../../test/HelloWorldContract.Test/dotnet test
The output should look somewhat like this:
Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
You've just seen a simple example of a smart contract run with our Boilerplate tutorial. When launching (with dotnet run) the contract was automatically deployed and ready to interact with. You also discovered how to navigate to the test folder and run the tests.
Next you will see how AElf's js sdk is used to interact with the contract.
The following commands will navigate to the SDK's folder and demonstrate the capabilities of the js sdk, execute them in order:
cd ../../../web/JSSDK/npm installnpm start
You should see the results in the terminal or in the browser dev tool.
To use the browser extension you must follow the following instructions:
1.Install the extension.
click to install dev version
If you meet some problem when use the extension, please click the extension repo and download the 0.7.0 version extension from the github. And add the extension manually.
2.Open the extension, create your wallet, create your keypair.
3.Next go into the extensions folder and run the app with the following commands:
cd ../browserExtension/npm installnpm start
To see the plugin in action you can navigate to the following address in your browser: http://localhost:3000
Please open dev tool to see the results.