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

区块链智能合约语言设计原则是什么,区块链智能合约语言有哪些

发布时间:2023-12-06-15:37:00 来源:网络 比特币基础 区块   合约   语言

区块链智能合约语言设计原则是什么,区块链智能合约语言有哪些

区块链智能合约语言是一种特殊的编程语言,旨在为区块链技术提供支持,用于编写可以在区块链上运行的智能合约。它的设计原则是:易读性、可扩展性、可靠性和可审计性。

易读性:区块链智能合约语言的设计原则之一是易读性,即使用简单的语法,便于开发者阅读和理解。这样,开发者可以更容易地查看和编写智能合约,从而提高开发效率。此外,易读性还可以帮助开发者更容易地发现和修复编码错误。

可扩展性:可扩展性是指区块链智能合约语言的设计原则之一,即智能合约可以被扩展以支持更多的功能。例如,智能合约可以被扩展以支持多种不同的货币,以及更复杂的交易类型,如多签名交易和去中心化交易所。这种可扩展性可以帮助开发者更快地实现更复杂的功能,从而更快地开发出更多的应用程序。

可靠性:可靠性是指区块链智能合约语言的设计原则之一,即智能合约必须可靠地执行,而不会出现意外的错误。这意味着,在智能合约执行过程中,不会出现意外的错误,从而确保交易的安全性。此外,可靠性还可以确保交易的有效性,即交易将按照开发者的预期执行,而不会出现意外的错误。

可审计性:可审计性是指区块链智能合约语言的设计原则之一,即智能合约必须可以被审计,以确保其安全性和有效性。这意味着,开发者可以通过审计来检查智能合约的代码,以确保其正确性和安全性。此外,可审计性还可以帮助开发者发现和修复编码错误,从而使智能合约更加安全和可靠。

总之,区块链智能合约语言的设计原则包括易读性、可扩展性、可靠性和可审计性,这些原则可以帮助开发者更容易地开发出可靠和安全的智能合约,从而更快地开发出更多的应用程序。


请查看相关英文文档

Ⅰ Learn it as soon as possible and teach you step by step to call smart contracts using Go language

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

Let’s first understand the basic principles of smart contract calls. 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 Go language and use the go-ethereum source code library to achieve intelligence.Contract call. 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 the 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 download to "$GOPATH/src/github.com/ethereum/go-ethereum", this is not bad. However, since version 1.11 of the Go language, a mole mode has been added to manage projects. As long as the go mod is set up, you don't have to worry about downloading dependent projects.

Next, set mole to take effect and GOPROXY, the command is as follows:

In the project project, perform initialization, 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 the dependency files. This is the magic of go mod. After seeing 2020, I believe readers also know that the running results are correct.

II The key in Defi: What is a smart contract?

People often ask, what is a smart contract? So it must be First understand what a "contract" is.

What is a smart contract?

Smart Contract is a concept proposed by cryptologist Nick Szabo in the 1990s. At that time, there was a lack of credible execution environment, and smart contracts were not applied and developed. It was not until the emergence of Ethereum that smart contracts were "resurrected".

So what exactly is a smart contract? In simple terms, smart contracts A contract is a contract that uses computer language instead of legal language to record terms and is automatically executed by a program. In other words, a smart contract is a digital version of a traditional contract, running on the blockchain network and automatically executed by the program.

< p> Vending machines and ATM cash machines can all be understood as machines that execute smart contracts to some extent, but these are not smart contracts in the true sense

Smart contract security precautions in the design stage Things to consider

Consider threat modeling and security design

What: It is important to implement a specific approach to identifying and prioritizing potential threats to your system from the beginning of the development life cycle —— Smart contract developers should identify all security controls to be implemented in development and all threat testing, auditing, and monitoring that should be checked during development. All security assumptions, including the expected sophistication and means of attacks, should be made in the design Phases are clearly defined and clarified.

How: Follow known threat modeling practices. If the development team does not have in-house security expertise, then it should work with security consultants early in the design phase. When designing the system Adopt an "attacker" mentality and assume that any person, hardware, or service can be compromised.

What are the characteristics of smart contracts

Compared with traditional contracts, smart contracts have three major characteristics:
1. The content of the contract is open and transparent
Smart contracts are deployed in the block On the chain, the contract content is naturally open and transparent.

2. The content of the contract cannot be tampered
Similarly, because it is deployed on the blockchain, the content of the smart contract cannot be modified.

3. Permanent operation
Smart contracts running on the blockchain are also jointly maintained by network nodes on the blockchain. As long as the blockchain exists, the smart contracts can run permanently. . There is a sense of brotherhood that "the chain is as long as the contract is there".

Smart contracts supported by the three major characteristics of the blockchain have the following main advantages compared with traditional contracts

Smart contracts use computer language to replace legal language to record terms. A contract that is automatically executed by the program. Deployed on the block, it also has the characteristics of blockchain data being open, transparent, non-tamperable, and running permanently.

Compared with traditional contracts, smart contracts have the advantages of being trustless, safe, efficient, and not requiring third-party arbitration. But smart contracts are not perfect, and they are not smart or have a very low level of smartness.

The article mentioned that the execution of smart contracts does not require the judgment of a third-party agency. It also mentioned that when the execution conditions involve external information, the smart contract cannot sense it, and relevant information needs to be input into the smart contract. Trigger smart contracts to execute rulings

Ⅲ Blockchain and smart contracts, Ethereum development, compiled by 183 developers, summary of knowledge system

Availability of developing applications on Ethereum A guide to tools, components, patterns, and platforms.

The creation of this list was driven by product managers at ConsenSys who saw a need for better sharing of tools, development patterns, and components between new and experienced blockchain developers.

