ALEO COIN — How to create a wallet and send transactions to the network

ALEO COIN — How to create a wallet and send transactions to the network


Aleo SDK

The Aleo SDK is a developer platform that makes it easy to create a new account, create a transaction, and broadcast it to the network. For more information about Aleo, visit the Welcome to Aleo page to get started.

Welcome to AleoHTTPS://DEVELOPER.ALEO.ORG/OVERVIEW/

HTTPS://DEVELOPER.ALEO.ORG/OVERVIEW/

Aleo assembly guide

1 Install Rust

We recommend installing Rust with  rustup  . You can install  rustuplike this:

  • macOS or Linux:curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Windows (64-bit): Download  the 64-bit  or  32-bit Windows executable  and follow the on-screen instructions.

2 Building from source

GitHub Aleo

HTTPS://GITHUB.COM/ALEOHQ/ALEO/

We recommend installing  aleothis way. In your terminal, run:

# Download the source code
git clone https://github.com/AleoHQ/aleo.git

# Enter the 'aleo' directory
cd aleo

# Install 'aleo'
cargo install --path .

Now to use  aleo, in your terminal run:

come on

Aleo User Guide

An Aleo  account  consists of  an account private key , an  account  view key ,  and an account  address  .

The account’s private key is used to authorize a transaction that updates the global state of the account’s records. The account view key is used to decrypt account entries that are encrypted under the user’s account address. Finally, the account address allows users to interact with each other by sending and receiving records that encode application values ​​and data.

To protect user  assets  and  record data  ,  you should never disclose your account’s private key to  third parties. For real applications on Aleo, users must obtain a compute key from their account’s private key to allow third parties to  insecurely  run applications and generate transactions on behalf of the user.

Create a new Aleo account  here : https://aleo.tools/

1 Create a new Aleo account

To create a new Aleo account, run:

aleo account new [FLAGS] [OPTIONS]

The command can be run with the following optional parameters:

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -s, --seed <seed>

2 Create and build a new project

To create a new project, we will use  newthe command. Our project:

aleo new foo

This will create the foo directory   and files with the basic project structure:

  • README.md contains  a skeleton README with compilation instructions.
  • main.aleo is  the main source code file.
  • program.json  containing the project identification in JSON format. In particular, the address of the developer and his private key for the program.

The main.aleo file should have the following content:

// The 'foo.aleo' program.
program foo.aleo;

function hello:
    input r0 as u32.public;
    input r1 as u32.private;
    add r0 r1 into r2;
    output r2 as u32.private;

To compile the project, run in the main directory:

aleo build

You will see output like this:

⏳ Compiling 'foo.aleo'...
 • Loaded universal setup (in 1478 ms)
 • Built 'hello' (in 3250 ms)
✅ Built 'foo.aleo' (in "~/foo")

First, a “universal install” is loaded into your environment. You can read more about it  here  or in  the Marlin article  .

Once the generic install is ready, each function in your  main.aleo file  will be created, generating this in the output folder:

  • hello.prover proving  the function  hello.
  • hello.verifier  –  hellofunction verifier.
  • main.avm  is the bytecode of your aleo program that the virtual machine will run.

As you may have guessed,  .avmwe have only one file for the entire program, but each function has its own prover and verifier.

3 Starting the program

You can run a program with a  aleo runcommand followed by the name of the function you want to execute and its input parameters.

aleo run hello 2u32 3u32

When the execution completes, you should see the following output:

🚀 Executing 'foo.aleo/hello'...
 • Calling 'foo.aleo/hello'...
 • Executed 'hello' (in 1170 ms)
➡️  Output
 • 5u32
✅ Executed 'foo.aleo/hello' (in "[...]/foo")

As you can see, the output register has been assigned  5u32a value representing the sum of the inputs.

4 Program overview

Let’s look at the foo program inside the  main.aleo file  :

// The 'foo.aleo' program.
program foo.aleo;

function hello:
    input r0 as u32.public;
    input r1 as u32.private;
    add r0 r1 into r2;
    output r2 as u32.private;

First, we need to declare the program like this:

program foo.aleo;

After that, we can start writing its functions (or other Aleo structures like structs, records, closures, as we’ll see later).

