SlideShare a Scribd company logo
The
CheatSheet
Solidity
Created by JS Mastery

Visit for more
jsmastery.pro
Don’tworryifyouareabeginnerandhavenoidea
abouthowSolidityworks,thischeatsheetwillgiveyou
aquickreferenceofthekeywords,variables,syntax
andbasicsthatyoumustknowtogetstarted.
AgreatwaytoexperimentwithSolidityistousean
onlineIDEcalledRemix.WithRemix,youcanloadthe
website,startcodingandrunyourfirstsmartcontract.
Solidityisanobject-orientedprogramminglanguage
forwritingsmartcontracts.Itisusedforimplementing
smartcontractsonvariousblockchainplatforms.
LearningSoliditydoesn'tmeanthatyouarerestricted
toonlytheEthereumBlockchain;itwillserveyouwell
onotherBlockchains.Solidityistheprimary
programminglanguageforwritingsmartcontracts
fortheEthereumblockchain.
Introduction
https://jsmastery.pro JavaScriptMastery
BroughttoyoubyJSM
Thisguidewillprovideyouwithuseful
informationandactionablesteps,butifyoutruly
wanttodominatethecompetitionandsecurea
high-payingjobasafull-stacksoftware
developer, istheanswer.
jsmastery.pro
Readuntiltheendformoreinformationand
specialdiscounts!
< >
header
< =” ”>
section id hero
< >
h1
< >
h1
< >
h2
</ >
h2
<!-- React.js -->
<!-- Next.js -->
Web Development
<!-- Blockchain -->
<!-- Solidity -->
< >
/h1
</ >
h1
Start Learning
Right Now
// With your help on
projects and watching your
videos I was able to land a
$110k/yr React job at a
company in San Diego, CA!
― Jake Simon
Full Stack Developer at Tragic Media
500k+ supporters
Say toJSMPro
https://jsmastery.pro JavaScript Mastery
Data Types
! Logical negation
&& AND
|| OR
== equality
!= inequality
Data type is a particular kind of data defined
by the values it can take
Logical:
Comparisons:
Boolean
https://jsmastery.pro JavaScript Mastery
Data Types
& AND
| OR
^ Bitwise XOR
~ Bitwise negation
<< Left Shift
>> Right Shift
Bitwise operators
https://jsmastery.pro JavaScript Mastery
Data Types
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
-- Decrement
Arithmetic Operators
https://jsmastery.pro JavaScript Mastery
Data Types
<= Less than or equal to
< Less than
== equal to
!= Not equal to
>= Greater than or equal to
> Greater than
Relational Operators
https://jsmastery.pro JavaScript Mastery
Data Types
= Simple Assignment
+= Add Assignment
-= Subtract Assignment
*= Multiply Assignment
/= Divide Assignment
%= Modulus Assignment
Assignment Operators
https://jsmastery.pro JavaScript Mastery
Value Types
This data type accepts only two values.

True or False.
Boolean
This data type is used to store integer values,
int and uint are used to declare signed and
unsigned integers respectively.
Integer
Address hold a 20-byte value which represents
the size of an Ethereum address. An address
can be used to get balance or to transfer a
balance by balance and transfer method
respectively.
Address
https://jsmastery.pro JavaScript Mastery
Value Types
Bytes are used to store a fixed-sized character
set while the string is used to store the
character set equal to or more than a byte. The
length of bytes is from 1 to 32, while the string
has a dynamic length.
Bytes and Strings
It is used to create user-defined data types,
used to assign a name to an integral constant
which makes the contract more readable,
maintainable, and less prone to errors. Options
of enums can be represented by unsigned
integer values starting from 0.
Enums
https://jsmastery.pro JavaScript Mastery
Reference Types
An array is a group of variables of the same
data type in which variable has a particular
location known as an index. By using the index
location, the desired variable can be accessed.
Array can be dynamic or fixed size array.
uint[] dynamicSizeArray;
uint[7] fixedSizeArray;
Arrays
https://jsmastery.pro JavaScript Mastery
Reference Types
Solidity allows users to create and define their
own type in the form of structures. The structure
is a group of different types even though it’s not
possible to contain a member of its own type.
The structure is a reference type variable which
can contain both value type and reference type
New types can be declared using Struct
struct Book { 

string title;

string author;

uint book_id;

}
Struct
https://jsmastery.pro JavaScript Mastery
Reference Types
Mapping is a most used reference type, that
stores the data in a key-value pair where a key
can be any value types. It is like a hash table or
dictionary as in any other programming
language, where data can be retrieved by key.
_KeyType can be any built-in types plus bytes
and string. No reference type or complex
objects are allowed.
mapping(_KeyType => _ValueType)
- can be any type.
_ValueType
Mapping
https://jsmastery.pro JavaScript Mastery
Import files
Syntax to import the files
or
import "filename";
import * as jsmLogo from "filename";
import "filename" as jsmLogo;
import {jsmLogo1 as alias, jsmLogo2} from "filename";
https://jsmastery.pro JavaScript Mastery
Function Visibility
Specifiers
function returns
return
() ( ) {

;

}

