为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

git 区块链,gate区块链已确认

发布时间:2023-12-05-21:15:00 来源:网络 区块链知识 区块   geth

git 区块链,gate区块链已确认

近年来,随着技术的发展,区块链技术已经成为一种新兴的技术,它可以用来解决传统技术无法解决的问题,并为人们带来新的发展机遇。其中,git和gate区块链技术是最具有前瞻性的技术之一。

Git是一种分布式版本控制系统,它可以帮助开发者跟踪文件的变化,更容易管理代码。它可以帮助开发者更快地完成开发任务,并且可以更好地控制代码的质量。Git也可以帮助开发者更好地管理代码,更容易追踪和解决问题。

Gate区块链技术是一种新兴的技术,它可以帮助开发者更好地管理数据和流程,并且可以更安全地存储和传输数据。Gate区块链技术可以帮助开发者更好地管理数据,更安全地存储和传输数据,更容易地实现数据共享,并且可以更有效地实现数据安全。

Git和Gate区块链技术的结合,可以帮助开发者更好地管理数据,更安全地存储和传输数据,更容易地实现数据共享,并且可以更有效地实现数据安全。这是一种新兴的技术,它可以帮助开发者更快地完成开发任务,并且可以更好地控制代码的质量。

总之,git和gate区块链技术的结合可以极大地提升开发效率,提高数据的安全性和可靠性,并且可以更有效地实现数据共享。这是一种新兴的技术,它可以帮助开发者更好地管理数据,更安全地存储和传输数据,更容易地实现数据共享,并且可以更有效地实现数据安全。因此,git和gate区块链技术的结合将为人们带来新的发展机遇,使我们更好地把握未来的发展趋势。


请查看相关英文文档

A. What are gETH and gBZZ

gEth is a native token on the goerli test blockchain. gBZZ is also the BZZ token on the goerli test blockchain. You get gETH from the goerli faucet, which is required to deploy the checkbook contract (once only), deposit gBZZ into the checkbook, and cash the check deposit. gBZZ is Bee currency, collected or paid for transmitting data in the network and for storage when stamps are issued. The industry's leading bzz technology provider; a high-quality mining machine manufacturer will give away gbzz and geth for free.

B. Entering the Ethereum Network

Contents


The term "Ethereum node" refers to a certain A program that interacts with the Ethereum network in one way or another. Any device can act as an Ethereum node, from a simple mobile wallet app to a computer that stores a copy of the entire blockchain.

All nodes act as communication points in some way, but there are many types of nodes in the Ethereum network.


Unlike Bitcoin, Ethereum cannot find any program as a reference implementation. In the Bitcoin ecosystem, Bitcoin Core is the main node software, and the Ethereum Yellow Paper proposes a series of independent (but compatible) programs. The most popular ones currently are Geth and Parity.


To connect to the Ethereum network in a way that allows independent verification of blockchain data, you should run a full node using the previously mentioned software.

The software will download blocks from other nodes and verify the correctness of the transactions it contains. The software will also run all smart contracts called, ensuring that the information received is the same as other nodes. If everything works as planned, we can assume that all node devices store the same copy of the blockchain.

Full nodes are crucial to the operation of Ethereum. Without numerous nodes spread across the globe, the network would lose its censorship-resistant and decentralized nature.


By running a full node, you can directly contribute to the healthy and safe development of the network. However, full nodes typically require the use of independent machines for operation and maintenance. For users who are unable (or simply unwilling) to run a full node, light nodes are a better option.

As the name implies, light nodes are lightweight devices that can significantly reduce resource and space usage. Portable devices such as mobile phones or laptops can serve as light nodes. However, lowering overhead comes at a cost: light nodes cannot be fully self-sufficient. They cannot be synchronized with the entire blockchain and require full nodes to provide relevant information.

Light nodes are highly discussedcustomers, service providers and users. They are widely used for payments where full nodes are not necessary and running costs are too high.

The mining node can be either a full node client or a light node client. The term "mining node" is used differently than in the Bitcoin ecosystem, but is still used to identify participants.

To participate in Ethereum mining, some additional hardware must be used. The most common approach is to build a miner. Users connect multiple GPUs (graphics processing units) through mining machines to calculate hash data at high speed.

Miners can choose between two mining options: mining alone or joining a mining pool. Solo mining means that miners create blocks alone. If successful, the mining rewards will be exclusive to you. If you join a mining pool, the hashing power of many miners is combined. The block generation speed is increased, but the mining rewards will be shared by many miners.


One of the most important features of blockchain is "open access". This shows that anyone can run an Ethereum node and strengthen the network by validating transactions and blocks.

Similar to Bitcoin, many businesses offer plug-and-play Ethereum nodes. This device is undoubtedly the best choice if you just want to get a single node up and running, but the downside is that you have to pay extra for convenience.

As mentioned earlier, there are many different types of node software implementations in Ethereum, such as Geth and Parity. To run a personal node, you must understand the installation process for your chosen implementation.

Unless running a special node called an archive node, a consumer-grade laptop is sufficient to support the normal operation of an Ethereum full node. However, it's best not to use your day-to-day work equipment, as nodes can seriously slow things down.

When running a personal node, it is recommended that the device is always online. If a node is offline, it may take a lot of time to synchronize when it is connected to the Internet again. Therefore, it is best to choose equipment that is cheap to build and easy to maintain. You can even run light nodes via a Raspberry Pi.


With the network about to transition to a proof-of-stake mechanism, Ethereum mining is no longer the safest way to invest long-term. After the transition is successful, Ethereum miners can only transfer their mining equipment to other networks or sell it directly.

Given that the transition is not yet complete, participating in Ethereum mining still requires the use of special hardware (such as a GPU or ASIC). To make substantial profits, you must customize your mining rig and find mining farms with low electricity prices. In addition, you need to create an Ethereum wallet and configure the corresponding mining software. This all consumes a lot of time and money. Before participating in mining, please carefully consider whether you can handle various challenges. (Mining is strictly prohibited in China, do not try it yourselfMethod)


ProgPow stands for Programmed Proof of Work. This is an extension of the Ethereum mining algorithm Ethash, designed to make GPUs more competitive than ASICs.

In the Bitcoin and Ethereum communities, ASIC resistance has been a controversial topic for many years. In the Bitcoin network, ASICs have become the main mining force.

In Ethereum, ASIC is not mainstream, and a considerable number of miners still use GPU. However, this will soon change as more and more companies introduce Ethereum ASIC mining rigs to the market. However, what are the problems with ASICs?

On the one hand, ASIC significantly weakens the decentralization of the network. If GPU miners are unable to make a profit and have to stop mining, the hash rate will eventually be concentrated in the hands of a few miners. In addition, the development cost of ASIC chips is quite expensive, and only a handful of companies have the development capabilities and resources. This current situation may lead to the concentration of the Ethereum mining industry in the hands of a few companies, forming a certain degree of industry monopoly.

ProgPow’s integration has been controversial since 2018. Some people believe that it is beneficial to the healthy development of the Ethereum ecosystem. Others are opposed, arguing that it could lead to a hard fork. With the arrival of proof-of-stake, it remains to be seen whether ProgPoW can be applied to the network.


Ethereum and Bitcoin are the same, both are open source platforms. Anyone can participate in protocol development or build applications based on the protocol. In fact, Ethereum is currently the largest developer community in the blockchain field.

Mastering Ethereum by Andreas Antonopoulos and Gavin Wood, as well as the developer resources launched by Ethereum.org, are ideal starting points for new developers.


The concept of smart contracts was first proposed in the 1990s. Its application in blockchain brings a new set of challenges. Solidity, proposed by Gavin Wood in 2014, has become the main programming language for developing Ethereum smart contracts, and its syntax is similar to Java, JavaScript and C++.

Essentially, using the Solidity language, developers can write instructions that can be parsed by the Ethereum Virtual Machine (EVM) when broken down. You can learn more about how it works via the Solidity GitHub.

In fact, Solidity language is notThe only choice for Ethereum developers. Vyper is also a popular development language, and its syntax is closer to Python.

C. Blockchain news on July 22: Musk holds Bitcoin, Ethereum and Dogecoin

1. Tesla CEO Elon Musk The Word said at the conference that it makes sense to support something that improves the quality of the information we manage the economy. Bitcoin is a candidate product. One needs to be wary of cryptocurrencies, especially Bitcoin, which consumes so much energy. Musk said: “In general, I support Bitcoin.

2. Tesla CEO Elon Musk said at The Word conference that he personally owns Bitcoin, Ethereum and Dogecoin. Musk said: “I may buy it, but I won’t sell it. I want to see Bitcoin succeed. "In addition, he revealed that Tesla and SpaceX hold Bitcoin. It is reported that because SpaceX is privately held, it was not previously known that the space exploration technology company also held some cryptocurrencies.

3 . Golden Finance reported that Tesla CEO Elon Musk said at The Word conference that neither Tesla, SpaceX nor I will sell any Bitcoin. Tesla is likely to continue to accept Bitcoin payments. Musk Said that it seems that Bitcoin is moving more towards renewable energy, with a trend of switching to more than 50% renewable energy. In this case, Tesla will resume accepting Bitcoin. In addition, Musk said that he is going to Fans of centralized finance.

4. Cathie Wood, founder of ARK Fund, said at The Word conference: “Bitcoin is the solution to inflation. I truly believe that Bitcoin will definitely be more environmentally friendly than gold mining or the traditional financial services industry. In many ways, it already is. ”

5. Ethereum developers have been working hard to solve problems with the code and clients on the test network to prepare for the next major network upgrade-the London upgrade. July 21, Ethereum OpenEthereum lead developer Tim Beiko has released a "London Testnet Review" report detailing the latest developments in the testing phase of the upcoming Ethereum upgrade. According to the report, OpenEthereum clients noticed on July 21 that their nodes were The Ropsten testnet stopped running. After investigation, the problem was not with the client, but with the go-ethereum protocol and the Geth client, which checked the sender balance of the EIP-1559 transaction. It was reported that some clients rejected the block, while other clients accepted the block and continued processing: “Specifically, OpenEthereum and Besu rejected the transaction/block, while Nethermind, go-etheReum and Erigon accepted them. "Later, the issue was fixed by adding new assertions to the validity of the EIP-1559 transaction, and testing continues. It is reported that the test was first activated on the Ropsten testnet on June 24; earlier this month At that time, the Rinkeby test network also launched the final testing phase.

6. Tesla CEO Musk said that modern nuclear power plants are safe and supports the use of nuclear energy to generate electricity to mine Bitcoin.
< br /> 7. The Reserve Bank of India (RBI) is working on a "phased rollout" of India's central bank digital currency (CBDC) - the digital rupee, with possible pilots in the future, Reserve Bank of India Deputy Governor T Rabi Shankar said on Thursday. Reserve Bank of India The bank's definition of CBDC is a digital form of sovereign currency that can be converted into cash or sovereign-backed deposits. The Reserve Bank of India has taken several considerations on the scope and legal framework of the proposed CBDC, which is likely to be related to cash and digital Payment forms coexist. The time for an Indian CBDC is near. The Reserve Bank of India has carefully assessed the risks and the RBI’s efforts are that as we move forward, India’s CBDC can reaffirm its leadership in the world’s payment systems. The RBI has carefully Several aspects of launching a universal CBDC are examined, including: what it could be used for; the technology underpinning it (distributed or centralized ledger); the basis for verification (token or account-based); and whether it would be issued only by a central bank Or issued by commercial banks. There are also several enabling legal frameworks that need to be considered before launching a CBDC. Importantly, these include amendments to Sections 24, 25 and 26 of the RBI Act, as well as the Coinage Act, 2011, the Foreign Exchange Management Act and Provisions of the Information Technology Act. The RBI has been exploring the pros and cons of issuing an Indian sovereign CBDC for a long time. The RBI has studied the purpose-specific CBDC proposed by different central banks around the world for the wholesale and retail sectors. The launch of a population-sized CBDC is being considered For a universal CBDC, the RBI is working on a phased introduction strategy and looking at use cases with little disruption to the Indian banking and monetary system. Shankar added that cryptocurrencies like Bitcoin do not meet the RBI’s definition of a currency, central banks around the world One reason for experimenting with CBDC is that they want to minimize the risks cryptocurrencies pose to the fiat economy.

8. Sources say JPMorgan Chase is allowing all of its wealth management clients to access cryptocurrency funds. The The bank told advisers in a memo earlier this week that as of July 19, they can now accept buy and sell orders for five cryptocurrency products, four from Grayscale Investments and one from Osprey Funds. According to A person familiar with the matter revealed that this measure applies toFor all JPMorgan Chase clients seeking investment advice, including the bank’s proprietary clients who use its commission-free Chase trading app, mass affluent clients whose assets are managed by financial advisors affiliated with JPMorgan Advisors, and those of the private bank’s private banking services Ultra-wealthy customers. JPMorgan advisors can only perform “unsolicited” crypto trades, meaning advisors cannot recommend products but can buy and sell on behalf of clients at their request. According to sources, the funds approved by JPMorgan include Grayscale’s Bitcoin Trust, Bitcoin Cash Trust, Ethereum Trust and Ethereum Classic Trust, as well as Osprey funds’ Bitcoin Trust.

D. Ethereum developers are preparing for the worst-case scenario


Is Ethereum ready for the "London" hard fork?


