update chinese version content

This commit is contained in:
shooter 2018-12-25 15:05:13 +08:00
parent 484e1325ef
commit 84f9aa47fc
2 changed files with 35 additions and 28 deletions

View File

@ -5,6 +5,7 @@ contributors:
- ["Nemil Dalal", "https://www.nemil.com"] - ["Nemil Dalal", "https://www.nemil.com"]
- ["Joseph Chow", ""] - ["Joseph Chow", ""]
- ["Bhoomtawath Plinsut", "https://github.com/varshard"] - ["Bhoomtawath Plinsut", "https://github.com/varshard"]
- ["Shooter", "https://github.com/liushooter"]
--- ---
Solidity lets you program on [Ethereum](https://www.ethereum.org/), a Solidity lets you program on [Ethereum](https://www.ethereum.org/), a
@ -237,7 +238,7 @@ uint x[][5]; // arr with 5 dynamic array elements (opp order of most languages)
// Dictionaries (any type to any other type) // Dictionaries (any type to any other type)
mapping (string => uint) public balances; mapping (string => uint) public balances;
balances["charles"] = 1; balances["charles"] = 1;
// balances["ada"] is 0, all non-set key values return zeroes // balances["ada"] result is 0, all non-set key values return zeroes
// 'public' allows following from another contract // 'public' allows following from another contract
contractName.balances("charles"); // returns 1 contractName.balances("charles"); // returns 1
// 'public' created a getter (but not setter) like the following: // 'public' created a getter (but not setter) like the following:

View File

@ -6,6 +6,7 @@ contributors:
- ["Nemil Dalal", "https://www.nemil.com"] - ["Nemil Dalal", "https://www.nemil.com"]
- ["Joseph Chow", ""] - ["Joseph Chow", ""]
- ["Bhoomtawath Plinsut", "https://github.com/varshard"] - ["Bhoomtawath Plinsut", "https://github.com/varshard"]
- ["Shooter", "https://github.com/liushooter"]
translators: translators:
- ["Bob Jiang", "https://github.com/bobjiang"] - ["Bob Jiang", "https://github.com/bobjiang"]
--- ---
@ -217,7 +218,7 @@ uint x[][5]; // 5个动态数组元素的数组(和多数语言的顺序相反)
// 字典类型 (任一类型到其他类型的映射) // 字典类型 (任一类型到其他类型的映射)
mapping (string => uint) public balances; mapping (string => uint) public balances;
balances["charles"] = 1; balances["charles"] = 1;
console.log(balances["ada"]); // 所有没有设定key值的返回0 // balances["ada"]得到 0, 所有没有设定key值的返回0
// 'public' 允许跟着(调用)另一份合约 // 'public' 允许跟着(调用)另一份合约
contractName.balances("charles"); // returns 1 contractName.balances("charles"); // returns 1
// 'public' 创建 getter (而不是 setter )如下: // 'public' 创建 getter (而不是 setter )如下:
@ -373,17 +374,22 @@ event LogSent(address indexed from, address indexed to, uint amount); // 注意
// 调用 // 调用
LogSent(from, to, amount); LogSent(from, to, amount);
// 对于外部方(合约或外部实体),使用 Web3 Javascript 库来监听 /*
Coin.LogSent().watch({}, '', function(error, result) { // 对于外部方(合约或外部实体),使用 Web3 Javascript 库来监听
if (!error) { // 以下是javascript代码,不是solidity代码
console.log("Coin transfer: " + result.args.amount + Coin.LogSent().watch({}, '', function(error, result) {
" coins were sent from " + result.args.from + if (!error) {
" to " + result.args.to + "."); console.log("Coin transfer: " + result.args.amount +
console.log("Balances now:\n" + " coins were sent from " + result.args.from +
"Sender: " + Coin.balances.call(result.args.from) + " to " + result.args.to + ".");
"Receiver: " + Coin.balances.call(result.args.to)); console.log("Balances now:\n" +
"Sender: " + Coin.balances.call(result.args.from) +
"Receiver: " + Coin.balances.call(result.args.to));
}
} }
}
*/
// 一个合约依赖另一个合约的共同范例(例如,合约取决于另一个合约提供的当前汇率) // 一个合约依赖另一个合约的共同范例(例如,合约取决于另一个合约提供的当前汇率)
// C. 修饰器 // C. 修饰器