Mastering Web3 with Waves Module #2

Ventuary Lab
Mastering Web3 with Waves
13 min readJul 5, 2019

Module #2 Web 3.0, decentralization, blockchain and crypto.

Hey,

It’s Mastering Web3 with Waves online course. Today we’ll talk about the basic aspects of the web of the future:

Evolution of web technology. Basic principles of Web3. Digital Signatures, Distributed Ledger Technology (DLT), Blockchain and Cryptocurrencies.

We’ll overview Waves blockchain, its consensus, and token utility more precisely.

And, of course, at the end of this module, we’ll complete the practical coding challenge.

Let’s go!

2.0 “Coupon Bazaar” open marketplace overview

2.1 Issues with existing Web 1/2 architectures. The short story of Web evolution;

2.2 Web services now and Web 3.0 services. Digital Signatures;

2.3 Transactions. Blockchain. Decentralization. DLT & Consensus. Test nets/Mainnets;

2.4 Cryptocurrency. Transparency. Liquidity. Gateways. Exchanges;

2.5 Waves token utility. Fees.

2.6 Practice: “Coupon Bazaar” with decentralized data storage and crypto payments.

Enjoy!

Remember, it’s a practical online course and we’re building a decentralized Web3 coupon marketplace — “Coupon Bazaar”.

Users are searching for discounts on goods and services and they can buy them for a small price on the platform.

Each coupon — is a digital asset which represents a special discount from suppliers.

“Coupon Bazaar” is a marketplace. It provides a matching, payments operations and delivery service between suppliers and customers.

Cool! But what’s wrong with today’s web services? Let’s look at the internet evolution.

In the beginning, web pages were mostly “read-only” for regular users. Big companies were the main content creators, and pages itself were only static.

Internet adoption and penetration were growing very fast. And now we have a lot of user-generated content. The internet became “read” and “write” web. Pages became dynamic and interactive.

But what’s next?
We can see that the internet is becoming more and more intelligent. There are a lot of users, their communications, their content. The complexity of the user’s behavior is also increasing dramatically. And this is also amplifying by the integration of modern technologies into web such as the Internet of Things, Artificial Intelligence, BigData, Virtual and Augmented Reality.

To handle this complexity growth internet should be more decentralized, secure and user-centric.

Let’s see how it might look like!

The traditional web services have “server” and “client” parts. When a user opens the page in his browser the server responses a Web Page static content, HTML, assets (like images and fonts) and JavaScript code.

When a user interacts with UI components of a web page, for example, buttons and forms, the JavaScript code creates new requests to the server to get more data to display or write some data to the server’s database.

After processing this request server returns a response as a JSON key-value data format. Browser is using this data to change a client application state and view.

he Web3 works in a bit different way. Of course, the Web3 app also requires the HTML plus JavaScript code to run it in the browser. So, to do that, the server with the client application code is still needed.

When a user interacts with client application the “Read” request is created. This request is being processed by node application from Distributed Ledger — Blockchain Network. The main difference here is that this data can be read by anyone. It’s public for popular opened distributed ledgers.

The most important moment is: how to write new information into the blockchain network. Here we have a transaction term and digital signature.

All updates in the blockchain network must be implemented by transaction submit which requires a digital signature from transaction initiator.

What is a digital signature?

Imagine: Bob created two keys private key and public key. These keys are connected by a mathematical formula, so for each public key, we have only one private key and vice versa.

When Bob creates a message or transaction he can sign it by his private key. Bob must keep the private key in secret. But Bob can share the public key with anyone who will validate the signed message or transaction. Anyone with Bob’s public key is able to verify that a certain transaction was signed by Bob’s private key. So, it means that only Bob was able to create and sign it.

In general, it is called asymmetric cryptography.

Public and private keys are connected by a mathematical formula, so for each public key, we have only one private key and vice versa.

Here is one important moment:

The private key can be generated from some random seed phrase using hashing functions. A public key is obtained from a private key by elliptic curve multiplication. A network address is obtained from the public key by using hashing functions.

