File tree Expand file tree Collapse file tree 4 files changed +97
-0
lines changed
javascript-developer/solidity Expand file tree Collapse file tree 4 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 1+ # contract
2+
3+ as like other oop language solidity has contract that is similar to class.
4+
5+ ``` sol
6+ contract Code4mk {
7+ // code will be here
8+ }
9+ ```
10+
11+ ## visibility
12+
13+ Solidity has 4 types visibility.
14+
15+ 1 . external
16+ 2 . internal
17+ 3 . public
18+ 4 . private
19+
20+ ### external
21+
22+ ` external ` function can accessable from own contract and other contract too.
23+
24+ ``` sol
25+ function test() pure external returns(string memory){
26+ return('external function');
27+ }
28+ ```
29+
30+ * access by ` this.f() `
31+
32+ ### public
33+
34+ ` public ` access from any where as like other oop language.
35+
36+ ### internal
37+
38+ ` internal ` only accessable from internally.
39+
40+
41+
42+
43+
44+ # source
45+
46+ * [ official contract] ( https://solidity.readthedocs.io/en/latest/contracts.html )
Original file line number Diff line number Diff line change 1+
2+
3+ # define solidity version
4+
5+ on the top of code you need to assign solidity version with pragma
6+
7+ ``` sol
8+ pragma solidity "0.5.1";
9+ ```
10+
11+ * string must be double quote.
12+
13+
14+ ## constructor
15+
16+ solidity constructor simillar other oop langauge.
17+
18+ ``` sol
19+ contract Code4mk {
20+ string name;
21+ constructor(string memory _name) public {
22+ name = _name;
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ # modifier
2+
3+ * modifier change the function behaviour. it woeks as like middleware also.
4+
5+ ``` sol
6+ modifier onlyOwner {
7+ require(
8+ msg.sender == owner,
9+ "Only owner can call this function."
10+ );
11+ _;
12+ }
13+ // use modifier
14+ function human() view public onlyOwner {
15+ //
16+ }
17+ ```
18+
19+ * [ video coursestro] ( https://coursetro.com/posts/code/101/Solidity-Modifier-Tutorial---Control-Functions-with-Modifiers )
20+
21+ * [ modifier official] ( https://solidity.readthedocs.io/en/latest/contracts.html#function-modifiers )
22+ * [ video] ( https://youtu.be/qkBAwyJWjLA?list=PLL5pYVd8AWtQJ3Ne1nkBbrQpD7L8C36SF&t=397 )
Original file line number Diff line number Diff line change 1+
2+
3+
4+ * https://medium.com/upstate-interactive/mappings-arrays-87afc697e64f
5+ * [ video courestro] ( https://coursetro.com/posts/code/102/Solidity-Mappings-&-Structs-Tutorial )
You can’t perform that action at this time.
0 commit comments