Position: Home page » Blockchain » How to build blockchain in web front end

How to build blockchain in web front end

Publish: 2021-05-02 06:48:48
1.

We need to establish data layer, network layer, consensus layer, incentive layer, contract layer and application layer

1. The data layer encapsulates the underlying data blocks and related basic data and algorithms such as data encryption and time stamp

2. The network layer includes distributed networking mechanism, data transmission mechanism and data verification mechanism

The consensus layer mainly encapsulates all kinds of consensus algorithms of network nodes

The incentive layer integrates economic factors into the blockchain technology system, mainly including the issuing mechanism and distribution mechanism of economic incentives

5. The contract layer mainly encapsulates all kinds of scripts, algorithms and smart contracts, which is the basis of the programmable characteristics of blockchain

6. The application layer encapsulates various application scenarios and cases of blockchain

, general secretary of the CPC Central Committee, stressed in the eighteenth collective learning of the Central Political Bureau, "block chain as an important breakthrough in core technology and independent innovation", "accelerating the development of block chain technology and instrial innovation". <

p>

the forward-looking judgment of the CPC Central Committee has brought the "blockchain" into the public view and become the common focus of financial capital, real economy and public opinion

from network power to big data, from media integration to blockchain, the Politburo of the CPC Central Committee has collectively studied and aimed at the forefront of technological change, showing the direction, foresight and foresight of the CPC Central Committee, leading the pace of China's instrial change and economic transformation. This collective study of the Political Bureau of the Central Committee of the CPC, with special emphasis on "blockchain", has opened up an imaginary space for the development and application of blockchain

from the perspective of science and technology, blockchain involves many scientific and technological issues such as mathematics, cryptography, Internet and computer programming. From the perspective of application, in short, blockchain is a distributed shared ledger and database, which is decentralized, tamper proof, traceable, collective maintenance, open and transparent

these features ensure the "honesty" and "transparency" of the blockchain, and lay the foundation for creating trust in the blockchain. The rich application scenarios of blockchain are basically based on the fact that blockchain can solve the problem of information asymmetry, and realize the cooperative trust and concerted action among multiple agents

2. Go is an open source programming language, which makes it easy to construct simple, reliable and efficient software. If you want to learn this programming language, you should first find a good tutorial. Brother Lian's go language + blockchain training has recently published a new set of go language tutorial, and the teacher's speaking is very good

with the global hot discussion of the concept of "blockchain", the application of blockchain technology has been quietly added to the daily life scenes such as finance, logistics, credit reference, manufacturing and retail. Some experts have shown that the future blockchain will be closely related to people's lives, and the integration of blockchain technology and people's daily life is the general trend

the popularity of the blockchain market has triggered a large number of talents demand based on blockchain technical personnel, and the popularity of blockchain talents is rising at the speed of light. According to the "2018 blockchain high salary list" released by lagou.com, Tencent, Xiaomi, Suning, Jingdong and other domestic enterprise giants have released many high salary blockchain post demands, trying to explore blockchain related technologies and applications. It is also pointed out in the list that the demand for high salary jobs is mainly based on blockchain related technical jobs, among which Suning and Keda have been given the highest monthly salary of 100k

the huge market demand for technical talents will inevitably lead to the explosive emergence and growth of the whole blockchain training market. Most of the training modes can be divided into online training, traditional IT organization training, and offline short-term training camps, which mainly focus on high-end forms. However, in the process of the hot market evolution, there are also a variety of blockchain training chaos: lecturers' qualifications are watered down, and even the most basic names are not disclosed, the syllabus is opaque, and the teaching quality is shrinking, Unreasonable class arrangement and uneven training fees and so on

with the large-scale development of the whole blockchain training market, brother company ecation, together with Yin Cheng, a senior blockchain expert, and his Tsinghua Shuimu Weiming team, has set up a blockchain college. With its professional and powerful team of technical lecturers, detailed and comprehensive curriculum system, and a large number of authentic enterprise blockchain projects, it aims to deepen the blockchain teaching and training field, And train more professional technical talents for enterprises and society<