So, as you can see all these transformations are only one directional. The opposite direction is very hard in terms of required computations.

It’s an astronomical value (~2²⁵⁶)!

Seed phrase and private key must be stored securely. But, at the same time, it should be easy to use to sign transactions. The main software for web is a web browser, so one of the best solutions is to keep seed and keys in browser extension applications.

Waves Keeper is a browser extension which is able to keep keys securely and easily sign transactions on third party websites.

Enjoy!

Let’s look deeper into the definitions.

What is a transaction? The blockchain transaction is a new record with some required and optional fields. Each new record changes the state of the blockchain network. It happens reversible or irreversible depending on the stage of the transaction, block validation status and infrastructure conditions.

For example: Asset Transfer transaction contains a timestamp, block number, sender, recipient, amount and transaction fee.

Waves blockchain supports many different types of transactions on the core level.

What is blockchain? Basically, it’s just a data structure with specific rules: several transactions are combined into one block, each block has a unique hash value represented by hashes from each particular transaction (in the format of Merkle Tree).

Each block contains a hash string of the previous block. The sequence of blocks is a blockchain.

This structure protects the data to be changed.

If something will be changed in block A, all next blocks will not be valid and must be recreated again.

As we can see — rewriting of history is pretty computational expensive for data structures like blockchain.

But let’s imagine that we have hundreds and thousands of data copies on different computers in different countries and continents. Now, to change the history we have to rewrite blocks for the majority of copies which is even more expensive in terms of required computational resources.

That is why you might hear that blockchain is able to keep data immutable for ages.

The problem is that different machines are able to generate different chains of blocks. This phenomenon is called forks.

To keep the same data on different machines all participants have to reach consensus for each new block.

The network participants must decide who is responsible for the new block generation. The selected by consensus algorithm participant is responsible for the creation of the new block. It’s called block miner, block generator or block producer. And the process of block generation is called mining.

There are actually many types of consensus algorithms with different advantages and disadvantages.

The first classical consensus algorithm is called Proof of Work (PoW). It was originally designed by Adam Back for an email service project — Hashcash. Hashcash is a proof-of-work system used to limit email spam and denial-of-service attacks. It is based on the computation of special “nonce” value where hash from it will have a certain number of zeros. All participants do the same random permutations to find the right value.

The probability to find this value depends on computation power. It’s a pretty expensive consensus algorithm and not so efficient in terms of scalability and speed.

In two thousand eight, an anonymous author with nickname Satoshi Nakamoto has proposed to use the Proof of Work for the new digital currency called Bitcoin.

One of the most popular consensus algorithms now is Delegated Proof of Stake. All cryptocurrency holders are voting for their delegates. The amount of delegates is limited by some relatively small number.

Only selected participants are able to generate a new block in some predefined order. All other participants can’t participate in block-creation procedure. There are a lot of questions on whether this is a real decentralization.

Waves blockchain is using a Leased Proof of Stake (LPoS) consensus. Instead of selecting the limited number of block producers LPoS is able to lease (not transfer) some amount of Waves tokens to nodes that you like and trust. The probability to be a block validator is proportional to a total amount of attracted tokens from leasers.

Leased WAVES are locked in the user’s account and cannot be transferred or traded. Still, the tokens remain in the full control of the account holder and leases can be canceled at any time.

In both types of consensus, the node owners are usually working on popularisation and users attraction by providing some social media activities or creating products for the platform community.

To work with blockchain network developers need to have a test version of the network. Waves have two types of public networks which developers can use:

TestNet and MainNet. MainNet — is a production mode network. TestNet is a network to test your products and dApps in the environment which is similar to the production environment but without financial risks during the testing period.

Every action with blockchain network has a cost in native platform token — WAVES. The same thing is true for the TestNet. But there is free TestNet WAVES faucet available for everyone. Just put your TestNet public address and pass the captcha and you’ll receive free TestNet tokens to test your apps.

Let’s talk a bit about the economic aspects of Web3.

