-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.sol
More file actions
58 lines (45 loc) · 1.03 KB
/
function.sol
File metadata and controls
58 lines (45 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: MIT;
pragma solidity ^0.8.7;
/* function f2() pure returns(uint) {
uint u = 120;
return u;
}
contract A {
function f3() external pure returns (string memory) {
string memory str = 'haha';
return str;
}
function f4() public pure {
f3();
}
}
contract B {
function f1() internal pure returns(bool) {
bool b = true;
return b;
}
function callInternal() public pure returns (bool) {
return f1();
}
function callExternal() public pure returns (uint) {
return f2();
}
function callContractFn(A a) public pure {
a.f3();
}
} */
contract A {
function f1() external pure returns (string memory) {
string memory str2 = 'hehe';
return str2;
}
function f2() public view {
// f1();//报错
this.f1();//正确
}
}
contract B {
function callContractFn(A a) public pure {
a.f1();
}
}