As Ethereum prepares to activate its 11th backwards-incompatible upgrade, also known as a "hard fork," on Wednesday, August 4, some Developers are concerned that the upgrade may require more testing before deployment.


Shortly after the bi-weekly Ethereum Core Developers meeting on Friday, July 23, the Ethereum Foundation’s Tim Beko Writing in the All Core Developers Discord chat, “Several people have reached out or tweeted that they weren’t necessarily happy with not delaying [the hard fork]… I asked about it [at the meeting], No one seems to have a strong opinion, but some have mentioned that this might not be the right approach."


In response to Beko's comments, Ethereum Software Client developer Alexei Ahunov said he agreed that there was no more discussion at the bi-weekly meeting on the possibility of delaying the hard fork, dubbed "London," in light of recent events.


"I think I know why," Ahunov wrote. "Postponing [London] is a sensitive topic and no one wants to take the pressure, understandably."


Others in the chatroom plead for Ethereum The developers are seriously considering delaying London for a few more weeks for further testing.

Concerns over the risks of the London upgrade — which includes a controversial code change affecting the Ethereum fee market known as Ethereum Improvement Proposal (EIP) 1559 — arise after a bug was discovered in the Ethereum software client Geth later growth.


As background, Geth is the most popular software used to connect to Ethereum. According to Ethernodes.org, all syncs toAn estimated 86% of the computers (also called nodes) on the Ethereum network run the Geth client software.

On Wednesday, July 21, the Ethereum test network Ropsten, which launched the London hard fork a month ago, had invalid transactions mined into a block on nodes running Geth, while a small number of clients running Besu and Open Ethereum The node in the square rejected it.


Within a few hours, the Geth team released a patch and encouraged all users to update their software to the latest version number, Terra Nova 1.10.6.

While no developers believed the vulnerability should delay London's mainnet activation during Friday's conference call, some developers did discuss if such a vulnerability were discovered on Ethereum rather than on the test network appropriate course of action.


"What would we do if something like this happened on mainnet, especially where the majority of clients Geth is producing blocks? There is an obvious need It took hours to fix it,” Beko said during the meeting.


Martin Holst Swind of the Ethereum Foundation emphasized that these vulnerabilities are not unprecedented on Ropsten, although fixing them is "very easy." Trouble", but there are two ways to solve them.


First, if a user's node follows the wrong version of the blockchain, the user will need to internally "rewind" the chain to a block before the chain splits , and use patched Geth software to sync to the new chain. Second, if a user's node has not synced to a certain version of the blockchain but is trying to connect to the network to collect data about recent transactions or execute transactions, the user may end up connecting to the wrong version of the chain. To avoid this, these users need to “whitelist” certain nodes on Ethereum that follow the correct chain and isolate them from other nodes that are stuck on the wrong chain.

Both rewinding and whitelisting Ethereum nodes can be done through Geth. Miners on Ropsten were able to use these strategies to resolve the chain split that occurred last Wednesday, although one miner pointed out at Friday's meeting that instructions to fix the chain split were not communicated effectively before Wednesday's incident, leaving many miners Confused about how to properly restart a node.


User "AlexSSD7" wrote in the Discord chat room that as a representative of the Ethereum mining pool, they were "concerned" about bugs in Geth, noting, "One minute of [network] downtime costs us a lot. One hour of downtime is $20,000 to us."

Unexpected bugs in client software can really cause disruption to exchanges and businesses running on the main network, which is why developers emphasize the need for a robust monitoring system that can quickly alert node operators and encourage chain splits They have suspended operations until further investigation.


"This seems like a very low-hanging fruit and provides a tone of value to the ecosystem. If you're not sure how to get started, please post in Discord inquiry,” Beko said at Friday’s meeting.


These solutions will certainly help if a bug similar to what happened on Wednesday happens again after deploying London on mainnet, but they are not necessarily meant for The same solution to a larger scale problem, like a hacker magically printing 100 million ETH.


If something so catastrophic were to happen, the Ethereum Foundation’s Danny Ryan said at Friday’s conference that it would be difficult to know in advance what developers would do. how to proceed.


"I think there are just multiple options for the multiple types of bugs and multiple types of features that are going to happen," Ryan said.


The more severe the impact of a network vulnerability, the more likely the solution to address it will be invasive — and detrimental to Ethereum’s reputation as a secure blockchain. The greater the damage.


As recent hard forks in Ethereum’s development roadmap become increasingly ambitious, identifying potential solutions to worst-case scenarios and maintaining relationships with network stakeholders Someone's damage control plan may soon become a top priority for developers.

"DeFi for traditional markets: when security tokens emerge," said Fountain co-founder Matthew Shanson. Highlights: Fountain is a decentralized exchange on Ethereum that enables users to buy and sell security tokens. Shansen highlighted the liquidity and accessibility provided by blockchain technology, which is accessible 24 hours a day and allows for instant settlement. There are several other benefits to security tokenization, including asset transparency and unbundling that further improves accessibility. However, there are many challenges to building a fully decentralized stock exchange. Both onboarding clients and new securities require compliance with international regulations, including know-your-customer laws and custody licenses.


"The Power of Credit Empowerment", a speech by Aave founder Stany Kulehov. Highlights: Aave is a decentralized lending protocol built on Ethereum. The team behind the protocol has developed a product that offers zero-collateral loans. kuleHof believes this is a step forward in bringing DeFi liquidity to the real economy and driving demand for Aave lending.


"Things beyond DeFi" said by Ethereum creator Vitalik Butlin. Highlights: In addition to financial services, social media and public goods financing are two activities that Ethereum has not yet developed. Butlin believes the network’s token economics and resistance to censorship are two reasons why these activities could benefit from being built on a decentralized blockchain.


"Uniswap, DeFi & the future of consumer finance", a talk by Ashleigh Schap, Head of Growth at Uniswap. Highlights: Uniswap Labs is trying to establish partnerships with blockchain infrastructure companies such as Talos, Paxos, and Fireblocks to connect DeFi solutions to the backends of well-known fintech companies such as PayPal and E*Trade.


Circle Protocol developer Julian Butlup talks about "Why DEXs are eating the world." Highlights: At its best, [decentralized finance] allows citizens of the world to have equal access to all currencies, stocks, and financial platforms. As the field develops, decentralization will become a trend. Regulators will oversee the protocols used by the traditional financial world, and users will still have access to what is now DeFi’s “Wild West” testing ground.


#BTC[超话]# #digital currency#

E. Bugs in the Ethereum blockchain --2020/ 05/19

In order to prevent transaction replay, ETH (ETC) nodes require that each transaction must have a nonce value. When each account initiates a transaction from the same node, the nonce value starts counting from 0, and sending a nonce increases by 1. The subsequent nonce will be processed only after the previous nonce is processed. Note that the prerequisite here is that the same address sends the transaction on the same node.

The following are several rules for using nonce:

