Skip to content

Instantly share code, notes, and snippets.

View sepisoltani's full-sized avatar
🎯
Focusing

Sepehr Soltani sepisoltani

🎯
Focusing
View GitHub Profile
contract Example{
function eatHotDogs(string memory _name, uint _amount) public {
}
}
contract Example{
eatHotDogs("sepehr", 100);
}
contract Example{
struct Person {
uint age;
string name;
}
Person[] public people;
function createNewPersonAndAddToArray() public {
contract Example{
uint[] numbers;
function _addToArray(uint _number) private {
numbers.push(_number);
}
}
contract Example{
string x = "hello";
function sayHello() public returns (string memory) {
return x;
}
}
contract Example{
string x = "hello";
function sayHello() public view returns (string memory) {
return x;
}
}
contract Example{
string name = "sepehr";
function _multiply(uint a, uint b) private pure returns (uint) {
return a * b;
}
}
contract Example{
function test() public {
//6e91ec6b618bb462a4a6ee5aa2cb0e9cf30f7a052bb467b0ba58b8748c00d2e5
keccak256(abi.encodePacked("aaaab"));
//b1f078126895a1424524de5321b339ab00408010b7cf0e6ed451514981e58aa9
keccak256(abi.encodePacked("aaaac"));
}
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);
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;