Skip to content

Commit 05fd3ac

Browse files
authored
Merge pull request #750 from arc0035/main
[Translation] Fix typos and make English README as default
2 parents dd889cd + 2af31db commit 05fd3ac

File tree

6 files changed

+108
-108
lines changed

6 files changed

+108
-108
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ We have collected a list of classic blockchain-related books to help developers
7474

7575
At the same time, feel free to keep expanding this [book list](./docs/books.md).
7676

77-
**Encryption course**
77+
**Cryptographic course**
7878

7979
We have collected some crypto courses from top universities and the Ethereum community to help developers systematically understand blockchain and cryptocurrencies.
8080
- [MIT Online Course: Blockchain and Money by Prof. Gary Gensler](https://ocw.mit.edu/courses/sloan-school-of-management/15-s12-blockchain-and-money-fall-2018/video-lectures/)

basic/41-nft-farming/README-CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## NFT Farming
2+
- NFT farming is all about earning rewards for on-chain activity on a platform.
3+
## 概述
4+
- NFT farming,与Defi中的yield farming类似,但其使用的是NFT而非token,近年Onchain APP的发展推动流动性较低的NFT也可以farming。
5+
- 传统方法的NFT Farming,即就是将NFT质押成某一种特定的token,添加NFT-token的交易对进行farming。
6+
- 游戏化的NFT Farming,即就是将获取NFT的过程编写成游戏,NFT作为游戏道具,与游戏中设计的Token进行交易转换,通过流动性Farming。
7+
## 参考链接
8+
- https://coinquora.com/what-is-nft-farming-and-how-does-nft-farming-work/
9+
- https://superfarm.com/farms

basic/41-nft-farming/README-en.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

basic/41-nft-farming/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
## NFT Farming
22
- NFT farming is all about earning rewards for on-chain activity on a platform.
3-
## 概述
4-
- NFT farming,与Defi中的yield farming类似,但其使用的是NFT而非token,近年Onchain APP的发展推动流动性较低的NFT也可以farming。
5-
- 传统方法的NFT Farming,即就是将NFT质押成某一种特定的token,添加NFT-token的交易对进行farming。
6-
- 游戏化的NFT Farming,即就是将获取NFT的过程编写成游戏,NFT作为游戏道具,与游戏中设计的Token进行交易转换,通过流动性Farming。
7-
## 参考链接
3+
4+
## Overview
5+
6+
- NFT farming has similiarities to yield farming in DeFi sector but differs in that it involves NFTs as either stakings or rewards: Holders can stake NFTs for FTs and vice versa.As Dapp is developing so fast these years, even illiquid NFT could be used for farming.
7+
8+
- In a traditional manner, NFT Farming requires user to acquire specific token by depositing NFTs, then add it to some NFT-token pairs to farm.
9+
10+
- In a gamefied manner, where the lifecyle of NFTs is encapusulated into games, you can swap in-game items for tokens to do yield farming.
11+
12+
13+
## References
814
- https://coinquora.com/what-is-nft-farming-and-how-does-nft-farming-work/
915
- https://superfarm.com/farms

basic/42-merkle-distributor-airdrop/README-en.md renamed to basic/42-merkle-distributor-airdrop/README-CN.md

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Merkle Distributor Airdrop
22

3-
## Introduction
3+
## 介绍
44

55
### NFT merkle airdrop
66

7-
This demo introduces 5 methods for NFT-airdrop:
8-
- Airdrop to specific address
9-
- A signature implying the beneficiary is submitted to blockchain for verification and airdropping
10-
- A signature following EIP-712 is submitted to blockchain for verification and airdropping
11-
- A signature following EIP-712 is submitted to blockchain for verification ,signature check and airdropping
12-
- A merkle proof is submitted to blockchain for verification and airdropping
7+
本样例介绍了 5 种 NFT 空投方式
8+
9+
- 直接对特定账户进行空投
10+
- 线下签名,线上验证通过后空投
11+
- 线下 EIP-712 方式签名, 线上验证后空投
12+
- 线下 EIP-712 方式签名, 线上进行 EIP-712 验证, Signature Check
13+
- 线下生成 Merkle 证明, 线上 Merkle 验证
1314

1415
### ERC20 merkle airdrop
1516

16-
Kindly refer to 1inch, dydx, uniswap for more details, all the projects utilize merkle proof for airdropping. Please read more for details:
17+
参考 1inchdydxuniswap 都实现 merkle 空投。 具体原理请参考:
1718

1819
- <https://itzone.com.vn/en/article/merkle-airdrop-the-airdrop-solution-for-token-issues/>
1920

20-
### Demo: Red packet
21-
22-
We present a demo in which you can airdrop to your friends on holiday!
21+
### 抢红包
2322

24-
Please refer to the code: contracts/redpacket
23+
本样例演示了抢红包合约的功能, 在节假日的时候可以部署相应的合约进行红包发放.
24+
对应合约路径为 contracts/redpacket
2525

26-
## Demo instruction
26+
## 合约功能说明
2727

2828
- ERC721Basic
29-
The most simple demo where the issuer can airdrop NFT to specific address by calling "mint" :
29+
最简单的 NFT 空投合约, 项目方直接调用 mint 接口, 对指定账户投放 NFT
3030

3131
```js
3232
//
@@ -36,23 +36,22 @@ Please refer to the code: contracts/redpacket
3636
```
3737

3838
- ERC721LazyMint
39-
This is a demo where airdropping happens after verification. Considier the following case: Before the real "mint" is called on blockchain, the issuer firstly send an email containing the token id to the user, who will respond with a signature created with this token id. Then, the issuer wraps user address(fetched from some database), token id and signature as input to calls "redeem" of the NFT contract, which will mint a new NFT to the target user on verification success.
40-
39+
经过验证的空投方式. 可能在下面这种场景中出现, 比如项目方准备空投 NFT 给一些用户, 那么项目方先发送一个邮件给该用户, 邮件中包含此 NFT 的 tokenID. 用户收到邮件后, 在线下根据 toukenID 和 账户地址进行签名, 然后发送给项目方. 项目方拿到用户签名后, 调用空投合约的 redeem 接口, 传入 account, tokenId, signature. 其中 account, tokenId 需要从预先保留的项目方数据库中获取, 以验证该用户确实对应该 NFT. 如果验证通过, 则生成一个 NFT 给该用户.
4140

4241
```js
43-
// Signature
42+
// 签名
4443
this.token.signature = await this.accounts[1].signMessage(hashToken(this.token.tokenId, this.token.account));
4544

46-
// Post the signature to blockchain
45+
// 签名上链验证
4746
await expect(this.registry.redeem(this.token.account, this.token.tokenId, this.token.signature))
4847
.to.emit(this.registry, 'Transfer')
4948
.withArgs(ethers.constants.AddressZero, this.token.account, this.token.tokenId);
5049
```
5150

5251
- ERC721LazyMintWith712
53-
In the above example, we create signature with a parameter maybe friendly to machine but not that friendly to humans. Moreover, when Metamask pops up for signing we do not know what is being signed. We prefer a more structured, more readable scheme for us to see what data will be signed. EIP-712 address this point; It can display the data to be signed to user, and the generated signature will be verified by smart contract. The whole process is similiar to that in ERC721LazyMint.
54-
55-
Here is a example for creating signature by EIP-712:
52+
在传统的签名方式中, 我们直接调用签名接口, 传入需要的签名参数, 这个过程中我们无法直观的感知需要签名具体参数意义, 特别是当 MetaMask 弹出提示, 需要你对一笔数据进行签名时, 如果不能结构化的看到需要签名的具体数据, 我们可能会拒绝签名这笔交易.
53+
EIP-712 就是在用户签名时把结构化数据展示给他们确认的场景. 之后链上确认签名是否正确, 过程和 ERC721LazyMint 类似
54+
链下签名样例如下:
5655

5756
```js
5857
// Domain
@@ -75,7 +74,7 @@ Please refer to the code: contracts/redpacket
7574
```
7675

7776
- ERC721LazyMintWith712SignatureChecker
78-
This demo is similiar to ERC721LazyMintWith712 but with a SignatureChecker inside.
77+
ERC721LazyMintWith712 类似, 唯一的区别就是在链上进行验证时, 增加了 SignatureChecker
7978

8079
```js
8180
function _verify(address signer, bytes32 digest, bytes memory signature)
@@ -86,96 +85,96 @@ Please refer to the code: contracts/redpacket
8685
```
8786

8887
- ERC721MerkleDrop
89-
A merkle proof is generated and sent to blockchain for verification, if valid, the newly created NTT is minted to specific user.
88+
链下生成 Merkle 证明, 之后把 Merkle 证明发送到链上进行验证, 验证通过后, 就会给用户生成相应的 NFT token
9089

9190
```js
92-
// Generate merkle proof offchain
91+
// 链下生成 Merkle 证明
9392
this.token.proof = this.merkleTree.getHexProof(hashToken(this.token.tokenId, this.token.account));
9493

95-
// Verify the proof and mint to some user. Whole process happens onchain.
94+
// 调用链上接口进行验证, 同时生成 NFT token
9695
await expect(this.registry.redeem(this.token.account, this.token.tokenId, this.token.signature))
9796
.to.emit(this.registry, 'Transfer')
9897
.withArgs(ethers.constants.AddressZero, this.token.account, this.token.tokenId);
9998
```
10099

101-
## Quickstart
100+
## 测试流程
102101

103102
### Merkle airdrop
104103

105-
- Install dependencies
104+
- 安装依赖
106105

107106
```bash
108107
yarn
109108
```
110109

111-
- Test
110+
- 执行测试程序
112111

113112
```bash
114113
npx hardhat test
115114
```
116115

117116
### HappyRedPacket
118117

119-
- Setup enviroments
118+
- 配置环境环境变量
120119

121120
```shell
122121
cp .env.exmpale .env
123122

124-
## Please configure PRIVATE_KEY, PRIVATE_KEY1, PRIVATE_KEY2,INFURA_ID, PROJECT_ID, TARGET_ACCOUNT in .env
125-
## PRIVATE_KEY is the private key of your wallet account , while TARGET_ACCOUNT is your wallet address.
126-
## If you want multiple accounts trying to claim the same redpacket, please configures multiple PRIVATE_KEYs.
123+
## 在 .env 文件中配置 PRIVATE_KEY, PRIVATE_KEY1, PRIVATE_KEY2,INFURA_ID, PROJECT_ID, TARGET_ACCOUNT
124+
## 比如有一个账户 A , 那么 PRIVATE_KEY 为账户 A 对应的 PRIVATE_KEY, TARGET_ACCOUNT 为账户 A 对应的账户地址
125+
## 模拟多人抢红包,需要配置三个私钥
127126
```
128127

129-
- Install dependencies
128+
- 安装依赖
130129

131130
```shell
132131
yarn
133132
```
134133

135-
- Deploy ERC20 smart contract
136-
Execute the following command and we take "Token address" from output as address of the deployed contract.
134+
- 部署 ERC20 合约
135+
执行如下命令,然后获取输出的 "Token address"
137136

138137
```shell
139138
npx hardhat run scripts/redpacket/1-deploySimpleToken.js --network kovan
140139

141-
## Console output
140+
## 输入信息如下:
142141
Deploying contracts with the account: 0x3238f24e7C752398872B768Ace7dd63c54CfEFEc
143142
Account balance: 796474026501725149
144143
Token address: 0xdc6999dC3f818B4f74550569CCC7C82091cA419F
145144
1000000000
146145
```
147146

148-
- Deploy RedPacket smart contract
149-
Execute the following command and we take "RedPacket address" from output as address of the deployed contract.
147+
- 部署 RedPacket 合约
148+
执行如下命令,然后获取输出的 "RedPacket address"
150149

151150
```shell
152151
npx hardhat run scripts/redpacket/2-deployHappyRedPacket.js --network kovan
153152

154-
## Console output
153+
## 输出信息如下:
155154
Deploying contracts with the account: 0x3238f24e7C752398872B768Ace7dd63c54CfEFEc
156155
Account balance: 783625061469463255
157156
RedPacket address: 0x6F35e57a7421F5b04DDb47b67453A5a5Be32e58B
158157
```
159158

160-
- Create a red packet
159+
- 创建红包
161160
```shell
162161
npx hardhat run scripts/redpacket/3-createRedPacket.js --network kovan
163162

164-
## Console output
163+
## 输出值
165164
Approve Successfully
166165
merkleTree Root: 0x5cc6f1ff34a2c6f871d40cdc4559468f96a7ec06d7bf6ab0f9b5aeccc9b33154
167166
CreationSuccess Event, total: 10000 RedpacketId: 0x45eb11e56a1b699f5e99bd16785c84b73a8257c712e0d1f31306ab1e3423b2e0
168167
Create Red Packet successfully
169168
```
170169

171-
- Claim packet
170+
- 领取红包
172171
```shell
173172
npx hardhat run scripts/redpacket/4-claimRedpacket.js --network kovan
174173

175-
## We can see "Sign Message:" followed by a signature verified by smart contract
174+
## 得到的输出 "Sign Message:" 即为领取红包时需要输入的签名信息,防止恶意领取
176175
```
177176

178-
## References
177+
## 参考链接
179178

180179
- <https://github.com/Anish-Agnihotri/merkle-airdrop-starter>
181180
- <https://github.com/OpenZeppelin/workshops/tree/master/06-nft-merkle-drop/contracts>

0 commit comments

Comments
 (0)