New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Aleo 🛠 How to Deploy on Aleo

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join us for a workshop on how to Deploy on Aleo! Some of the most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long hackathon at ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

I guess I'll start with a short story about Aleo. Aleo is a about Aleo. Aleo is a first-level ZK project. Our main goal is to make the development of ZK to make the development of ZK applications simple, abstracting away from the complex mathematics and cryptography required to understand the schemes. So, we'll move on to the workshop almost immediately.

I usually show a bunch of slides and talk a little about our programming language. But I do n't have time for that today. So I'd rather refer you to the documentation. I recommend visiting the website aleo.org.

But more importantly, if you're programming on Aleo this week, is this week, is developer.aleo.org. This is our main resource, where all documentation is collected. Here you can find answers to your questions.

I also recommend checking out our Discord, the link to which is on the main website. aleo.org. If you scroll down the page , you will find links to Discord, Twitter, YouTube, etc. We have a large community, over 200,000 people who create projects on Aleo.

Congratulations to Eugene, who helps a lot in running this community. So, with that out of the way, let's get straight to the point. If you want, you can repeat after me. Or just watch me do it and do it yourself later. We are offering a $100 reward if you successfully deploy your app.

This is a quick way to make 100 bucks. You will leave the hackathon a winner, even if you don't receive any other awards. So, I'll just walk you through the whole process. It's very simple. The nice thing is that regardless of the complexity of your application, the deployment process does not change.

So once you master it once , you never have to learn it again. There is software that needs to be installed: Git, of course, and Rust. Our entire stack is open source and built on Rust. If you are a Rust developer, I highly recommend trying it out, contributing, etc. The most important thing you need to install is our programming language Leo, a high-level language.

It's a bit like TypeScript or Rust. And finally, it is compiled into ZK- compiled into ZK- schemes. If you're interested, you can read the documentation or come up to me after the talk and we'll talk about it in more detail. You also need to install SnarkOS. There are certain instructions on how to do this.

If you have Windows, please see this FAQ for instructions. You need to install LLVM and other prerequisites LLVM and other prerequisites for the installation to work, and that can be a bit tricky. If you're on a Mac, don't worry. Everything will work without problems, I promise. I also recommend you install the Leo wallet.

It looks something like this. This is a Chrome extension. You will use it throughout the tutorial, and it is the easiest way to interact with your account and online entries. So let's get started. Today, I will be using VS Code for everything I do.

You can use use any editor you want. We have Leo plugins for most major editors, including Sublime, IntelliJ, VS Code, and more. OK. So, I have already cloned the repository. You will see a file structure that looks something like this.

I'll just make it bigger for you. This is the private key to the workshop wallet. If you want to steal my tokens, please, I don't mind. We are currently on the test network. We plan to launch the main network sometime in December.

So be sure to keep an eye on this. In the meantime, check the network, deploy applications, and try building something. We encourage everyone who creates something and is interested in ZK. So, first I'll introduce Leo. I usually spend a lot of time talking about our programming language before a demo, but I do n't have time for that today.

So I'll get straight to the point. This probably looks pretty familiar to you. As I said, if you've worked with TypeScript or Rust, you'll recognize this— Rust, you'll recognize this— it's a type of function called a transition. It's important to note about Aleo, and this is one of the reasons we decided to build a Layer 1 instead of building a Layer 2 on top of EVM, — we have a different infrastructure model than most projects than EVM. First of all, there are two infrastructure players.

We have validators that check things, as you're probably used to, but we also have another infrastructure layer called an layer called an approver. The main purpose of approvers is purpose of approvers is to execute transactions off- network, combine them into a proof, and submit them to validators. This allows you to implement quite a few useful things. useful things. First, we have fixed gas prices fixed gas prices , so you don't pay a network congestion fee to fight for a spot in the block.

In our paradigm, such a concept simply does not exist. So, you know, a read operation always costs as a read, and a write operation always costs as a write. Also thanks to this we have privacy by default. Therefore, you need to explicitly mark the variable as public. So, the main purpose of transition functions is that everything in the transition function will be executed by the approver.

There is also another type of function that I can show you. I'll jump into the development environment to quickly show an example with tokens to demonstrate the finalization feature. So, if you are working with public data, the finalization functions are performed by validators, and this is the way to handle public state. Typically you use mapping. Maps work just like any other any other hashmap or similar data structure you may be familiar with.

The key difference here is that a reflection a reflection is an on-chain state is an on-chain state . Therefore, you can use them to search for anything that should be public. And with everything that is not public, you will work with the " with the " record" type. The records have an owner, they are encrypted and can only be decrypted with the private key with which they were encrypted on the network. I highly recommend taking a look at the development environment if you want to see more complete examples than the ones I have time to show today.

This can be done at play.leo-lang.org. You can also find this information on the main website by visiting aleo.org.

If you go to the "build" section, there are links to everything I mentioned, as well as our grants program, which my team runs. If you are interested in developing and receiving a grant for this, be sure to contact me and we can discuss your idea. So, going back to the workshop, how do we deploy this online? First, we installed all our software. Now we need to create a new wallet.

There are two ways to do this. You can use the CLI for this or the Aleo wallet extension as I showed here. You will go through the typical process of setting up a seed phrase and receive a wallet. Then you can use our faucet to get tokens. The faucet will offer you a QR code, you scan it, send a message to our bot, and it will send you tokens.

If you don't have a US phone number, we currently use Twilio, which is limited in the number of countries supported. Just find me and I'll give you some tokens so you can follow the demo. Back to the topic, the first thing we'll do is initialize our project. This can be done by running the Leo new command. In this case, we have a weird random string to make our project name unique.

