Created
February 12, 2022 15:55
-
-
Save lornawanjiru/85bcffdf61ae331c5309aeaefea2df4a to your computer and use it in GitHub Desktop.
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
//SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.11; | |
//Different data structures | |
contract Variable{ | |
// Fized size types which hold a fixed memory size | |
bool isReady; | |
uint a ; | |
address recepient; | |
//used mainly for strings that wont exceed 32byte | |
bytes32 data; | |
// Variables size type | |
string name ; | |
bytes _data; | |
// arrays have to be the same data type | |
uint[] amounts; | |
mapping (uint => string) users; | |
// User-defined data | |
struct User{ | |
uint id; | |
string name; | |
uint[] friendIds; | |
} | |
enum Color{ | |
RED, | |
GREEN, | |
BLUE | |
} | |
// For accessing the property | |
// Color.RED | |
} | |
contract MyFunc{ | |
uint value; | |
// view is a read only hence cant be modified | |
function getValue() external view returns(uint){ | |
return value; | |
} | |
//In the set we want to modify the value to the _value variable. | |
function setValue(uint _value) external { | |
value = _value; | |
} | |
} | |
//You can deploy as much as you want every deployment is independent. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment