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-License | |
pragma solidity ^0.8.0; | |
contract first_sample { | |
} |
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: UNLICENSED | |
pragma solidity ^0.8.0; | |
uint constant T = 10; | |
contract Arithmetic_Operation { | |
uint x = 10; | |
uint y = 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: UNLICENSED | |
pragma solidity ^0.8.0; | |
uint constant T = 10; | |
contract Logical_Operation { | |
uint x = 10; | |
uint y = 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.0; | |
contract comparison_operator { | |
uint x = 10; | |
uint y = 12; | |
int z = 10; | |
// Less than | |
bool res = x < y; // res = true |
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.0; | |
contract bitwise_operator { | |
bytes1 x = 0x16; // bit representation: 00010110 | |
bytes1 y = 0x11; // bit representation: 00010001 | |
// Bitwise 'AND' | |
bytes1 byte_and = x & y; // 00010110 & 00010001 -> 00010000 -> in byte (0x10) |
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: GPL-3.0 | |
pragma solidity >=0.5.0 <0.9.0; | |
// code for view type function | |
contract sample { | |
uint s = 10; | |
function f_name(uint _a) public view returns (uint) { | |
return _a + block.number; | |
} |
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 | |
); |
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 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 demo_for { | |
uint public counter = 0; | |
function update_cnt() public { | |
for (uint i=0 ; i<10 ; i++){ |
OlderNewer