Solidity
Solidity是一门为实现智能合约而创建的面向对象的语言。智能合约是管理以太坊内账户行为的程序。
Solidity是一种面向以太坊虚拟机(EVM)的带花括号的语言<https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Curly_bracket_languages>。它受到了C++, Python, 和 JavaScript的影响。你可以在:doc:`语言影响`<language-influences>部分中找到更多有关 Solidity 受哪些语言启发的细节。
Solidity 是静态类型语言,支持继承,库和复杂的用户自定义的类型以及其他特性。
使用 Solidity,您可以创建用于投票、众筹、盲拍以及多重签名钱包等用途的合约。
当开发智能合约时, 你应该使用最新版本的Solidity。 除某些特殊情况之外,只有最新版本才会收到 `安全修复`<https://github.com/argotorg/solidity/security/policy#supported-versions>。 此外,重大的变化以及新功能会定期引入。 目前,我们使用 0.y.z 版本号`来表明这种快速的变化`<https://semver.org/#spec-item-4>。
警告
Solidity最近发布了0.8.x版本,该版本引入了许多重大更新。请务必阅读:doc:`完整列表`<080-breaking-changes>。
Ideas for improving Solidity or this documentation are always welcome, read our contributors guide for more details.
提示
You can download this documentation as PDF, HTML or Epub by clicking on the versions flyout menu in the bottom-right corner and selecting the preferred download format.
Getting Started
1. Understand the Smart Contract Basics
If you are new to the concept of smart contracts, we recommend you to get started by digging into the "Introduction to Smart Contracts" section, which covers the following:
A simple example smart contract written in Solidity.
2. Get to Know Solidity
Once you are accustomed to the basics, we recommend you read the "Solidity by Example" and “Language Description” sections to understand the core concepts of the language.
3. Install the Solidity Compiler
There are various ways to install the Solidity compiler, simply choose your preferred option and follow the steps outlined on the installation page.
提示
You can try out code examples directly in your browser with the Remix IDE. Remix is a web browser-based IDE that allows you to write, deploy and administer Solidity smart contracts, without the need to install Solidity locally.
警告
As humans write software, it can have bugs. Therefore, you should follow established software development best practices when writing your smart contracts. This includes code review, testing, audits, and correctness proofs. Smart contract users are sometimes more confident with code than their authors, and blockchains and smart contracts have their own unique issues to watch out for, so before working on production code, make sure you read the Security Considerations section.
4. Learn More
If you want to learn more about building decentralized applications on Ethereum, the Ethereum Developer Resources can help you with further general documentation around Ethereum, and a wide selection of tutorials, tools, and development frameworks.
If you have any questions, you can try searching for answers or asking on the Ethereum StackExchange, or our Gitter channel.
Translations
Community contributors help translate this documentation into several languages. Note that they have varying degrees of completeness and up-to-dateness. The English version stands as a reference.
You can switch between languages by clicking on the flyout menu in the bottom-right corner and selecting the preferred language.
备注
We set up a GitHub organization and translation workflow to help streamline the community efforts. Please refer to the translation guide in the solidity-docs org for information on how to start a new language or contribute to the community translations.
Contents
语言描述
- Layout of a Solidity Source File
- Structure of a Contract
- Types
- Units and Globally Available Variables
- Expressions and Control Structures
- Contracts
- Creating Contracts
- Visibility and Getters
- Function Modifiers
- Transient Storage
- Composability of Smart Contracts and the Caveats of Transient Storage
- Constant and Immutable State Variables
- Custom Storage Layout
- Functions
- Events
- Custom Errors
- Inheritance
- Abstract Contracts
- Interfaces
- Libraries
- Using For
- Inline Assembly
- Cheatsheet
- Language Grammar
编译器
内部说明
推荐内容