The complete guide to EOS — smart contracts – BlockToken – Medium ⋆ Crypto New Media

admin

VKontakte Well, worry no more as this guide has you covered. We will explain everything we can to make sure that at the end of it you have the tools you need actually to understand the EOS blockchain. This guide will provide a wealth of information not just for the advanced crypto lovers but for…

VKontakte Well, worry no more as this guide has you covered. We will explain everything we can to make sure that at the end of it you have the tools you need actually to understand the EOS blockchain. This guide will provide a wealth of information not just for the advanced crypto lovers but for the beginners as well. The wealth of information we are talking about here includes details of how the project started and how the technology works. It’s likely that you will find some real-world examples to help us internalize the concepts and make you an expert in EOS and EOS blockchain. First and foremost, let’s get started with the correct pronunciation of EOS.

EOS is pronounced “E-OS.” With that out of the way, let’s now get answers to the question, “What is EOS?” The Story Behind EOS The EOS blockchain was initiated with the intention of building a network that would have the capacity to process millions of transactions per second. EOS initial coin offering (ICO) was interesting for various reasons. To begin with, EOS ICO took place in June 2017, and it ran till June 2018, setting the record as the longest running ICO of all time.

Raising over $4Billion Dollars!!! Why did the EOS team do this? They wanted to ensure that everyone got the opportunity to get involved and buy some EOS. The second thing is that this ICO managed to raise the equivalent of over $4 billion making it a very successful ICO. Upon completion of the ICO timeframe, the ICO released 700 million tokens or 70% of the entire supply. Several experienced and well-known people are part of the EOS team. These include Daniel Larimer, the co-founder of both Steem and BitShares. His cryptocurrency projects are known to be worth billions of dollars.

Block One is the company behind EOS, and they are also involved in various business and blockchain projects. That’s the history of EOS Blockchain; let’s now move to the next phase of this EOS guide. The Complete EOS Guide As we embark on understanding what the project is all about, it’s important to note that at this moment in time EOS has not yet completed building their product and that everything is theoretical. However, we hope that EOS will keep its word and create exactly what they have said they will. EOS aspires to develop a decentralized blockchain which will process free and fast transactions. It will also grant permission for smart contracts to be put up on top of it which will facilitate the release of dApps by developers. EOS wants to take it further by building a platform that will work as an operating system. This will make the platform really easy to use.

The future of the internet lies in dApps.

So far, there are over a thousand of them already created on other blockchains. A decentralized type of Facebook is a good example of a dApp which can be used on the EOS blockchain. Here, there’s no one controlling the network, and no one can gain access to another person’s personal information. EOS wants to process millions of transactions per second which will solve a huge problem. Other blockchains can recognize smart contracts , but they cannot perform that quickly.

To illustrate this, Ethereum, one of the more renowned smart contract blockchains can only handle 15 transactions per second. Why should we be concerned about it? On Facebook, there are 52,000 likes clicked every second and each of these likes is a separate and individual transaction which you and I don’t see or think about. Social media aside, you have the financial industry that’s required to process no less than 100,000 transactions per second. There’s a need here that requires to be met. By promising to handle millions of transactions per second, EOS is the perfect solution for these kinds of industries. EOS also seeks to provide a solution to the issue of usability.

For instance, both BitShares and Steem can process roughly 100,000 transactions per second and also use smart technology. Nevertheless, developers find it quite difficult to insert basic functions like task scheduling and account recovery. Since EOS will use an operating system protocol, all these core functions will be built-in, and they will enable developers to work more efficiently. These are the things that the EOS team is striving hard to achieve. Next, we look at how the technology works. How EOS Works? Like several other smart contract blockchains, EOS is often times referred to as the “Ethereum Killer.

” The name is derived from the position of EOS’ ability to do everything Ethereum does and do it much better. To understand how the technology works, we will be comparing them. We have established that both Ethereum and EOS have the capability of hosting dApps that are supported via smart contracts .

The main difference is the number of transactions that each system can process at any one point in time. The name for this is “scalability,” and it is one the principal considerations when evaluating the capabilities of a blockchain. At the moment, Ethereum’s capacity stands at around 15 transactions per second, and this number is extremely low to facilitate global adoption.

EOS is aiming at increasing the number of transactions to over a million once it’s fully built. How will EOS achieve this? Going back to Ethereum, we notice that its inability to process a larger number of transactions is due to the way its data is managed, i.e. one block can only store a limited amount of information. To illustrate this point, let’s consider an empty shipping container with the capacity to store only 1,000 boxes. The size of the shipping container cannot allow it to store more than 1,000 boxes. A thousand boxes are its maximum capacity. With Ethereum, each block (container) can only carry 15 transactions, and it takes a long time before reaching its destination.

Proof-of-Work or PoW is the technology behind this data processing. Not only is it expensive but it’s also really slow and environmentally unfriendly. The Ethereum team is hard at work in an attempt to solve this issue. Some of the attempts include sharding and off-chain solutions, but none of these solutions have been implemented yet.

Unlike Ethereum that relies on PoW, the EOS blockchain will make use of a new consensus model known as Delegated-Proof-of-Stake or DPoS. This model will sort out the current problems being experienced by Ethereum. It may prove a difficult task is explaining DPoS to a person who has no prior knowledge of blockchain technology. However, we will attempt to explain DPoS in the simplest way we can.

Here’s how Delegated-Proof-of-Stake works: Imagine a situation where 200 individuals are required to aid in the verification of each and every blockchain transaction. These individuals are referred to as “witnesses.” Since blockchain is decentralized, investors are given the opportunity to vote for witnesses. The strength or the power of the vote is pegged on the number of EOS coins you have. The name for this is a “stake.” The more coins a person stakes, the more powerful their vote is. The sole task of the 200 witnesses is to ensure the safety of the network; something they get paid for. There are several backup witnesses available, and they wait their turn to help keep the blockchain safe and make money in the process.

A witness who fails to do their work correctly or one who fails to secure the network as is required can end up being voted to be kicked out of the network. In this case, a backup witness will step up and take on the job. Essentially, this creates a far more efficient system. It allows the processing of cheap, fast and eco-friendly transactions. The best thing about this is that a transaction takes only 3 seconds to process. With Ethereum, the process is longer since it requires every individual computer (or node) connected to the network to be in agreement before any transaction is confirmed. No wonder it takes so long before a transaction can reach its destination. Another advantage of the EOS blockchain is the ability to freeze transactions — an extremely vital feature.

Ever heard of the infamous DAO hack? Well, in 2016, someone stole Ethereum coins worth $50 million which led to the blockchain being forked. If the Ethereum blockchain were using DPoS technology (like EOS is), then the hack/ the or theft would have been prevented. Having looked at how this technology works, we will now move to the usage of the EOS crypto coins. What Are the EOS Coins Used For? EOS, just like most blockchains in the crypto space, has its own cryptocurrency. This currency serves different purposes as we will see below. Again, for the purposes of comparison, we will use Ethereum in our illustrations. When a person uses the Ethereum blockchain, they have to pay a transaction fee. This transaction fee is known as GAS and what happens is that the more people use the Ethereum network, the more expensive it becomes.

On a global scale, the network becomes unusable since it’s not practical to spend so much money on GAS fees just send small amounts of coins. Remember the illustration we gave earlier on Facebook likes.

Well, if say a Facebook dApp was operating on the Ethereum blockchain, clicking the “Like” button would cost you money every single time! Ethereum network was built in such a way that for you to use the network you will need to rent Ethereum’s Virtual Machine, and this requires a transaction fee. The EOS model works differently because instead of a person “renting” computing power, an EOS coin holder has ownership of the network. Let’s have an illustration to explain this further. If say, you hold 1% stake in EOS, then you own 1% of the network, and 1% of the needed computing power to process a transaction. EOS coins operate similarly to other cryptocurrencies in the crypto space.

A person can send, receive or hold funds between wallets. It’s an excellent payment model because it allows you to transfer funds all over the world and in just a couple of seconds. Can EOS Be Abused? A key and unique feature of cryptocurrencies is their ability to transact anonymously which works in the same way as paying using tangible money in the real world.

No one has to show their identification papers any time they get on the bus or pay for milk and bread — you simply pick the goods, pay at the counter and go on your way. This unique feature of cryptocurrencies also means it can be misused by people out there. They may take advantage of the anonymity to commit crimes such as buying and selling illegal weapons, drugs and stolen cards among others. There was a case when Bitcoin was used to pay for an assassination.

Unfortunately, even EOS is not past this anonymous feature. Additionally, the database on most blockchains like Ethereum’s is public which means that anyone with an internet connection is able to view all the transactions taking place on a blockchain.

By viewing all transactions, they can also see the account balances on all wallets. EOS founder Daniel Larimer states that the address of a sender or receiver will not be hidden but concealing the total balance on a user’s wallet is a feature on EOS blockchain. This feature, however, may appeal to the wrong crowd. Anyone wants to evade taxes can choose to hide their wealth there just as well as an anonymous shell company can. The flip side means that wealthy cryptocurrency holders will get the much-needed security. It’s important to keep in mind that all technologies can be abused. Overview of EOS Programs & Tools EOSIO comprises several different programs. However, its three core components are: Nodeos  — This is the server-side node component of Blockchain.

Cleos  — This is the command line interface which interacts with the Blockchain technology and is used to manage wallets. Keosd  — This is the part responsible for the managing of EOSIO wallets. Let’s talk a little bit more about each one of them: Nodeos Nodeos is an essential component of the EOSIO daemon, which can be configured using plugins to run a node.

It’s mainly responsible for administering your node and networking with the EOS Blockchain through the creation of blocks. Cleos This is the command line tool, which is interfaced with REST API as exposed by the nodeos. You must have an endpoint to node OS instance which consists of the port number and IP address to be able to use cleos. This is also required to configure cleos to be able to load “eosio::chain_api_plugin,” which contains documentation of all the commands. Keosd This is an EOSIO wallet daemon which loads plugins that are wallet-related including HTTP interface as well as RPC API.

EOS Tools Let’s also discuss a bit more about some other tools of the EOSIO. Launcher This application streamlines the distribution of the various nodeos nodes in a LAN or in a much wider network. It can be configured through CLI to compose the per-node configuration files and securely distribute these files within the peer hosts and start the various instances of the nodeos. Eosiocpp The main use of Eosiocpp is in the development of smart contracts. It’s mainly used for generating ABI files and is also capable of developing helper functions that serialize and de-serialize the types that are defined within the ABI or the development of the contract. But these things are not the only ones that make EOS what it really is.

Let’s discuss more its consensus mechanism that powers at 0.5 sec block time. Consensus Mechanism (DPoS) The EOS.IO software makes use of the only decentralized algorithm consensus that has been proven to be capable of accomplishing the requirements of the applications within the Blockchain and DPOS or Delegated Proof of Stake. Under such algorithm, those holding tokens within the Blockchain and adopting the EOS software can choose to block producers using a continuous voting approval system. Anyone can choose to participate in the block production and be given the opportunity to generate blocks, as long as they are able to persuade the token holders to be able to vote for them. The EOS allows for the blocks to be produced at every 0.

5 seconds and one producer will be authorized to generate a block at a certain point in time. If the block isn’t produced within a specific time, the block for that particular time slot will be skipped. If one or more blocks are skipped, there will be a 0.5 and more second gap within the Blockchain. Using the EOS software, the blocks will be generated in 126 rounds, since there are 6 blocks each multiplied to 21 producers.

At the beginning of every round, producers of 21 unique blocks will be chosen using voting, where token holders have to cast a vote. The chosen producers will be scheduled by an order that’s agreed upon by producers.

If one producer misses a block and hasn’t been able to produce any block in the last 24 hours, they’ll be taken out of the consideration until such time that they will advise the Blockchain of their intention to start producing the blocks again. This is to ensure that the network will be able to operate smoothly as it minimizes the number of blocks that are missed when not being able to schedule unreliable producers. Under normal conditions, the DPOS Blockchain will not experience any forks, since, instead of competing, the Blockchain producers will cooperate with each other to produce blocks. If there’s a fork, the consensus will immediately change to the longest chain. This method is effective since the rate at which the blocks are added into the Blockchain fork is directly related to the percentage of the block producers that are sharing similar consensus.

The Blockchain fork that has more producers in it will basically grow faster than other forks that have fewer producers since the fork that has more producers could miss fewer blocks. Also, no block producer must produce blocks on two forks all at the same time. Any block producers that will be doing this have to be voted out. Cryptographic evidence of double production can also be used to remove abusers immediately. Overview of Consensus Mechanism (DPoS) To better understand the diagram above, let’s break it down a bit: Wallets Wallets refer to clients that store keys similar to the one shown above.

These keys could be associated with the permission of an account of one or more. For example, each of the 3 keys above is linked to an account. Key 1 is linked to the owner permission level while key 2 and key 3 are both linked to the active permission level. Preferably, a wallet should have an encrypted and decrypted state secured by a high-entropy password.

The EOS repository usually comes with a command line interface client known as cleos that provides you with an interface which allows you to interact with the lite client known as the keosd. Accounts The account is basically a name readable by humans that’s stored within the Blockchain. Either an individual or group of individuals own it, depending on the permissions configuration. In the above scenario, an individual owns an account, which is the person that’s holding key 1. The account is needed to transfer or push a transaction within the Blockchain. Each and every account within the EOS can be referenced by a unique name that’s human-readable, which usually consists of up to 12 characters in any given length, as provided by the creator of the account.

To understand the significance of the permission structure, we need to understand the actions and the handlers. Actions and Handlers Each account is capable of sending structured actions to some other accounts and could define scripts that could handle Actions once they are received. The EOS.IO provides each account with its own database that can only be accessed through its own handlers.

The action handling scripts are also capable of sending actions into another account. The combination of automated action handlers and Actions is how the EOS would define smart contracts. Authorities and Permissions As shown above, there are various actions that can be performed. Furthermore, multiple keys are linked to each account to be used for different actions.

This can be really messy to handle. Luckily, the permission structure is well capable of handling this mess. How do the Authorities and Permissions Work? Authorities will determine whether or not any of the given actions is authorized properly. Each account comes with two native named permissions: Owner authority signifies account ownership.

There are few transactions that would require such authority. However, in most cases, this refers to any action that triggers any kind of change to the owner authority. Active authority is used when transferring funds and when voting for producers as well as when making some other high-level changes in the account. Aside from the native permissions, an account may also possess custom-named permissions available to extend the management of the account further.

Custom permissions are highly flexible and are capable of addressing various possible cases once implemented. Most of these will mainly depend on how they are employed and the type of conventions adopted. It’s also possible to assign permission for any given authority to one or various public keys or a valid account name. Setting up Accounts on EOS Default Accounts This basically refers to the way in which the account is configured after it’s created.

It consists of a single key for both the active and owner permissions, where both keys have a weight of 1 with both having a threshold of 1. @bob account Using the @bob account example, the table above shows that @bob’s owner key comes with a permission weight of 1, while the required threshold to push the transaction under such authority is 1. To move a transaction under an owner authority, the only @bob will need to sign the transaction using his owner key for the transaction to be validated. Such key will have to be stored in a wallet and processed using cleos.

Multi-Sig Account and Custom Permissions The examples below are authorities for fictional account referred to as @multisig. In this example, two users are authorized to both the owner as well as the active permission of the fictional account, @multisigaccount, where three users are authorized to a customized published permission that has varying weight. In the example, it requires a weight threshold of 2 to be able to make modifications to the owner permission level, and this simply means that all parties will have a weight of 1 while all users are required to sign the transaction before it can be fully authorized. To send a transaction that requires active authority, the threshold will be set to 1. This further implies that only one signature is needed to authorize an action from the account’s active authority. There’s also third custom-named permission known as publishing . For the benefit of this example, the publish permission is used in publishing posts for the blog of @multisig using a theoretical dApp blog. There’s a threshold of 2 for the publish permission, and @stacy and @bob both have a weight of 2, while a public key has a weight of 1.

This basically implies that both @stacy and @bob will be able to publish without the need for an added signature. However, the public key would require an additional signature for a particular action, under a public permission, before it can be authorized. The permission table above shows that @stacy and @bob, being the owners of the account, will have elevated privileges similar to an editor or moderator. Although this primitive example comes with limitations most especially regarding scalability and is not entirely a good design, it sufficiently demonstrates the flexible nature of the EOSIO permission system.

Furthermore, in the table above, the permissions are set with the use of both a key and an account name. On your first glance, this might appear trivial, but it does suggest additional dimensions of flexibility. Here are some observations: @stacy and @bob can be identified explicitly as owners of the account. A public key won’t be able to trigger any action under a published authority without the additional signature of @stacy and @bob. @stacy and @bob can move an action through a published authority without the need for more signatures. Getting Started with EOS Mainnet and Implementing EOS Functions The launch of the EOS network is one of the highly anticipated events in the cryptocurrency developer community. Although it’s not guaranteed to be free from any issues, we’re excited to start building applications within the EOS.

We will try to stay away from any controversies that surround its launch, as well as EOS overall model.

Instead, we’ll try to give a short introduction allowing anyone to get his or her hands dirty as much as possible. On the following sections, we will describe: Connecting to Mainnet with minimum effort How the resource allocation works Useful links Wallets and accounts We may need to install local software that allows for the interaction with API. The most important tool needed for this is the cleos which are a command line interface that makes it possible for users to sign transactions and make calls for API. As of the moment, the easiest method to locally install cleos is through Docker.

Here is how to go about this: # Download EOS docker image # Run keosd tool in docker docker run — rm — name eosio -d -v ~/eosio-wallet:/root/eosio-wallet eosio/eos-dev /bin/bash -c ‘keosd’ # Create an alias for convenience alias cleos=’docker exec -i eosio /opt/eosio/bin/cleos — wallet-URL http://localhost:8888 -u https://api.eosnewyork.

io:443′ As soon as you run the commands above, you should be able to interact with Mainnet. To ensure that it’s working, let’s do a test: Cleos will obtain info, and after that, it should be able to produce output similar to what’s shown below. If it does, then you’re on the right track! Wallets Like any Blockchain, once you send transactions within the EOS network, you will authorize them by signing a private key. The keys are kept in a local wallet.

At first, you will not have any wallets so let’s make one.

Make sure you remember the displayed password because you will need it to unlock the wallet when you need access to the private keys. “cleos wallet create.” This command creates a wallet that will have a default name. Let us find out if it comes with any keys: “cleos wallet private_keys.” Be Careful: The default wallet comes with initial private/public key pair EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV / 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3.

Never use this one, it is hardcoded in the source code and is not secure. Instead, let’s generate a new key pair. # generate new key pair # import the private key into the wallet cleos wallet import $private key you just generated The wallet is going to be auto-locked when there’s no activity in 15 minutes. To unlock it, run this command: cleos wallet unlock By now, you are all set with your wallet. So it’s time to get into accounts. Accounts Unlike Ethereum or Bitcoin where your public key serves as an account that you’ll send transactions from, there will be a separate concept of account within the EOS.

It works just like the traditional web applications. You will create a named account, where, in EOS, it consists of 12 characters. Your private key will be similar to the password that’s used to control the account. Unfortunately, there’s a bummer — it’s not possible for you to create an account except if you already have an account that has EOS in it. This means that you can’t really interact with the network except if you ask another person that has an account to generate one for you. Worse, this doesn’t come for free.

As a result, some people have created services that will allow for the creation of EOS accounts in exchange for a minimal payment. Resource Allocation Unlike other Blockchain technologies, like Bitcoin and Ethereum, there are no transaction fees with EOS .

Instead, staking regulates spam prevention and distribution of resources. There are three different types of resources consumed by accounts, namely: Bandwidth and Log Storage — Staking Computation and Computational Backlog (CPU) — Staking State Storage (RAM) — Market purchase The first two of them are allocated in proportion to the number of tokens held within a 3-day staking contract. For instance, let’s assume that the network’s total CPU capacity is 1,000 units. If within the 3-day window, you want to use 10 CPU units, you will need 1% of all the CPU-stalked tokens written under your name.

In other words, you will be competing with some other accounts for the available capacity within the CPU, and the more you stake, the more you will get. Eventually, the consumed CPU, as well as the bandwidth, will be freed up. Thus, you can use similar staked tones over and over again. For instance, if you don’t have any activity for three days, your resources will be freed up fully, and you’ll be able to use them again without having to stake additional tokens. However, RAM is a totally different story. You must purchase it at a market price depending on the supply and demand.

RAM will be consumed by data that your accounts store within the Blockchain state. For instance, creating a new account will consume RAM since there’s now a record that describes this account. Unlike the bandwidth and CPU, RAM doesn’t automatically get freed up. To free it up, you must delete the data from the account. As soon as it’s freed, RAM can be sold at a market price. It’s worth it to note that for the bandwidth and the CPU, you can either stake your EOS or another person can stake it under your name.

Delegation is not really considered a gift since it’s possible for them to un-delegate the staked EOS at a later time. The same thing is applicable for RAM, but in this case, somebody will need actually to transfer the RAM into your account as a gift and they cannot force you into returning it. How to Create Your Own EOS Token Contrary to Ethereum, the EOS comes with a token smart contract directly out of the box. While the Ethereum has the ERC20, what EOS has is the eosio.

token smart contract. This allows you to be able to come up with your own token by providing you with a maximum supply of tokens. The EOS tokens within the EOS Blockchain are often issued using a similar contract. cleos — URL

Leave a Reply

Next Post

Bitcoin Cash Hard Fork Debate Reconvenes After the Stress Test - Free Altcoins

Altcoin News Over the last few weeks, there’s been a heated discussion within the Bitcoin Cash (BCH) community concerning the scheduled November 15 hard fork. There’s a strong disagreement between the BCH development teams, Bitcoin ABC, Nchain, and Bitcoin Unlimited in regard to the hard fork’s upcoming consensus changes. Fast forward to this week as…

Subscribe US Now