myFunction <visibility specifier> bool
true
visible externally and internally (creates a
getter function for storage/state
variables)
public
only visible in the current contract
private
https://jsmastery.pro JavaScript Mastery
Function Visibility
Specifiers
only visible externally (only for functions) - i.e.
can only be message-called (via this.func)
external
only visible internally
internal
https://jsmastery.pro JavaScript Mastery
Modifiers
for functions: Disallows modification or
access of state
pure
for functions: Disallows modification of state
view
for functions: Allows them to receive Ether
together with a call
payable
for events: Does not store event signature
as topic
anonymous
https://jsmastery.pro JavaScript Mastery
Modifiers
for event parameters: Stores the
parameter as topic
indexed
for functions and modifiers: Allows the
function’s or modifier’s behaviour to be
changed in derived contracts
virtual
States that this function, modifier or public
state variable changes the behaviour of a
function or modifier in a base contract
override
https://jsmastery.pro JavaScript Mastery
Modifiers
for state variables: Disallows assignment
(except initialisation), does not occupy
storage slot
constant
for state variables: Allows exactly one
assignment at construction time and is
constant afterwards. Is stored in code
immutable
https://jsmastery.pro JavaScript Mastery
Global Variables
current block’s base fee
block.basefee (uint)
current chain id
block.chainid (uint)
current block miner’s address
block.coinbase (address payable)
current block difficulty
block.difficulty (uint)
current block gaslimit
block.gaslimit (uint)
https://jsmastery.pro JavaScript Mastery
Global Variables
current block number
block.number (uint)
current block timestamp
block.timestamp (uint)
remaining gas
gasleft() returns (uint256)
complete calldata
msg.data (bytes
sender of the message (current call)
msg.sender (address)
https://jsmastery.pro JavaScript Mastery
Global Variables
number of wei sent with the message
msg.value (uint)
gas price of the transaction
tx.gasprice (uint)
sender of the transaction (full call chain)
tx.origin (address)
abort execution and revert state changes
if condition is false (use for internal error)
assert(bool condition)
https://jsmastery.pro JavaScript Mastery
Global Variables
abort execution and revert state changes if
condition is false
require(bool condition)
abort execution and revert state changes if
condition is false
require(bool condition, string memory message)
abort execution and revert state changes
revert()
abort execution and revert state changes
providing an explanatory string
revert(string memory message)
https://jsmastery.pro JavaScript Mastery
Global Variables
hash of the given block - only works for 256
most recent blocks
blockhash(uint blockNumber) returns (bytes32)
compute the Keccak-256 hash of the input
keccak256(bytes memory) returns (bytes32)
compute the SHA-256 hash of the input
sha256(bytes memory) returns (bytes32)
compute the RIPEMD-160 hash of the input
ripemd160(bytes memory) returns (bytes20)
https://jsmastery.pro JavaScript Mastery
Global Variables
abort execution and revert state changes if
condition is false
addmod(uint x, uint y, uint k) returns (uint)
compute(
x * y
) % k where the multiplication
is performed with arbitrary precision &
does not wrap around at 2**256
mulmod(uint x, uint y, uint k) returns (uint)
(current contract’s type): the current
contract, explicitly convertible to address
or address payable
this
https://jsmastery.pro JavaScript Mastery
Global Variables
the contract one level higher in the
inheritance hierarchy
super
destroy the current contract, sending its
funds to the given address
selfdestruct(address payable recipient)
balance of the Address in Wei
<address>.balance (uint256)
code at the Address (can be empty)
<address>.code (bytes memory)
https://jsmastery.pro JavaScript Mastery
Global Variables
the codehash of the Address
<address>.codehash (bytes32)
send given amount of Wei to Address,
returns false on failure
<address payable>.send(uint256 amount) returns (bool)
the name of the contract
type(C).name (string)
creation bytecode of the given contract
type(C).creationCode (bytes memory)
https://jsmastery.pro JavaScript Mastery
Global Variables
runtime bytecode of the given contract
type(C).runtimeCode (bytes memory)
value containing the EIP-165 interface
identifier of the given interface
type(I).interfaceId (bytes4)
the minimum value representable by the
integer type T
type(T).min (T)
the maximum value representable by the
integer type T
type(T).max (T)
https://jsmastery.pro JavaScript Mastery
Global Variables
ABI-decodes the provided data. The types
are given in parentheses as second
argument
abi.decode(bytes memory encodedData, (...)) returns (...)
ABI-encodes the given arguments
abi.encode(...) returns (bytes memory)
Performs packed encoding of the given
arguments.
abi.encodePacked(...) returns (bytes memory)
https://jsmastery.pro JavaScript Mastery
Global Variables
ABI-encodes the given arguments starting
from the second and prepends the given
four-byte selector
abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)
ABI-encodes a call to functionPointer with
the arguments found in the tuple. Performs
a full type-check, ensuring the types match
the function signature
abi.encodeCall(function functionPointer, (...)) returns (bytes memory)
Equivalent to
abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)
abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)
https://jsmastery.pro JavaScript Mastery
Global Variables
Concatenates variable number of
arguments to one byte array
bytes.concat(...) returns (bytes memory)
Concatenates variable number of
arguments to one string array
string.concat(...) returns (string memory)
https://jsmastery.pro JavaScript Mastery
Reserved Keywords
after
alias
apply
auto
byte
case
copyof
default
https://jsmastery.pro JavaScript Mastery
Reserved Keywords
define
final
implements
in
inline
let
macro
match
https://jsmastery.pro JavaScript Mastery
Reserved Keywords
mutable
null
of
partial
promise
reference
relocatable
sealed
https://jsmastery.pro JavaScript Mastery
Reserved Keywords
sizeof
static
supports
switch
typedef
typeof
var
https://jsmastery.pro JavaScript Mastery
JS Mastery Pro
Looking to advance your career and
understand the concepts & technologies that
top-shelf employers are looking for?
JS Mastery Pro offers two courses that will
help you master libraries, tools, and
technologies such as React.js, Next.js,
Material UI, Solidity, Redux, and many more.
If your goal is to earn a high income while
working on projects you love, JS Mastery Pro
can help you develop your skills to become
a top candidate for lucrative employment
and freelance positions.
https://jsmastery.pro JavaScript Mastery
Become a React.js master as you create a stunning
Netflix clone streaming app to showcase movies, actor
bios, and more with advanced AI voice functionality.
Leverage Web 3.0 and blockchain technology to build
a comprehensive NFT platform where users can
discover, create, purchase, & sell non-fungible tokens.
https://jsmastery.pro JavaScript Mastery
Collaborate with other developers on exciting monthly
group projects, have your code reviewed by industry
experts, and participate in mock interviews and live
Q&As. With two masterclass options available, this is
the best way to truly launch your programming career
and secure the job of your dreams!
Plus, if you really want to make a splash and add
multiple group projects to your portfolio, join the JSM
Masterclass Experience to set yourself above the rest
and impress hiring managers.
Visit today to get started!
jsmastery.pro
https://jsmastery.pro JavaScript Mastery

