This file contains 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 ownable{ | |
address public owner; | |
constructor(){ | |
owner = msg.sender; | |
} | |
This file contains 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; | |
//data type & value type - references | |
contract valueType{ | |
bool public boolTemp = true; | |
uint public temp = 2335; | |
This file contains 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 funcIntro{ | |
uint age; | |
function add(uint _x,uint _y) public pure returns(uint){ | |
return _x + _y; |
This file contains 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 stateVariable{ | |
//state variable which is defined in contract but used outside of the functions | |
//state variable stored on blockchain block storage so we can't create extra state variable bcz its cost gas | |
uint public salary; | |
constructor(){ |
This file contains 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 localVariable{ | |
//local variable created in functions that are local | |
//when function work is done that local variable work washout from RAM as well | |
uint public age; | |
bool public b; | |
address public addr; | |
This file contains 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 gloablVariable{ | |
//predefined variable used in workspace is global variable | |
address public addr = msg.sender; | |
uint public timestamp = block.timestamp; | |
uint public diff = block.difficulty; | |
uint public gasprice = tx.gasprice; |
This file contains 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 viewAndPureFunctions{ | |
uint public age; | |
constructor(){ | |
age =20; | |
} |
This file contains 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 defaultValue{ | |
uint public x; | |
bool public y; | |
string public str; | |
address public addr; | |
bytes32 public b32; |
This file contains 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 _string{ | |
string public str= "gateway"; //state variable | |
//constant keyword variable charge lower gas than other variable | |
address public constant ownerAddress = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4; //lower gas cost |
This file contains 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 CONSTRUCTOR{ | |
//contract level | |
/** | |
inside the contract and outside of function | |
**/ | |
uint public age; |
OlderNewer