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.6.0 <0.9.0; | |
contract Vars { | |
// State variables | |
uint age ; | |
address public myAddr = msg.sender; | |
function random() external view returns (uint){ |
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.6.0 <0.9.0; | |
contract PaymentData { | |
enum paymodes { | |
None, | |
Cash, | |
Crypto, | |
Online, | |
Cheque |
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.6.0 <0.9.0; | |
contract struct_sample { | |
struct myOrg { | |
string name; | |
uint num_emp; | |
} |
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.6.0 <0.9.0; | |
contract array_sample { | |
uint[] myDynArray ; // length is 0 | |
uint[] someVal = [1,2,3]; // length is 3 | |
// Check the content of each array | |
function getElements() public view returns (uint[] memory, uint[] memory){ | |
return (myDynArray, someVal); |
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.6.0 <0.9.0; | |
contract XYZ { | |
uint[] x; | |
function f1 (uint[] calldata _x) external { | |
x = _x ; | |
} |
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.6.0 <0.9.0; | |
contract map_demo { | |
mapping (address => uint) Eth_users; | |
function add_amnt(address _myadd, uint _amnt) external { | |
Eth_users[_myadd] = _amnt; |
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.6.0 <0.9.0; | |
contract demo_for { | |
uint public counter = 0; | |
function update_cnt() public { | |
for (uint i=0 ; i<10 ; i++){ |
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.6.0 <0.9.0; | |
contract demo_if { | |
uint x = 10; | |
function Compare (uint _x) external view returns (string memory){ | |
if (_x >= x) { // if section | |
return 'Given value is greater or equal to x';} | |
else { // else section | |
return 'Given value is less than x'; |
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.6.0 <0.9.0; | |
contract Consttr { | |
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.6.0 <0.9.0; | |
contract Event_sample { | |
event HighValueTx( | |
address _from, | |
address _to, | |
uint amount, | |
uint timeStamp | |
); |
NewerOlder