Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions zh-cn/1/contract_structure.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
<!-- Add translation for the following page: https://vyper.fun/#/1/contract_structure
Do NOT change the code below. The below code runs the code editor -->

# 第一章:契约(Contracts)

让我们从最基本的开始:

一份契约(Contract)是当创建以太坊(Ethereum)应用程序块时的基本 —— 所有变量以及函数都将属于一份契约,且它会成为你所有专案的起点。

Vyper的契约包含在文件中,每份文件只会拥有一份契约。

## 版本编译指示

Vyper支持一个版本编译指示,以确保一份契约只会被一个预期的编译器版本或一些版本范围编译。版本字串跟从[NPM](https://docs.npmjs.com/misc/semver)语法风格。

在此教学中,我们想用任何在`0.2.0`(含)到`0.3.0`(不含)之中的编译器版本来编译我们聪明的契约。它看起来就像是:

```vyper
# @version >=0.2.0 <0.3.0
```

## 来试试看吧

1. 在右侧的框中,让我们来创建一份可以被任何在`0.2.4`(含)到`0.3.0`(不含)之中的编译器版本编译的契约。

2. 当你完成时,你可以从`🛠 你的代码`标签转到`✅ 答案`标签来看看你的答案是不是与标准答案相同(标签在荧幕的右下方).

3. 利用`𝌡 区别`标签来查看`🛠 你的代码`与`✅ 答案`的分别。

4. 如你有任何疑问,你可以在`打开聊天`来在聊天框里询问 😊

恭喜🎉

你刚刚完成了第一章,来分享一下你的壮举吧!

[![Tweet](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fvyper.fun%2F%23%2F1%2Fcontract_structure)](https://twitter.com/intent/tweet?hashtags=VyperFun&ref_src=twsrc%5Etfw&text=I%20just%20completed%20Chapter%201%20of%20%40VyperFun%3A%20Create%20your%20Pok%C3%A9mon%20on%20blockchain%20using%20%40vyperlang%20%F0%9F%98%8E%20&tw_p=tweetbutton&url=https%3A%2F%2Fvyper.fun%2F%23%2F1%2Fcontract_structure)

<!-- tabs:start -->

#### ** Template **
Expand Down
4 changes: 4 additions & 0 deletions zh-cn/1/introduction.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<!-- Add translation for the following page: https://vyper.fun/#/1/introduction
Do NOT change the code below. The below code runs the code editor -->

# 创造属于你的第一个宝可梦!

在这个单元里,我们会学习Vyper的基础来创造属于你的第一个宝可梦。
40 changes: 40 additions & 0 deletions zh-cn/1/state_vars_and_ints.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
<!-- Add translation for the following page: https://vyper.fun/#/1/state_vars_and_ints
Do NOT change the code below. The below code runs the code editor -->

# 第二章:状态变量,整数及常量

做得不错!现在我们已经摸索过契约,让我们来学习一下Vyper是如何处理变量吧。

状态变量(State variables)会被永久储存在契约的存储中,这表示它们会被写入以太坊区块链(Ethereum blockchain)。想象一下它们就像是在写入进一个资料库。

### 例子

```vyper
# @version >=0.2.4 <0.3.0

# 这会被永久储存到区块链中
storedData: int128
```

在这个例子中, 我们创建了一个名叫`storedData`的[`int128`](https://vyper.readthedocs.io/en/stable/types.html#signed-integer-128-bit)。它的*默认值*为`1`。

## 无符号整数:`uint256`

`uint256`资料类型是一个无符号整数(占256位元),意味着他的值一定不是负数。

另外也有带有符号整数的`int128`(占128位元)资料类型(它可以储存正数及负数)。

### 例子

```vyper
# @version >=0.2.4 <0.3.0

# 这会创建一个值为10的uint256常量(Constant)
TEN: constant(uint256) = 10
```

在这个例子中,我们创建了一个名为`TEN`的`uint256` `常量`并把它的值设为`10`。

## 来试试看吧

我们的宝可梦DNA将会被判断成一串16位的数字。

在右侧的编码范围,声明一个名为`DNA_DIGITS`的`uint256` `常量`,并把它的值设置为`16`。

<!-- tabs:start -->

#### ** Template **
Expand Down
8 changes: 8 additions & 0 deletions zh-cn/2/introduction.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
<!-- Add translation for the following page: https://vyper.fun/#/2/introduction
Do NOT change the code below. The below code runs the code editor -->

# 把宝可梦们统统收进精灵球!

在这个单元里,我们会学习Vyper的一些更高阶的概念来创建宝可梦训练员。

每个人都可以成为一名宝可梦训练员,且都会得到一个宝可梦。训练员们可以和野生的宝可梦战斗 ⚔️,还可以捕捉它们哦。

来看看你可不可以成为一个合格的训练员,把宝可梦们统统收进精灵球吧。😉