Created
February 28, 2023 01:14
-
-
Save duanescarlett/1301dffdb65431c42f63eeb8a17d95fc to your computer and use it in GitHub Desktop.
This is for a tutorial that teaches datatypes
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.8.17; | |
contract VariablesAndDataTypes { | |
// State Variables | |
int256 public oneIng = 1; | |
uint256 public oneUint = 1; | |
// Local Variable | |
function getValue() public pure returns(uint256) { | |
uint256 value = 1; | |
return value; | |
} | |
// Strings and Bytes32 | |
string public helloWorld = "Hello World!!"; | |
bytes32 public helloWorld32 = "Hello World!!"; | |
// Addresses | |
address public myAddress = 0xC96146959790EfB2e354802f664090fCc75296D6; | |
// Struct | |
struct AuctionItem { | |
address nftContract; | |
address payable seller; | |
address payable royaltyAddress; | |
uint256 itemId; | |
uint256 tokenId; | |
uint256 floorPrice; | |
uint256 royalty; | |
bool sold; | |
bool started; | |
bool ended; | |
} | |
// Data Types | |
bool public a = true; | |
// uint256 = 0 to 2**256 - 1 | |
uint256 public u256 = 321; | |
// uint8 = 0 to 2**8 - 1 | |
uint8 public u8 = 32; | |
// uint16 = 0 to 2**16 - 1 | |
uint16 public u16 = 321; | |
// int256 = -2**256 - 1 to 2**256 - 1 | |
int256 public i256 = -321; | |
// int8 = -2**8 - 1 to 2**8 - 1 | |
int8 public i8 = -32; | |
int256 public minInt = type(int256).min; | |
uint256 public maxUint = type(uint256).max; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment