arrow_back

Block.one: Getting Started with The EOSIO Blockchain

Join Sign in
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

Block.one: Getting Started with The EOSIO Blockchain

Lab 30 minutes universal_currency_alt 1 Credit show_chart Introductory
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

This lab was developed with our partner, Block.one. Your personal information may be shared with Block.one, the lab sponsor, if you have opted-in to receive product updates, announcements, and offers in your Account Profile.

GSP873

Google Cloud self-paced labs logo

Overview

In this lab, you will create a virtual machine (VM) to host an EOSIO blockchain single node. You will load and start a local single node blockchain, create a wallet, and load the eosio private key. This is an EOSIO Fundamentals lab.

Objectives

In this lab, you will learn how to perform the following tasks:

  • Create a Compute Engine virtual machine
  • Install the EOSIO platform
  • Run a single node blockchain
  • Create a wallet
  • Load the EOSIO private key
  • Install the EOSIO Contract Development Toolkit (CDT)
  • Create a blockchain account

Prerequisites

Before you start this lab, make sure you get familiar with the following:

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left. Navigation menu icon

Background

This section provides an overview of the EOSIO concepts covered in this lab.

EOSIO Blockchain

An EOSIO blockchain is a highly efficient, deterministic, distributed state machine that can operate in a decentralized fashion. The blockchain keeps track of transactions within a sequence of interchanged blocks.

Each block cryptographically commits to the previous blocks along the same chain. It is therefore intractable to modify a transaction recorded on a given block without breaking the cryptographic checks of successive blocks. This simple fact makes blockchain transactions immutable and secure. Block production and block validation are performed by special nodes called Block Producers.

EOSIO Consensus

Block validation presents a challenge among any group of distributed nodes. A consensus model must be in place to validate such blocks in a fault tolerant way within the decentralized system. Consensus is the way for such distributed nodes and users to agree upon the current state of the blockchain. Two of the most common consensus models used in blockchains are Proof of Work (PoW) and Proof of Stake (PoS). In Proof of Stake, nodes that own the largest stake or percentage of some asset have equivalent decision power.

One interesting variant is Delegated Proof-of-Stake (DPoS) in which a large number of participants or stakeholders elect a smaller number of delegates, which in turn make decisions for them. EOSIO uses Delegated Proof of Stake (DPoS) to elect the active producers who will then be authorized to produce blocks, validate them, and sign them to eventually be added to the blockchain.

EOSIO Accounts, Keys, and Permissions

An account identifies a participant in an EOSIO blockchain. A participant can be an individual or a group depending on the assigned permissions within the account. Accounts also represent the smart contract actors that push and receive actions to and from other accounts in the blockchain. Keys in EOSIO are binary strings represented in Base58 used for signing and verification of transactions, blocks, and other messages. Keys are created within a digital wallet associated with an account.

Since account ownership is defined solely by the account name, the keys associated with an account can be updated without compromising security. A novel permission scheme involving accounts, permissions, and authority tables determine what accounts can do and how the actions that make a transaction are authorized. To that end, each account is assigned a hierarchical permission structure and each permission is assigned a pair of public and private keys used for signing and verification.

Task 1. Create a virtual machine using the Google Cloud Console

  1. In the Navigation Menu Navigation menu icon, click Compute Engine > VM instances.
  2. Click +Create Instance.
  3. For the Name, use my-vm-1.
  4. For and , use the defaults.
  5. For Machine Configuration, select:
  • Machine Family - General Purpose
  • Series - E2
  • Machine Type > Standard - e2-standard-2
  1. For Boot disk, if the Image shown is not Ubuntu 20.04 LTS, click Change and select Ubuntu from the Operating system drop down menu and then select Ubuntu 20.04 LTS from Version drop down menu.

  2. Leave the size as default and click on Select.

  3. Leave the defaults for Identity and API access and all other fields unmodified.

  4. Click Create.

Note: The VM can take about two minutes to launch and be fully available for use.

Click Check my progress to verify the objective. Create a virtual machine using the Google Cloud Console

Task 2. Install the EOSIO platform

  1. In the Navigation Menu Navigation menu icon, click Compute Engine > VM instances. You will see the VM instance you created.

  2. Click the SSH button next to the my-vm-1 instance.

  3. Update the libraries on your OS by running:

sudo apt update
  1. At the command prompt on my-vm-1, run the following to get the eosio binaries:
curl -LO https://github.com/eosio/eos/releases/download/v2.1.0/eosio_2.1.0-1-ubuntu-20.04_amd64.deb
  1. Next, run the following to install the EOSIO platform:
sudo apt install ./eosio_2.1.0-1-ubuntu-20.04_amd64.deb
  1. Confirm nodeos is installed:
nodeos --version

The response will be the nodeos version:

v2.1.0
  1. Confirm cleos is installed:
cleos version client

The response will be the cleos version:

v2.1.0
  1. Confirm keosd is installed:
keosd -v

The response will be the keosd version:

v2.1.0

Click Check my progress to verify the objective. Install the EOSIO platform

Task 3. Run a local single node blockchain

  1. At the command prompt on my-vm-1, start the nodeos service daemon as a background task and launch a single node blockchain, directing the console output to a nodeos.log file:
nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --contracts-console >> nodeos.log 2>&1 &