As we can see The evolution of Money has several important milestones:

  • Barter before money
  • Gold and Silver after
  • Metal Coins
  • Paper Money or Bank Notes
  • Plastic Cards
  • Electronic Money
  • And finally cryptocurrencies — the modern phenomenon.

Due to decentralized nature — cryptocurrencies don’t belong to anyone. Cryptocurrency can’t be controlled or blocked by any single party. Every person who has access to the internet is able to operate with it without any restrictions. It makes the cryptosystem global and available for everyone on the Earth. No matter what is a country of origin, political situation, culture, religion or economic situation…

Everything with a public blockchain network is transparent. Everyone is able to see his transactions and transaction of others.

Everything is anonymous until you’ll broadcast somehow that certain public address belongs to you or someone you know.

You can see details of any transaction in the blockchain explorer.

To have a monetary value any crypto asset must be liquid. In business, economics or investment, market liquidity is a market’s feature whereby an individual or firm can easily and quickly purchase or sell an asset without causing a drastic change in the asset’s price.

Just like everything in the economy crypto assets has price determined by the equilibrium between demand and supply.

More demand — the higher price of an asset.

To purchase or sell the crypto assets people can use gateways or exchanges.

All national or traditional assets are called as “fiat”. So purchase the crypto assets you should use fiat-to-crypto gateways/exchanges and vice versa.

Waves are able to use many gateways with national fiat currencies.

You can also trade crypto assets with many strategies on exchanges by placing orders to sell or to buy. Waves DEX — is a decentralized exchange for many liquid crypto assets.

The waves public blockchain has a native token — WAVES. The demand to the Waves native token ensured by its utility within the platform.

All transactions have fees in WAVES. It means that in order to use the platform users should pay for that. But fortunately, waves fees are very small and it makes this platform available for everyone.

For example transfer transaction has a fee equal to approximately half of 1 US-cent. For any amount of transferred assets.

Pretty cheap right?

https://forum.wavesplatform.com/t/proposal-new-fee-calculation-model/13601

The native token is very important for the platform functionality:

  • It makes any DDoS attacks expensive
  • It incentivizes networks nodes/block producers to maintain the network
  • It incentivizes the platform contributors to improve the infrastructure

Remember.

Waves blockchain is using a Leased Proof of Stake consensus. The probability to be a block validator is proportional to the total amount of attracted tokens from leasers. And with each validated block the miner receives the reward generated from transaction fees.

http://dev.pywaves.org/generators/

Waves Nodes Monitor (by waves)

In this module, we’ll be practicing with decentralized data storage and crypto payments with Waves

Let’s come back to our Marketplace of the Future.

We’re building a decentralized Web3 coupon marketplace — “Coupon Bazaar”. Users are searching for goods and services discounts and they can buy them for a small price in the marketplace. Each coupon — is a digital asset which represents a special discount from suppliers.

So we gonna implement functionality for Suppliers:

  • A supplier registration
  • Items management
  • Purchases confirmation

…and functionality for Customers:

  • Search for “coupon”
  • Purchase with cryptocurrency

So we gonna implement functionality for Suppliers:

  • A supplier registration
  • Items management
  • Purchases confirmation

And functionality for Customers:

  • Search for “coupon”
  • Purchase with cryptocurrency

We’ll use a special and most important feature for dApp development — Data Transaction.

… and smart account (dApp) — which will accept all Data Transactions from suppliers and decline all other outgoing transactions, except set script transactions which are required for us to update the smart account logic in the future.

Waves IDE

Data Transactions — provide a way to store information in the blockchain network with key-value structure:

“The maximum size for a key is 100 characters, and a key can contain arbitrary Unicode code points including spaces and other non-printable symbols. String values have a limit of 32,768 bytes and the maximum number of possible entries in data transaction is 100. Overall, the maximum size of a data transaction is around 140kb — for reference, almost exactly the length of Shakespeare’s play ‘Romeo and Juliet’.”

We wish you good luck with the “Code Challenge”!

Enjoy!

--

--

Ventuary Lab
Mastering Web3 with Waves

DLT, Web3.0, Blockchain, Decentralization, Startups, Waves Platform