Build a step-by-step, decentralized application (Ethereum Blockchain Dapp) in more than 128 words – Part 1

This article aims to explain the key concepts of blockchain, dapp (decentralized app), smart contract and tokenization.

Blockchain

A blockchain is a decentralized database, it is shared between several nodes that has a copy of that database.

Block

A request for a user to add data to the database is a transaction. Transactions are grouped and added to a block in the blockchain.

Note that all data in this shared register, the blockchain, is secured by cryptographic hash and validated by an algorithm that is a consensus among network users.

Block concept in a blockchain

Minor

Minors are network users who use a program to validate new transactions and record them on the blockchain.

Example of a miner's farm equipped to calculate transactions on the blockchain (via complex mathematical and cryptographic problem solving), miners receive a "reward" for their work.

Blockchain Ethereum

Ethereum is an open source platform that uses blockchain technology to run decentralized applications (dapps).

This platform is based on the creation of Smart Contract, it is a program that contains data and functions called by applications.

Based on the blockchain there is no centralized database but a register shared and maintained in peer to peer by users.

This technology can be used to exchange currencies or to create decentralized applications that call smart contracts and store their data in blocks of the blockchain.

Public Blockchain

In a public blockchain there is no permission, everyone can join the blockchain network, which means they can read, write or participate with a public blockchain.

Public Blockchains are decentralized, no one has control over the network and they remain secure because the data cannot be changed once validated on the block chain.

Public blockchain platforms such as Bitcoin, Ethereum, Litecoin are un authorized blockchain platforms, striving to increase and protect the anonymity of the user.

Private Blockchain

In a private blockchain there are restrictions to filter who is allowed to participate in the network and what transactions.

Private blockchains tend to be associated with identity management tools or a modular architecture on which you can plug in your own identity management solution.

This may be an OAuth solution service provider that uses Facebook, LinkedIn, for example,…

Token Ethereum

Ethereum tokens or tokens are digital assets that are built from the Ethereum blockchain. These are tokens that attest that you have a value (economic for example). These tokens are based on Ethereum's existing infrastructure.

To store, receive, send ether (cryptocurrency on the blockchain ethereum) or tokens (which are tokens that are digital assets), you need at least one account. The easiest way to create an account is:

It is possible to create its own token to create its decentralized application that uses the public blockchain ethereum.

Tokenisation of financial assets

Tokenization is a method that converts the rights of an asset (financial, real estate …) into digital tokens (tokens).

Example for a 400,000 Euro apartment. Tokenizing it consists of turning it into 400,000 tokens (the number is arbitrary, the Issue can be 4 million or 100 chips).

Tokens are issued on a kind of platform that supports intelligent contracts, for example on Ethereum. The goal is for tokens to be freely exchanged.

When you buy a token, you actually buy a share of the ownership of the asset (from the apartment of 400,000 euros).

Buy 200,000 chips and you own half the assets. The Blockchain is shared register that is immutable, it ensures that once you buy tokens, no one can delete your property.

Decentralized application

Decentralized applications are applications that communicate with the blockchain. The decentralized application interface is similar to any website or mobile application.

The Smart Contract represents the central logic of decentralized application.

Illustration of a DApp that uses a blockchain with smart contracts combined with the looters of Swarm and Whisper.
Source: Ethereum Stack exchange

Smart Contract

Smart Contracts contain all the business logic of a DApp. They are responsible for reading and writing data in the blockchain, so they execute business logic.

Intelligent contacts are written in a programming language called SOLIDITY https://solidity.readthedocs.io, similar to Javascript.

To read on the subject:

ANGULAR in less than 128 words – TypeScript – Angular Part 8

This article follows the first seven on the subject ANGULAR and deals with the language TypeScript:

Templates and interpolation

Interpolation is the incorporation of expressions into marked text. By default, interpolation uses double braces, 'and 'a' as a delimiter.

<h3>Customer Number: 'numbereroClient'</h3>

Example of a directive with iteration:

<li *ngfor="let client of listeClients">'customer.name'</li>

Services:

The services allow to decouple the component of the call to a service, they are thus reusable.

ng generate customer service
import - Injectable - from '@angular/core';

@Injectable
  providedIn: 'root',
})
export class ClientService

  constructor()

}

The logic is then decoupled from the service which is injectable via the addiction injection.

Addiction injection

Example of injection of CustomerService dependency into a CustomerComponent component

import - Component, OnInit - from '@angular/core';

import 'Hero ' from '.. /hero';
import 'HeroService ' from '.. /hero.service';
import 'MessageService ' from '.. /message.service';

@Component
  selector: 'app-heroes',
  templateUrl: './heroes.component.html',
  StyleUrls:['./heroes.component.css']
})
export class ClientComponent implements OnInit

...

  getClients(): void
    this.clientService.getClients();
  }
}

ANGULAR in less than 128 words – TypeScrip – Angular Part 7

This article follows the first six on the subject ANGULAR and deals with the language TypeScript:

Manufacturer:

The builder is the method called to create the instance of an object