The response will be the PID for nodeos.

  1. Verify that nodeos is running and producing blocks:
tail -f nodeos.log

The output will look like this:

info 2021-03-08T02:44:11.900 nodeos producer_plugin.cpp:2227 produce_block ] Produced block e0dc6324ce3c8f35... #588 @ 2021-03-08T02:44:12.000 signed by eosio [trxs: 0, lib: 587, confirmed: 0]

You will see the current block, and last irreversible block (lib) incrementing.

  1. Press Ctrl+C to exit tail.

Click Check my progress to verify the objective. Run a local single node blockchain

Task 4. Create wallet

  1. At the command prompt on my-vm-1, create a wallet, named my_wallet, and output the wallet password to a file named my_wallet_password:
cleos wallet create --name my_wallet --file my_wallet_password

The response will show:

"/usr/opt/eosio/2.0.9/bin/keosd" launched Creating wallet: my_wallet Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable. saving password to wallet_password
  1. View the wallet password:
cat my_wallet_password
  1. To view the local wallets execute this command:
cleos wallet list

The response will be:

Wallets: [ "my_wallet *" ]

Click Check my progress to verify the objective. Create wallet

Task 5. Add the EOSIO system account private key to the new wallet

Every new EOSIO blockchain has a default system user called eosio. This account is used initially to set up the blockchain. It defaults to the private key, 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3. Import this private key to your wallet to sign transactions on behalf of the eosio user.

  1. At the command prompt on my-vm-1, use the cleos wallet open command to open the my_wallet wallet:
cleos wallet open --name my_wallet

The response will be:

Opened: my_wallet
  1. Copy the wallet password from the my_wallet_password file.

  2. Use the cleos wallet unlock command to unlock the my_wallet wallet, add the wallet password in to YOUR_PASSWORD:

cleos wallet unlock --name my_wallet --password YOUR_PASSWORD

The response will be:

Unlocked: my_wallet
  1. Use the cleos wallet import command to import the EOSIO private key, 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3, to the my_wallet wallet:
cleos wallet import --name my_wallet --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

The response will be:

imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

Click Check my progress to verify the objective. Add the eosio system account private key to the new wallet

Task 6. Install the EOSIO Contract Development Toolkit (CDT)

  1. At the command prompt on my-vm-1, run the following to get the eosio binaries:
curl -LO https://github.com/eosio/eosio.cdt/releases/download/v1.8.1/eosio.cdt_1.8.1-1-ubuntu-20.04_amd64.deb
  1. At the command prompt on my-vm-1, install the CDT:
sudo apt install ./eosio.cdt_1.8.1-1-ubuntu-20.04_amd64.deb
  1. Confirm the CDT is installed:
eosio-cpp --version

The response will be the CDT version:

eosio-cpp version 1.8.1

Click Check my progress to verify the objective. Install the EOSIO Contract Development Toolkit (CDT)

Task 7. Create a blockchain account

  1. At the command prompt on my-vm-1, use the cleos wallet open command to open the my_wallet wallet:
cleos wallet open --name my_wallet

The response will be:

Opened: my_wallet
  1. Copy the wallet password from the my_wallet_password file:
export wallet_password=$(cat my_wallet_password) echo $wallet_password
  1. Use the cleos wallet unlock command to unlock the my_wallet wallet, using the $wallet_password environment variable you just created:
cleos wallet unlock --name my_wallet --password $wallet_password

The response will be:

Unlocked: my_wallet
  1. Use the cleos create key command to create a public/private key pair to use with the blockchain account:
cleos create key --file my_keypair1

The response will be:

saving keys to my_keypair1
  1. Check the file my_keypair1:
cat my_keypair1

The response will be the generated public and private keys and will look like:

Private key: 5J4drLKDPL6zHKSeMDQPNoSTsnBfkue757bR7CUxM21vJfgb9oR Public key: EOS7puQYu36qyTbgPvJRgRoTU88BCREiqQTANTLZA44hxsdtxT9bY

This shows YOUR_PRIVATE_KEY and YOUR_PUBLIC_KEY.

  1. Use the cleos wallet import command to import the eosio private key created in the previous step YOUR_PRIVATE_KEY, to the my_wallet wallet:
cleos wallet import --name my_wallet --private-key YOUR_PRIVATE_KEY

The response will be:

imported private key for: YOUR_PUBLIC_KEY
  1. Use the cleos create account command to create a blockchain account using YOUR_PUBLIC_KEY:
cleos create account eosio bob YOUR_PUBLIC_KEY

The response will be:

executed transaction: 6a2aab0f2960c062652884e16e95c5313828d4630725bb2427f81f0d3dfe8f85 200 bytes 299 us # eosio <= eosio::newaccount {"creator":"eosio","name":"bob","owner":{"threshold":1,"keys":[{"key":"EOS7puQYu36qyTbgPvJRgRoTU88BC... warning: transaction executed locally, but may not be confirmed by the network yet

Click Check my progress to verify the objective. Create a blockchain account

Congratulations!

In this lab, you created a virtual machine (VM) instance, loaded and started a single node blockchain. You then created a wallet and loaded the default eosio private key used for development.

Next steps / learn more

Be sure to check out the following resources for more practice with Block.one:

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Last Tested Date: October 3, 2023

Last Updated Date: October 3, 2023

Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.