2. ZeroLAB
ZeroLAB
Welcome back!
In the last session, we have discussed the basic information and
concepts in blockchain. We hope you enjoy and get excited for the
upcoming session!
For this session will provide you with information about the most
essential concepts in blockchain. Those concepts are extremely
important when you want to learn about development in blockchain or
blockchain in general.
INTRO
7. ZeroLAB
ZeroLAB
Blockchain Account is the most
frequent component you will
interact in the blockchain network.
Users use Blockchain Account to:
• Store cryptocurrency, and tokens on
blockchain network
• Deposit and transfer cryptocurrency as
well as token
• Sign transactions
BLOCKCHAIN ACCOUNT
Deposit Cryptocurrency
Transfer Cryptocurrency
8. ZeroLAB
ZeroLAB
BLOCKCHAIN ACCOUNT
Blockchain account is comprised of a private key and a public key. While
the public key is the cryptographic derivation of the private key, public
address is the cryptographic derivation of the public key.
Blockchain Account
Public Address Public Key Secret Private Key
Validate Messages
Sign Transactions
Encrypt Messages
10. ZeroLAB
ZeroLAB
BLOCKCHAIN WALLET
Therefore, it is important to note that account is not a wallet or vice versa.
They are two completely different concepts.
Blockchain Account
Blockchain Wallet
Blockchain Wallet is either a hardware or a software that enables users to hold and
manage their accounts.
Like a blockchain account, there are also a lot cryptographic applications involve in a
blockchain wallet. Some people may confuse between blockchain wallet and
blockchain account.
12. ZeroLAB
ZeroLAB
BLOCKCHAIN TRANSACTION
Among various concepts in blockchain, transaction is always one of the
most important ones.
A transaction can be a transfer of cryptocurrency from one account to another. It can
also be an interaction of an account with a smart contract or between two different
smart contracts.
Transaction
Smart Contract Interaction
Transfer of Cryptocurrency Transaction
13. ZeroLAB
ZeroLAB
BLOCKCHAIN TRANSACTION EXAMPLE
When Alice transfers 3
Ethers to Bob as a gift, that
action of transferring by
Alice creates a transaction
that will modifies Alice’s
balance to have 3 Ethers
less and Bob’s balance to
have 3 more Ethers. Alice Bob
3 Eths
Transaction
14. ZeroLAB
ZeroLAB
BLOCKCHAIN TRANSACTION EXAMPLE
In another case, when Alice
buys an NFT from a
marketplace, this action
calls the marketplace smart
contract to transfer the NFT
to Alice’s account. This call
to a smart contract is also a
transaction made by Alice. Alice SC
Contract invocation
Transaction
15. ZeroLAB
ZeroLAB
The way transactions being processed in blockchain can be
conceptualized by the following diagram. In particular, as soon as
a transaction is submitted:
TRANSACTION LIFECYCLE
Hash Broadcast Bundle
Generate
Verify
Append
17. ZeroLAB
Public blockchain usually have multiple
networks running in parallel. Different
networks are provided on which
developers can build and test before
deploying their application on the
main one.
Different blockchains have different
set of networks. They can be identical
replicas of the Mainnet or run different
consensus protocol to provide easy and
quick testing environment. However, in
most cases, cryptocurrencies on these
networks have no monetary value.
TEST NETWORKS
18. ZeroLAB
ZeroLAB
Using the blockchain testnet, developers are able to avoid costs as
cryptocurrencies do not have economical value. Given the fact that testnet is
also a public blockchain, there are a lot of users and available contracts on the
network.
Thus, developers is enabled to develop on a testing environment that is
extremely close to a real one.
TEST NETWORKS
Available Contracts
Cost Free Other Users
20. ZeroLAB
Blockchain client is a
software implementation
of the blockchain which
enables user to verify
transactions, keep the
network secure and data
accurate by participating
in the consensus.
BLOCKCHAIN CLIENT
21. ZeroLAB
In order to interact with
blockchain network, we
need a node.
Connecting to a node
gives developers the
ability to access on-chain
data and perform
read/write functionalities.
BLOCKCHAIN CLIENT
23. ZeroLAB
ZeroLAB
REMOTE CLIENT
Remote client provides users with a number of the functionalities, but not as
many as that when users run a full node. However, those functionalities are
usually more than enough for blockchain development.
Key
Management
Transaction
Setup
Smart Contract
Interactions
DApps Interactions Cryptocurrencies Exchanges
25. ZeroLAB
Blockchain nodes run
decentrally on the
blockchain network. They
participate in the
consensus protocol,
which we will go deeper
in the future session, to
keep the network secure
and moving forward.
DECENTRALIZATION
26. ZeroLAB
All validations and executions, or
in general transactions, on the
blockchain network are validated
by the decentralized nodes
through a “common agreement”
between them or at least most of
them.
Therefore, the network is owned
and governed by everyone
instead any single central entity.
DECENTRALIZATION
27. ZeroLAB
Decentralization provides
blockchain users with the
following benefits.
▪ Trustless environment
▪ Data availability and integrity
▪ Network persistance
▪ Optimized resource
accessibility
DECENTRALIZATION BENEFITS
28. ZeroLAB
Everyone does not need to
trust each other to
collaborate on the
decentralized network.
Identical replicas of data are
stored by each node on the
network as ledgers. If any of
the ledger is tempered, it will
be rejected by other nodes.
TRUSTLESS ENVIRONMENT
31. ZeroLAB
As a result of the above-
mentioned benefits,
decentralization provides
optimized distribution of
resource so that data and
service access are highly
fault tolerant and accurate
reducing the level of risk that
a systematic failure may
occur.
OPTIMIZED RESOURCE DISTRIBUTION
32. ZeroLAB
Time to build
The second part of the theory is over, time to setup
development environment
(Algorand Sandbox)
33. ZeroLAB
ZeroLAB
We are at one third of the
journey.
By the end of this practical
session, you will have an
environment setup for
smart contract deployment.
PRACTICAL JOURNEY
Topics
1. Create and fund your account
with testnet funds.
2. Setup your development
environment.
3. Connect account to a Dapp.
4. Write a simple smart contract,
deploy and test.
5. Upload images to IPFS through a
Dapp.
6. Create NFT on the Dapp and
transfer using your wallet.
35. ZeroLAB
ZeroLAB
We assume that you already have Git install on
your machine. If not, you can follow the guidelines
from https://git-scm.com/downloads.
If you are a Windows user, you need to install a few
prerequisites:
▪ Docker Desktop
▪ Windows Terminal
▪ Windows Subsystem for Linux (WSL) 2
Prerequisites
37. ZeroLAB
ZeroLAB
DOCKER DESKTOP INSTALLATION
Go to https://docs.docker.com/desktop/install/windows-install/ > Click on “Docker Desktop for
Windows” (above screenshot) > Run the downloaded Docker Desktop Installer.exe file with all
default choices to install.
40. ZeroLAB
ZeroLAB
Enable WSL 2 and install
Ubuntu 20.04 LTS by
running the following
command on the opened
windows terminal.
WSL 2 INSTALLATION
wsl --install -d Ubuntu-20.04
42. ZeroLAB
ZeroLAB
DOCKER DESKTOP CONFIGURATION
After Docker Desktop is installed, we need to configure it to connect to our Ubuntu 20.04
subsystem that we installed in the previous step:
Run Docker Desktop (left) > Go to Settings (top right arrow) > Tick “Use the WSL 2 based engine”
43. ZeroLAB
ZeroLAB
DOCKER DESKTOP CONFIGURATION
In the left side menu, extend “Resources” > Select “WSL Integration” > Enable “Ubuntu-20.04” >
Click “Apply & Restart”.
Note: Make sure the rectangle on the bottom left corner is green meaning Docker is running.
Make sure this is green
44. ZeroLAB
ZeroLAB
Verify that Docker is
accessible on the Ubuntu
WSL by running the
following command.
CHECK DOCKER ON WSL 2
// Get docker version
docker -v
46. ZeroLAB
ZeroLAB
Clone the
sandbox repo
from Github to
a folder called
zerolab-prac
by running the
following
commands in
the terminal
DOWNLOAD SANDBOX
// Create a directory called zerolab-prac
mkdir zerolab-prac
// Change to zerolab-prac directory
cd zerolab-prac
// Clone the sandbox repo
git clone https://github.com/jasonhtpham/sandbox.git
// Use change mode command to give permission to all files
chmod -R u=rwx sandbox/
// Change to the sandbox directory
cd sandbox
// List files and directories in the current directory
ls
47. ZeroLAB
ZeroLAB
Start the sandbox with the
connection to Algorand
Testnet by running the
following command.
The connection to Algorand
testnet enables us to use
the accounts created in
practical 1 in future
activities.
START SANDBOX
// Start the sandbox with
connection to the testnet
./sandbox up testnet -v
48. ZeroLAB
ZeroLAB
Once the sandbox is up and
running, we can enter the
algod container.
This provides us the ability
to quickly and easily interact
with the blockchain in later
activities.
ENTER THE ALGOD CONTAINER
// Go into the algod container
./sandbox enter algod
49. ZeroLAB
ZeroLAB
We need to use the goal
command to create a wallet
called test which is used to
hold our accounts in the
future.
We can verify if the wallet is
created by running.
CREATE A WALLET IN THE ALGOD CONTAINER
// Create a wallet called test
and provide a password
goal wallet new test
// List all wallet
goal wallet list
50. ZeroLAB
We have done setting up the development
environment with the Algorand sandbox, which will
set us ready for the next practical session.
In the next practical session, we will connect an
account to a Dapp using Pera Algo Wallet.
PRACTICAL 2