What is Stellar? How does Stellar work?

Tram Ho

I. Overview of stellar

Stellar is an open source network project, aimed at solving monetary and payment problems. Stellar provides the ability to create, send and exchange tokens representing currencies such as dollars, pesos, bitcoins, etc. in digital form. It is designed with the goal of bringing the entire world financial system into a single network.

Stellar is not owned by any individual or organization, but belongs to the entire community. The system is run on an open, decentralized network and processes millions of transactions per day. Like Bitcoin and Ethereum, Stellar relies on blockchain to keep the network synchronized, but offers a cash-like experience to users. Stellar is faster, cheaper, and more energy efficient than conventional blockchain-based systems.

II. What are stellar used for?

The Stellar Network launched in 2015. Since then, it has handled more than 450 million operations performed by more than 4 million individual accounts. Large companies like IBM and Franklin Templeton or small companies like startups have chosen Stellar to transfer money and access new markets.

From the beginning, Stellar has brought the characteristics of the cryptocurrency system, but stellar always aims to improve instead of destroying or replacing the existing financial system. While the Bitcoin network was born just for Bitcoin trading, Stellar is a great decentralized system for transacting any currency in a transparent and efficient manner.

For example: You want to create a digital representation of the US dollar on Stellar and call it “dollar token”. Then you will tell the world that, whenever someone brings you a dollar, you will give them a “dollar token” and vice versa, when a person brings a “dollar token” you have to make sure can give them dollars. You have then created a 1: 1 relationship between your digital currency and the dollar. So when people hold the dollar token, they can use it with features like traditional money and can exchange it when they want. Of course in addition to dollars you can also create digital representations for any other currency.

This is quite similar to the work that large and small banks around the world operate every day. However, the difference is that the token can be exchanged and traded around the world without having to go through bank settlement and approval. Thanks to this, the Stellar network makes the currency without any borders. A person working in the US or Europe can send dollar tokens to Vietnam anytime. A Vietnamese company can pay workers in Laos through the Stellar network, …

Stellar also allows users to deposit one currency and the recipient will receive another. Basically, you can send and exchange money in an automic transaction (i.e. tokens will be automatically exchanged at the current exchange rate on the stellar network).

Like other blockchain networks, Stellar also has a native crypto currency, lumen. The system will require users to have a very small amount of lumens to create an account as well as send transactions (0.00001 lumens per transaction). Other than the above requirement, Stellar does not prioritize any money.

III. How does stellar work?

At a minimum, Stellar can be understood as a system for tracking ownership. Just like accounting has done for centuries, it uses a ledger to do so. The difference is that Stellar has no real accountants. Instead, there is a network of independent computers, each checking and reviewing the work of other computers. Stellar is a system without a central authority, meaning no one can stop the network or secretly adjust the numbers to their liking even without a central authority, verified ledgers and update, every 5 seconds.

An algorithm called the Stellar Consensus Protocol (SCP), keeps everything in sync. There are many ways to reach consensus on a decentralized system, Bitcoin’s proof of work is the first and still the most famous method. However, because of being a pioneer, proof of work has many problems to improve. SCP strives to be better by being able to configure, faster and more energy efficient systems. Find out more about SCP here

For every account holder, Stellar’s ledger stores two important things: what they own (account balance, such as 100 pesos tokens or or 5000 5000 lumens) and what they want to do with what they own. property (works, like selling 10 tokens in 50 lumens, or, depositing 100 pesos tokens into the same account.) Every five seconds, all balances and all actions are resolved and propagated the whole network.

Computers that run Stellar core, store and test the ledger are called nodes. So when you send someone a euro token on an application using Stellar, the nodes check to see if the correct balance has been recorded, and each node ensures that every other node sees and agrees with the transaction. . The current Stellar network is verified by hundreds of nodes around the globe; The nodes and the way they communicate are public information and anyone can install Stellar software and participate in the consensus process. This is different from how an accountant works at a bank, where a corporation unilaterally decides what happens.

Just above this core layer contains an API to build on Stellar, giving developers the ability to build Stellar applications without having to dig too deeply into consensus algorithms. Read more about the Stellar SDK here

III. Stellar system architecture

Using the Stellar network, you can build mobile wallets, banking tools, self-pay smart devices and anything else you want to do with payments! Although Stellar is a complex distributed system, working with it is not complicated at all.

API: Horizon

Most applications interact with the Stellar network through Horizon, the RESTful API server. Horizon provides you a simple way to send deals, check your accounts and keep track of events. Because it’s just HTTP, you can communicate with Horizon using a web browser, simple command line tools like cURL or Stellar SDK for your favorite programming language. The easiest way to install Horizon is to use the stellar / quickstart docker image .