In the case of functions, everything is very simple:

function [function_name]:

Functions consist of three main parts:

  • Input section Here we declare its input parameters: input r0 as u32.public; input r1 as u32.private; Everything in Aleo instructions is declared/stored inside a register with type (  i8,  field,  booletc.) and visibility option (  publicor  private), registers are named  r0,  r1, …,  rn. In this case, we use  r0and  r1for storing the input data passed in sequential order to the program as  u32values, where we can store unsigned 32-bit integers to perform our sum operation.
  • Instruction section The next section consists of the core of our function, here we call the number of Aleo instructions we need to make our program do what we want. For example, performing an addition operation: add r0 r1 into r2; Each Aleo instruction is followed by its input parameters with specific types, and the result is stored in the  into register. You can find all available aleo instructions  here  .
  • Output section Like the input section, the output section does the same for the program’s output. This is the return of the function. output r2 as u32.private;

5 Types

Aleo uses a strongly typed syntax. The language supports 16 primitive types and allows users to define their own types.

Primitive Aleo types include:

address
boolean
field
group
i8
i16
i32
i64
i128
u8
u16
u32
u64
u128
scalar
string

structsUsers can define custom types using the or  keywords  record. We will cover them in the next few sections.

1 Registers

Registers are places where you store data so that you can change it later.

2 Interfaces

Interfaces are user-defined data structures. They are very similar to traditional structures in conventional programming languages. You can store structures in registers like any other Aleo data type.

For example, let’s create a structure that represents a fixed-size array of 3 elements. Add this at the bottom of  your main.aleo file  :

struct array3:
    a0 as u32;
    a1 as u32;
    a2 as u32;

Now, just as an example, let’s write a function that adds one to each element of a register with  array3a data type stored in it.

function sum_one_to_array3:
    input r0 as array3.private;
    add r0.a0 1u32 into r1;
    add r0.a1 1u32 into r2;
    add r0.a2 1u32 into r3;
    cast r1 r2 r3 into r4 as array3;
    output r4 as array3.private;

As you can see, we can enter a structure into a register  r0and access the members of the structure using  .syntax. We execute the  addinstruction for each element, storing the results in registers  r1,  r2and  r3finally use the cast command to create a new  array3structure in  r4.

Now let’s run it. In this case, the only new thing you need to know is that structures are passed to the CLI in the following format:

"{a0: 1u32, a1: 2u32, a2: 3u32}"

Now we can execute  aleo runthe command. We’ll clean up the project to pick up the new code:

aleo clean && aleo run sum_one_to_array3 "{a0: 0u32, a1: 1u32, a2: 2u32}"

And we get the new  array3element as output:

🚀 Executing 'foo.aleo/sum_one_to_array3'...
 • Calling 'foo.aleo/sum_one_to_array3'...
 • Executed 'sum_one_to_array3' (in 1331 ms)
➡️  Output
 • {
  a0: 1u32,
  a1: 2u32,
  a2: 3u32
}
✅ Executed 'foo.aleo/sum_one_to_array3' (in "[...]/foo")

3 Entries

A record is the main data structure for encoding custom assets and application state. They are very similar to structs, but have two optional parameters:

record token:
    owner as address.private
    gates as u64.private

refers to the  ownerAleo address the entry belongs to and  gatesis the amount of credits the entry must spend.

Records are important because they are Aleo’s basic structure for managing state in your application.

When executing the Aleo function, only records belonging to the application address can be transferred as input registers. Otherwise, an error will occur and the application will not start.

You can find the address of your development application inside the  program.json file  :

{
    "program": "foo.aleo",
    "version": "0.0.0",
    "description": "",
    "development": {
        "private_key": "APrivateKey1zkpFsQNXJwdvjKs9bRsM91KcwJW1gW4CDtF3FJbgVBAvPds",
        "address": "aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09"
    },
    "license": "MIT"
}

4 State of Aleo

In Aleo, application state is managed using entries. An Aleo account can create a transaction to use an entry and create a new entry in its place. Records in Aleo are encrypted at the address of the owner of the record, which guarantees complete confidentiality of all records in Aleo.