The global package manager requires a unique project identifier. So this is just a way for me to increase the likelihood that we have So I'll introduce Leo new. I'll just paste it here. We have a new project. Class.

You will see that our catalog looks like this . And then we can write our program. I have provided a very basic example of a token here. You can just copy, paste and check it out. As I said, check out the examples for more complex code or for more examples of syntax and language features.

Today we are focused on deployment. So I'll open the new directory I just created because I personally prefer working in VS Code. We have three types of important files here. One of them is our main file. This is a kind of "Hello World" application for Aleo.

We can compile it and it will output an intermediate representation called dot Aleo. This looks like any assembly language you've probably seen. This exists because we are not executing code in an x86 environment or even an EVM environment. We compile it into schemas, which is a kind of new execution paradigm execution paradigm . So, to abstract away from all these complex details, we had to create a language from scratch.

You've probably heard of other projects like Noir or Aztec. Also Circom is another example of this type. So, let's take our token example and insert it here. I'm going to collect it. It seems we have a mistake.

Yes. So we have a mistake. Yes. So , the last file I didn't mention is the input file. ZK- input file.

ZK- schemes are deterministic, so you definitely need input data to build the scheme. And currently, we provide input to programs, at least locally, through this file. So I have an example of this file here that you can copy. After that, we can compile our program. It looks like I missed a semicolon or added an extra or added an extra .

Class. Now, if we go back to our instructions, we will see the two functions that we just defined. We have a mint function, which is quite simple. We take this token record and return it; if we execute Leo run mint, we will see the result. On the network it would be encrypted, but since I'm running everything locally with my private key, I can of course see what's going on here.

So, if we want to transfer the token to another address, it is important to note that Aleo does not work on an account model. You may have heard of UTXO. We have a model similar to UTXO, called the record model. So to execute a transaction you need to spend a record, which means you have to provide a record as input to the transaction, which usually also produces a record as output produces a record as output . There is also a standard type of record on the network, which I will show you in a few minutes when we get to the deployment example.

So, we want to run transfer, right? We want to simulate transferring the tokens we just created from this record to another wallet. So I'm going to take this token entry that we just got in the console and paste it in here. We need to remove these suffixes. It's just a minor inconvenience at the moment.

This is not an important detail. So, after that we can run our transfer function. And if we look at our transfer function before we run it, you'll see run it, you'll see that we're actually outputting a tuple of records, right? So, we calculate the new balance, create a record for the recipient and the transfer amount we are interested in. And we also need to create a new record since we are spending the one provided by the sender where the tokens are.

If we run this, we will see the result. Our program is working. We transferred 10 tokens to this address, and the original sender now only has 90 tokens. This was the part about creation and testing. This is just an example to show example to show how you can run, build, and work with programs.

I mentioned the recording, didn't I ? If we want to send a deployment transaction, we need to pay for it . And we need to spend a record for that. One easy way to get a record is to get a record is to go to your Leo wallet and check the latest activity. This is a transaction I made a few weeks ago to deposit credits into this wallet.

Let's move on to the result of this transition. It is important to note that all of this is fully encrypted fully encrypted . You see the encrypted text here. If you are another user, you cannot see what happened in this transaction. But since I own this record, I can connect my wallet.

I can decrypt it and get the plaintext of the record. And that's what I'll use to tell the deployment program which record this is. Let me zoom in on this for you. What record am I talking about? How many credits can be spent in this entry ?

And also the value of nonce. So, I'll create a deploy.sh file to keep things convenient and repeatable. I'll copy this long command, this is the deployment command. SnarkOS is a utility that you will install during this workshop.

It provides a bunch of CLI utilities for interacting with the chain. If you want to run a node or prover, you will use SnarkOS for that. Now we'll take that private key, which, as I said before, you can take. I'll put it here. I will also take the name of my project, which will be the name of my package in the chain.

And we'll launch it. Oh, I forgot something. That recording I mentioned was extremely important. I forgot about him . So, let's take this quickly.

Perfectly. So, we're launching this deployment. I'm pretty sure it will be successful. And then we can test our program in the explorer when we get the transaction ID. Oh, the input record must belong to the signer belong to the signer .

This error message is usually not very informative. This usually happens when the private key does not match the one we are trying to use. So let's quickly get this private key and just check again . He was wrong. So, now that our private key is correct—you've seen that if you try to spend someone else's record, it just doesn't work.

You can't decrypt it, so you can't use it. One second. Uh-huh. I'll leave some time for questions at the end questions at the end . Yes.

We'll be done in about a minute when this is complete. Thank you. There are several conductors. Here is one of them. It is open source.

A wonderful community member named Haruka, big thanks to him, created this himself. We tried to give him money, but he didn't want to. So, yeah, the guy is just awesome. There is another one called aleo123.io one called aleo123.

io . It's a little newer. It's a little more refined, it has a nicer interface nicer interface . They both have some differences in functions. So, if we go back to our deployment, you'll see that it was successful.

We can take this transaction ID and check it in the explorer, and we will see that our application was successfully deployed, and we can go into it and see our source code on the web source code on the web . So, we just privately deployed an application that implements a basic private token with private minting and private transfers—all in about 17 minutes about 17 minutes . And this concludes our seminar. Very quickly, very efficiently. Please contact me with any questions.

I will answer questions as time allows, and then I will be available for individual communication.

Automatic transcript — names and jargon may be misspelled.