Logo
Section 1 / 9

Solidity 简介

简要了解 Solidity 以及它与其他常见编程语言的对比。

导入

Solidity 简介

简要了解 Solidity 以及它与其他常见编程语言的对比。

**Solidity** 是一种静态类型、面向对象的高级语言,用于在以太坊区块链上开发和实现智能合约。它是一种大括号语法的语言,使我们能够编写智能合约。

Solidity 受到 Python、C++ 和 JavaScript 等语言的深刻影响,并专为在 EVM(以太坊虚拟机)上运行而设计。

...
...

代码示例

1let x = 20; 2 3x = "new string";

代码示例

1uint x = 20; 2 3// 有效 4x = 40; 5 6// 会抛出错误 7x = "new string"
1contract TestContract { 2 address owner; 3 string testString; 4 5 constructor(string _testString) { 6 owner = msg.sender; 7 testString = _testString; 8 } 9 10 function changeString(string newString) public { 11 if (msg.sender == owner) { 12 testString = newString; 13 } 14 } 15}

区块链、以太坊与智能合约

使用 Remix IDE 编写代码