>> In this video,
I'm going to introduce Solidity.
Solidity is currently the main programming language for Ethereum.
Up until this point of this series,
I've been talking about how blockchain works.
Now I'm going to move into more practical solutions and
share how you can create and manage blockchain networks.
Solidity is an object oriented high-level language
for implementing smart contracts.
Sometimes it's referred to as a contract oriented language.
Smart contracts or programs which specify
behavior of accounts within the Ethereum state.
It is an open source language that was
created by the Ethereum core contributors.
The language was influenced by C++ Python and JavaScript.
It is designed to target
Ethereum Virtual Machine or EVM for short.
The EVM is the runtime environment
for smart contracts and Ethereum.
It is not only Sandbox,
but actually completely isolated,
which means that the code running inside
the EVM has no access to the network,
file system or other processes running.
Smart contracts even have limited access to other smart contracts.
Solidity is statically typed,
meaning that the type of variable is known at
compile time instead about runtime.
Solidity supports inheritance, libraries,
and complex user-defined types.
Now we'll head over to the Solidity website to take a look
at the primary structures that make up a smart contract.
Here you can find lots of information
about how to get started with Solidity.
To visit the Solidity website,
you can head to solidity.readthedocs.io.
Here you'll be taken to the Solidity homepage.
Right off the bat I can see lots of
helpful information about the language.
I definitely recommend this as a resource for getting
started with just knowing more about the language.
For the purposes of this video,
I will focus on this section,
the structure of a contract.
I wanted to take a moment just to explain
the primary structure that
you'll see in a typical smart contract
and talk through each of these.
First step you would have state variables.
State variables are going to be used in
every single contract and they're going to help store some value.
A typical type that you'll see is integer.
Here you see an unsigned integer represented as uint.
You can also have signed integers which are represented as int.
Then there are functions.
Every contract will typically have some kind of functions.
Functions are executable units of
code and can be defined inside a contract,
but also can be defined out of a contract.
Functions in Solidity are similar to
other functions and other programming languages.
If you're familiar with that,
like super familiar with functions and
JavaScript or C++ for example,
this might be very familiar to you.
Typically, you'll have a function that
will do one action that you're describing.
There are also function modifiers.
Function modifiers are interesting because they
limit who can basically call and interact with this function.
If you look at this example,
and here we have a function called
abort with this modifier onlyseller,
this modifier onlyseller is defined up here and it
requires that only the seller can
be able to call this abort function.
Next we have events.
Events are really a key part to smart contracts.
With events, these are going to log directly to the EVM
if you're in virtual machine about
activity that's happening within the contract.
To define an event,
I can do this here using
this syntax event with a name as well as different parameters.
Then when I went to call the event,
I use this emit keyword with the event name.
Then next are struct types.
Structs are an example of a custom defined
type that group separate information together.
In this example here,
we have a struct voter and
they'll be different attributes about that voters.
So wait, whether or not they voted the address,
which is going to identify that voter,
and then a integer,
an unsigned integer vote.
All of these related items
basically make up the struct of a voter.
Then there are Enum Types.
Enums are another custom type that you can define.
Basically what you're doing here is listing all of
the possibilities that can be
happening with this particular enumeration.
If you look at this example,
we have an enums state and we're going to list out
all the possible states which are created, locked, and inactive.
That's pretty much what you need to get started with Solidity.
These are the primary structures
that you're going to be using in Solidity contracts.
[MUSIC]