Stellar.org maintains SDKs based on JavaScript , Java and Go to communicate with Horizon. There are also community-maintained SDKs for Ruby , Python, and C #.

Stellar Core

Every Horizon server connects to Stellar Core, the backbone of the Stellar network. The Stellar Core software performs the status of every transaction through the Stellar Consensus Protocol (SCP).

The Stellar Network is a collection of Stellar Cores worldwide, each group maintained by different people and organizations. All nodes agree on transactions. Each online transaction has a small cost: 100 stroops (0.00001 XLM). This fee helps prevent bad actors from sending network spam.

IV. Demo

Before embarking on the code, let’s take a look at Stellar Laboratory – allowing interaction with the stellar network through the UI. The Stellar Laboratory allows you to create an account, get money on the Stellar testnet, build transactions, run any action and check feedback from Horizon through Endpoint Explorer.

1. Create a Stellar account

Ok, got it Just like you did through the Laboratory, the first thing to do to interact with the Stellar network is to create an account. Accounts keep all your money inside Stellar and allow you to send and receive payments, in fact, almost everything in Stellar is in some way tied to an account.

Every Stellar account has a public key and a private seed. Stellar uses public key cryptography to ensure all transactions are secure. Others use the public key to identify your account and verify that you authorized the transaction. Private seed, meanwhile, is private information proving you own your account. You should never share private seed with anyone because that person can take ownership of your account.

Now that you have the seed and the public key, you can create your stellar account. To prevent the creation of a series of unnecessary accounts, each account must have at least 1 lumens. However on the Stellar testnet you can ask Friendbot to create an account.

Ok, got it Now just check the account information you just received. Each account may contain different types of tokens.

2. Send / receive money

Send money

Actions that make changes on the Stellar network such as depositing payments, changing your account or making offers to trade different currencies are called operation .

To actually perform an operation, you create a transaction, which is just a set of operations with some additional information, such as which account is performing the transaction and an electronic signature to verify that the transaction is accuracy. If any operation fails, all trasaction will fail.

Example: You have 100 lumens and you perform 2 actions sending 60 lumens. If two actions are performed at two different transactions, you will successfully execute one transaction and have 40 lumens left. However, if two actions are sent in one transaction, the transaction will fail and you will have 100 lumens in your account.

Stellar stores and transmits transaction data in a binary format called XDR. Luckily, the Stellar SDK provides tools to handle all that. Here’s how you can send 10 lumens to another account:

Let’s analyze the above code:

  1. We first need to confirm that the account ID you are sending actually exists by downloading the linked account data from the Stellar network. Everything will be fine if you skip this step, but doing it gives you the opportunity to avoid making a transaction you know will fail. You can also use this call to perform any other verification you may want to make on the target account:

  1. Download data for the account you are sending. An account can only make one transaction at a time and has something called a sequence number , which helps Stellar verify the order of transactions. The transaction sequence number needs to match the account number, so you need to get the current account number from the network.

  1. Now we have just started building a transaction. This requires an account object, not just an account ID, because it will increase the account number.

  1. Add operation to account. Note that you need to specify the type of asset you are depositing – Stellar native token is lumen, but you can deposit any type of asset or currency you want, from dollars to bitcoin to any asset you trust.

Note: Numbers are strings, not numbers. 5. You can also optionally add metadata via memo but stellar will not use this data /

  1. Now that the transaction has all the necessary data, you must sign it using your private seed. This proves that the data actually comes from you, not someone impersonating.

  1. Finally, submit it to the Stellar network:

Receive money

You don’t need to do anything to receive money on the stellar network. If someone sends you money, the money will be automatically transferred to your account.

However, you still need to know the information of the person who sent the money to you.

There are two main parts of this program. First, you create a query for payments related to a certain account.

Like most queries in Stellar, this can return a large number of items, so the API returns paging tokens, which you can use later to start your query. from the same point that you previously left. In the example above, the paging token saving and loading functions are left blank, but in a real application, you want to save paging tokens to a file or database so you can choose where you are. leave in case the program crashes or the user closes it.

Second, the results of the query are streamed. This is the easiest way to view payments or other transactions. Each current payment is sent through the stream, one by one. Once all current payments have been sent, the stream remains open and new payments are sent as soon as they are made.

You can also request payments in groups or pages. Once you’ve processed each payment page, you’ll need to request the next page until there are no more payments.

V. Source

Stellar applications: https://galactictalk.org/t/winners

Document: https://www.stellar.org/

Share the news now

Source : Viblo