Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All right.
Now that we have our first smart contract in remix, I think it's time to actually talk about how smart
contracts are working a little bit more under the hood.
So you have the theory side as well.
Now, in general, what is a smart contract?
The term itself was coined by a computer scientist named Nick Szabo already in 1994.
So it's not particularly new what smart contracts are.
They are a piece of code that is running on the blockchain, and the blockchain itself is like a state
machine, so it needs a transaction to change from one state to the other and it can do some logic operations.
So that is basically how that thing works.
And the state change happens through mining and the mining is going to take the transactions to the
transaction pool and then changing the state on the blockchain.
Now the Ethereum blockchain is a Turing complete blockchain, so that means in theory it can solve any
computational problem.
And it's just a theory because it's very limited by the computational power that it has.
You will see it later.
It's calculated in the gas amount.
So if you need a certain amount of gas, which is getting too much, you cannot in practice solve any
computational problem.
But in theory you can.
So in theory you have all the functions and all the logic there to solve anything that needs to be solved.
Now there are a couple of programming languages for
Ethereum virtual machines, and the most popular one is solidity.
But there is also Viper, which came from Vitalik, wanting a new language that is more secure and a
little bit also more for academic purposes.
Then there was a L, which I think looks a little bit like Python, but it's, it's, there is no development
for these languages anymore.
And then there was bamboo and there were a lot of other languages that basically compile the source
code into IBM bytecode and that is what is run on the blockchain.
So the IBM byte code is actually the kind of code that the Ethereum blockchain nodes are executing.
And then there is high level languages, very much like C, C++, what do we have go and so on.
So those languages, you can write them in a specific syntax and you have specific language features
and then they compile down to the actual byte code or assembly code for the EVM.
And this stays constant and the language features change.
Actually, the EVM also doesn't doesn't stay constant because there are hard forks, but more on that
later.
So how about solidity?
I mean, that's by far the most popular language and this course is also building upon it.
We are doing a lot in solidity and we are trying to touch on every kind of topic that solidity has to
offer in the projects that we are doing.
It is very often compared to JavaScript and actually it's compared to a script and it's like.
Every high language code is then compelled to bytecode, and that is very important to understand.
And in the Ethereum network, every node then executes the same code.
So you're going to write your solidity smart contracts in.
So it's going to be compiled to even bytecode.
Then you send the transaction with that byte code to the blockchain and then every node in the network
is going to execute the same code because every node has a copy of the whole chain.
It's very important to understand that it is not like you're going to send your code to the data center
and then there is it's a machine that is going to execute the code.
It is you send the code to the network and then the network itself takes care of distributing your transactions
across all the nodes to the running in the network.
And then those are executing the same code again.
Now, as I said before, there are other languages I will serve them that is similar to Python at least
like Lisp.
This was mute then and now there is Viper and in between they also had bamboo.
But I still recommend staying in solidity because it's really by far the most famous language that is
out there for smart contract development.
Now, how does a solidity smart contract actually look like?
And it's very tiny here, but I want to touch on a couple of features that these the language has that
are probably very familiar to some of you who are coming from a language like Java or like C-sharp or
like C++.
So there is a class like structure and those classes are well the keyword for the classes are contract
and they contain functions and the functions can contain control structures like if else there is loops
for and while loops there's different data types, it's a statically type language.
So you have to give it for every variable that you define, you have to tell it which kind of data type
is that?
There is unsigned integers, integers, booleans array, struct, states, mappings, which a little
bit look like hash maps.
There is a special data type called address that is, I think, not available in any other language
that I've ever seen.
And be careful, there are no floats.
So if you want to have some sort of decimal points, you have to make a large enough integer to take
care of the decimal places.
And more on that also later.
When we do our first coin, there is inheritance.
So you can have contracts, extending other contracts, there is special structures like modifiers that
yeah, a little bit like go to statements in basic and then there is also import.
So you can finally fine grained structure your smart contract files and then just import whatever you
need.
You will also see that later on.
Now as dee dee dee lay out more, more at the beginning, what you saw now is that one what we did in
the previous lectures with an SPD license identifier, that one identifies the license of that file.
It doesn't identify the license of the project that is running under.
So make no mistake, it's not that because the neft is sees 721 token file is a license as MIT that
the NFT is licenses MIT.
It's about the source code.
So this one depicts the license of the source code as far as I know.
Then there is a line, the line is a pre compiler line that tells the pre compiler to select the rights.
So really the compiler for that file or at least it tells it like this file is written for this compiler
version and that is in a similar style semantic versioning.
So in this case it is clearly zero 814.
So it's locked into a specific version.
And if there was a carrot in the front, then it would mean zero 814 or larger, but not more than zero
nine, excluding zero nine.
Or you can also use the the greater sign, smaller sign, greater equal sign and so on.
So you can use those to, to tell the compiler or the, the environment that you're in, the compiler,
what kind of compiler version is that file written for?
And the reason is that you want to lock in specific compiler version because sometimes the compilers
change and they have a different meaning for the same for the same language features.
Now let me give you an example.
Unsigned integers and integers in previous versions.
We're rolling over and we'll show you this later.
So if you hit zero and then you decrement an unsigned integer, you suddenly hit max int and this was
changed in I think it is 086 or free or something.
So be careful that you lock in a specific compiler version that you're currently working on and then
make sure if you upgrading to a new compiler version that.
All of your files are still compatible.
This is where unit tests come in which we are also writing.
Now then comes a contract.
This is what I told you before with the classes.
The contract is depicted with a contract keyword and then comes in captured style.
Well, you don't have to.
But the official naming convention of solidity, which you can also find in the city docs, is here
is a cap word style, meaning the first letter is capitalized and then every other word is also capitalized.
So my name is capitalized and the contract is capitalized.
And then if there would be other words, then you would also capitalize them.
And it's the first letter.
Then there is curly brackets, and then inside the curly brackets are this one is a storage variable
which you are talking about later on is basically the the variable that stays across several transactions.
So you can store some value in there.
There is going to be events and modifiers and functions and constructors and all of the other things
that we want to do with solidity are in there.
Now for the deployment we sent off a transaction.
And what when you had a look when you opened the transaction field in remix, then you probably saw
that there was a data field or a value field that was populated.
It's called Input Field in Remix, but it's actually for the transaction.
It's a data field and this data field has the compiled bytecode.
And that one, if it's not sent to any specific address, if the two field is empty, then it will the
EVM will know this is bytecode.
I have to deploy it to the blockchain and then it will create a new address which is a deterministic
operation.
We create a new address for this smart contract, and then it will deploy the smart contract bytecode
that is sent in the data field, in the blocks, in the blockchain.
That's how it is.
And this is what we are going to do now in a couple of next lectures over and over again.
So you understand exactly how this works.
But this this is the basic so this is the very basic.
If you understand that, then you understand already 80% of how smart contracts are deployed, how the
interaction works, and so on.
Now the key takeaways are the smart contracts are running on the blockchain and they are deployed as
EVM bytecode and blockchain itself or the EVM is a Turing complete system.
The structure for a smart contract, if you had any prior coding experience, should look fairly familiar.
Even if you come from only JavaScript or only PHP, it should still look very familiar.
So there is.
There shouldn't be much of a new thing other than the addresses and the special edge cases like no floating
points.
The deployment is done with transactions and this is going to change the state of what is basically
a state machine, the blockchain.
All right.
I will see you in the next lecture.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.