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
contract Example{ | |
function eatHotDogs(string memory _name, uint _amount) 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
contract Example{ | |
eatHotDogs("sepehr", 100); | |
} |
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
contract Example{ | |
struct Person { | |
uint age; | |
string name; | |
} | |
Person[] public people; | |
function createNewPersonAndAddToArray() 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
contract Example{ | |
uint[] numbers; | |
function _addToArray(uint _number) private { | |
numbers.push(_number); | |
} | |
} |
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
contract Example{ | |
string x = "hello"; | |
function sayHello() public returns (string memory) { | |
return x; | |
} | |
} |
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
contract Example{ | |
string x = "hello"; | |
function sayHello() public view returns (string memory) { | |
return x; | |
} | |
} |
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
contract Example{ | |
string name = "sepehr"; | |
function _multiply(uint a, uint b) private pure returns (uint) { | |
return a * b; | |
} | |
} |
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
contract Example{ | |
function test() public { | |
//6e91ec6b618bb462a4a6ee5aa2cb0e9cf30f7a052bb467b0ba58b8748c00d2e5 | |
keccak256(abi.encodePacked("aaaab")); | |
//b1f078126895a1424524de5321b339ab00408010b7cf0e6ed451514981e58aa9 | |
keccak256(abi.encodePacked("aaaac")); | |
} |
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
contract Example{ | |
uint8 a = 5; | |
uint b = 6; | |
// throws an error because a * b returns a uint, not uint8: | |
uint8 c = a * b; | |
// we have to typecast b as a uint8 to make it work: | |
uint8 c = a * uint8(b); | |
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
contract Example{ | |
// declare the event | |
event IntegersAdded(uint x, uint y, uint result); | |
function add(uint _x, uint _y) public returns (uint) { | |
uint result = _x + _y; | |
// fire an event to let the app know the function was called: | |
emit IntegersAdded(_x, _y, result); | |
return result; |