paint-brush
Getting started on EOS Mainnet in 10 minutesby@andrei.anisimov
11,711 reads
11,711 reads

Getting started on EOS Mainnet in 10 minutes

by Andrei AnisimovJune 28th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The EOS network launch was one of the most anticipated events of this summer in the crypto developer community. Although not without issues, the launch happened, and we’re super excited to start building applications on EOS. We’ll stay away from any debate surrounding the launch and EOS’s overall model, and instead provide a short intro that allows anyone to get their hands dirty as quickly as possible.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Getting started on EOS Mainnet in 10 minutes
Andrei Anisimov HackerNoon profile picture

The EOS network launch was one of the most anticipated events of this summer in the crypto developer community. Although not without issues, the launch happened, and we’re super excited to start building applications on EOS. We’ll stay away from any debate surrounding the launch and EOS’s overall model, and instead provide a short intro that allows anyone to get their hands dirty as quickly as possible.

Here we’ll describe:

  1. Connecting to Mainnet with minimum effort
  2. Wallets and Accounts
  3. How the resource allocation works
  4. Useful links

Getting started

For the purpose of this article, we’re not concerned with running a local EOS node. Although this is pretty easy to do, for the sake of simplicity we’ll be connecting to an API endpoint of one of the 21 block producers.

We still need to install some local software in order to interact with the API. The main tool we need is cleos, a command line interface allowing users to sign transactions and make API calls. Currently, the easiest way to install cleos locally is via Docker. Here’s how you do it:


# Download EOS docker imagedocker pull eosio/eos-dev


# Run keosd tool in dockerdocker run --rm --name eosio -d -v ~/eosio-wallet:/root/eosio-wallet eosio/eos-dev /bin/bash -c 'keosd'


# Create an alias for conveniencealias cleos='docker exec -i eosio /opt/eosio/bin/cleos --wallet-url http://localhost:8888 -u https://api.eosnewyork.io:443'

Once you run these commands you’re ready to interact with the Mainnet. Let’s test that it’s working:

cleos get info

If this produces output similar to below, you’re good to go!

Wallets

Just like in any other blockchain, when you send transactions to the EOS network you authorize them by signing with a private key. Your keys are stored in a local wallet. Initially, you don’t have any wallets, so let’s create one.

# don’t forget to save the displayed password — you’ll need it to unlock the wallet and view private keys

cleos wallet create

This creates a wallet named default. Let’s check if it has any keys in it:

cleos wallet private_keys

WARNING 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 paircleos create key


# import the private key into the walletcleos wallet import ${private key you just generated}

The wallet will be auto-locked after 15 minutes of inactivity. To unlock it run:

cleos wallet unlock

Now you’re all set with the wallet. Let’s get to accounts.

Accounts

Unlike Bitcoin or Ethereum where your public key is an account that you send transactions from, there is a separate concept of accounts in EOS. It’s more like in traditional web applications. You create a named account — which in EOS is 12 characters long, e.g. eoscentralio — and your private key is similar to a password that controls the account. This is a slightly oversimplified description, and you can learn more in the official EOS docs.

Now, there’s a bummer: you can’t create an account unless you already have an account with some EOS in it. Meaning you can’t really interact with the network unless you ask somebody with an account to create one for you. And it’s not free! What?? Yes, this chicken-and-egg problem is due to how EOS resource allocation works. We’ll explain this below.

Knowing this, some people developed services that allow creating EOS accounts in exchange for a small payment. There are articles describing how to do so, but we can’t endorse any particular service.

Resource allocation

Now a word on the resource allocation and why accounts are not free. In EOS, unlike other blockchains such as Ethereum or Bitcoin, there are no transaction fees. Instead, spam prevention and resource distribution are regulated through staking and RAM market. There are three types of resources consumed by accounts:

  • Bandwidth and Log Storage (Disk) — staking
  • Computation and Computational Backlog (CPU) — staking
  • State Storage (RAM) — market purchase

The first two (bandwidth and CPU) are allocated proportional to the amount of tokens held in a 3-day staking contract. For example, let’s say the total CPU capacity of the network is 1,000 units. If during a 3-day window you want to consume 10 CPU units, you need to have 1% of all CPU-staked tokens in your name. In other words, you’re competing with other accounts for available CPU capacity, and the more you stake relative to others the more you get.

As time goes by, the consumed CPU and bandwidth free up and you can use the same staked tokens again and again. For example, if you don’t produce any activity for 3 days, your resources fully free up and you can consume them again without staking any additional tokens.

RAM is a different story. You need to purchase it at the market price that is determined by supply and demand. RAM is consumed by data your accounts store in the blockchain state. For example, creating a new account consumes RAM as there is now a record describing this account. Unlike CPU and bandwidth RAM doesn’t get freed up automatically. The only way to free it up is to delete data from the account state. Once freed up, the RAM can be sold at the market price.

It’s worth noting that for CPU and bandwidth you can either stake your own EOS or somebody else can stake it in your name (i.e. delegate it). Delegation can’t be considered a gift, because they can un-delegate the staked EOS later. Same goes for RAM, however in this case somebody has to actually transfer the RAM to your account as a gift as there is no way for them to force you to return it.

Useful links

Now you have all you need to interact with the EOS Mainnet, publish transactions and start building DApps. Below are some useful resources to help get you further. Feel free to suggest other tools that can benefit readers.