More Related Content

Similar to Solidity-CheatSheet.pdf

Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's NewTed Pennings
 
Flex Maniacs 2007
Flex Maniacs 2007Flex Maniacs 2007
Flex Maniacs 2007
rtretola
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
fastechsrv
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
Timur Shemsedinov
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questions
jbashask
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
Saltmarch Media
 
.Net Framework 2 fundamentals
.Net Framework 2 fundamentals.Net Framework 2 fundamentals
.Net Framework 2 fundamentals
Harshana Weerasinghe
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
Werner Keil
 
VB.net
VB.netVB.net
VB.net
PallaviKadam
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
Paras Mendiratta
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
ReactJS
ReactJSReactJS
React JS part 1
React JS part 1React JS part 1
React JS part 1
Diluka Wittahachchige
 
Solidity Contract: the code, compilation, deployment and accessing
Solidity Contract: the code, compilation, deployment and accessing Solidity Contract: the code, compilation, deployment and accessing
Solidity Contract: the code, compilation, deployment and accessing
KC Tam
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in react
Imran Sayed
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
Oliver Cai
 
Knockoutjs databinding
Knockoutjs databindingKnockoutjs databinding
Knockoutjs databinding
Boulos Dib
 
SystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.pptSystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.ppt
ravi446393
 
