Skip to content

Commit

Permalink
Merge pull request #767 from PolymetisOutis/WTF_ja_101_1_11_modify
Browse files Browse the repository at this point in the history
Wtf ja 101 1 11 modify
  • Loading branch information
AmazingAng authored Aug 4, 2024
2 parents f4e86eb + a41512f commit 5bd3519
Show file tree
Hide file tree
Showing 18 changed files with 203 additions and 100 deletions.
41 changes: 21 additions & 20 deletions Languages/ja/02_ValueTypes_ja/ValueTypes.sol
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
contract ValueTypes{
// Boolean
// Boolean(真偽値型)
bool public _bool = true;
// Boolean operators
bool public _bool1 = !_bool; // logical NOT
bool public _bool2 = _bool && _bool1; // logical AND
bool public _bool3 = _bool || _bool1; // logical OR
bool public _bool4 = _bool == _bool1; // equality
bool public _bool5 = _bool != _bool1; // inequality
// Boolean operators(論理演算子)
bool public _bool1 = !_bool; // logical NOT     (否定)
bool public _bool2 = _bool && _bool1; // logical AND(論理積)
bool public _bool3 = _bool || _bool1; // logical OR (論理和)
bool public _bool4 = _bool == _bool1; // equality (等価)
bool public _bool5 = _bool != _bool1; // inequality(不等価)


// Integer
// Integer(整数型)
int public _int = -1;
uint public _uint = 1;
uint256 public _number = 20220330;
// Integer operators
// Integer operators(整数型の演算子)
uint256 public _number1 = _number + 1; // +,-,*,/
uint256 public _number2 = 2**2; // exponent
uint256 public _number3 = 7 % 2; // modulo (modulus)
bool public _numberbool = _number2 > _number3; // greater than
uint256 public _number2 = 2**2; // exponent     (べき乗)
uint256 public _number3 = 7 % 2; // modulo (modulus)(剰余(モジュロ))
bool public _numberbool = _number2 > _number3; // greater than(大なり)


// Address data type
// Address data type(アドレス型)
address public _address = 0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71;
address payable public _address1 = payable(_address); // payable address (allows for token transfer and balance checking)
// Members of addresses
uint256 public balance = _address1.balance; // balance of address
//(ペイアブルなアドレス(トークンの移動や残高の確認が可能))
// Members of addresses(アドレスのメンバ)
uint256 public balance = _address1.balance; // balance of address(アドレスの残高)


// Fixed-size byte arrays
// Fixed-size byte arrays(固定長配列)
bytes32 public _byte32 = "MiniSolidity"; // bytes32: 0x4d696e69536f6c69646974790000000000000000000000000000000000000000
bytes1 public _byte = _byte32[0]; // bytes1: 0x4d


// Enumeration
// Let uint 0, 1, 2 represent Buy, Hold, Sell
// Enumeration(列挙型)
// Let uint 0, 1, 2 represent Buy, Hold, Sell(uint型の0,1,2がBuy,Hold,Sellを表すとする)
enum ActionSet { Buy, Hold, Sell }
// Create an enum variable called action
// Create an enum variable called action(actionという列挙型変数を作成)
ActionSet action = ActionSet.Buy;

// Enum can be converted into uint
// Enum can be converted into uint(列挙型はuint型に変換出来る)
function enumToUint() external view returns(uint){
return uint(action);
}
Expand Down
51 changes: 26 additions & 25 deletions Languages/ja/02_ValueTypes_ja/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Booleanはバイナリ変数で、その値は`true``false`です。

```solidity
// Boolean
// Boolean(真偽値型)
bool public _bool = true;
```

Expand All @@ -44,12 +44,12 @@ Boolean型の演算子には次のものがあります:
ソースコード:

```solidity
// Boolean operators
bool public _bool1 = !_bool; // logical NOT
bool public _bool2 = _bool && _bool1; // logical AND
bool public _bool3 = _bool || _bool1; // logical OR
bool public _bool4 = _bool == _bool1; // equality
bool public _bool5 = _bool != _bool1; // inequality
// Boolean operators(論理演算子)
bool public _bool1 = !_bool; // logical NOT(否定)
bool public _bool2 = _bool && _bool1; // logical AND(論理積)
bool public _bool3 = _bool || _bool1; // logical OR (論理和)
bool public _bool4 = _bool == _bool1; // equality (等価)
bool public _bool5 = _bool != _bool1; // inequality (不等価)
```

上記のソースコードより: 変数`_bool`の値は`true`; `_bool1``_bool`じゃないので、`false`となる; `_bool && _bool1``false`; `_bool || _bool1``true`; `_bool == _bool1``false`; そして`_bool != _bool1``true`となります。
Expand All @@ -60,10 +60,10 @@ Boolean型の演算子には次のものがあります:
SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`があります。 最大256ビット型の整数やデータユニットを格納出来ます。

```solidity
// Integer
int public _int = -1; // integers including negative numbers
uint public _uint = 1; // non-negative numbers
uint256 public _number = 20220330; // 256-bit positive integers
// Integer(整数型)
int public _int = -1; // integers including negative numbers(負の数を含む整数型)
uint public _uint = 1; // non-negative numbers(非負の数)
uint256 public _number = 20220330; // 256-bit positive integers(256ビットの正の数)
```
よく使われる整数向け演算子には次のものがあります:

Expand All @@ -74,11 +74,11 @@ SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`が
ソースコード:

```solidity
// Integer operations
// Integer operations(整数演算)
uint256 public _number1 = _number + 1; // +, -, *, /
uint256 public _number2 = 2**2; // Exponent
uint256 public _number3 = 7 % 2; // Modulo (Modulus)
bool public _numberbool = _number2 > _number3; // Great than
uint256 public _number2 = 2**2; // Exponent (べき乗)
uint256 public _number3 = 7 % 2; // Modulo (Modulus)(剰余(モジュロ))
bool public _numberbool = _number2 > _number3; // Great than(大なり)
```

上記のソースコードを実行し、各変数の値をチェックすることが出来ます。
Expand All @@ -94,25 +94,26 @@ SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`が
ソースコード:

```solidity
// Address
// Address(アドレス型)
address public _address = 0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71;
address payable public _address1 = payable(_address); // payable address (can transfer fund and check balance)
// Members of address
uint256 public balance = _address1.balance; // balance of address
//(ペイアブルなアドレス(資金の移動と残高の確認が可能))
// Members of address(アドレスのメンバ)
uint256 public balance = _address1.balance; // balance of address(アドレスの残高)
```

### 4. Fixed-size byte arrays(固定サイズのバイト配列型
### 4. Fixed-size byte arrays(固定サイズのバイト配列(固定長配列)型

Solidityのバイト配列には2つの種類があります:

- 固定長のバイト配列: それぞれの要素のサイズ(最大32バイト)によって`byte``bytes8`, `bytes32`などを含む値型に属しています。配列の長さは宣言された後で変更されることは出来ません。
- 固定長のバイト配列(固定長配列): それぞれの要素のサイズ(最大32バイト)によって`byte``bytes8`, `bytes32`などを含む値型に属しています。配列の長さは宣言された後で変更されることは出来ません。

- 可変長バイト配列: `bytes`などを含み、参照型に属しています。配列の長さは宣言された後で変更することが可能です。後の章で詳しく学んでいきます。
- 可変長バイト配列(可変長配列): `bytes`などを含み、参照型に属しています。配列の長さは宣言された後で変更することが可能です。後の章で詳しく学んでいきます。

ソースコード:

```solidity
// Fixed-size byte arrays
// Fixed-size byte arrays(固定長配列)
bytes32 public _byte32 = "MiniSolidity";
bytes1 public _byte = _byte32[0];
```
Expand All @@ -128,16 +129,16 @@ Solidityのバイト配列には2つの種類があります:
ソースコード:

```solidity
// Let uint 0, 1, 2 represent Buy, Hold, Sell
// Let uint 0, 1, 2 represent Buy, Hold, Sell(uint型の0,1,2がBuy,Hold,Sellを表すとする)
enum ActionSet { Buy, Hold, Sell }
// Create an enum variable called action
// Create an enum variable called action(actionという列挙型変数を作成)
ActionSet action = ActionSet.Buy;
```

`uint`に容易に変換出来ます。

```solidity
// Enum can be converted into uint
// Enum can be converted into uint(列挙型はuint型に変換出来る)
function enumToUint() external view returns(uint){
return uint(action);
}
Expand Down
11 changes: 8 additions & 3 deletions Languages/ja/03_Function_ja/Function.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,39 @@ contract FunctionTypes{

constructor() payable {}

// function type
// function type(関数型)
// function (<parameter types>) {internal|external} [pure|view|payable] [returns (<return types>)]
// default function
// default function(デフォルトの関数)
function add() external{
number = number + 1;
}

// pure: not only does the function not save any data to the blockchain, but it also doesn't read any data from the blockchain.
//(pure: 関数がブロックチェーンにどんなデータも保存しないだけでなく、ブロックチェーンからデータを読み込むこともない)
function addPure(uint256 _number) external pure returns(uint256 new_number){
new_number = _number+1;
}

// view: no data will be changed
//(view: 何もデータが変更されない)
function addView() external view returns(uint256 new_number) {
new_number = number + 1;
}

// internal: the function can only be called within the contract itself and any derived contracts
//(internal: 関数は、コントラクトそのものの中か、あらゆる派生したコントラクト内でのみ呼び出されることが出来る)
function minus() internal {
number = number - 1;
}

// external: function can be called by EOA/other contract
//(external: 関数はEOAか他のコントラクトによって呼び出されることが出来る)
function minusCall() external {
minus();
}

//payable: money (ETH) can be sent to the contract via this function
// payable: money (ETH) can be sent to the contract via this function
//(payable: 関数を経由してお金(イーサリアム)をコントラクトに送金することが出来る)
function minusPayable() external payable returns(uint256 balance) {
minus();
balance = address(this).balance;
Expand Down
3 changes: 2 additions & 1 deletion Languages/ja/03_Function_ja/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Solidityにおける関数の書式を示します:

3. 他のコントラクトを作成する。

4. 自己破壊を使用する
4. selfdestructを使用する

5. callメソッドを通してイーサリアムを送金する。

Expand Down Expand Up @@ -149,6 +149,7 @@ Solidityにおける関数の書式を示します:

```solidity
// payable: money (ETH) can be sent to the contract via this function
//(payable: 関数を経由してお金(イーサリアム)をコントラクトに送金することが出来る)
function minusPayable() external payable returns(uint256 balance) {
minus();
balance = address(this).balance;
Expand Down
16 changes: 8 additions & 8 deletions Languages/ja/04_Return_ja/Return.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

// Return multiple variables
// Named returns
// Destructuring assignments
// Return multiple variables(複数の変数を返す)
// Named returns       (名前付き返り値)
// Destructuring assignments(分割代入)

contract Return {
// Return multiple variables
// Return multiple variables(複数の変数を返す)
function returnMultiple() public pure returns(uint256, bool, uint256[3] memory){
return(1, true, [uint256(1),2,5]);
}

// Named returns
// Named returns(名前付き返り値)
function returnNamed() public pure returns(uint256 _number, bool _bool, uint256[3] memory _array){
_number = 2;
_bool = false;
_array = [uint256(3),2,1];
}

// Named returns, still supports return
// Named returns, still supports return(名前付き返り値、通常のreturnステートメントも引き続きサポート)
function returnNamed2() public pure returns(uint256 _number, bool _bool, uint256[3] memory _array){
return(1, true, [uint256(1),2,5]);
}

// Read return values, destructuring assignments
// Read return values, destructuring assignments(返り値の読み込み、分割代入)
function readReturn() public pure{
// Read all return values
uint256 _number;
Expand All @@ -32,7 +32,7 @@ contract Return {
uint256[3] memory _array;
(_number, _bool, _array) = returnNamed();

// Read part of return values, destructuring assignments
// Read part of return values, destructuring assignments(返り値の一部を読み込み、分割代入)
(, _bool2, ) = returnNamed();
}
}
6 changes: 3 additions & 3 deletions Languages/ja/04_Return_ja/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- `return`は関数本体で使用され、予期された変数を返します。

```solidity
// returning multiple variables
// returning multiple variables(複数の変数を返す)
function returnMultiple() public pure returns(uint256, bool, uint256[3] memory){
return(1, true, [uint256(1),2,5]);
}
Expand All @@ -29,7 +29,7 @@
`returns`では返り値となる変数の名前を表明することができます。そうすることで、`solidity`は自動的にこれらの変数を初期化し、そして`return`キーワードを付与することなくこれらの関数の値を自動的に返すことができるようになります。

```solidity
// named returns
// named returns(名前付き返り値)
function returnNamed() public pure returns(uint256 _number, bool _bool, uint256[3] memory _array){
_number = 2;
_bool = false;
Expand All @@ -41,7 +41,7 @@

勿論、名前付き返り値に`return`キーワードを用いることによって変数を返すことも出来ます:
```solidity
// Named return, still support return
// Named return, still support return(名前付き返り値、通常のreturnステートメントも引き続きサポート)
function returnNamed2() public pure returns(uint256 _number, bool _bool, uint256[3] memory _array){
return(1, true, [uint256(1),2,5]);
}
Expand Down
Binary file added Languages/ja/05_DataStorage_ja/img/5-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Languages/ja/05_DataStorage_ja/img/5-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5bd3519

Please sign in to comment.