● When the nonce is too small (less than the nonce value used in previous transactions), the transaction will be directly rejected.

● When the nonce is too large, the transaction will always be in the queue, which is the reason for the problem we described above;

● When sending a relatively large nonce value, and then fill in the nonce between the starting nonce and that value, then the transaction can still be executed.

● When the geth client is stopped when the transaction is in the queue, the transactions in the transaction queue will be cleared.

The first field AccountNonce, the literal translation is the account random number. It is a small but important detail in Ethereum. Ethereum creates a Nonce for each account and transaction. When a transaction is initiated from the account, the Nonce value of the current account is used as the Nonce of the transaction. Here, if it is an ordinary account, then Nonce is the number of transactions issued by it, and if it is a contract account, it is the number of contracts created from it.

Why use this Nonce? Its main purpose is to prevent repeated attacks (Replay Attack). Because transactions all need to be signed, assuming there is no Nonce, then as long as the transaction data and the initiator are certain, the signature must be the same. In this way, the attacker can regenerate an identical transaction after receiving a transaction data. And submit it again. For example, A sends a transaction to B. Because the transaction is signed, although B cannot change the transaction data, as long as he repeatedly submits the same transaction data, all the funds in the A account can be transferred to B. inside.

When using account Nonce, every time a transaction is initiated, the Nonce value of account A will increase. When B resubmits, the transaction will be rejected because the Nonce does not match. This prevents repeated attacks. Of course, the matter is not over yet, because cross-chain attacks can also be carried out. It was not until EIP-155 introduced chainID that the transaction data between different chains was incompatible. In fact, Nonce cannot really prevent repeated attacks. For example, A buys something from B, initiates transaction T1 to B, and then submits another transaction T2. ​​The gas price of T2 is higher and the priority will be prioritized. If It happens that after T2 processing is completed, the remaining funds are insufficient to pay T1, then T1 will be rejected. At this time, if B has given the thing to A, then A will have successfully attacked. Therefore, even if the transaction is processed, you still have to wait for a certain period of time to ensure that a block of sufficient depth is generated to ensure that the transaction is irreversible.

Price refers to the price of unit Gas. The so-called Gas is the consumption of the transaction. Price is how many Ether coins (Ether) are consumed per unit of Gas. Gas * Price is how many Ether coins are consumed to process the transaction. It It is equivalent to the transaction fee in Bitcoin.

GasLimit limits the maximum resource consumption allowed for this transaction. In other words, transactions in Ethereum cannot consume resources without limit. This is also one of the security strategies of Ethereum to preventPrevent attackers from maliciously occupying resources.

Recipient is the transaction receiver, which is a common.Address pointer type and represents an address. This value can also be empty. In this case, when the transaction is executed, an address will be created through the smart contract to complete the transaction.

Amount is the transaction amount. This is simple and requires no explanation.

Payload is more important. It is a byte array, which can be used as an instruction array to create a contract. At this time, each byte is a separate instruction; it can also be used as a data array, which is generated by the contract. instructions to operate. Contracts are created and executed by the Ethereum Virtual Machine (EVM).

V, R, and S are the signature data of the transaction. In Ethereum, after a transaction is digitally signed, the generated signature is a byte array of length 65, which is cut into three segments. The first 32 bytes are put into R, the next 32 bytes into S, and the last 1 word. Put the section into V. So why is it cut into 3 sections? Ethereum uses the ECDSA algorithm, R and S are the ECSDA signature output, and V is the Recovery ID.

R, S, V are the values ​​after the transaction is signed, which can be used to generate the signer's public key; R, S are the output values ​​of the ECDSA elliptical encryption algorithm, and V is used to restore the result ID

F. [Blockchain] What is a blockchain wallet?

When mentioning blockchain wallets, we have to talk about Bitcoin wallets (Bitcoin core). Other areas Most blockchain wallets are modeled after Bitcoin wallets, which are our tools for managing Bitcoins.

Our Bitcoin information is stored in the Bitcoin wallet, including Bitcoin address (similar to your bank card account number) and private key (similar to your bank card password). The Bitcoin wallet can Store multiple Bitcoin addresses and the independent private keys corresponding to each Bitcoin address.

The core function of a Bitcoin wallet is to protect your private key. If the wallet is lost, you may lose your Bitcoins forever.

Blockchain wallets come in many forms.

According to whether the user has the private key, wallets can be divided into: on-chain wallet (onchain wallet) and escrow wallet (offchain wallet). There are two differences between them:

About money on the chainPackages (onchain wallets) can be divided into cold wallets and hot wallets according to whether the private key storage is connected to the Internet; cold wallets and hot wallets are also called offline wallets and online wallets.

Generally speaking, hardware wallets are cold wallets (it is generally recommended to use cold wallets to store large amounts of digital currency that are intended to be held for a long time). In addition to this kind of professional equipment, we can also use offline computers, Mobile phones, paper wallets, brain wallets, etc. are used as cold wallets to store our digital assets.

The biggest advantage of a cold wallet is its security, because it does not touch the Internet, which can greatly reduce the possibility of hacker attacks; the only thing you need to worry about is not to lose your cold wallet.

Corresponding to the cold wallet is the hot wallet. Hot wallets need to be connected to the Internet; hot wallets can be divided into desktop wallets, mobile wallets and web wallets.

Hot wallets are often in the form of online wallets, so when using hot wallets it is best to set different passwords on different platforms and enable secondary authentication to ensure the security of your assets.

According to the maintenance method of blockchain data and the degree of decentralization of the wallet, wallets can be divided into full node wallets, light node wallets, and centralized wallets.

Most full-node wallets are desktop wallets, representatives of which include Bitcoin-Core core wallet, Geth, Parity, etc. Such wallets need to synchronize all blockchain data and occupy a large amount of memory. , but can achieve complete decentralization.

Most mobile wallets and web wallets are light node wallets. Light wallets rely on other full nodes in the blockchain network and only synchronize transaction data related to themselves, which can basically achieve decentralization.

The centralized wallet does not rely on the blockchain network. All data is obtained from its own centralized server; however, the transaction efficiency is very high and can be credited in real time. The account you registered in the trading platform It is a centralized wallet.

Remember that in the world of blockchain, whoever holds the private key is the real owner of digital assets.

G. Ethereum isWhat丨Introduction Guide to Ethereum Development