6 Your first Aleo program: translating

Consider this program:

// The 'foo.aleo' program.
program foo.aleo;
record token:
    owner as address.private;
    gates as u64.private;
    amount as u64.private;
function transfer_amount:
    //  sender token record
    input r0 as token.record;
    // receiver address
    input r1 as address.private;
    // amount to transfer
    input r2 as u64.private;
    // final balance of sender
    sub r0.amount r2 into r3;
    // final balance of receiver
    add 0u64 r2 into r4;
    // sender token record after the transfer
    cast r0.owner r0.gates r3 into r5 as token.record;
    // receiver token record after the transfer
    cast r1 0u64 r4 into r6 as token.record;
    // sender new token record
    output r5 as token.record;
    // receiver new token record
    output r6 as token.record;

First, we define our own record data type named  token, which has two optional parameters  ownerand  gates, as well as a user-defined parameter named  amount, representing the number of tokens we have.

This  transfer_amountfunction takes 3 input parameters (  senderwrite,  receiverwrite and  amount) and stores them in 3 registers (  r0,  r1and  r2). After that, it calculates the final balance for both of them and stores it in  r3and  r4(using the  sub  and  add instructions  to calculate the subtraction and addition, respectively). With these final amounts, it creates output records for the sender and receiver, saving them in files  r5and  r6Finally, both entries are sent out of the function along with the output instruction  .

To run this function, the first parameter is the input entry of the program. The format of this parameter is the same as for structure types:

{
  owner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,
  gates: 0u64.private,
  amount: 50u64.private
}

Where:

  • owner: The public address of the program, as specified  development.addressin the build/program.json file.
  • gate: the gate that the record has.
  • other parameters: depending on the program itself (in this example, we used the  amount parameter  with a value of 50).

Let’s run  transfer_amountthe function (if you’re following, don’t forget to use the address found in program.json for the owner field):

aleo clean && aleo run transfer_amount "{
owner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,
gates: 0u64.private,
amount: 50u64.private
}" aleo1h3gu7fky36y8r7v2x9phc434fgf20g8qd7c7u45v269jfw6vmugqjegcvp 10u64

We get the following output records:

🚀 Executing 'foo.aleo/transfer_amount'...
 • Calling 'foo.aleo/transfer_amount'...
 • Executed 'transfer_amount' (in 3520 ms)
➡️  Outputs
 • {
  owner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,
  gates: 0u64.private,
  amount: 40u64.private
  _nonce: 2293253577170800572742339369209137467208538700597121244293392265726446806023group.public
}
 • {
  owner: aleo1h3gu7fky36y8r7v2x9phc434fgf20g8qd7c7u45v269jfw6vmugqjegcvp.private,
  gates: 0u64.private,
  amount: 10u64.private
  _nonce: 2323253577170856894742339369235137467208538700597121244293392765726742543235group.public
}
✅ Executed 'foo.aleo/transfer_amount' (in "[...]/foo")

That’s all. You have transferred your first own tokens to Aleo!

Note:  _nonceAleo manual does not say. The compiler outputs _nonce in the entry’s output. The user must provide it as input when using the record.

Aleo instructions

Learn the most important Aleo concepts.

Conclusions and thoughts about AleoCoin

I’ve been mining Aleo since last week at https://aleo.zionodes.com/ and they’re giving away around 8-13 credits per day (10,000 c/s each). By the end of my contract, I should have over 320 credits (roughly) that will be converted at a 5:1 ratio to a coin. So, by the launch of the main network, I should have about 60-65 coins. While I think the upside potential is huge, how much do you think each coin will be worth? According to the current forecast, each coin is expected to be worth between $40 and $60. If you guys have already explored Aleo like me, how far do you think the project will go? FYI: they have already raised about $290 million from investors.


If you like to read such articles and want to support the author, then you can subscribe to our telegram channel and recommend us to your friends, this will help a lot to support our project! Telegram: CRYPTO WIKIES | Bitcoin & Altcoins Mining

Be the first to know all the news, read more about cryptocurrencies and mining at CRYPTO-MINING.BLOG.

Leave a Reply

Your email address will not be published. Required fields are marked *