Class Point
    x: number;
    y: number;

    constructor (x: number, y: number)
        this.x x;
        this.y - y;
    }
    add (point: Point)
        return new Point (this.x - point.x, this.y - point.y);
    }
}

var p1 - new Point (30, 5);
var p2 - new Point (14, 21);
var p3 - p1.add (p2);

Optional setting:

If a setting is declared optional then all the parameters declared to its right are optional. Example of the name setting in the manufacturer.

Class Point
    x: number;
    y: number;
    name: string;

    constructor (x: number, y: number, name?:string)
        this.x x;
        this.y - y;
        this.name - name;
    }
}

Visibility:

By default the visibility of the setting is public, you can use "access modifiers" to change it.

Class Point
    private x: number;

Access modifiers can be positioned on methods, variables and properties.

Class Point
...
     private add (point: Point)
        return new Point (this.x - point.x, this.y - point.y);
    }
}
Class Point
...
    constructor (private x: number, private y: number)
...

Adding an access modifier (public/private/protected/reading only) to a builder setting will automatically assign that setting to a field of the same name.

Getter and setter:

TypeScript supports getters/setters as a way to intercept access to a member of an object.

This allows for a finer control over how a member is accessed on each object.

Const lengthMaxDuNom - 10;

Wage class
    private _nomComplet: string;

    get nameComplet(): thong
        return this._nomComplet;
    }

    name setComplet (newName: string)
        if (newName - newNom.length - lengthMaxDuNom)
            throw new Error ("Error Maximum length of the name reached, maximum length allowed - " lengthMaxDuNom);
        }
        
        this._nomComplet - newName;
    }
}

let salarie - new Salarie();
salarie.nameComplet - "Toto Hello";
if (employee.nomComplete)
    console.log (employee.nameComplete);
}

References to read:

ANGULAR in less than 128 words – Angular Components – Part 6

Block application construction

Components are like building blocks in an Angular application.

Components are defined using the @component decorator. A component has a selector, model, style and other properties, using which it specifies the metadata required to process the component.

Example of Angular component block architecture

AppComponent is the root component of our application. This is the base of the Angular application component tree.

https://angular.io/guide/architecture-modules

To generate a component the command is:

ng g component MyComponent

Sample component:

import - Component - from "@angular/core";

@Component
  selector: "articles"
  template: "<h2>Article</h2>"
})
export class ArticlesComponent
}

Note that if you haven't used the component generation control, then you have to manually add the component to the src/app/app.module.ts file in the imports.

import - BrowserModule - from "@angular/platform-browser";
import - NgModule - from "@angular/core";
import - AppComponent - from "./app.component";
import - ArticlesComponent - from "./articles.component";

@NgModule
  declarations: [AppComponent, ArticlesComponent],
  Imports[BrowserModule, ArticlesComponent]:
  Providers[]:
  Bootstrap:[AppComponent]
})
export class AppModule

ANGULAR in less than 128 words – TypeScript – Part 5

This article follows the first four on the subject ANGULAR and deals with the language TypeScript:

Use of classes

As in other languages a class allows to create objects and gathers variables and functions that are strongly related "Highly Related"

Class example

Class Person
  name: string;
  first name: string;

  To be more
    console.log ('My name is'- this.name' - this.prenom);
  }
}

Modules:

Class storage can be done in separate files, in this case it is a module statement.

The modules make the class accessible outside the file. The class must first be exported via "export" to be visible example of person.ts:

export class Person
  name: string;
  first name: string;

  To be more
    console.log ('My name is'- this.name' - this.prenom);
  }
}

example of hand.ts file that imports the Person class:

import - Person - from "./person";

let person - new person();

Note that there are Angular modules that will be imported with the mention @angular example:

import - Component - from '@angular/core';

Read:

https://www.typescriptlang.org/docs/handbook/modules.html

https://www.angularchef.com/recette/50/

ANGULAR in less than 128 words – TypeScript – Part 4

This article follows on from the first three on the subject ANGULAR and deals with the TypeScript language:

Concept of "assertion type"

Type assertion is a way to tell the TypeScript compiler what type of variable is. Type assertion is similar to type conversion in other languages, but in TypeScript, it's just a compilation function.

let testComplete: any - "Test Assertion type";
let test -<string>(complete test). substring (0.4);</string>
console.log(s);

Other ratings:

and full test: any - "Test Assertion type";
let test - (testComplete as string).substring (0.4);
console.log(s);

Arrow Function:

The use of function arrow removes the need to use the keyword "function." The settings are switched between brackets <> and the function expression is placed in brackets.

let addition - (a: number, b: number): number
            return a b;
}
addition (1, 2);

In line annotation:

In TypeScript, online type annotations allow you to declare an object for each of the object's properties.

Other use:

let addition - (pairDeNombre - numberA: number,numberB: number' number: number
            return a b;
}

Interface:

Interfaces allow you to name these types and are a powerful way to define contracts in your code as well as contracts with code outside of your project.

Point interface
  x: number,
  y: number
}

Link to TypeScript documentation: https://www.typescriptlang.org/docs/home.html