Lesson 1 - Getting started with ink!
In this lesson, you will learn how to install the necessary tools and deploy a simple smart contract.
1. Setup
This section demonstrates how to install the different tools to be able to develop on Aleph Zero.
To develop on Aleph Zero, you will need openssl installed. If it is not already installed, onpenssl can be installed with the following command:
+++ MacOS
+++ Ubuntu
+++ Protobuf is also needed and can be installed with the following command:
+++ MacOS
+++ Ubuntu
+++
You will need to first install Rust which means that you will need to have curl installed as well. Do not install curl with snap, use apt instead:
+++ MacOS
+++ Ubuntu
+++ After installing curl, Rust can be installed with the following two commands.
The minimum version of rust that needs to be installed is 1.66.
==- ink! version 3 installation Following the Rust installation, toolchains need to be installed. This can be done thanks to the following commands
Then, binaryen is needed and can be installed with the following command
+++ MacOS
+++ Ubuntu
+++
Finally, the cargo package manager is required to develop on Aleph Zero and can be installed with one of the following commands
==- To install ink! v4, you just need to execute this command.
If you already started a project with ink! v3 please follow thise guidelines in order to migrate to ink! v4: Migration
Course_01:
2. Create and write your smart contract
The second section consists of writing a smart contract which plays the role of a computer which can perform addition and subtraction only. The smart contract will have the following element:
a global variable;
an addition function that will take a value as input to be added to the global variable;
a subtraction function that will take a value as input to be subtracted to the global variable.
The source code is avalaible ate the bottom of this page.
The command used to create the smart contract is the following.
The command above will create a folder computer
with the following files:
Cargor.tolm: Rust Dependencies and ink! Configuration;
lib.rs: source code of your smart contract;
.gitingore.
Course_02:
3. Test & compile
In this this section, we will demonstrate how to test and compile your smart contract. First, we need to go in you project folder, this means for this example, we need to executed the command
Then, the command to perform the tests on the contract is the following.
After testing the smart contract, the compilation can be performed thanks to the following command ==- ink! v3 With ink! v3, we need the nightly toolchain, therefore, the following command needs to be executed:
==-
Course_03:
4. Deploy on the Aleph Zero Testnet
In this section, we will demonstrate how to deploy your contract on Aleph Zero testnet and how to interact with it. The video first demonstrates how to deploy and interact with a smart contract with a user interface. Then we will demonstrate a way to deploy and interact with your smart contract using the command line.
To deploy your smart contract you can first execute these two commands.
The first one to store your seed
and the second one to store the URL of Aleph Zero testnet.
Then you need to be in the folder of your project. In our case, we need to be inside the folder computer
.
Then, this command will deploy the smart contract on Aleph Zero testnet
The command above will generate an address for your contract and this will generate
Then to interact, the following command can be used
Note about the flag -x
: This will execute your command on Aleph Zero testnet. Executing the command presented above without this flag will present you the expected command.
Course_04:
5. Deploy Locally
The last section demonstrate how to use substrate locally. First, we need to install the substrate you can download the binaries at the link binaries or build it locally from the git repository gitparitycheck
After downloading the binary, please open a terminal in the folder substrate-contracts-node-linux
on linux or substrate-contracts-node-mac
if you are using Mac and execute the following command:
If you want have more information about substrate please visit substrate.io.
Course_05:
Sample Code
Last updated