You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: junior-1/solidity/README.md
+68-2Lines changed: 68 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -69,8 +69,8 @@
69
69
## Типы. Reference types
70
70
71
71
1. Что можешь рассказать про reference types?
72
-
- Data location(storage, memory, calldata)
73
-
- Массивы(динамические и с фиксированной длиной)
72
+
- Data location(storage, memory, calldata)
73
+
- Массивы(динамические и с фиксированной длиной)
74
74
- Структуры
75
75
2. Как получить длину массива?
76
76
3. Как добавлять данные в массив?
@@ -173,3 +173,69 @@ contract C {
173
173
1. Что такое библиотека?
174
174
2. Как подключить библиотеку?
175
175
- Что такое using for?
176
+
177
+
178
+
## Интересные вопросы
179
+
180
+
1. Округление при делении.
181
+
- Какой ожидается результат вызова функции `roundingDivision()`? В чем заключается проблема? Как это можно обойти?
182
+
```solidity
183
+
function roundingDivision() external pure returns (uint256) {
184
+
return uint256(7) / uint256(5);
185
+
}
186
+
```
187
+
- Какой ожидается результат вызова функции `divisionByZero()`?
188
+
```solidity
189
+
function divisionByZero() external pure returns (uint256) {
190
+
return uint256(7) / 0;
191
+
}
192
+
```
193
+
2. Что произойдет при вызове функции `setOwner(addressB, anyAccount)` на контракте A? Чему будет равен вызов функций `manager()` и `owner()`? Почему важен порядок переменных в этих двух контрактах?
194
+
```solidity
195
+
contract A {
196
+
address public manager;
197
+
address public owner;
198
+
199
+
function setOwner(address target, address account) external {
Copy file name to clipboardExpand all lines: junior-2/solidity/README.md
+24-13Lines changed: 24 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@
25
25
pragma solidity 0.8.0;
26
26
27
27
contract Counter {
28
-
uint8 _counter= 255;
28
+
uint8 _counter= 255;
29
29
30
30
function increase() public payable {
31
31
_counter++;
@@ -42,10 +42,12 @@ contract Counter {
42
42
pragma solidity 0.8.0;
43
43
44
44
contract Counter {
45
-
uint8 _counter= 255;
45
+
uint8 _counter= 255;
46
46
47
47
function increase() public payable {
48
-
unchecked {_counter++;}
48
+
unchecked {
49
+
_counter++;
50
+
}
49
51
}
50
52
51
53
function getCounter() external view returns(uint8) {
@@ -56,16 +58,18 @@ contract Counter {
56
58
57
59
```solidity
58
60
// SPDX-License-Identifier: MIT
59
-
pragma solidity 0.7.0;
61
+
pragma solidity 0.8.0;
60
62
61
63
contract Counter {
62
-
uint8 _counter= 255;
64
+
int8 _counter= -128;
63
65
64
-
function increase() public payable {
65
-
_counter++;
66
+
function decrease() public payable {
67
+
unchecked {
68
+
_counter--;
69
+
}
66
70
}
67
71
68
-
function getCounter() external view returns(uint8) {
72
+
function getCounter() external view returns(int8) {
69
73
return _counter;
70
74
}
71
75
}
@@ -76,13 +80,19 @@ contract Counter {
76
80
pragma solidity 0.8.0;
77
81
78
82
contract Counter {
79
-
int8 _counter= -128;
83
+
uint8 _counter = 255;
80
84
81
-
function decrease() public payable {
82
-
unchecked {_counter--;}
85
+
function increase() public payable {
86
+
unchecked {
87
+
_increase();
88
+
}
83
89
}
84
90
85
-
function getCounter() external view returns(int8) {
91
+
function _increase() private {
92
+
_counter++;
93
+
}
94
+
95
+
function getCounter() external view returns(uint8) {
86
96
return _counter;
87
97
}
88
98
}
@@ -268,7 +278,7 @@ contract Counter {
268
278
269
279
1. Какие есть два возможных способа создания контрактов?
270
280
2. Как создать контракт через new? Что на самом деле внутри происходит при создании таким способом?
271
-
3. Для чего нужен constructor? Сколько раз он вызывается? Можно ли делать перегрузку для constructor?
281
+
3. Для чего нужен constructor? Сколько раз он вызывается? Можно ли делать перегрузку для constructor? Является ли constructor частью байт-кода контракта?
272
282
4. Как передать эфир при создании контракта?
273
283
5. Как создать контракт через create? Как создать контракт через create2? Какие различия между create и create2? Как у них происходит образование адреса контракта? Почему не безопасно создавать через create?
274
284
6. Можно ли каким-то образом передеплоить смарт-контракт на тот же адрес но с другим кодом?
0 commit comments