Ethereum private key deployment contract nodejs
Publish: 2021-05-01 18:16:11
1. At the top of Ethereum is DAPP. It exchanges with the smart contract layer through Web3. JS. All smart contracts run on EVM (Ethereum virtual machine) and use RPC calls. Below EVM and RPC are the four core contents of Ethereum, including: blockchain, consensus algorithm, mining and network layer. Except DAPP, all other parts are in the Ethereum client. The most popular Ethereum client is geth (go Ethereum)
2. Before, when we talked about decentralized applications, we always thought of foreign procts, such as Ethereum. But when we talk about this topic today, I think more about China's own Asch, a new generation of decentralized application development based on side chain technology<
arch is a decentralized application development, and it is also the first decentralized application in China. Its purpose is to help developers quickly create decentralized applications. The system is easy to use, flexible and safe
in terms of mode, it is similar to Ethereum and belongs to blockchain service, but the implementation mechanism is quite different. Taking Ethereum as an example, its biggest feature is that it greatly expands the functions of the script engine, adds new instructions such as reading blockchain, charging and jumping, and relieves stack memory, function call depth and script length restrictions. However, this method has a big disadvantage that the application code itself and the data generated by the application exist in the same blockchain, resulting in the rapid expansion of the blockchain
but arch is different. Its extensibility is not realized by transaction script, but by side chain. There is a main chain and several side chains (mainly provided by developers) in the ash system, but each chain only supports a limited number of transaction types. The logic of transaction or contract is written directly by the host language, not by the transaction script
the advantages are as follows: firstly, it reces the difficulty of contract programming; secondly, it avoids blockchain expansion; thirdly, each application can customize personalized blockchain parameters<
ash does not directly crypti (decentralized, blockchain based app store) or lisk (it is a new generation, allowing JavaScript development and distributed applications to use an easy-to-use, fully functional ecosystem), But it will refer to crypti's architecture and reuse some of its code, but not too much
there are two main differences.
crypti uses dpos, on which we add pbft algorithm to enhance consistency and rece double payment risk
we use C + + language to write some key moles, and nodejs is still used to write the non performance hot parts.
arch is a decentralized application development, and it is also the first decentralized application in China. Its purpose is to help developers quickly create decentralized applications. The system is easy to use, flexible and safe
in terms of mode, it is similar to Ethereum and belongs to blockchain service, but the implementation mechanism is quite different. Taking Ethereum as an example, its biggest feature is that it greatly expands the functions of the script engine, adds new instructions such as reading blockchain, charging and jumping, and relieves stack memory, function call depth and script length restrictions. However, this method has a big disadvantage that the application code itself and the data generated by the application exist in the same blockchain, resulting in the rapid expansion of the blockchain
but arch is different. Its extensibility is not realized by transaction script, but by side chain. There is a main chain and several side chains (mainly provided by developers) in the ash system, but each chain only supports a limited number of transaction types. The logic of transaction or contract is written directly by the host language, not by the transaction script
the advantages are as follows: firstly, it reces the difficulty of contract programming; secondly, it avoids blockchain expansion; thirdly, each application can customize personalized blockchain parameters<
ash does not directly crypti (decentralized, blockchain based app store) or lisk (it is a new generation, allowing JavaScript development and distributed applications to use an easy-to-use, fully functional ecosystem), But it will refer to crypti's architecture and reuse some of its code, but not too much
there are two main differences.
crypti uses dpos, on which we add pbft algorithm to enhance consistency and rece double payment risk
we use C + + language to write some key moles, and nodejs is still used to write the non performance hot parts.
3. If it's lost, it's better to post the lost advertisement
4. Go language is the mainstream language of blockchain
according to the data survey of boss Research Institute, go and C + + are the mainstream languages of blockchain Posts currently recruited. The early blockchain system and application
programs are mainly implemented in C + +, and now most companies will use go language to
build public chain systems<
C + + is suitable for the development of local programs.
go language is suitable for the development of network programs and local programs.
compared with C + + go, it has the following advantages:
garbage collection
clear meaning
unified format
disadvantages:
efficiency is not as high as C + + at present, but for desktop programs, efficiency is not a big problem, Because hardware is fast growing.
C + + is the mainstream language at present, and I believe it will become a classic just like C.
to become a classic means that people who learn it can get a good salary, but it is only good for themselves.
in the future network world, go will have a big chance to get hot, I think it has a bright future.
the developers of go, including the founders of UNIX and C language, are the first generation of hackers, and I believe they will do a good job.
now the go stack + blockchain market is out of an unprecedented gale, and the situation is gratifying.
according to the data survey of boss Research Institute, go and C + + are the mainstream languages of blockchain Posts currently recruited. The early blockchain system and application
programs are mainly implemented in C + +, and now most companies will use go language to
build public chain systems<
C + + is suitable for the development of local programs.
go language is suitable for the development of network programs and local programs.
compared with C + + go, it has the following advantages:
garbage collection
clear meaning
unified format
disadvantages:
efficiency is not as high as C + + at present, but for desktop programs, efficiency is not a big problem, Because hardware is fast growing.
C + + is the mainstream language at present, and I believe it will become a classic just like C.
to become a classic means that people who learn it can get a good salary, but it is only good for themselves.
in the future network world, go will have a big chance to get hot, I think it has a bright future.
the developers of go, including the founders of UNIX and C language, are the first generation of hackers, and I believe they will do a good job.
now the go stack + blockchain market is out of an unprecedented gale, and the situation is gratifying.
5. The Internet has just begun, intelligent life coming
6. In solidness, a contract consists of a set of code (contract function) and data (contract state). The contract is located at a special address on the Ethereum blockchain. uint storedData; This line of code declares a state variable, named storeddata, of type uint (256 bits unsigned integer). You can think of it as a storage unit in a database. Just like managing a database, you can query and modify it by calling functions. In Ethereum, usually only the owner of the contract can do so. In this example, the functions set and get are used to modify and query the values of variables, respectively
like many other languages, when accessing state variables, it is not necessary to add a prefix such as this
this contract can't do a lot (limited by Ethereum's infrastructure), it just allows anyone to store a number. And anyone in the world can access this number. There is no reliable way to protect the number you publish. Anyone can call the set method to set a different number to cover your published number. But your numbers will remain in the history of blockchain. Later we'll learn how to add an access limit so that only you can change the number
token example
the next contract will implement a cryptocurrency in the simplest form. Taking money in the air is no longer a magic trick. Of course, only the person who creates the contract can do it (it's also very easy to use other currency issuance modes, just to realize the differences in details). And anyone can send money to others, without registering a user name and password, as long as there is a pair of Ethereum public and private keys
note
this is not a good example for online solidness environments. If you use the online solidity environment to try this example. The address of from cannot be changed when the function is called. So you can only play the role of a coiner, you can cast money and send it to others, but you can't play the role of others. This online solidity environment will be improved in the future.
like many other languages, when accessing state variables, it is not necessary to add a prefix such as this
this contract can't do a lot (limited by Ethereum's infrastructure), it just allows anyone to store a number. And anyone in the world can access this number. There is no reliable way to protect the number you publish. Anyone can call the set method to set a different number to cover your published number. But your numbers will remain in the history of blockchain. Later we'll learn how to add an access limit so that only you can change the number
token example
the next contract will implement a cryptocurrency in the simplest form. Taking money in the air is no longer a magic trick. Of course, only the person who creates the contract can do it (it's also very easy to use other currency issuance modes, just to realize the differences in details). And anyone can send money to others, without registering a user name and password, as long as there is a pair of Ethereum public and private keys
note
this is not a good example for online solidness environments. If you use the online solidity environment to try this example. The address of from cannot be changed when the function is called. So you can only play the role of a coiner, you can cast money and send it to others, but you can't play the role of others. This online solidity environment will be improved in the future.
7. Truffle is a world-class development environment, testing framework, Ethereum resource management channel, dedicated to making Ethereum development easier, truffle has the following:
built in smart contract compilation, linking, deployment and binary file management
automatic contract testing under rapid development
scripted and extensible deployment and publishing framework
the network environment management function deployed to no matter how many public or private networks
uses the package management provided by ethpm & NPM and erc190 standard
a direct interactive console that communicates directly with the contract (after writing the contract, you can verify it on the command line)
the configurable construction process supports tight integration
external scripts can be executed in truffle environment< Truffle is the most popular development framework, whose mission is to make development easier
installation method:
$NPM install - G truffle
environment requirements
nodejs 5.0 +
windows, Linux, or Mac OS X
truffle needs Ethereum client and supports standard JSON RPC API. For development, some are more suitable, which will be introced in the following chapters (for example, testrpc provides real-time feedback ring coding and debugging)
suggestions for Windows users
if you are a Windows user, we recommend that you use PowerShell or git bash to install and use the truffle framework. These two shell environments provide more convenient features than the default
if you have to use the command line, see the discussion here on how to configure truffle.
built in smart contract compilation, linking, deployment and binary file management
automatic contract testing under rapid development
scripted and extensible deployment and publishing framework
the network environment management function deployed to no matter how many public or private networks
uses the package management provided by ethpm & NPM and erc190 standard
a direct interactive console that communicates directly with the contract (after writing the contract, you can verify it on the command line)
the configurable construction process supports tight integration
external scripts can be executed in truffle environment< Truffle is the most popular development framework, whose mission is to make development easier
installation method:
$NPM install - G truffle
environment requirements
nodejs 5.0 +
windows, Linux, or Mac OS X
truffle needs Ethereum client and supports standard JSON RPC API. For development, some are more suitable, which will be introced in the following chapters (for example, testrpc provides real-time feedback ring coding and debugging)
suggestions for Windows users
if you are a Windows user, we recommend that you use PowerShell or git bash to install and use the truffle framework. These two shell environments provide more convenient features than the default
if you have to use the command line, see the discussion here on how to configure truffle.
8. Ethereum contracts are written in high-level language (solidness), compiled, deployed and interacted with nodejs, distributed applications are developed with truffle framework, and contracts are interacted with console or web page.
Hot content