Develop smart contracts

Smart contract language

Architecture

IDE

Other tools

< p> Test the blockchain network

Test the Ethereum faucet

Front-end Ethereum API


Back-end Ethereum API

Bootstrap/Out-of-the-Box Tools

Ethereum ABI (Application Binary Interface) Tools

Ethereum Client

storeStore

Mahuta - IPFS storage service with additional search capabilities, formerly known as IPFS-Store

OrbitDB - Decentralized database on top of IPFS

JS IPFS API - Client library for the IPFS HTTP API, implemented in JavaScript

TEMPORAL - Easy-to-use API to IPFS and other distributed/decentralized storage protocols

PINATA - Using IPFS The easiest way

Messaging

Testing tools

Security tools

Monitoring

Other miscellaneous tools< /p>

Cheshire - A native sandbox implementation of the CryptoKitties API and smart contracts, available as a Truffle Box

ERCs - Ethereum comment request repository

ERC-20 - The original token contract for fungible assets

ERC-721 - A token standard for non-fungible assets

ERC-777 - An improved token standard for fungible assets

< p> ERC-918 - Minable Token Standard

Popular Smart Contract Library

Scalability

Payment/State Channels

Plasma

Sidechain

POA Bridge

POA Bridge User Interface

POA Bridge Contract

ZK -SNARK

ZK-STARK

Pre-built UI components

The above content is from the git library:

github.com/ConsenSys /ethereum-developer-tools-list

I am Yu Ge, a full-stack programmer starting a business in Shenzhen, focusing on blockchain, metaverse and smart contracts, as well as additional small programs and app development.

[Prayer]

IV What is solidity, the Ethereum smart contract development language?

Solidity language is a language specifically used for writing andThe language for executing smart contracts is a high-level contract-oriented language that runs on the Ethereum Virtual Machine. It was first proposed in August 2014 by Gavin Wood, the former CTO and co-founder of Ethereum, and later developed by Ethereum. The developers have formed a dedicated team to continuously improve the Solidity language, which is still under development and optimization. The development storage area on GitHub is https:/github.com/thereum/solidity, where we can learn more Get the most comprehensive process details and related documentation about Solidity language development and iteration. In terms of language style, Solidity language is deeply influenced by C++, Python and JavaScript. It is a statically typed programming language that is compiled in bytecode (Bytecode) mode, so it can be used in the Ethereum Virtual Machine. run on. Gavin Wood drew on the grammatical rules of JavaScript's ECMAScript scripting language when developing the Solidity language, making it somewhat similar to existing web development languages, but actually quite different. For example, the Solidity language has static types, variable return functions, etc. The most important point is that the Solidity language can write contracts with self-executing business logic and embedded in smart contracts. Therefore, it is not only one of the basic programming languages ​​​​of Ethereum, but also most other Ethereum-based smart contracts. The basic programming language of various blockchain products (Blockchain 2.0) of the contract is widely used in most current blockchain products. For example, the Hyperledger project was developed using the Soliditv language.

The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is the only "Smart Learning Factory 2020- Xueshuo Innovation Workstation" launched by the School Planning and Construction Development Center of the Ministry of Education of China. Approved "Blockchain Technology Professional" pilot workstation. The professional position is based on providing students with diversified growth paths, promoting the reform of the training model integrating professional degree research, production, and research, and building an applied and compound talent training system.

IV How to understand smart contracts in blockchain

The term "smart contract" can be traced back to at least 1995, and was coined by the prolific cross-field legal scholar Nick. It was proposed by Nick Szabo. He mentioned the concept of smart contracts in several articles published on his website. His definition is as follows:

“A smart contract is a set of digital Defined promises, including protocols on which contract participants can execute those promises. ”

Let’s explore in more detailHis definition means.

Commitments

A set of commitments refers to the (often mutual) rights and obligations agreed upon by the parties to a contract. These promises define the nature and purpose of the contract. Take a sales contract as a typical example. The seller promises to deliver the goods and the buyer promises to pay a reasonable price.

Digital form

Digital form means that the contract has to be written in computer-readable code. This is necessary because as long as the parties reach an agreement, the rights and obligations established by the smart contract are executed by a computer or computer network.

Further explanation:

(1) Reaching an agreement

When will the participants of the smart contract reach an agreement? The answer depends on the specific smart contract implementation. Generally speaking, a contract is discovered when a party commits to its execution by installing the contract on the contract hosting platform.

(2) Contract execution

The true meaning of "execution" also depends on implementation. Generally speaking, implementation means active implementation through technical means.

(3) Computer-readable code

In addition, the specific "digital form" required for the contract depends very much on the protocol the parties agree to use.

Agreement

Agreement is a technical implementation, based on which contract commitments are realized or the realization of contract commitments is recorded. Which protocol is chosen depends on many factors, the most important being the nature of the assets being traded during the performance of the contract.

Take the sales contract as an example again. Assume that the parties agree to pay in Bitcoin. The protocol of choice will obviously be the Bitcoin protocol, on which smart contracts are implemented. Therefore, the "digital form" that the contract must use is the Bitcoin script language. The Bitcoin Script Language is a non-Turing complete, imperative, stack-based programming language similar to Forth.

Smart Contract


The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is a Chinese education It is the only approved "blockchain technology professional" pilot workstation for the "Smart Learning Workshop 2020-Master's Degree Innovation Workstation" launched by the Ministry of Education's Planning, Construction and Development Center. The professional position is based on providing students with diversified growth paths, promoting the reform of the training model integrating professional degree research, production, and research, and building an applied and compound talent training system.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 37338 文章总数
  • 3637271访问次数
  • 3078建站天数