This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract A{ | |
uint private x= 100; | |
uint public y =200; | |
address private addr = msg.sender; | |
function fun1() public pure returns(string memory){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract Events{ | |
//event is used to set the values on blockchain. | |
event balance(address account,string message,uint val); | |
//this function transaction function or simple function because its have no return did change any state variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
// in multiple inhertiance | |
// Most Based Like to Most Derived | |
//Right to left - Depth First Manner | |
contract A{ | |
uint public a; | |
constructor(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract A{ | |
uint public a; | |
constructor(){ | |
a = 100; | |
} | |
function funA() public{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract A{ | |
string public name; | |
uint public age; | |
constructor(string memory _name,uint _age){ | |
name = _name; | |
age = _age; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract A{ | |
event log(string text,uint age); | |
function fun1() public virtual{ | |
emit log("A.fun1",21); | |
} | |
function fun2() public virtual{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract Require{ | |
address public owner = msg.sender; | |
uint public age = 25; | |
//when require condition is false than execution stopped and previously set the state variable goes to reset state | |
// and refund the gas fee. | |
function CheckAge(uint _x) public{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract RevertAssert{ | |
address public owner = msg.sender; | |
uint public age = 25; | |
function CheckAge(uint _x) public{ | |
age = age + 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract modifiers{ | |
address public owner = msg.sender; | |
uint public _xx = 10; | |
//modifier is used to reuse the same code from the starting or ending of the function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract Payable{ | |
// address make it payable | |
address payable public owner = payable(msg.sender); | |