What is Ethereum丨Introduction Guide to Ethereum Development
Many students are already eager to join the blockchain development team, but they feel they have no way to start. This article will Based on the Ethereum platform, various obscure concepts involved in the development of Ethereum are introduced in a popular way, and you can easily get started.
What is Ethereum
Ethereum is a decentralized application platform built on blockchain technology. It allows anyone to build and use decentralized applications running on blockchain technology within the platform.
For students who don’t understand this sentence, you can temporarily understand that Ethereum is Android in the blockchain. It is a development platform that allows us to write applications based on blockchain technology just like the Android Framework.
Before there was Ethereum, writing blockchain applications was like this: copy a copy of the Bitcoin code, and then change the underlying code such as encryption algorithm, consensus mechanism, network protocol, etc. (This is the case for many altcoins. A new coin will come out if you change it).
The Ethereum platform encapsulates the underlying blockchain technology, allowing blockchain application developers to develop directly based on the Ethereum platform. Developers only need to focus on the development of the application itself, thus greatly reducing the difficulty.
At present, a relatively complete development ecosystem has been formed around Ethereum: with community support, there are many development frameworks and tools to choose from.
Smart Contract
What is a Smart Contract
The program on Ethereum is called a smart contract, which is a collection of code and data (state).
Smart contracts can be understood as contracts (special transactions) written in code that can be automatically executed on the blockchain (driven by events).
In Bitcoin Script, we have mentioned that Bitcoin transactions can be programmed, but Bitcoin Script has many restrictions and the programs that can be written are also limited, while Ethereum is more complete (in computer science terms , calling it "Turing complete"), allows us to write programs (smart contracts) that can do almost anything just like any high-level language.
Smart contracts are very suitable for application scenarios that require high trust, security and durability, such as: digital currency, digital assets, voting, insurance, financial applications, prediction markets, property ownership management, Internet of Things, peer-to-peer transactions, etc. wait.
At present, apart from digital currency, there are not many real-life applications (just like the mobile platform has just begun to come out). I believe that within 1 to 3 years, various killers will slowly appear.
Programming language: Solidity
The default programming language for smart contracts is Solidity, and the file extension ends with .sol.
Solidity is a language similar to JavaScript. Use it to develop contracts and compile them into the Ethereum Virtual Machine.Byte code.
There is also a smart contract development language that looks like Python: Serpent, but it is recommended that you still use Solidity.
Browser-Solidity is a Solidity IDE for browsers. You can click in to have a look. We will introduce more articles about the Solidity language in the future.
Operating environment: EVM
EVM (Ethereum Virtual Machine) Ethereum Virtual Machine is the operating environment for smart contracts in Ethereum.
Solidity is to EVM just like it is to JVM, so it will be easy for everyone to understand.
The Ethereum Virtual Machine is an isolated environment, and the code running inside the EVM cannot have any contact with the outside world.
The EVM runs on the Ethereum node. When we deploy the contract to the Ethereum network, the contract can run on the Ethereum network.
Contract Compilation
The Ethereum Virtual Machine runs the bytecode form of the contract, which requires us to compile the contract before deployment. You can choose Browser-Solidity Web IDE or solc compiler.
Contract deployment
When developing applications on Ethereum, the Ethereum client (wallet) is often used. Usually when we are developing, we generally do not come into contact with the concept of client or wallet. What is it?
Ethereum client (wallet)
Ethereum client, in fact, we can understand it as a developer tool, which provides account management, mining, transfer, deployment and execution of smart contracts, etc. Function.
EVM is provided by the Ethereum client.
Geth is a typical client used when developing Ethereum and is developed based on the Go language. Geth provides an interactive command console, which contains various functions (API) of Ethereum through the command console. We will introduce the use of Geth in an article later, but here everyone has a concept.
The Geth console is similar to the console in the Chrome browser developer tools, but it runs in the terminal.
Compared to Geth, Mist is an Ethereum client with a graphical operation interface.
How to deploy
The deployment of smart contracts refers to publishing the contract bytecode to the blockchain and using a specific address to identify the contract. This address is called a contract account.
There are two types of accounts in Ethereum:
· External accounts
This type of account is controlled by a private key (controlled by a person) and is not associated with any code.
·Contract Account
This type of account is controlled by their contract code and has code associated with it.
Unlike Bitcoin’s UTXO design, Ethereum is simpler to useSingle account concept.
Both types of accounts are the same for EVM.
The difference and relationship between external accounts and contract accounts is this: an external account can send messages to another external account or contract account by creating and signing transactions with its own private key.
Sending a message between two external accounts is the process of transferring value. But messages from the external account to the contract account activate the code of the contract account, allowing it to perform various actions (such as transferring tokens, writing to internal storage, mining a new token, performing some operations, creating a new contract, etc. wait).
Only when the external account issues instructions, the contract account will perform the corresponding operation.
Contract deployment is to deploy the compiled contract bytecode to the Ethereum blockchain in the form of sending transactions through an external account (the actual deployment is successful only after the actual miner produces the block).
Run
After the contract is deployed, when you need to call the method of this smart contract, you only need to send a message (transaction) to this contract account. After the message is triggered, the code of the smart contract will be executed in the EVM. .
Gas
Similar to cloud computing, the resources that occupy the blockchain (whether it is a simple transfer transaction or the deployment and execution of a contract) also require corresponding fees (there is no free lunch in the world, right? ).
Gas mechanism is used for billing on Ethereum. Gas can also be considered as a workload unit. The more complex the smart contract is (the number and type of calculation steps, the memory occupied, etc.), the more it requires to complete the operation. Gas.
The amount of Gas required to run the contract for any particular contract is fixed and is determined by the complexity of the contract.
The Gas price is stipulated by the person running the contract when submitting a request to run the contract to determine the fee he is willing to pay for this transaction: Gas price (denominated in Ethereum) * Gas ​​quantity.
The purpose of Gas is to limit the amount of work required to execute a transaction while paying for execution. When the EVM executes a transaction, Gas will be gradually consumed according to specific rules. No matter where it is executed, once the Gas is exhausted, an exception will be triggered. All state modifications made in the current call frame will be rolled back. If there is Gas remaining at the end of execution, these Gas will be returned to the sending account.
Without this restriction, someone would write a contract that cannot be stopped (such as an infinite loop) to block the network.
So actually (to put the previous content together), we need an external account with an Ethereum balance to initiate a transaction (ordinary transaction or deploy and run a contract). When running, the miner charges the corresponding work Quantity fee.
Ethereum Network
Some anxious students may want to ask, how can we develop smart contracts without Ethereum? You can choose the following methods:
Select the Ethereum official website test network Testnet
In the test network, we can easily obtain free Ether coins. The disadvantage is that it takes a long time to initialize the node.
Use a private chain
Create your own Ethereum private test network, often called a private chain, which we can use as a test environment to develop, debug and test smart contracts.
With the Geth mentioned above, it is easy to create your own test network. You can mine as much Ethereum as you want without having to synchronize the entire blockchain data of the official network.
Using the Developer Network (Mode)
Compared with the private chain, under the Developer Network (Mode), a developer account with a large balance will be automatically allocated for us to use.
Use simulation environment
Another way to create a test network is to use testrpc. testrpc is an Ethereum environment simulated locally using memory. It is more convenient and faster for development and debugging. And testrpc can help us create 10 test accounts with funds at startup.
When developing a contract, you can test it in testrpc and then deploy it to the Geth node.
Update: testrpc has now been integrated into the Truffle development framework and is now named Ganache CLI.
Dapp: Decentralized Application
The Ethereum community calls applications based on smart contracts decentralized applications (DecentralizedApp). If we understand the blockchain as a database that cannot be tampered with, and smart contracts as programs that deal with the database, then it is easy to understand Dapp. A Dapp not only has smart contracts, but also needs a friendly user interface and other things.
Truffle
Truffle is a Dapp development framework. It can help us deal with a lot of trivial things, allowing us to quickly start the process of writing code - compiling - deploying - testing - packaging DApp.
Summary
Let’s summarize now. Ethereum is a platform that allows us to easily use blockchain technology to develop decentralized applications. In this application, Solidity is used to write and blockchain Interactive smart contracts, after the contract is written, we need to use the Ethereum client to deploy and run the contract with an account with balance (using the Truffle framework can better help us do these things). For the convenience of development, we can use Geth or testrpc to build a test network.
Note: In order to make it easier for everyone to understand, this article makes analogies to some concepts. Some of them are not strictly accurate. However, I also think that for beginners, it is not necessary to master every concept in detail and accurately. Learning is A gradual and in-depth process, many times we will find that after a period of time, IPeople will have different understandings of the same thing.