Yin Cheng, a senior blockchain technology expert, graated from Tsinghua University, is the dean of brother Lian blockchain college. He once served as Google Algorithm Engineer, the world's most valuable expert in the field of Microsoft blockchain, and the gold medal lecturer of Microsoft tech.ed conference. Proficient in C / C + +, python, go language, sicikit learn and tensorflow. With 15 years of programming experience and 5 years of teaching experience, senior software architect, Intel Software Technology expert, famous technology expert, with many years of working experience in the world's top it company Microsoft Google. He has many years of experience in software programming and lecturing, and has developed many procts in human-computer interaction, ecation, information security, advertising and blockchain system. He has deep experience in project management and R & D, has two AI invention patents, and has practical experience in developing e-money deployed to Microsoft Windows azure. Teaching explanation is in simple language, so that students can apply what they have learned
the first stage: blockchain instry and go programming for 5 weeks
the second stage: cryptography and consensus algorithm for 2 weeks
the third stage: Ethereum source code analysis and development for 3 weeks
the fourth stage: Super ledger and node.js for 2 weeks
the fifth stage: bitcoin & EOS for 4 weeks
the sixth stage: comprehensive actual combat of the project
3. At present, blockchain technology is in the stage of rapid development. In the past two years, China has invested a lot of funds and talents in this area
technical personnel can learn this technology, while non-technical personnel can start from the instry media and instry community
If an enterprise needs to develop blockchain applications, it can entrust a professional third-party company. In Guangzhou, today's technology is good.
4. The development cost is about 500000 yuan. It's very easy to find websites with blockchain information types. You can network "blockchain network" and "blockchain XX network" and other information stations. There are at least thousands of them in China. No, let's go online.
5. The blockchain browser is the main window to browse the blockchain information, and the content recorded in each block can be viewed from the blockchain browser. Generally, digital asset users will use blockchain browser to query the transaction information recorded in the block. For example, the blockchain browser scheme developed by Yingtang Zhongchuang is mainly used to record in detail the confirmation process of each block, the generation and distribution process of digital currency, and the circulation of digital currency between each block, so as to more completely and publicly disclose the stock, increment, turnover rate and other information of digital currency, The only thing hidden is the owner behind each block.
6. GT has no erc20 token on Ethereum
7. In what area
8. Those who are familiar with front-end development should know that in recent years, various front-end frameworks have emerged one after another, H5 development mode has become more and more popular, and the era of big front-end has come
every year, a variety of front-end technologies emerge as the times require, and quickly mastering the latest front-end technologies is also an indispensable skill for every developer. Today, let's talk about the five trends of web development, hoping to bring you some useful information
1. Chatbot provides a new channel for user communication and service delivery. It is also called intelligent agent because it usually integrates artificial intelligence technology
through artificial intelligence, all problems and doubts of customers can be solved in the best way, greatly improving customer service efficiency and satisfaction. In the next few years, websites, especially the intelligent chat robots of transactional websites, will be popular all over the world. The reason is very simple, which can improve the conversion rate
2. The main reason why progressive web applications
surpass the web is better performance, function and experience. The goal of progressive web applications is to provide proct experience close to app. Progressive web applications provide the same functions as mobile applications, such as offline support. The advantage is that they are available everywhere, and there is no need to download from app
store or play store store
although progressive web applications are still inseparable from browsers, they are suitable for all users, because these web applications are built and improved based on open web standards. This cross platform and hot iteration attribute makes web applications more attractive than closed app development in highly uncertain market environment
3. Web development of Internet of things
we are entering a new era of front-end web design, and the design of website needs to consider the functions of intelligent devices. The Internet of things will promote the design of e-commerce website to a new level
the development of Internet of things (IOT) web appears with the web management of traditional software management. The purpose is to manage traditional controllable intelligent devices through web means, display and control the technology of these intelligent devices through the media of web, and control these intelligent devices to accomplish things that are not easy for human beings, although it is still relatively far away at present
4. Static website generator
static website generator is used to develop Archival Websites Based on simple text. In many cases, the static website created by static website generator has the advantages of faster loading speed, better security and easy traffic management
5. Blockchain web development
blockchain is in the landing stage, the first thing to be solved is the accessibility of blockchain applications, and Web3.0 technology will open the door to blockchain (closed systems such as wechat and Facebook obviously will not show mercy to subversive third-party blockchain developers), and opera even can't wait to launch a blockchain browser. In the future, there will be more and more web proct integration, and the security and browser compatibility of blockchain applications (such as wallets and dapps) will be the focus of blockchain web development.
9. <span style="font-family:Arial, Helvetica, sans-serif;">'use strict';</span>var CryptoJS = require("crypto-js");var express = require("express");var bodyParser = require('body-parser');var WebSocket = require("ws");var http_port = process.env.HTTP_PORT || 3001;var p2p_port = process.env.P2P_PORT || 6001;var initialPeers = process.env.PEERS ? process.env.PEERS.split(',') : [];class Block { constructor(index, previousHash, timestamp, data, hash) { this.index = index; this.previousHash = previousHash.toString(); this.timestamp = timestamp; this.data = data; this.hash = hash.toString(); }}var sockets = [];var MessageType = { QUERY_LATEST: 0, QUERY_ALL: 1, RESPONSE_BLOCKCHAIN: 2};var getGenesisBlock = () => { return new Block(0, "0", 1465154705, "my genesis block!!", "");};var blockchain = [getGenesisBlock()];var initHttpServer = () => { var app = express(); app.use(bodyParser.json()); app.get('/blocks', (req, res) => res.send(JSON.stringify(blockchain))); app.post('/mineBlock', (req, res) => { var newBlock = generateNextBlock(req.body.data); addBlock(newBlock); broadcast(responseLatestMsg()); console.log('block added: ' + JSON.stringify(newBlock)); res.send(); }); app.get('/peers', (req, res) => { res.send(sockets.map(s => s._socket.remoteAddress + ':' + s._socket.remotePort)); }); app.post('/addPeer', (req, res) => { connectToPeers([req.body.peer]); res.send(); }); app.listen(http_port, () => console.log('Listening http on port: ' + http_port));};var initP2PServer = () => { var server = new WebSocket.Server({port: p2p_port}); server.on('connection', ws => initConnection(ws)); console.log('listening websocket p2p port on: ' + p2p_port);};var initConnection = (ws) => { sockets.push(ws); initMessageHandler(ws); initErrorHandler(ws); write(ws, queryChainLengthMsg());};var initMessageHandler = (ws) => { ws.on('message', (data) => { var message = JSON.parse(data); console.log('Received message' + JSON.stringify(message)); switch (message.type) { case MessageType.QUERY_LATEST: write(ws, responseLatestMsg()); break; case MessageType.QUERY_ALL: write(ws, responseChainMsg()); break; case MessageType.RESPONSE_BLOCKCHAIN: handleBlockchainResponse(message); break; } });};var initErrorHandler = (ws) => { var closeConnection = (ws) => { console.log('connection failed to peer: ' + ws.url); sockets.splice(sockets.indexOf(ws), 1); }; ws.on('close', () => closeConnection(ws)); ws.on('error', () => closeConnection(ws));};var generateNextBlock = (blockData) => { var previousBlock = getLatestBlock(); var nextIndex = previousBlock.index + 1; var nextTimestamp = new Date().getTime() / 1000; var nextHash = calculateHash(nextIndex, previousBlock.hash, nextTimestamp, blockData); return new Block(nextIndex, previousBlock.hash, nextTimestamp, blockData, nextHash);};var calculateHashForBlock = (block) => { return calculateHash(block.index, block.previousHash, block.timestamp, block.data);};var calculateHash = (index, previousHash, timestamp, data) => { return CryptoJS.SHA256(index + previousHash + timestamp + data).toString();};var addBlock = (newBlock) => { if (isValidNewBlock(newBlock, getLatestBlock())) { blockchain.push(newBlock); }};var isValidNewBlock = (newBlock, previousBlock) => { if (previousBlock.index + 1 !== newBlock.index) { console.log('invalid index'); return false; } else if (previousBlock.hash !== newBlock.previousHash) { console.log('invalid previoushash'); return false; } else if (calculateHashForBlock(newBlock) !== newBlock.hash) { console.log(typeof (newBlock.hash) + ' ' + typeof calculateHashForBlock(newBlock)); console.log('invalid hash: ' + calculateHashForBlock(newBlock) + ' ' + newBlock.hash); return false; } return true;};var connectToPeers = (newPeers) => { newPeers.forEach((peer) => { var ws = new WebSocket(peer); ws.on('open', () => initConnection(ws)); ws.on('error', () => { console.log('connection failed') }); });};var handleBlockchainResponse = (message) => { var receivedBlocks = JSON.parse(message.data).sort((b1, b2) => (b1.index - b2.index)); var latestBlockReceived = receivedBlocks[receivedBlocks.length - 1]; var latestBlockHeld = getLatestBlock(); if (latestBlockReceived.index > latestBlockHeld.index) { console.log('blockchain possibly behind. We got: ' + latestBlockHeld.index + ' Peer got: ' + latestBlockReceived.index); if (latestBlockHeld.hash === latestBlockReceived.previousHash) { console.log("We can append the received block to our chain"); blockchain.push(latestBlockReceived); broadcast(responseLatestMsg()); } else if (receivedBlocks.length === 1) { console.log("We have to query the chain from our peer"); broadcast(queryAllMsg()); } else { console.log("Received blockchain is longer than current blockchain"); replaceChain(receivedBlocks); } } else { console.log('received blockchain is not longer than received blockchain. Do nothing'); }};var replaceChain = (newBlocks) => { if (isValidChain(newBlocks) && newBlocks.length > blockchain.length) { console.log('Received blockchain is valid. Replacing current blockchain with received blockchain'); blockchain = newBlocks; broadcast(responseLatestMsg()); } else { console.log('Received blockchain invalid'); }};var isValidChain = (blockchainToValidate) => { if (JSON.stringify(blockchainToValidate[0]) !== JSON.stringify(getGenesisBlock())) { return false; } var tempBlocks = [blockchainToValidate[0]]; for (var i = 1; i < blockchainToValidate.length; i++) { if (isValidNewBlock(blockchainToValidate[i], tempBlocks[i - 1])) { tempBlocks.push(blockchainToValidate[i]); } else { return false; } } return true;};var getLatestBlock = () => blockchain[blockchain.length - 1];var queryChainLengthMsg = () => ({'type': MessageType.QUERY_LATEST});var queryAllMsg = () => ({'type': MessageType.QUERY_ALL});var responseChainMsg = () =>({ 'type': MessageType.RESPONSE_BLOCKCHAIN, 'data': JSON.stringify(blockchain)});var responseLatestMsg = () => ({ 'type': MessageType.RESPONSE_BLOCKCHAIN, 'data': JSON.stringify([getLatestBlock()])});var write = (ws, message) => ws.send(JSON.stringify(message));var broadcast = (message) => sockets.forEach(socket => write(socket, message));connectToPeers(initialPeers);initHttpServer();initP2PServer();
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750