Learn java
Learn javaLearn java
Learn javaPalahuja
 

Similar to Solidity-CheatSheet.pdf (20)

Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
 
Flex Maniacs 2007
Flex Maniacs 2007Flex Maniacs 2007
Flex Maniacs 2007
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questions
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
.Net Framework 2 fundamentals
.Net Framework 2 fundamentals.Net Framework 2 fundamentals
.Net Framework 2 fundamentals
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
VB.net
VB.netVB.net
VB.net
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
ReactJS
ReactJSReactJS
ReactJS
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
 
Solidity Contract: the code, compilation, deployment and accessing
Solidity Contract: the code, compilation, deployment and accessing Solidity Contract: the code, compilation, deployment and accessing
Solidity Contract: the code, compilation, deployment and accessing
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in react
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Knockoutjs databinding
Knockoutjs databindingKnockoutjs databinding
Knockoutjs databinding
 
SystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.pptSystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.ppt
 
Learn java
Learn javaLearn java
Learn java
 

Recently uploaded

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

Solidity-CheatSheet.pdf

  • 1. The CheatSheet Solidity Created by JS Mastery Visit for more jsmastery.pro
  • 3. BroughttoyoubyJSM Thisguidewillprovideyouwithuseful informationandactionablesteps,butifyoutruly wanttodominatethecompetitionandsecurea high-payingjobasafull-stacksoftware developer, istheanswer. jsmastery.pro Readuntiltheendformoreinformationand specialdiscounts! < > header < =” ”> section id hero < > h1 < > h1 < > h2 </ > h2 <!-- React.js --> <!-- Next.js --> Web Development <!-- Blockchain --> <!-- Solidity --> < > /h1 </ > h1 Start Learning Right Now // With your help on projects and watching your videos I was able to land a $110k/yr React job at a company in San Diego, CA! ― Jake Simon Full Stack Developer at Tragic Media 500k+ supporters Say toJSMPro https://jsmastery.pro JavaScript Mastery
  • 4. Data Types ! Logical negation && AND || OR == equality != inequality Data type is a particular kind of data defined by the values it can take Logical: Comparisons: Boolean https://jsmastery.pro JavaScript Mastery
  • 5. Data Types & AND | OR ^ Bitwise XOR ~ Bitwise negation << Left Shift >> Right Shift Bitwise operators https://jsmastery.pro JavaScript Mastery
  • 6. Data Types + Addition - Subtraction * Multiplication / Division % Modulus ++ Increment -- Decrement Arithmetic Operators https://jsmastery.pro JavaScript Mastery
  • 7. Data Types <= Less than or equal to < Less than == equal to != Not equal to >= Greater than or equal to > Greater than Relational Operators https://jsmastery.pro JavaScript Mastery
  • 8. Data Types = Simple Assignment += Add Assignment -= Subtract Assignment *= Multiply Assignment /= Divide Assignment %= Modulus Assignment Assignment Operators https://jsmastery.pro JavaScript Mastery
  • 9. Value Types This data type accepts only two values. True or False. Boolean This data type is used to store integer values, int and uint are used to declare signed and unsigned integers respectively. Integer Address hold a 20-byte value which represents the size of an Ethereum address. An address can be used to get balance or to transfer a balance by balance and transfer method respectively. Address https://jsmastery.pro JavaScript Mastery
  • 10. Value Types Bytes are used to store a fixed-sized character set while the string is used to store the character set equal to or more than a byte. The length of bytes is from 1 to 32, while the string has a dynamic length. Bytes and Strings It is used to create user-defined data types, used to assign a name to an integral constant which makes the contract more readable, maintainable, and less prone to errors. Options of enums can be represented by unsigned integer values starting from 0. Enums https://jsmastery.pro JavaScript Mastery
  • 11. Reference Types An array is a group of variables of the same data type in which variable has a particular location known as an index. By using the index location, the desired variable can be accessed. Array can be dynamic or fixed size array. uint[] dynamicSizeArray; uint[7] fixedSizeArray; Arrays https://jsmastery.pro JavaScript Mastery
  • 12. Reference Types Solidity allows users to create and define their own type in the form of structures. The structure is a group of different types even though it’s not possible to contain a member of its own type. The structure is a reference type variable which can contain both value type and reference type New types can be declared using Struct struct Book { string title; string author; uint book_id; } Struct https://jsmastery.pro JavaScript Mastery
  • 13. Reference Types Mapping is a most used reference type, that stores the data in a key-value pair where a key can be any value types. It is like a hash table or dictionary as in any other programming language, where data can be retrieved by key. _KeyType can be any built-in types plus bytes and string. No reference type or complex objects are allowed. mapping(_KeyType => _ValueType) - can be any type. _ValueType Mapping https://jsmastery.pro JavaScript Mastery
  • 14. Import files Syntax to import the files or import "filename"; import * as jsmLogo from "filename"; import "filename" as jsmLogo; import {jsmLogo1 as alias, jsmLogo2} from "filename"; https://jsmastery.pro JavaScript Mastery
  • 15. Function Visibility Specifiers function returns return () ( ) { ; } myFunction <visibility specifier> bool true visible externally and internally (creates a getter function for storage/state variables) public only visible in the current contract private https://jsmastery.pro JavaScript Mastery
  • 16. Function Visibility Specifiers only visible externally (only for functions) - i.e. can only be message-called (via this.func) external only visible internally internal https://jsmastery.pro JavaScript Mastery
  • 17. Modifiers for functions: Disallows modification or access of state pure for functions: Disallows modification of state view for functions: Allows them to receive Ether together with a call payable for events: Does not store event signature as topic anonymous https://jsmastery.pro JavaScript Mastery
  • 18. Modifiers for event parameters: Stores the parameter as topic indexed for functions and modifiers: Allows the function’s or modifier’s behaviour to be changed in derived contracts virtual States that this function, modifier or public state variable changes the behaviour of a function or modifier in a base contract override https://jsmastery.pro JavaScript Mastery
  • 19. Modifiers for state variables: Disallows assignment (except initialisation), does not occupy storage slot constant for state variables: Allows exactly one assignment at construction time and is constant afterwards. Is stored in code immutable https://jsmastery.pro JavaScript Mastery
  • 20. Global Variables current block’s base fee block.basefee (uint) current chain id block.chainid (uint) current block miner’s address block.coinbase (address payable) current block difficulty block.difficulty (uint) current block gaslimit block.gaslimit (uint) https://jsmastery.pro JavaScript Mastery
  • 21. Global Variables current block number block.number (uint) current block timestamp block.timestamp (uint) remaining gas gasleft() returns (uint256) complete calldata msg.data (bytes sender of the message (current call) msg.sender (address) https://jsmastery.pro JavaScript Mastery
  • 22. Global Variables number of wei sent with the message msg.value (uint) gas price of the transaction tx.gasprice (uint) sender of the transaction (full call chain) tx.origin (address) abort execution and revert state changes if condition is false (use for internal error) assert(bool condition) https://jsmastery.pro JavaScript Mastery
  • 23. Global Variables abort execution and revert state changes if condition is false require(bool condition) abort execution and revert state changes if condition is false require(bool condition, string memory message) abort execution and revert state changes revert() abort execution and revert state changes providing an explanatory string revert(string memory message) https://jsmastery.pro JavaScript Mastery
  • 24. Global Variables hash of the given block - only works for 256 most recent blocks blockhash(uint blockNumber) returns (bytes32) compute the Keccak-256 hash of the input keccak256(bytes memory) returns (bytes32) compute the SHA-256 hash of the input sha256(bytes memory) returns (bytes32) compute the RIPEMD-160 hash of the input ripemd160(bytes memory) returns (bytes20) https://jsmastery.pro JavaScript Mastery
  • 25. Global Variables abort execution and revert state changes if condition is false addmod(uint x, uint y, uint k) returns (uint) compute( x * y ) % k where the multiplication is performed with arbitrary precision & does not wrap around at 2**256 mulmod(uint x, uint y, uint k) returns (uint) (current contract’s type): the current contract, explicitly convertible to address or address payable this https://jsmastery.pro JavaScript Mastery
  • 26. Global Variables the contract one level higher in the inheritance hierarchy super destroy the current contract, sending its funds to the given address selfdestruct(address payable recipient) balance of the Address in Wei <address>.balance (uint256) code at the Address (can be empty) <address>.code (bytes memory) https://jsmastery.pro JavaScript Mastery
  • 27. Global Variables the codehash of the Address <address>.codehash (bytes32) send given amount of Wei to Address, returns false on failure <address payable>.send(uint256 amount) returns (bool) the name of the contract type(C).name (string) creation bytecode of the given contract type(C).creationCode (bytes memory) https://jsmastery.pro JavaScript Mastery
  • 28. Global Variables runtime bytecode of the given contract type(C).runtimeCode (bytes memory) value containing the EIP-165 interface identifier of the given interface type(I).interfaceId (bytes4) the minimum value representable by the integer type T type(T).min (T) the maximum value representable by the integer type T type(T).max (T) https://jsmastery.pro JavaScript Mastery
  • 29. Global Variables ABI-decodes the provided data. The types are given in parentheses as second argument abi.decode(bytes memory encodedData, (...)) returns (...) ABI-encodes the given arguments abi.encode(...) returns (bytes memory) Performs packed encoding of the given arguments. abi.encodePacked(...) returns (bytes memory) https://jsmastery.pro JavaScript Mastery
  • 30. Global Variables ABI-encodes the given arguments starting from the second and prepends the given four-byte selector abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory) ABI-encodes a call to functionPointer with the arguments found in the tuple. Performs a full type-check, ensuring the types match the function signature abi.encodeCall(function functionPointer, (...)) returns (bytes memory) Equivalent to abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...) abi.encodeWithSignature(string memory signature, ...) returns (bytes memory) https://jsmastery.pro JavaScript Mastery
  • 31. Global Variables Concatenates variable number of arguments to one byte array bytes.concat(...) returns (bytes memory) Concatenates variable number of arguments to one string array string.concat(...) returns (string memory) https://jsmastery.pro JavaScript Mastery
  • 36. JS Mastery Pro Looking to advance your career and understand the concepts & technologies that top-shelf employers are looking for? JS Mastery Pro offers two courses that will help you master libraries, tools, and technologies such as React.js, Next.js, Material UI, Solidity, Redux, and many more. If your goal is to earn a high income while working on projects you love, JS Mastery Pro can help you develop your skills to become a top candidate for lucrative employment and freelance positions. https://jsmastery.pro JavaScript Mastery
  • 37. Become a React.js master as you create a stunning Netflix clone streaming app to showcase movies, actor bios, and more with advanced AI voice functionality. Leverage Web 3.0 and blockchain technology to build a comprehensive NFT platform where users can discover, create, purchase, & sell non-fungible tokens. https://jsmastery.pro JavaScript Mastery
  • 38. Collaborate with other developers on exciting monthly group projects, have your code reviewed by industry experts, and participate in mock interviews and live Q&As. With two masterclass options available, this is the best way to truly launch your programming career and secure the job of your dreams! Plus, if you really want to make a splash and add multiple group projects to your portfolio, join the JSM Masterclass Experience to set yourself above the rest and impress hiring managers. Visit today to get started! jsmastery.pro https://jsmastery.pro JavaScript Mastery