H. Blockchain technology concept

Blockchain technology concept

Blockchain technology concept, nowadays, blockchain has become the In the field of concern, many companies have already studied the technology in depth, but there are still people who don’t know much about it. Below I will share an article about the concept of blockchain technology.

Blockchain technology concept 1

Basic concepts and working principles of blockchain

1. Basic concepts

Blockchain is a distributed data storage, point-to-point New application models of computer technologies such as transmission, consensus mechanisms, and encryption algorithms. The so-called consensus mechanism is a mathematical algorithm that establishes trust and obtains rights and interests between different nodes in the blockchain system.

Blockchain is an important concept of Bitcoin. It is essentially a decentralized database and serves as the underlying technology of Bitcoin. The blockchain is a series of data blocks generated using cryptographic methods. Each data block contains information about a Bitcoin network transaction, which is used to verify the validity of the information, prevent counterfeiting, and generate the next block.

In a narrow sense, blockchain is a chained data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-tamperable. Fake distributed ledger.

Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, and uses cryptography to ensure data transmission and access. It is a new distributed infrastructure and computing method that uses smart contracts composed of automated script codes to program and operate data securely.

2. Working principle

The blockchain system consists of data layer, network layer, consensus layer, incentive layer, contract layer and application layer. Among them, the data layer encapsulates the underlying data blocks and related basic data and basic algorithms such as data encryption and timestamps; the network layer includes distributed networking mechanisms, data dissemination mechanisms, and data verification mechanisms; the consensus layer mainly encapsulates network nodes Various consensus algorithms; the incentive layer integrates economic factors into the blockchain technology system, mainly including the issuance mechanism and distribution mechanism of economic incentives; the contract layer mainly encapsulates various scripts, algorithms and smart contracts, and is the core of the blockchain The basis of programmable features; the application layer encapsulates various application scenarios and cases of the blockchain. In this model, the chain block structure based on timestamps, the consensus mechanism of distributed nodes, economic incentives based on consensus computing power, and flexible programmable smart contracts are the most representative innovations of blockchain technology.

Blockchain mainly solves the trust and security issues of transactions, so it proposes four technological innovations to address this issue:

1. Distributed ledger means that transaction accounting is completed by multiple nodes distributed in different places, and each node records a complete account, so they can all participate in supervising the legality of transactions. At the same time, they can also jointly testify for them.

Different from traditional distributed storage, the uniqueness of blockchain distributed storage is mainly reflected in two aspects: First, each node of the blockchain stores complete data according to the block chain structure. For data, traditional distributed storage generally divides the data into multiple parts for storage according to certain rules. Second, the storage of each node in the blockchain is independent and has equal status, relying on the consensus mechanism to ensure the consistency of storage, while traditional distributed storage generally synchronizes data to other backup nodes through the central node. [8]

No node can record ledger data independently, thus avoiding the possibility of a single bookkeeper being controlled or bribed to record false accounts. Also because there are enough accounting nodes, theoretically speaking, the accounts will not be lost unless all nodes are destroyed, thereby ensuring the security of the accounting data.

2. Asymmetric encryption and authorization technology. Transaction information stored on the blockchain is public, but account identity information is highly encrypted and can only be accessed with authorization from the data owner. , thus ensuring data security and personal privacy.

3. The consensus mechanism is how all accounting nodes reach a consensus to determine the validity of a record. This is both a means of identification and a means of preventing tampering. Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and strike a balance between efficiency and security.

The consensus mechanism of the blockchain has the characteristics of "the minority obeys the majority" and "everyone is equal". "The minority obeys the majority" does not entirely refer to the number of nodes, but can also be the computing power and the number of shares. Or other characteristic quantities that the computer can compare. "Everyone is equal" means that when a node meets the conditions, all nodes have the right to give priority to the consensus result, which will be directly recognized by other nodes and may eventually become the final consensus result. Taking Bitcoin as an example, it uses proof of work. Only when more than 51% of the accounting nodes in the entire network are controlled, it is possible to forge a non-existent record. When there are enough nodes joining the blockchain, this is basically impossible, thus eliminating the possibility of fraud.

4. Smart contracts. Smart contracts are based on these trustworthy and non-tamperable data. Some predefined rules and terms can be automatically executed. Take insurance as an example. If everyone's information, including medical information and risk occurrence information, is true and trustworthy, it will be easy to implement automated claims settlement in some standardized insurance products.

3. Others

The Internet exchanges information, and the blockchain exchanges value. Human history and the history of the Internet can be understood in eight words: if they are separated for a long time, they must be united for a long time.It must be divided. In the era of long-term separation, all network information is scattered on the Internet. It is very difficult for everyone to mine information. At this time, platforms such as Google and Facebook will appear. The only thing they do is to recombine all our information. For a moment. In the Internet era, what the monopoly giants reorganize is information, rather than generating their own information. The information generated is entirely our own. Once the information is reorganized, a new monopoly giant will emerge, so it will be an era of long-lasting separation. Now, due to the emergence of blockchain technology, it has entered an era of integration and division. It is a new multi-centralization. After the new multi-centralization, new value will be generated. These data will be in our own hands, and personal data will generate value. It belongs to oneself. This is the most exciting era of this era.

What is the value of blockchain? A low-cost mechanism to establish trust, establish data rights, and resolve data property rights.

At present, blockchain technology continues to develop, including the current development of single chains to multi-chains, and the technology can be further expanded. I think there may still be disruptions in the future, especially in transactions and other aspects. , especially many disruptive scenarios for existing industries.

The essence of blockchain is to establish trusted information exchange on untrustworthy networks.

One Belt, One Road + One Chain. The bigger thing about blockchain is not to create trust, but to allow trust to be transmitted losslessly, reducing the friction cost of society as a whole, thereby improving the overall efficiency.

Now the blockchain itself is still in its initial stage, so it includes the information transmission and encryption of the blockchain. Quantum encryption and other encryption appear in this process, which actually attacks the encryption algorithm used by the blockchain itself. This phenomenon also occurs from time to time. Including blockchain is also a recognition of assets, a recognition of digital assets, but now many of us use cryptographic algorithms, or as the key for us to decrypt, but if you forget the password, it is very likely that your current assets will be lost. If you lose them, you won't be able to get back your original assets. Therefore, there are still some hidden dangers in asset management, including information transmission and some security aspects. Of course, from a technical perspective, the processing speed of our blockchain itself, or its scalability, is because from the perspective of the working mechanism, the entire ledger must be copied to all participants, so in the blockchain Its operational efficiency and scalability are still relatively limited. We feel that these still need further development in terms of technology.

The underlying technologies of the blockchain platform also form blockchain wallets, blockchain browsers, node elections, mining machines, mining pools, development components, development modules, technical communities and project communities. and a series of ecosystems. The perfection of these ecosystems directly determines the efficiency and effectiveness of the underlying platform of the blockchain.

4. Mundell’s Impossible Triangle

It is impossible to achieve the ultimate in decentralization, efficiency, and security at the same time.

BlockChain Technology Concept 2

The essence of blockchain is a distributed accounting technology, as opposed to centralized accounting technology, which is widely present in our current lives. Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.

Blockchain is an important concept of Bitcoin. It is essentially a decentralized database. At the same time, as the underlying technology of Bitcoin, it is a series of related cryptographic methods. Each data block contains a batch of Bitcoin network transaction information, which is used to verify the validity and anti-counterfeiting of the information and generate the next block.

In a narrow sense, blockchain is a chained data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-tamperable. Fake distributed ledger.

Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, and uses cryptography to ensure data transmission and access. It is a new distributed infrastructure and computing method that uses smart contracts composed of automated script codes to program and operate data securely.

The popular understanding of blockchain technology is: connecting the front, back, left and right blocks of "things" into a chain using one technology, but each block The original data of the block cannot be tampered with. It is a "linked module" technology in the field of Internet of Things that allows participants to trust. The application of blockchain technology is inseparable from the Internet and the Internet of Things. It is based on the integration and interaction of the two, but allows participants to remain independent, decentralized, and work together. With this set of value chain co-construction and sharing, technology.

Characteristics of blockchain: decentralization, openness, autonomy, information cannot be tampered with, and anonymity.

Blockchain is a network that can deliver value. The demand for a network that can deliver value is an important reason for the emergence of blockchain technology. Blockchain emerged driven by the need to protect information with ownership or other value. Through public and private key cryptography, distributed storage and other technical means, blockchain ensures on the one hand the efficient transmission of valuable information, and on the other hand ensures that this information will not be easily copied and tampered with during the transmission process.

Understand the connotation of blockchain from the inevitability of its birth. Blockchain is a distributed accounting technology that solves the shortcomings of centralized accounting and solves the problem of distributed consistency. It is also The connected Internet is upgraded to a value network that ensures the safe and efficient transmission of valuable information.

Blockchain Technology Concept 3

Blockchain: Blockchain is like a globally unique account book, or database, which records the history of all transactions in the network.

Ethereum Virtual Machine (EVM):It allows you to write more powerful programs on Ethereum and script programs on Bitcoin. It is also sometimes used to refer to the Ethereum blockchain, which is responsible for executing smart contracts and everything.

Node: You can run a node to read and write to the Ethereum blockchain, that is, using the Ethereum Virtual Machine. Full nodes require downloading the entire blockchain. Light nodes are still under development.

Miner: Mining, that is, the node that processes blocks on the blockchain. You can see some of the currently active Ethereum miners on this page: stats.ethdev.com.

Proof of Work: Miners are always competing to solve some mathematical problem. The first one to solve the problem (calculate the next block) will be rewarded with Ether coins. All nodes then update their own blockchain. All miners who want to figure out the next block have an incentive to stay in sync with other nodes and maintain the same blockchain, so the entire network can always reach consensus. (Note: Ethereum is planning to move to a proof-of-stake system (POS) without miners, but that is outside the scope of this article.)

Ethereum: Abbreviation ETH. A true digital currency that you can buy and use. Here is a chart from one of the exchanges where Ethereum can be traded. At the time of writing, 1 Ether is worth 65 cents.

Gas: Executing programs and saving data on Ethereum consumes a certain amount of Ethereum. Gas is converted from Ethereum. This mechanism is used to ensure efficiency.

DApp: The Ethereum community calls applications based on smart contracts decentralized applications (Decentralized App). The goal of DApp is (or should be) to have a friendly interface for your smart contracts, plus some extras, such as IPFS, a decentralized network that can store and read data, not from the Ethereum team but in a similar spirit ). DApp can run on a centralized server that can interact with Ethereum nodes, or it can run on any Ethereum equal node. (Take a minute to think about this: Unlike ordinary websites, DApps cannot run on ordinary servers. They need to submit transactions to the blockchain and read important data from the blockchain rather than a centralized database. Compared to typical users When logging into the system, the user may be represented as a wallet address and other user data is stored locally. Many things will be structured differently from current web applications.)

Ethereum client, smart contract language

p>

Writing and deploying smart contracts does not require you to run an Ethereum node. Browser-based IDEs and APIs are listed below. But if you are just learning, you should still run an Ethereum node to understand the basic components, and running a node is not difficult.

Clients available for running Ethereum nodes

Ethereum has many client implementations in different languages, that is, multiple methods of interacting with the Ethereum network, including C++, Go, Python, Java, Haskell, etc. Why do we need so many implementations? Different implementations can meet different needs. For example, the goal of Haskell implementation is to be mathematically verifiable, to make Ethereum more secure, and to enrich the entire ecosystem.

At the time of writing this article, I am using the client geth (go-ethereum) implemented in the Go language. At other times, I also use a tool called testrpc, which uses the Python client pyethereum. Later examples will use these tools.

About mining: Mining is fun, a bit like caring for your houseplant, but also a way to learn about the entire system. Although the current price of Ethereum may not even cover the electricity bill, who knows in the future. People are creating many cool DApps that may make Ethereum more and more popular.

Interactive console: Once the client is running, you can synchronize the blockchain, create a wallet, and send and receive Ethereum. One way to use geth is through the Javascript console. In addition, you can use cURL-like commands to interact with the client through JSON RPC. The goal of this article is to take you through the process of DApp development, so I won’t go into details about this. But we should remember that these command line tools are useful for debugging, configuring nodes, and using wallets.

Running the node on the test network: If you run the geth client on the official network, it will take quite a while to download the entire blockchain and synchronize with the network. You can determine if synchronization has occurred by comparing the last block number printed in the node logs with the latest block listed on stats.ethdev.com. ) Another problem is that running smart contracts on the official network requires real Ethereum. Running the node on the test network does not have this problem. At this time, there is no need to synchronize the entire blockchain. Just create your own private chain, which saves time for development.

Testrpc: Use geth to create a test network. Another faster way to create a test network is to use testrpc. Testrpc can help you create a bunch of test accounts with funds at startup. It also runs faster and is therefore better suited for development and testing. You can start with testrpc, and then as the contract slowly takes shape, move to the test network created by geth - the startup method is very simple, you only need to specify a networkid: geth --networkid "12345". Here is the code repository for testrpc, we will talk about it again below.

Next, let’s talk about the available programming languages, and then we can start the real programming.. Solidity is the programming language used to write smart contracts.

There are several languages ​​to choose from when writing smart contracts: Solidity, which is somewhat similar to Javascript, has a file extension of .sol. Serpent, which is similar to Python, has a file name ending in .se. There is also a Lisp-like LLL. Serpent has been popular for a while, but now the most popular and stable one is Solidity, so just use Solidity. I heard you like Python? Use Solidity.

solc compiler: After writing the smart contract with Solidity, you need to use solc to compile it. It is a component from a C++ client implementation. Again, different implementations complement each other. Here is how to install it. If you don't want to install solc, you can also use a browser-based compiler, such as Solidity real-time compiler or Cosmo. The programming sections below will assume you have solc installed.

web3.js API. After the Solidity contract is compiled and sent to the network, you can use Ethereum's web3.js JavaScript API to call it and build web applications that can interact with it.

I. Ethereum mining, what to use to mine

Ethereum mining tutorial

1. Create a new folder on the hard disk, such as C:Eth . All mining software will be stored here.

2. Download the following software

1) Geth - select Geth-Win to download and unzip it

2) Ethminer - download and unzip it to the same folder , rename to "miner"

3) Ethereum Wallet (Ethereum wallet) - Download Win Ethereum wallet, unzip and rename "wallet"

Install all software< /p>

3. Open the command prompt (click the Win and R keys at the same time or click the Start menu and enter cmd). Command Prompt is a command line parser, a software that allows you to execute command input in the operating system.

After that you will have an Ethereum wallet. But there is no balance, so next you need to set up ethminer. The wallet can be minimized for now.

Mining

J. Learn it as soon as you can, and teach you step by step how to call smart contracts using Go language

Smart contract calling is the key to realizing a DApp, a A complete DApp includes front-end, back-end, smart contract and blockchain system. The call of smart contract is the key to connecting the blockchain with the front-end and back-end.

Let’s first understand the wisdomThe basic principles of contract calling. Smart contracts run in the EVM of the Ethereum node. Therefore, in order to call the contract, you must visit a certain node.

Taking the back-end program as an example, if the back-end service wants to connect to the node, there are two possibilities. One is that both parties are on the same host. In this case, the back-end connection node can use local IPC (Inter-Process Communication, Inter-process communication) mechanism, you can also use the RPC (Remote Procere Call, remote procedure call) mechanism; another situation is that the two parties are not on the same host, in this case only the RPC mechanism can be used for communication.

Speaking of RPC, readers should have some impression of the Geth startup parameters. When Geth starts, you can choose to enable the RPC service, and the corresponding default service port is 8545. .

Next, let’s take a look at the process of smart contract operation.

The running process of a smart contract is that the back-end service connects to a node and sends the call (transaction) of the smart contract to the node. After the node verifies the legality of the transaction, it broadcasts it to the entire network and is packaged by the miners. Entering the block means that the transaction has been confirmed, and the transaction is not completed until then.

Just like databases, each blockchain platform will provide SDK (Software Development Kit) for mainstream development languages. Since Geth itself is written in Go language, if you want Use Go language to connect nodes, send transactions, and directly import the go-ethereum (Geth source code) package into the project. The remaining issues are the process and API.

To summarize, the two key points for smart contracts to be called are nodes and SDK.

Since IPC requires that the backend and the node must be on the same host, developers often use the RPC mode. In addition to RPC, Ethereum also provides developers with the json-rpc interface, which will not be discussed in this article.

Next, we will introduce how to use the Go language and use the go-ethereum source code library to implement smart contract calls. There are fixed steps. Let’s talk about the overall steps first, taking the following contract as an example.

Step 01: Compile the contract and obtain the contract ABI (Application Binary Interface). Click the [ABI] button to copy the contract ABI information and paste it into file calldemo.abi (you can use the Go language IDE to create this file, the file name can be customized, and it is best to use abi as the suffix).

It is best to save calldemo.abi in a separate directory. Enter the "ls" command to only see the calldemo.abi file. The reference effect is as follows:

Step 02 :Get the contract address. Note that the contract must be deployed to the Geth node. Therefore Environment is selected as Web3 Provider.

Select "Web3 Provider" in the [Environment] option box, and then click the [Deploy] button.

After deployment, the contract address obtained is:.

Step 03: Use the abigen tool (executable program in the Geth toolkit) to compile the smart contract into Go code. The abigen tool is used to convert abi files into Go code. The command is as follows:

The meaning of each parameter is as follows. (1)abi: specifies the incoming abi file. (2) type: specifies the basic structure type in the output file. (3)pkg: Specify the output file package name. (4)out: Specify the output file name. After execution, you will see the funcdemo.go file in the code directory. Readers can open the file and enjoy it, but be careful not to modify it.

Step 04: Create main.go and fill in the following code. Note that the HexToAddress function in the code needs to pass in the address after the contract is deployed. This address is obtained in step 01.

Step 04: Set up go mod so that the project can be automatically recognized.

As mentioned earlier, if you want to use Go language to call smart contracts, you need to download the go-ethereum project. You can use the following command:

This command will automatically convert go -ethereum downloaded to "$GOPATH/src/github.com/ethereum/go-ethereum", which is not bad. However, since version 1.11, the Go language has added a mole mode to manage projects. As long as go mod is set up, you don't need to worry about downloading dependent projects.

Next, set mole to take effect and GOPROXY. The commands are as follows:

In the project project, perform initialization and calldemo can customize the name.

Step 05: Run the code. Execute the code and you will see the following effect, as well as the final output of 2020.

In the above output information, you can see that the Go language will automatically download dependency files. This is the magic of go mod. After seeing 2020, I believe readers also know that the running results are correct.