Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,120 --> 00:00:03,959
welcome to the ultimate solidity smart
2
00:00:03,959 --> 00:00:06,799
contract web 3 blockchain developer
3
00:00:06,799 --> 00:00:10,000
course Foundry Edition previously we've
4
00:00:10,000 --> 00:00:12,719
done two other massive courses and
5
00:00:12,719 --> 00:00:14,040
tutorials like this one of them with
6
00:00:14,040 --> 00:00:15,759
JavaScript and one of them with python
7
00:00:15,759 --> 00:00:18,320
and then now one in pure solidity and
8
00:00:18,320 --> 00:00:21,519
combined those two videos have over 5
9
00:00:21,519 --> 00:00:23,760
million views making them the most
10
00:00:23,760 --> 00:00:25,560
watched blockchain developer educational
11
00:00:25,560 --> 00:00:27,840
material on the planet and we're looking
12
00:00:27,840 --> 00:00:30,560
to do it all over again we've learned a
13
00:00:30,560 --> 00:00:32,880
ton for making those first two courses
14
00:00:32,880 --> 00:00:35,360
and we've taken all of those learnings
15
00:00:35,360 --> 00:00:37,600
from those two courses wrapped them up
16
00:00:37,600 --> 00:00:39,920
into this one to make this one the best
17
00:00:39,920 --> 00:00:42,039
one yet if you're more interested in
18
00:00:42,039 --> 00:00:43,520
full stack development and working with
19
00:00:43,520 --> 00:00:45,440
JavaScript the hard hat one is still a
20
00:00:45,440 --> 00:00:47,039
phenomenal resource for you to get
21
00:00:47,039 --> 00:00:49,360
started however this one has a ton of
22
00:00:49,360 --> 00:00:51,480
advancements in it making it the most
23
00:00:51,480 --> 00:00:54,079
Cutting Edge web3 developer course
24
00:00:54,079 --> 00:00:55,920
period having done one of these videos
25
00:00:55,920 --> 00:00:57,600
every year for the past 3 years I've
26
00:00:57,600 --> 00:00:59,559
been reached out to by countless
27
00:00:59,559 --> 00:01:01,960
Developers ERS who are now full-time
28
00:01:01,960 --> 00:01:04,040
developers in the web 3 space making a
29
00:01:04,040 --> 00:01:05,960
living doing well and contributing to
30
00:01:05,960 --> 00:01:08,400
web 3 and there are thousands that I
31
00:01:08,400 --> 00:01:10,479
have not met who have left comments or
32
00:01:10,479 --> 00:01:12,040
left me notes and I know we're going to
33
00:01:12,040 --> 00:01:13,640
do it again with this video If you're
34
00:01:13,640 --> 00:01:16,200
looking to become a web 3 solidity smart
35
00:01:16,200 --> 00:01:18,560
contract or blockchain developer or any
36
00:01:18,560 --> 00:01:21,240
of those terms this is the course for
37
00:01:21,240 --> 00:01:23,560
you and this course is for anybody and
38
00:01:23,560 --> 00:01:26,680
everybody no matter your blockchain or
39
00:01:26,680 --> 00:01:28,320
developer experience level and
40
00:01:28,320 --> 00:01:30,079
additionally we're going to be using
41
00:01:30,079 --> 00:01:32,439
artificial intelligence to accelerate
42
00:01:32,439 --> 00:01:33,920
our learning progress and I'm going to
43
00:01:33,920 --> 00:01:35,360
teach you not only how to become a
44
00:01:35,360 --> 00:01:37,240
blockchain developer but how to work
45
00:01:37,240 --> 00:01:39,720
with AI tools to make you a 10x
46
00:01:39,720 --> 00:01:41,200
developer if you have a little bit of
47
00:01:41,200 --> 00:01:42,960
developer experience before this this
48
00:01:42,960 --> 00:01:44,640
course will be even easier to get
49
00:01:44,640 --> 00:01:46,479
through but again don't worry if you've
50
00:01:46,479 --> 00:01:48,320
never coded before and for those of you
51
00:01:48,320 --> 00:01:50,040
who are already familiar with blockchain
52
00:01:50,040 --> 00:01:51,799
and smart contract development feel free
53
00:01:51,799 --> 00:01:53,280
to jump around the different modules and
54
00:01:53,280 --> 00:01:54,399
different sections and grab the
55
00:01:54,399 --> 00:01:56,039
learnings that you want I promise
56
00:01:56,039 --> 00:01:57,360
there's a lot of cutting edge
57
00:01:57,360 --> 00:01:59,039
information in here and maybe you need
58
00:01:59,039 --> 00:02:00,920
to brush up so no matter if you're brand
59
00:02:00,920 --> 00:02:02,960
new to coding brand new to blockchain or
60
00:02:02,960 --> 00:02:04,719
you're an experienced smart contract
61
00:02:04,719 --> 00:02:06,399
engineer you're in the right place
62
00:02:06,399 --> 00:02:08,160
welcome to the edge of the rabbit hole
63
00:02:08,160 --> 00:02:10,160
let's get froggy for those of you who
64
00:02:10,160 --> 00:02:12,000
don't know me my name is Patrick Collins
65
00:02:12,000 --> 00:02:14,400
I'm a smart contract engineer security
66
00:02:14,400 --> 00:02:16,440
researcher and just lover of all things
67
00:02:16,440 --> 00:02:18,200
web3 I'm one of the co-founders of the
68
00:02:18,200 --> 00:02:19,920
smart contract auditing firm cyphon
69
00:02:19,920 --> 00:02:21,280
average smart contract YouTuber
70
00:02:21,280 --> 00:02:24,400
co-creator of web3 education. deev and I
71
00:02:24,400 --> 00:02:26,519
live and breathe smart contract
72
00:02:26,519 --> 00:02:29,200
development I absolutely love web 3
73
00:02:29,200 --> 00:02:30,800
blockchain and smart contracts and I
74
00:02:30,800 --> 00:02:32,920
love the power and the tools that they
75
00:02:32,920 --> 00:02:35,120
enable us to use but not only that I
76
00:02:35,120 --> 00:02:36,760
love taking blockchain developers like
77
00:02:36,760 --> 00:02:38,959
yourself watching this video right now
78
00:02:38,959 --> 00:02:41,280
on the journey to becoming a successful
79
00:02:41,280 --> 00:02:43,760
smart contract developer I think the key
80
00:02:43,760 --> 00:02:45,239
to web 3 to blockchain to
81
00:02:45,239 --> 00:02:47,239
cryptocurrencies being successful is
82
00:02:47,239 --> 00:02:50,200
having a phenomenal Foundation of
83
00:02:50,200 --> 00:02:52,480
developers so I'm incredibly excited
84
00:02:52,480 --> 00:02:54,120
that you're here with me and for those
85
00:02:54,120 --> 00:02:55,519
you who don't want to become blockchain
86
00:02:55,519 --> 00:02:57,840
developers the first two lessons of this
87
00:02:57,840 --> 00:03:00,319
course lesson zero and lesson one are
88
00:03:00,319 --> 00:03:02,440
foundational pieces of conceptual
89
00:03:02,440 --> 00:03:04,879
information for you just to understand
90
00:03:04,879 --> 00:03:06,760
how to get into this web three thing so
91
00:03:06,760 --> 00:03:08,360
if you don't want to become a developer
92
00:03:08,360 --> 00:03:10,280
just stop once we get to the coding for
93
00:03:10,280 --> 00:03:12,400
my pythonistas here I'm working on an
94
00:03:12,400 --> 00:03:15,080
addition of this course purely in Python
95
00:03:15,080 --> 00:03:17,519
and Viper stay tuned for that as well in
96
00:03:17,519 --> 00:03:19,120
any case I'm incredibly excited for your
97
00:03:19,120 --> 00:03:21,519
journey this is a data dump passion
98
00:03:21,519 --> 00:03:23,480
project of all the knowledge that I've
99
00:03:23,480 --> 00:03:25,239
collected over the past few years of
100
00:03:25,239 --> 00:03:26,680
working in this industry and being a
101
00:03:26,680 --> 00:03:28,480
smart contract developer myself and at
102
00:03:28,480 --> 00:03:29,879
this point I have the track record to
103
00:03:29,879 --> 00:03:33,040
show that I am 100% confident that if
104
00:03:33,040 --> 00:03:34,920
you follow along if you code along with
105
00:03:34,920 --> 00:03:36,920
us if you follow me on this journey you
106
00:03:36,920 --> 00:03:38,720
will come out the other side armed with
107
00:03:38,720 --> 00:03:41,360
the knowledge to be a positive force of
108
00:03:41,360 --> 00:03:42,680
the cryptocurrency and blockchain
109
00:03:42,680 --> 00:03:44,720
Industry smart contract and solidity
110
00:03:44,720 --> 00:03:47,200
developers are massively in demand with
111
00:03:47,200 --> 00:03:49,200
an average salary being around
112
00:03:49,200 --> 00:03:52,120
$145,000 a year and with AI coming in
113
00:03:52,120 --> 00:03:54,200
place it's becoming even easier to get
114
00:03:54,200 --> 00:03:56,680
up to speed quickly but only those that
115
00:03:56,680 --> 00:03:58,400
understand the technology truly will be
116
00:03:58,400 --> 00:04:00,840
able to take advantage of all these
117
00:04:00,840 --> 00:04:03,439
advancements AIS get stuff wrong a lot
118
00:04:03,439 --> 00:04:05,079
so we especially need the knowledge to
119
00:04:05,079 --> 00:04:07,120
fact check whenever AIS get things wrong
120
00:04:07,120 --> 00:04:09,200
being here you have the opportunity to
121
00:04:09,200 --> 00:04:12,159
be a Pioneer ushering in the age of web
122
00:04:12,159 --> 00:04:14,920
3 of cryptocurrency Blazing the trail of
123
00:04:14,920 --> 00:04:17,000
where this phenomenal industry has yet
124
00:04:17,000 --> 00:04:18,799
to go like I said this isn't the first
125
00:04:18,799 --> 00:04:20,280
time we've done this we've already
126
00:04:20,280 --> 00:04:22,759
helped so many developers get into space
127
00:04:22,759 --> 00:04:24,960
and we're going to give you the Cutting
128
00:04:24,960 --> 00:04:27,479
Edge most modern tools for Industries
129
00:04:27,479 --> 00:04:31,080
like defi nfts Dow tokens upgradeable
130
00:04:31,080 --> 00:04:32,479
smart contracts blockchains and
131
00:04:32,479 --> 00:04:34,039
everything else that you can think of
132
00:04:34,039 --> 00:04:35,919
once you finish this course it will be
133
00:04:35,919 --> 00:04:37,800
abundantly clear what you want your next
134
00:04:37,800 --> 00:04:39,600
steps to be and you'll have a ton of
135
00:04:39,600 --> 00:04:42,160
Economic Opportunity at your fingertips
136
00:04:42,160 --> 00:04:44,280
and opportunities to make a huge
137
00:04:44,280 --> 00:04:46,520
difference in this amazing industry
138
00:04:46,520 --> 00:04:48,479
however I can't just give it to you you
139
00:04:48,479 --> 00:04:50,880
have to come with me on this journey you
140
00:04:50,880 --> 00:04:52,639
have to take the step despite what you
141
00:04:52,639 --> 00:04:54,840
might think you know cryptocurrencies
142
00:04:54,840 --> 00:04:57,080
and smart contracts enable a more
143
00:04:57,080 --> 00:04:59,080
accountable World a more transparent
144
00:04:59,080 --> 00:05:01,280
World a more collaborative world a world
145
00:05:01,280 --> 00:05:03,600
where promises can't be broken and
146
00:05:03,600 --> 00:05:04,759
that's a world that I want to live in
147
00:05:04,759 --> 00:05:06,160
we'll learn more about the purpose of
148
00:05:06,160 --> 00:05:07,479
smart contracts and the purpose of
149
00:05:07,479 --> 00:05:09,440
blockchain technology in lesson one of
150
00:05:09,440 --> 00:05:11,000
this course and then of course we'll
151
00:05:11,000 --> 00:05:13,199
teach you how to build it so before we
152
00:05:13,199 --> 00:05:15,680
even get started I want to give you a
153
00:05:15,680 --> 00:05:17,680
huge thank you for even being here on
154
00:05:17,680 --> 00:05:20,400
this video and listening and being
155
00:05:20,400 --> 00:05:22,759
interested in engaging in this
156
00:05:22,759 --> 00:05:24,800
phenomenal technology so thank you for
157
00:05:24,800 --> 00:05:26,280
being here and welcome to the rabbit
158
00:05:26,280 --> 00:05:28,120
hole cuz we're about to drop down with
159
00:05:28,120 --> 00:05:31,639
that being said let's get
160
00:05:33,840 --> 00:05:36,199
froggy so let's begin our journey by
161
00:05:36,199 --> 00:05:38,160
talking about some best practices that
162
00:05:38,160 --> 00:05:41,000
way you can get the absolute most out of
163
00:05:41,000 --> 00:05:42,720
this course and be as effective as
164
00:05:42,720 --> 00:05:44,840
possible now there are two links in the
165
00:05:44,840 --> 00:05:46,759
description that I want you to pause the
166
00:05:46,759 --> 00:05:48,479
video right now go into the description
167
00:05:48,479 --> 00:05:51,120
and click on and open up the first one
168
00:05:51,120 --> 00:05:53,960
is web3 education. deev and the second
169
00:05:53,960 --> 00:05:56,600
one is a GitHub link to a repo also
170
00:05:56,600 --> 00:05:59,280
known as a repository with all the code
171
00:05:59,280 --> 00:06:01,240
and all the lessons and everything we're
172
00:06:01,240 --> 00:06:03,199
going to be covering in this video the
173
00:06:03,199 --> 00:06:05,199
web3 education. deev site is an
174
00:06:05,199 --> 00:06:07,080
education site that we're working on to
175
00:06:07,080 --> 00:06:09,240
have all of this video and everything
176
00:06:09,240 --> 00:06:10,919
else in all the Cutting Edge learnings
177
00:06:10,919 --> 00:06:13,319
of blockchain developers in this course
178
00:06:13,319 --> 00:06:15,599
in this site so if you enjoy written
179
00:06:15,599 --> 00:06:17,800
context as well be sure to subscribe to
180
00:06:17,800 --> 00:06:19,280
sign up for that so that you can be one
181
00:06:19,280 --> 00:06:20,440
of the first people to know when it
182
00:06:20,440 --> 00:06:22,880
launches and the second site is this
183
00:06:22,880 --> 00:06:25,080
GitHub link this is going to be your
184
00:06:25,080 --> 00:06:27,000
Bible for the duration of watching this
185
00:06:27,000 --> 00:06:29,160
video it has everything that we're going
186
00:06:29,160 --> 00:06:31,560
to go over it has all the code context
187
00:06:31,560 --> 00:06:33,360
text Etc that you're going to need to be
188
00:06:33,360 --> 00:06:35,039
successful in this video and I'm going
189
00:06:35,039 --> 00:06:37,199
to be referring to it pretty often as we
190
00:06:37,199 --> 00:06:39,120
go through the course additionally in
191
00:06:39,120 --> 00:06:41,199
this GitHub there's a discussions tab
192
00:06:41,199 --> 00:06:43,280
right here that you can click on and in
193
00:06:43,280 --> 00:06:44,960
here is where you can ask questions
194
00:06:44,960 --> 00:06:46,240
discuss with other people taking the
195
00:06:46,240 --> 00:06:48,160
course interact with members helping out
196
00:06:48,160 --> 00:06:49,880
and it's where you can discuss anything
197
00:06:49,880 --> 00:06:51,599
that you're having trouble with and an
198
00:06:51,599 --> 00:06:53,919
important note sometimes you'll see this
199
00:06:53,919 --> 00:06:56,800
as the chain Excel org Foundry F course
200
00:06:56,800 --> 00:06:58,800
we recently renamed it to The cyphon
201
00:06:58,800 --> 00:07:00,919
Foundry F course so this is the correct
202
00:07:00,919 --> 00:07:02,879
link but if you see chain excl org
203
00:07:02,879 --> 00:07:05,080
that's fine as well that being said as
204
00:07:05,080 --> 00:07:06,759
we go through this course we're also
205
00:07:06,759 --> 00:07:08,199
going to teach you some best practices
206
00:07:08,199 --> 00:07:11,000
on working with artificial intelligence
207
00:07:11,000 --> 00:07:13,639
how to best prompt these AI so that they
208
00:07:13,639 --> 00:07:15,599
can give you the best results just keep
209
00:07:15,599 --> 00:07:18,120
in mind they sometimes get things wrong
210
00:07:18,120 --> 00:07:19,479
and it's a good idea if you are going to
211
00:07:19,479 --> 00:07:22,000
use an AI to fact check it with a human
212
00:07:22,000 --> 00:07:24,000
or another resource so be sure to say hi
213
00:07:24,000 --> 00:07:25,960
in the discussions and maybe meet some
214
00:07:25,960 --> 00:07:28,240
like-minded peers and additionally once
215
00:07:28,240 --> 00:07:30,160
we do get to the coding portion of this
216
00:07:30,160 --> 00:07:32,840
course it's a good idea to code along
217
00:07:32,840 --> 00:07:35,479
with me as I'm explaining things so
218
00:07:35,479 --> 00:07:37,960
having the video up as well as your
219
00:07:37,960 --> 00:07:39,960
coding screen is a good idea so you can
220
00:07:39,960 --> 00:07:41,599
follow along with me as I'm explaining
221
00:07:41,599 --> 00:07:43,720
it now this space moves incredibly
222
00:07:43,720 --> 00:07:45,840
quickly so whenever I open some
223
00:07:45,840 --> 00:07:47,599
documentation or some codebase or
224
00:07:47,599 --> 00:07:49,840
something I highly recommend that you
225
00:07:49,840 --> 00:07:52,280
open it as well in your browser just so
226
00:07:52,280 --> 00:07:54,720
that you can know immediately right away
227
00:07:54,720 --> 00:07:56,599
that the code that I'm working with in
228
00:07:56,599 --> 00:07:57,800
the video is going to be the same that
229
00:07:57,800 --> 00:07:59,520
the code that you're working with
230
00:07:59,520 --> 00:08:00,879
locally now we're going to be keeping
231
00:08:00,879 --> 00:08:02,599
all of the code in here up to date but
232
00:08:02,599 --> 00:08:03,720
sometimes things change and something
233
00:08:03,720 --> 00:08:05,479
that I do in the video might not be the
234
00:08:05,479 --> 00:08:07,120
most up to- dat best practice so we're
235
00:08:07,120 --> 00:08:08,120
going to have this file called
236
00:08:08,120 --> 00:08:10,440
chronological updates. MD where you can
237
00:08:10,440 --> 00:08:12,280
go in and check to make sure that you're
238
00:08:12,280 --> 00:08:14,800
working on the most upto-date Edition so
239
00:08:14,800 --> 00:08:16,440
if you go into that file each lesson
240
00:08:16,440 --> 00:08:18,319
will have a section and if there's some
241
00:08:18,319 --> 00:08:19,960
update that we made to the lesson you
242
00:08:19,960 --> 00:08:21,840
can find it in there additionally if you
243
00:08:21,840 --> 00:08:23,360
think you found something that is
244
00:08:23,360 --> 00:08:25,120
different or doesn't quite work be sure
245
00:08:25,120 --> 00:08:27,000
to make a discussion for it in that
246
00:08:27,000 --> 00:08:28,560
GitHub repo like I said it's going to be
247
00:08:28,560 --> 00:08:30,159
your Bible but yes if you run into an
248
00:08:30,159 --> 00:08:31,599
issue make sure that file is one of the
249
00:08:31,599 --> 00:08:33,240
first places that you check just to make
250
00:08:33,240 --> 00:08:34,760
sure that all the code that you're
251
00:08:34,760 --> 00:08:36,880
working with is the most up to dat all
252
00:08:36,880 --> 00:08:39,000
of this is to say if you run into an
253
00:08:39,000 --> 00:08:41,760
issue jump to that GitHub repo and make
254
00:08:41,760 --> 00:08:43,599
a discussion we will also be giving you
255
00:08:43,599 --> 00:08:46,120
some tips very soon about how to best
256
00:08:46,120 --> 00:08:48,959
make a discussion yes asking questions
257
00:08:48,959 --> 00:08:51,320
to other human beings is a skill and
258
00:08:51,320 --> 00:08:52,600
we're going to try to teach you to be
259
00:08:52,600 --> 00:08:54,200
the most effective because asking well
260
00:08:54,200 --> 00:08:55,880
formatted questions is not only the
261
00:08:55,880 --> 00:08:58,000
secret to being a fantastic AI prompt
262
00:08:58,000 --> 00:09:00,680
engineer but also becoming an incredibly
263
00:09:00,680 --> 00:09:02,480
successful developer we're going to
264
00:09:02,480 --> 00:09:03,959
learn how to ask well-formatted
265
00:09:03,959 --> 00:09:05,680
questions and whenever we post on
266
00:09:05,680 --> 00:09:07,800
discussions or forums or whatever we're
267
00:09:07,800 --> 00:09:10,000
going to work on formatting them as best
268
00:09:10,000 --> 00:09:12,880
as possible take breaks I cannot tell
269
00:09:12,880 --> 00:09:15,079
you how many people have tried to rush
270
00:09:15,079 --> 00:09:16,519
through these courses and be like Oh I'm
271
00:09:16,519 --> 00:09:18,360
going to finish in a single weekend your
272
00:09:18,360 --> 00:09:19,959
brain doesn't work like that your brain
273
00:09:19,959 --> 00:09:22,480
needs time to absorb the information so
274
00:09:22,480 --> 00:09:25,160
take breaks maybe every 25 minutes to a
275
00:09:25,160 --> 00:09:27,160
half hour take a 5-minute break or maybe
276
00:09:27,160 --> 00:09:29,440
you like working in longer chunks Maybe
277
00:09:29,440 --> 00:09:31,279
take a whole hour and then take a 15 20
278
00:09:31,279 --> 00:09:33,079
minute break don't try to rush through
279
00:09:33,079 --> 00:09:34,920
the whole video in a day you're not
280
00:09:34,920 --> 00:09:36,680
going to retain the information go
281
00:09:36,680 --> 00:09:38,720
outside go for a walk grab some ice
282
00:09:38,720 --> 00:09:40,760
cream get some coffee go to the gym your
283
00:09:40,760 --> 00:09:43,880
brain needs time to have the information
284
00:09:43,880 --> 00:09:46,120
settled maybe every 2 hours just step
285
00:09:46,120 --> 00:09:48,160
away maybe be done for the day work at
286
00:09:48,160 --> 00:09:50,680
whatever Pace makes sense for you
287
00:09:50,680 --> 00:09:52,320
everyone's going to have a different
288
00:09:52,320 --> 00:09:54,720
learning Pace there is no right speed
289
00:09:54,720 --> 00:09:56,320
for this course I've had people take my
290
00:09:56,320 --> 00:09:59,120
courses in 2 weeks in 3 months in six
291
00:09:59,120 --> 00:10:02,079
months months it doesn't matter pick a
292
00:10:02,079 --> 00:10:04,640
pace that you can do and stick to it not
293
00:10:04,640 --> 00:10:06,360
only work at your pace make sure that
294
00:10:06,360 --> 00:10:08,240
I'm talking at a pace that makes sense
295
00:10:08,240 --> 00:10:10,120
for you there's a little gear icon in
296
00:10:10,120 --> 00:10:11,800
the YouTube video here where you can
297
00:10:11,800 --> 00:10:14,240
change the speed of how I'm talking and
298
00:10:14,240 --> 00:10:16,160
how fast the video is going so if I'm
299
00:10:16,160 --> 00:10:17,519
talking way too fast for you then you
300
00:10:17,519 --> 00:10:21,079
can slow me down but if I'm talking too
301
00:10:21,079 --> 00:10:23,519
slow then you can speed me up so make
302
00:10:23,519 --> 00:10:26,120
the adjustments you need to make me go
303
00:10:26,120 --> 00:10:27,880
the speed you want me to go now a giant
304
00:10:27,880 --> 00:10:29,320
video like this can be kind of hard to
305
00:10:29,320 --> 00:10:31,880
to triage where you left off so using
306
00:10:31,880 --> 00:10:33,600
the GitHub repo with the timestamps in
307
00:10:33,600 --> 00:10:35,560
there is a good way to say ah okay I was
308
00:10:35,560 --> 00:10:38,079
on lesson one let's click the link there
309
00:10:38,079 --> 00:10:39,720
to jump right to the timestamp if you
310
00:10:39,720 --> 00:10:41,320
pause a video in YouTube you can
311
00:10:41,320 --> 00:10:43,519
actually rightclick and say copy at
312
00:10:43,519 --> 00:10:45,399
current time and maybe drop that into a
313
00:10:45,399 --> 00:10:47,040
notes folder somewhere so that you can
314
00:10:47,040 --> 00:10:48,880
always just pick right back up where you
315
00:10:48,880 --> 00:10:50,600
left off or like I said you can use some
316
00:10:50,600 --> 00:10:52,279
of the timestamps in the GitHub repo
317
00:10:52,279 --> 00:10:54,079
associated with this course or depending
318
00:10:54,079 --> 00:10:55,600
on when you watch this the web3
319
00:10:55,600 --> 00:10:58,000
education. site might also be up be sure
320
00:10:58,000 --> 00:10:59,920
to check that out as well and of course
321
00:10:59,920 --> 00:11:02,399
this course is modular so you can Bounce
322
00:11:02,399 --> 00:11:04,200
Around topic to topic and go to where
323
00:11:04,200 --> 00:11:05,760
you want to go if you don't want to do
324
00:11:05,760 --> 00:11:07,560
any full stack stuff then skip that
325
00:11:07,560 --> 00:11:09,079
section if you want to go right to the
326
00:11:09,079 --> 00:11:11,200
advanced stuff do that like I said go
327
00:11:11,200 --> 00:11:12,920
the pace and take the learnings that you
328
00:11:12,920 --> 00:11:15,120
want to do and after every lesson it
329
00:11:15,120 --> 00:11:16,760
might be a good idea to go back and
330
00:11:16,760 --> 00:11:18,920
reflect on each lesson to really make
331
00:11:18,920 --> 00:11:21,320
sure the knowledge gets ingrained
332
00:11:21,320 --> 00:11:23,440
repetition is the mother of skill and
333
00:11:23,440 --> 00:11:26,000
we're going to be repeating a lot of
334
00:11:26,000 --> 00:11:27,480
smart contract development now
335
00:11:27,480 --> 00:11:29,360
additionally at the end of every lesson
336
00:11:29,360 --> 00:11:31,240
you'll see a little QR code that looks
337
00:11:31,240 --> 00:11:32,680
something like this and there will be a
338
00:11:32,680 --> 00:11:34,800
link in the GitHub repo pointing to the
339
00:11:34,800 --> 00:11:36,440
same place that this QR code is pointing
340
00:11:36,440 --> 00:11:38,959
to these are optional challenges that
341
00:11:38,959 --> 00:11:41,240
you can do to try to make sure that you
342
00:11:41,240 --> 00:11:42,639
actually learned what was meant to be
343
00:11:42,639 --> 00:11:45,000
learned here and if you do solve them
344
00:11:45,000 --> 00:11:47,480
you get a very cool nft along with it
345
00:11:47,480 --> 00:11:49,040
don't know what an nft is don't worry
346
00:11:49,040 --> 00:11:50,279
we'll teach you later blockchain
347
00:11:50,279 --> 00:11:51,800
development and open source development
348
00:11:51,800 --> 00:11:53,839
world is incredibly collaborative so be
349
00:11:53,839 --> 00:11:55,560
sure to use tools like of course the
350
00:11:55,560 --> 00:11:57,480
GitHub discussions tab ethereum stack
351
00:11:57,480 --> 00:11:59,600
exchange the decentralized Q&A Forum
352
00:11:59,600 --> 00:12:02,839
piranha issues on different
353
00:12:29,480 --> 00:12:32,199
to unblock yourself on this and really
354
00:12:32,199 --> 00:12:34,480
anything in life plus sinking with other
355
00:12:34,480 --> 00:12:36,000
people in the space makes it way more
356
00:12:36,000 --> 00:12:38,000
fun now before we can actually get to
357
00:12:38,000 --> 00:12:40,480
coding we need to understand how the
358
00:12:40,480 --> 00:12:42,600
blockchain even works what the purpose
359
00:12:42,600 --> 00:12:45,160
of these smart contracts even are and
360
00:12:45,160 --> 00:12:47,120
this is essential to becoming a
361
00:12:47,120 --> 00:12:48,959
successful smart contract developer
362
00:12:48,959 --> 00:12:51,320
because a technology is really just a
363
00:12:51,320 --> 00:12:53,639
solution and a solution is only as good
364
00:12:53,639 --> 00:12:55,360
as the problem is so we need to make
365
00:12:55,360 --> 00:12:56,959
sure we understand the problem really
366
00:12:56,959 --> 00:12:59,240
well so we know how to attack it with
367
00:12:59,240 --> 00:13:01,160
this smart contract technology and the
368
00:13:01,160 --> 00:13:02,480
better you understand this smart cont
369
00:13:02,480 --> 00:13:04,600
technology the better you'll be able to
370
00:13:04,600 --> 00:13:06,399
architect your smart contracts in the
371
00:13:06,399 --> 00:13:08,440
future and make really intelligent
372
00:13:08,440 --> 00:13:11,320
really powerful systems that further
373
00:13:11,320 --> 00:13:12,920
this amazing industry but if you already
374
00:13:12,920 --> 00:13:14,839
know the basics of blockchain feel free
375
00:13:14,839 --> 00:13:17,320
to jump into lesson two and skip over
376
00:13:17,320 --> 00:13:19,160
lesson one so those are some of the best
377
00:13:19,160 --> 00:13:21,040
practices to be really successful with
378
00:13:21,040 --> 00:13:22,839
this course but with that knowledge
379
00:13:22,839 --> 00:13:24,639
you're now standing at the edge of the
380
00:13:24,639 --> 00:13:26,760
rabbit hole and if you're like me once
381
00:13:26,760 --> 00:13:28,279
you jump in you'll just want to keep
382
00:13:28,279 --> 00:13:30,240
going deeper and and deeper I'm so
383
00:13:30,240 --> 00:13:32,680
excited for you to embark on this
384
00:13:32,680 --> 00:13:34,120
journey with us and I'm looking forward
385
00:13:34,120 --> 00:13:35,320
to seeing you on the other side just
386
00:13:35,320 --> 00:13:37,079
like the thousands of other developers
387
00:13:37,079 --> 00:13:39,040
who have taken these courses and have
388
00:13:39,040 --> 00:13:41,600
emerged the other side triumphant so it
389
00:13:41,600 --> 00:13:44,320
all starts with blockchain Basics let's
390
00:13:44,320 --> 00:13:46,480
get
391
00:13:56,600 --> 00:13:58,600
froggy now since you're here you've
392
00:13:58,600 --> 00:14:00,880
probably heard heard of Bitcoin before
393
00:14:00,880 --> 00:14:02,800
Bitcoin was one of the first protocols
394
00:14:02,800 --> 00:14:04,800
to use this revolutionary technology
395
00:14:04,800 --> 00:14:06,920
called blockchain the Bitcoin white
396
00:14:06,920 --> 00:14:08,480
paper was created by the pseudo
397
00:14:08,480 --> 00:14:10,920
Anonymous Satoshi Nakamoto and it
398
00:14:10,920 --> 00:14:12,320
outlined how Bitcoin could make
399
00:14:12,320 --> 00:14:14,279
peer-to-peer transactions in a
400
00:14:14,279 --> 00:14:16,360
decentralized network this network was
401
00:14:16,360 --> 00:14:18,839
powered by cryptography and decentral
402
00:14:18,839 --> 00:14:20,680
and allowed people to engage in
403
00:14:20,680 --> 00:14:23,240
censorship resistant Finance in a
404
00:14:23,240 --> 00:14:25,720
decentralized manner due to its features
405
00:14:25,720 --> 00:14:27,600
which we'll talk about in a little bit
406
00:14:27,600 --> 00:14:29,880
people took to this as a Superior
407
00:14:29,880 --> 00:14:32,800
digital store of value a better store of
408
00:14:32,800 --> 00:14:34,639
value over something like gold for
409
00:14:34,639 --> 00:14:36,199
example and that's why you'll also hear
410
00:14:36,199 --> 00:14:38,680
people commonly refer to it as a digital
411
00:14:38,680 --> 00:14:41,040
gold similar to Gold there's a scarce
412
00:14:41,040 --> 00:14:43,040
amount or a set amount of Bitcoin
413
00:14:43,040 --> 00:14:45,320
available on the planet only so much
414
00:14:45,320 --> 00:14:46,959
that you can buy and sell you can read
415
00:14:46,959 --> 00:14:48,839
more about the original Vision in the
416
00:14:48,839 --> 00:14:50,320
white paper we have a link to the white
417
00:14:50,320 --> 00:14:52,399
paper in the GitHub repo associated with
418
00:14:52,399 --> 00:14:54,399
this course now this was an insane
419
00:14:54,399 --> 00:14:55,839
breakthrough and in a little bit we're
420
00:14:55,839 --> 00:14:58,079
going to learn exactly how this is all
421
00:14:58,079 --> 00:14:59,560
possible and how this actually works
422
00:14:59,560 --> 00:15:01,639
under the hood some people though saw
423
00:15:01,639 --> 00:15:03,800
this technology and wanted to take it a
424
00:15:03,800 --> 00:15:06,160
little bit farther and do even more with
425
00:15:06,160 --> 00:15:08,120
this blockchain technology and a few
426
00:15:08,120 --> 00:15:10,839
years later a man named vitalic butterin
427
00:15:10,839 --> 00:15:12,680
released a white paper for a new
428
00:15:12,680 --> 00:15:15,680
protocol named ethereum which used this
429
00:15:15,680 --> 00:15:18,160
same blockchain infrastructure with an
430
00:15:18,160 --> 00:15:21,120
additional feature and in 2015 him and a
431
00:15:21,120 --> 00:15:23,240
number of other co-founders released the
432
00:15:23,240 --> 00:15:25,360
project ethereum where people could not
433
00:15:25,360 --> 00:15:27,880
only make decentralized transactions but
434
00:15:27,880 --> 00:15:30,160
decentralized agreements decentralized
435
00:15:30,160 --> 00:15:32,040
organizations and all these other ways
436
00:15:32,040 --> 00:15:34,160
to interact with each other without a
437
00:15:34,160 --> 00:15:36,519
centralized intermediary or centralized
438
00:15:36,519 --> 00:15:39,000
governing Force basically their idea was
439
00:15:39,000 --> 00:15:41,040
to take this thing that made Bitcoin so
440
00:15:41,040 --> 00:15:44,199
great and add decentralized agreements
441
00:15:44,199 --> 00:15:47,240
to it or smart contracts and in fact
442
00:15:47,240 --> 00:15:48,759
technically these smart contracts
443
00:15:48,759 --> 00:15:51,240
weren't even really a new idea back in
444
00:15:51,240 --> 00:15:54,120
1994 a man named Nick Zabo had actually
445
00:15:54,120 --> 00:15:55,920
originally come up with the idea smart
446
00:15:55,920 --> 00:15:58,360
contracts are a set of instructions
447
00:15:58,360 --> 00:16:00,839
executed in a decentralized autonomous
448
00:16:00,839 --> 00:16:03,759
way without the need for a third party
449
00:16:03,759 --> 00:16:05,839
or centralized body to run them and they
450
00:16:05,839 --> 00:16:07,920
come to life on these blockchains or
451
00:16:07,920 --> 00:16:09,959
these smart contract platforms like
452
00:16:09,959 --> 00:16:11,880
ethereum and it's these smart contracts
453
00:16:11,880 --> 00:16:13,560
that are going to be the core thing that
454
00:16:13,560 --> 00:16:14,720
we're going to be working on in this
455
00:16:14,720 --> 00:16:15,880
course and that we're going to be
456
00:16:15,880 --> 00:16:17,240
developing you can think of smart
457
00:16:17,240 --> 00:16:18,959
contracts in the same way you think of
458
00:16:18,959 --> 00:16:20,639
traditional contracts or traditional
459
00:16:20,639 --> 00:16:22,279
agreements they're just a set of
460
00:16:22,279 --> 00:16:24,560
instructions between parties except
461
00:16:24,560 --> 00:16:26,319
instead of written on pen and paper or
462
00:16:26,319 --> 00:16:28,120
typed up in Microsoft Word they are
463
00:16:28,120 --> 00:16:30,160
written in code code and embodied on
464
00:16:30,160 --> 00:16:32,040
these decentralized blockchain platforms
465
00:16:32,040 --> 00:16:34,199
and that's also where they're executed
466
00:16:34,199 --> 00:16:36,120
instead of being executed by the two
467
00:16:36,120 --> 00:16:37,920
parties or three parties or however many
468
00:16:37,920 --> 00:16:40,680
parties that are involved this removes
469
00:16:40,680 --> 00:16:42,480
this centralized issue that we'll talk
470
00:16:42,480 --> 00:16:44,079
about more in a bit this is one of the
471
00:16:44,079 --> 00:16:45,759
main differentiators between the
472
00:16:45,759 --> 00:16:47,560
ethereum protocol and the Bitcoin
473
00:16:47,560 --> 00:16:50,639
protocol it's these smart contracts now
474
00:16:50,639 --> 00:16:52,480
technically Bitcoin does have Smart
475
00:16:52,480 --> 00:16:54,360
contracts but they're intentionally
476
00:16:54,360 --> 00:16:56,360
touring incomplete which means they
477
00:16:56,360 --> 00:16:58,079
don't have all the functionality that a
478
00:16:58,079 --> 00:16:59,480
programming language would give them
479
00:16:59,480 --> 00:17:01,560
this was an intentional move by Bitcoin
480
00:17:01,560 --> 00:17:03,839
developers Bitcoin developers viewed
481
00:17:03,839 --> 00:17:06,600
Bitcoin as a store of value versus
482
00:17:06,600 --> 00:17:09,199
etherum developers viewed ethereum as
483
00:17:09,199 --> 00:17:12,439
both a store of value and a utility to
484
00:17:12,439 --> 00:17:14,199
facilitate these decentralized
485
00:17:14,199 --> 00:17:16,160
agreements now these smart contracts on
486
00:17:16,160 --> 00:17:18,160
blockchains alone are absolutely
487
00:17:18,160 --> 00:17:20,400
incredible however they do come with a
488
00:17:20,400 --> 00:17:22,400
huge issue if we want these digital
489
00:17:22,400 --> 00:17:24,400
agreements to replace the agreements in
490
00:17:24,400 --> 00:17:26,240
our everyday lives they probably are
491
00:17:26,240 --> 00:17:28,199
going to need data from The Real World
492
00:17:28,199 --> 00:17:30,240
blockchains by themselves actually can't
493
00:17:30,240 --> 00:17:32,520
interact with and can't read or listen
494
00:17:32,520 --> 00:17:34,679
to data from The Real World this is
495
00:17:34,679 --> 00:17:36,919
what's known as the Oracle problem these
496
00:17:36,919 --> 00:17:38,880
blockchains are deterministic systems
497
00:17:38,880 --> 00:17:40,880
and they're deterministic on purpose and
498
00:17:40,880 --> 00:17:42,640
we'll learn about more about how that
499
00:17:42,640 --> 00:17:44,440
works in the sessions to come so
500
00:17:44,440 --> 00:17:45,559
everything that happens with them
501
00:17:45,559 --> 00:17:47,520
happens in their little world but if
502
00:17:47,520 --> 00:17:48,640
they're going to be these agreements
503
00:17:48,640 --> 00:17:50,200
they need external data and they need
504
00:17:50,200 --> 00:17:52,280
external computation and this is where
505
00:17:52,280 --> 00:17:54,520
oracles come into play oracles are any
506
00:17:54,520 --> 00:17:56,200
device that delivers data to these
507
00:17:56,200 --> 00:17:58,320
decentralized blockchain or runs
508
00:17:58,320 --> 00:18:00,600
external computation however if we want
509
00:18:00,600 --> 00:18:02,679
our applications to stay truly
510
00:18:02,679 --> 00:18:05,080
decentralized we can't work with a
511
00:18:05,080 --> 00:18:07,320
single Oracle or a single data provider
512
00:18:07,320 --> 00:18:09,159
or a single Source that's running these
513
00:18:09,159 --> 00:18:11,760
external computations so we need a
514
00:18:11,760 --> 00:18:14,440
decentralized Oracle Network similar to
515
00:18:14,440 --> 00:18:16,400
our decentralized blockchain Network
516
00:18:16,400 --> 00:18:18,400
your onchain logic will be decentralized
517
00:18:18,400 --> 00:18:20,799
but you also need your offchain data and
518
00:18:20,799 --> 00:18:22,440
computation to be decentralized
519
00:18:22,440 --> 00:18:24,520
combining this onchain decentralized
520
00:18:24,520 --> 00:18:27,320
logic with this offchain decentralized
521
00:18:27,320 --> 00:18:29,520
data and decentralized computation gives
522
00:18:29,520 --> 00:18:31,679
rise to something called hybrid smart
523
00:18:31,679 --> 00:18:33,880
contracts and most of the biggest
524
00:18:33,880 --> 00:18:36,120
protocols that we interact with today
525
00:18:36,120 --> 00:18:38,520
are some type of hybrid smart contract
526
00:18:38,520 --> 00:18:40,320
or interact with hybrid smart contracts
527
00:18:40,320 --> 00:18:41,679
to some extent this is where the
528
00:18:41,679 --> 00:18:44,000
protocol chainlink comes into play it is
529
00:18:44,000 --> 00:18:46,720
a modular decentralized Oracle Network
530
00:18:46,720 --> 00:18:49,240
that can both bring external data and
531
00:18:49,240 --> 00:18:51,360
external computation into our smart
532
00:18:51,360 --> 00:18:52,760
contracts to make sure they're
533
00:18:52,760 --> 00:18:55,039
decentralized end to endend while giving
534
00:18:55,039 --> 00:18:57,520
them the feature richness that we need
535
00:18:57,520 --> 00:18:59,720
for our agreements chain link allows for
536
00:18:59,720 --> 00:19:02,440
us to get data do upkeeps get random
537
00:19:02,440 --> 00:19:04,480
numbers or really customize our smart
538
00:19:04,480 --> 00:19:06,520
contracts in any meaningful way now
539
00:19:06,520 --> 00:19:07,799
throughout the course we're going to use
540
00:19:07,799 --> 00:19:10,520
the terminology smart contract however
541
00:19:10,520 --> 00:19:12,520
whenever we say smart contract we're
542
00:19:12,520 --> 00:19:14,600
often using it a little interchangeably
543
00:19:14,600 --> 00:19:16,640
with hybrid smart contracts but just
544
00:19:16,640 --> 00:19:18,120
know that when we say hybrid smart
545
00:19:18,120 --> 00:19:20,360
contract we're talking specifically
546
00:19:20,360 --> 00:19:22,360
about smart contracts that have some
547
00:19:22,360 --> 00:19:24,320
type of offchain component now since
548
00:19:24,320 --> 00:19:26,000
ethereum's release a number of different
549
00:19:26,000 --> 00:19:28,240
blockchains or smart contract platforms
550
00:19:28,240 --> 00:19:30,520
have come to light such as Avalanche
551
00:19:30,520 --> 00:19:33,440
polygon Phantom Harmony and more for the
552
00:19:33,440 --> 00:19:35,200
majority of this course we're going to
553
00:19:35,200 --> 00:19:36,400
be assuming that we're going to be
554
00:19:36,400 --> 00:19:38,520
deploying to the ethereum network
555
00:19:38,520 --> 00:19:40,280
however everything that we learn here is
556
00:19:40,280 --> 00:19:42,240
going to be applicable to the vast
557
00:19:42,240 --> 00:19:43,919
majority of the blockchains out there
558
00:19:43,919 --> 00:19:46,360
like polygon Avalanche Phantom Harmony
559
00:19:46,360 --> 00:19:48,159
Etc and understanding everything from
560
00:19:48,159 --> 00:19:50,120
ethereum fundamentals will give you the
561
00:19:50,120 --> 00:19:52,520
skills that you need to switch chains
562
00:19:52,520 --> 00:19:54,679
very easily with literally one line of
563
00:19:54,679 --> 00:19:56,360
code so don't worry about learning a
564
00:19:56,360 --> 00:19:58,760
specific tool or with a specific change
565
00:19:58,760 --> 00:20:00,799
because most of them work together
566
00:20:00,799 --> 00:20:02,559
seamlessly now there are a couple of
567
00:20:02,559 --> 00:20:04,120
smart contract platforms that don't use
568
00:20:04,120 --> 00:20:06,039
solidity but still learning the
569
00:20:06,039 --> 00:20:07,919
fundamentals here will make you much
570
00:20:07,919 --> 00:20:10,120
better at those as well and ethereum by
571
00:20:10,120 --> 00:20:12,159
far has the most value locked and is the
572
00:20:12,159 --> 00:20:13,840
most used blockchain and smart contract
573
00:20:13,840 --> 00:20:15,440
platform out there you'll also hear
574
00:20:15,440 --> 00:20:16,960
those two terms used a little bit
575
00:20:16,960 --> 00:20:18,679
interchangeably as well sometimes I'll
576
00:20:18,679 --> 00:20:20,240
say smart contract platform sometimes
577
00:20:20,240 --> 00:20:22,159
I'll say blockchain they kind of mean
578
00:20:22,159 --> 00:20:24,200
the same thing obviously blockchains
579
00:20:24,200 --> 00:20:26,480
could mean store of value and smart
580
00:20:26,480 --> 00:20:28,880
contract platform but you get the idea
581
00:20:28,880 --> 00:20:30,960
similarly chain link is the most popular
582
00:20:30,960 --> 00:20:32,679
and Powerful decentralized Oracle
583
00:20:32,679 --> 00:20:34,159
network is the one that we're going to
584
00:20:34,159 --> 00:20:36,159
be focusing on for this course as well
585
00:20:36,159 --> 00:20:38,679
chain link is also blockchain agnostic
586
00:20:38,679 --> 00:20:40,919
so it'll work on ethereum Avalanche
587
00:20:40,919 --> 00:20:43,280
polygon salana or really any other
588
00:20:43,280 --> 00:20:45,320
blockchain out there now additionally
589
00:20:45,320 --> 00:20:47,760
over the last year a new term has come
590
00:20:47,760 --> 00:20:51,600
to light called an L2 or a layer 2 this
591
00:20:51,600 --> 00:20:53,559
solves an issue that most blockchains
592
00:20:53,559 --> 00:20:56,320
see where they don't scale very well or
593
00:20:56,320 --> 00:20:58,760
they don't grow big very well we'll be
594
00:20:58,760 --> 00:21:00,280
talking about l2s a little bit more in
595
00:21:00,280 --> 00:21:02,559
the future but the basic concept of is
596
00:21:02,559 --> 00:21:05,440
that blockchains can really only get so
597
00:21:05,440 --> 00:21:07,600
big so what they do if if this is
598
00:21:07,600 --> 00:21:08,720
ethereum you can actually have
599
00:21:08,720 --> 00:21:10,600
blockchains hook into them to
600
00:21:10,600 --> 00:21:12,440
essentially make them bigger if that
601
00:21:12,440 --> 00:21:14,039
doesn't really make too much sense don't
602
00:21:14,039 --> 00:21:16,000
worry about it for right now layer twos
603
00:21:16,000 --> 00:21:18,520
solve this scalability issues and at the
604
00:21:18,520 --> 00:21:20,400
moment there are two different types of
605
00:21:20,400 --> 00:21:23,520
true layer tws optimistic Roll-Ups and
606
00:21:23,520 --> 00:21:25,200
zero knowledge Roll-Ups optimistic
607
00:21:25,200 --> 00:21:27,840
rollups like arbitr and optimism or zero
608
00:21:27,840 --> 00:21:29,760
knowledge roll-ups like ZK sync or
609
00:21:29,760 --> 00:21:32,640
polygon ZK evm yes there's a polycon
610
00:21:32,640 --> 00:21:36,000
chain but there's also a polycon ZK evm
611
00:21:36,000 --> 00:21:38,400
L2 the two of them are very different
612
00:21:38,400 --> 00:21:39,919
don't worry about them for now and in
613
00:21:39,919 --> 00:21:42,120
fact it's this arbitrum layer two where
614
00:21:42,120 --> 00:21:43,760
our challenge contracts are going to be
615
00:21:43,760 --> 00:21:45,720
deployed on this rollup but like I said
616
00:21:45,720 --> 00:21:47,400
once we learn how blockchains work from
617
00:21:47,400 --> 00:21:50,240
a basic Level under the hood then we'll
618
00:21:50,240 --> 00:21:52,080
explain more about how these l2s
619
00:21:52,080 --> 00:21:53,600
actually work now throughout this course
620
00:21:53,600 --> 00:21:55,279
you'll hear the term dap or
621
00:21:55,279 --> 00:21:57,760
decentralized protocol or smart contract
622
00:21:57,760 --> 00:22:00,279
protocol or decentralized application
623
00:22:00,279 --> 00:22:02,159
and they all kind of mean the same thing
624
00:22:02,159 --> 00:22:04,200
a decentralized application is usually
625
00:22:04,200 --> 00:22:06,760
the combination of many smart contracts
626
00:22:06,760 --> 00:22:08,440
and when we get into solidity you'll see
627
00:22:08,440 --> 00:22:10,480
what a singular smart contract really
628
00:22:10,480 --> 00:22:12,360
looks like and like I said learning all
629
00:22:12,360 --> 00:22:14,559
these core fundamentals will make you a
630
00:22:14,559 --> 00:22:16,400
better solidity and a better smart
631
00:22:16,400 --> 00:22:18,159
contract developer you'll also hear the
632
00:22:18,159 --> 00:22:20,799
term web 3 a lot in this video and in
633
00:22:20,799 --> 00:22:22,799
the industry web 3 is the idea that
634
00:22:22,799 --> 00:22:24,840
blockchains and smart contracts are the
635
00:22:24,840 --> 00:22:27,559
next iteration of the web web one being
636
00:22:27,559 --> 00:22:29,960
this permissionless open- Source world
637
00:22:29,960 --> 00:22:32,320
with static content web 2 being the
638
00:22:32,320 --> 00:22:34,400
permissioned web with Dynamic content
639
00:22:34,400 --> 00:22:36,480
but all the agreements and logic runs
640
00:22:36,480 --> 00:22:38,559
off of centralized servers where they
641
00:22:38,559 --> 00:22:40,600
control your information and then web 3
642
00:22:40,600 --> 00:22:43,000
comes back to the permissionless web but
643
00:22:43,000 --> 00:22:45,360
once again with Dynamic content and
644
00:22:45,360 --> 00:22:47,080
instead of centralized servers running
645
00:22:47,080 --> 00:22:49,640
your logic decentralized networks run
646
00:22:49,640 --> 00:22:51,520
the logic creating these censorship
647
00:22:51,520 --> 00:22:53,640
resistant agreements that these smart
648
00:22:53,640 --> 00:22:55,400
contracts enable it is also generally
649
00:22:55,400 --> 00:22:57,640
accompanied by the idea that the users
650
00:22:57,640 --> 00:22:59,600
own the protocol that they work with and
651
00:22:59,600 --> 00:23:01,360
it's an ownership economy you'll see
652
00:23:01,360 --> 00:23:02,840
what I mean later in this course now
653
00:23:02,840 --> 00:23:04,520
we've talked a lot about the history and
654
00:23:04,520 --> 00:23:06,520
about the high level of these protocols
655
00:23:06,520 --> 00:23:08,240
and of these smart contracts and what
656
00:23:08,240 --> 00:23:10,559
they can do but what do these smart
657
00:23:10,559 --> 00:23:12,919
contracts really mean what is it when I
658
00:23:12,919 --> 00:23:15,240
say trust minimized agreements or
659
00:23:15,240 --> 00:23:17,960
unbreakable promises what is the real
660
00:23:17,960 --> 00:23:20,360
value ad of these smart contracts before
661
00:23:20,360 --> 00:23:22,080
we look under the hood and take a peek
662
00:23:22,080 --> 00:23:23,840
at how this all works from a technical
663
00:23:23,840 --> 00:23:26,600
standpoint let's learn what all the
664
00:23:26,600 --> 00:23:28,480
value of this is what is the purpose of
665
00:23:28,480 --> 00:23:30,120
of us building all these Technologies of
666
00:23:30,120 --> 00:23:32,600
you taking this course what problem does
667
00:23:32,600 --> 00:23:34,520
this technology solve in my mind a
668
00:23:34,520 --> 00:23:36,880
technology is really only as good as the
669
00:23:36,880 --> 00:23:38,520
problem that it solves if it doesn't
670
00:23:38,520 --> 00:23:41,039
solve a problem then why bother smart
671
00:23:41,039 --> 00:23:43,080
contracts blockchain web 3
672
00:23:43,080 --> 00:23:44,760
cryptocurrencies those are all just
673
00:23:44,760 --> 00:23:46,679
different words that encapsulate the
674
00:23:46,679 --> 00:23:48,679
idea of what we're doing in such a
675
00:23:48,679 --> 00:23:51,360
unique Paradigm I think the easiest way
676
00:23:51,360 --> 00:23:53,880
to sum up what these smart contracts do
677
00:23:53,880 --> 00:23:55,880
is that they create trust minimized
678
00:23:55,880 --> 00:23:57,360
agreements and if you might be
679
00:23:57,360 --> 00:23:59,080
scratching your head to that a much
680
00:23:59,080 --> 00:24:01,000
easier way to think about it is just
681
00:24:01,000 --> 00:24:04,279
they give rise to Unbreakable promises
682
00:24:04,279 --> 00:24:06,679
Yes you heard that right unbreakable
683
00:24:06,679 --> 00:24:08,880
agreements and Promises additionally
684
00:24:08,880 --> 00:24:10,960
they give rise to speed efficiency and
685
00:24:10,960 --> 00:24:12,799
transparency and a number of other
686
00:24:12,799 --> 00:24:14,880
things I made a video pretty recently
687
00:24:14,880 --> 00:24:17,840
about exactly this so let's dive in and
688
00:24:17,840 --> 00:24:19,760
take a listen to the purpose the
689
00:24:19,760 --> 00:24:23,919
undeniable value of smart
690
00:24:24,440 --> 00:24:27,039
contracts cryptocurrencies fundamentally
691
00:24:27,039 --> 00:24:28,880
Rel landscape Market markets and
692
00:24:28,880 --> 00:24:31,200
agreements as we know them unfortunately
693
00:24:31,200 --> 00:24:32,720
you've probably only been bombarded with
694
00:24:32,720 --> 00:24:34,760
people screaming about nfts and money
695
00:24:34,760 --> 00:24:36,440
now some of the memes are fun but let's
696
00:24:36,440 --> 00:24:38,000
forget the and get down to the
697
00:24:38,000 --> 00:24:40,000
essence of this space if you're already
698
00:24:40,000 --> 00:24:42,240
in web 3 this is the video to send to
699
00:24:42,240 --> 00:24:44,200
your friends to explain why you're so
700
00:24:44,200 --> 00:24:46,480
excited about this space and explain why
701
00:24:46,480 --> 00:24:48,200
we're here and then if you're not into
702
00:24:48,200 --> 00:24:50,039
crypto you've come to the right place
703
00:24:50,039 --> 00:24:52,000
and yes there are fun memes and markets
704
00:24:52,000 --> 00:24:53,440
and there's some money stuff and there
705
00:24:53,440 --> 00:24:55,600
all these things but outside of all that
706
00:24:55,600 --> 00:24:57,600
the purpose of blockchains relates to
707
00:24:57,600 --> 00:24:59,760
the age old old elementary school
708
00:24:59,760 --> 00:25:02,440
unbreakable promise the pinky swear
709
00:25:02,440 --> 00:25:03,279
let's get
710
00:25:03,279 --> 00:25:05,840
froggy nearly everything you do in life
711
00:25:05,840 --> 00:25:07,919
is the result of an agreement or a
712
00:25:07,919 --> 00:25:10,320
contract your chair was the result of an
713
00:25:10,320 --> 00:25:11,840
agreement to buy and sell lumber to
714
00:25:11,840 --> 00:25:13,080
assemble and sell the chair to a
715
00:25:13,080 --> 00:25:15,480
retailer on Amazon then you made an
716
00:25:15,480 --> 00:25:18,200
agreement to buy the chair for $40 the
717
00:25:18,200 --> 00:25:19,679
lights in your house are powered by
718
00:25:19,679 --> 00:25:21,480
electricity which is an agreement from
719
00:25:21,480 --> 00:25:22,799
you and the electric company you agree
720
00:25:22,799 --> 00:25:24,200
to pay them in return they'll keep the
721
00:25:24,200 --> 00:25:25,880
lights on the electricity that they
722
00:25:25,880 --> 00:25:27,679
generate is agreements between them and
723
00:25:27,679 --> 00:25:29,880
Engineers who built turbines to generate
724
00:25:29,880 --> 00:25:31,760
the electricity with insurance you agree
725
00:25:31,760 --> 00:25:33,320
to pay some amount of money to them
726
00:25:33,320 --> 00:25:35,520
every month and in return they will do
727
00:25:35,520 --> 00:25:37,799
nothing or I mean they'll cover your
728
00:25:37,799 --> 00:25:39,960
medical bills almost everything you do
729
00:25:39,960 --> 00:25:41,840
and everything you interact with is the
730
00:25:41,840 --> 00:25:43,880
result of some form of agreement or
731
00:25:43,880 --> 00:25:46,320
contract in some aspect now agreements
732
00:25:46,320 --> 00:25:48,120
and contracts can feel kind of abstract
733
00:25:48,120 --> 00:25:50,559
and boring to really grasp on to so to
734
00:25:50,559 --> 00:25:52,600
simplify we can also refer to them as
735
00:25:52,600 --> 00:25:54,440
promises when you get an oil change
736
00:25:54,440 --> 00:25:55,679
they're promising that they will
737
00:25:55,679 --> 00:25:57,559
Faithfully change your oil in exchange
738
00:25:57,559 --> 00:25:59,880
for money when you put money in the bank
739
00:25:59,880 --> 00:26:01,720
they promised to keep it safe in
740
00:26:01,720 --> 00:26:03,720
exchange for them to use your money to
741
00:26:03,720 --> 00:26:05,679
give out loans when you buy a lottery
742
00:26:05,679 --> 00:26:07,640
ticket the lottery promises to give you
743
00:26:07,640 --> 00:26:09,480
a fair chance at winning a ton of money
744
00:26:09,480 --> 00:26:11,559
in exchange for you buying the ticket
745
00:26:11,559 --> 00:26:12,720
whenever you make one of these
746
00:26:12,720 --> 00:26:15,320
agreements in a way you're asking them
747
00:26:15,320 --> 00:26:18,080
to pinky swear to not screw you over and
748
00:26:18,080 --> 00:26:19,799
to treat you fairly but this doesn't
749
00:26:19,799 --> 00:26:21,880
always happen let's look at a real world
750
00:26:21,880 --> 00:26:23,799
example of someone breaking the pinky
751
00:26:23,799 --> 00:26:25,399
swear back in the ' 80s and '90s
752
00:26:25,399 --> 00:26:27,080
McDonald's ran a promotion for people to
753
00:26:27,080 --> 00:26:28,799
win money by collecting McDonald's
754
00:26:28,799 --> 00:26:30,880
Monopoly game cards the idea was simple
755
00:26:30,880 --> 00:26:32,559
you buy McDonald's in return you get a
756
00:26:32,559 --> 00:26:34,880
chance to win $1
757
00:26:34,880 --> 00:26:37,120
million you can imagine McDonald's
758
00:26:37,120 --> 00:26:39,240
literally going hey everybody I promise
759
00:26:39,240 --> 00:26:41,240
if you buy our MC food and McNuggets
760
00:26:41,240 --> 00:26:42,880
we'll give you a fair chance of winning
761
00:26:42,880 --> 00:26:43,760
this
762
00:26:43,760 --> 00:26:45,960
money but they ended up breaking This
763
00:26:45,960 --> 00:26:47,720
Promise instead of having a fair chance
764
00:26:47,720 --> 00:26:51,080
of winning your chance was in fact zero
765
00:26:51,080 --> 00:26:55,120
in the mid90s between 13 and $24 million
766
00:26:55,120 --> 00:26:56,960
went into the pockets of not people
767
00:26:56,960 --> 00:26:59,159
playing the game honestly but a group of
768
00:26:59,159 --> 00:27:01,600
corrupt insiders who had rigged the game
769
00:27:01,600 --> 00:27:02,720
meaning that when you played the
770
00:27:02,720 --> 00:27:04,960
McDonald's Monopoly game you were buying
771
00:27:04,960 --> 00:27:06,760
into a set of lies and promises that
772
00:27:06,760 --> 00:27:10,320
were 100% always going to be broken and
773
00:27:10,320 --> 00:27:11,679
the thing is it doesn't really matter if
774
00:27:11,679 --> 00:27:13,640
this was McDonald's fault or not they
775
00:27:13,640 --> 00:27:15,240
were the ones making the promises that
776
00:27:15,240 --> 00:27:17,480
they ultimately could not keep another
777
00:27:17,480 --> 00:27:18,520
way you can think about it is that
778
00:27:18,520 --> 00:27:21,600
that's $24 million that they essentially
779
00:27:21,600 --> 00:27:25,360
stole from you and I now if this system
780
00:27:25,360 --> 00:27:27,120
was deployed on a blockchain with
781
00:27:27,120 --> 00:27:28,960
something called a smart contract it
782
00:27:28,960 --> 00:27:32,120
would have been impossible to defraud
783
00:27:32,120 --> 00:27:35,320
this $24 million due to Smart contracts
784
00:27:35,320 --> 00:27:37,840
being a mutable decentralized and
785
00:27:37,840 --> 00:27:39,600
transparent but I'll get back to that in
786
00:27:39,600 --> 00:27:40,360
a
787
00:27:40,360 --> 00:27:42,519
minute in all the agreements and
788
00:27:42,519 --> 00:27:45,200
contracts we make imagine making a pinky
789
00:27:45,200 --> 00:27:47,519
swear with a 10-year-old and imagining
790
00:27:47,519 --> 00:27:49,279
how that agreement would hold up hey
791
00:27:49,279 --> 00:27:50,760
buddy could you could you please keep my
792
00:27:50,760 --> 00:27:52,279
money safe you can play with it if you
793
00:27:52,279 --> 00:27:53,799
like but just just please have it when I
794
00:27:53,799 --> 00:27:56,000
come back immediately you might get that
795
00:27:56,000 --> 00:27:57,760
worrying feeling in your chest something
796
00:27:57,760 --> 00:27:59,320
might go wrong that this 10-year-old
797
00:27:59,320 --> 00:28:00,679
might lose your money you might be
798
00:28:00,679 --> 00:28:03,399
thinking how could I trust them will
799
00:28:03,399 --> 00:28:05,399
they break their promise and this
800
00:28:05,399 --> 00:28:07,640
feeling of I can't breathe because of
801
00:28:07,640 --> 00:28:10,480
untrustworthy situations happens to us
802
00:28:10,480 --> 00:28:12,559
all the time can I trust this used car
803
00:28:12,559 --> 00:28:14,679
salesperson to give me a good car can I
804
00:28:14,679 --> 00:28:16,279
trust this tag that says machine
805
00:28:16,279 --> 00:28:18,080
washable or will it make my shirt shrink
806
00:28:18,080 --> 00:28:19,640
will my insurance provider break their
807
00:28:19,640 --> 00:28:21,320
promise of covering my medical bills
808
00:28:21,320 --> 00:28:23,360
when I get hit by a bus when Patrick
809
00:28:23,360 --> 00:28:25,600
promises he'll go on a hike with me will
810
00:28:25,600 --> 00:28:28,399
he actually yes I I I actually will the
811
00:28:28,399 --> 00:28:29,960
issue with our current agreements and
812
00:28:29,960 --> 00:28:32,039
contracts is we have to trust the people
813
00:28:32,039 --> 00:28:33,600
who are making them to do the right
814
00:28:33,600 --> 00:28:35,559
thing however often they're actually
815
00:28:35,559 --> 00:28:37,960
incentivized to not do the right thing
816
00:28:37,960 --> 00:28:40,200
insurance doesn't want to pay out money
817
00:28:40,200 --> 00:28:42,159
sometimes salese just want to get the
818
00:28:42,159 --> 00:28:43,640
off their shelves and with my
819
00:28:43,640 --> 00:28:45,600
girlfriend I promised to go on a hike
820
00:28:45,600 --> 00:28:47,760
but I hate hikes where else has this
821
00:28:47,760 --> 00:28:49,399
happened now you might be thinking okay
822
00:28:49,399 --> 00:28:51,720
Patrick this seems cool but like where
823
00:28:51,720 --> 00:28:53,360
has this actually affected me well the
824
00:28:53,360 --> 00:28:54,880
McDonald's Lottery that we just spoke
825
00:28:54,880 --> 00:28:56,880
about above during the Great Depression
826
00:28:56,880 --> 00:28:58,640
with the run of the banks Banks promised
827
00:28:58,640 --> 00:29:00,279
to keep our money safe and that when we
828
00:29:00,279 --> 00:29:02,000
went back to go get it they would
829
00:29:02,000 --> 00:29:04,320
actually have the money there and well
830
00:29:04,320 --> 00:29:06,000
and behold there were times that they
831
00:29:06,000 --> 00:29:07,880
didn't have the money there just last
832
00:29:07,880 --> 00:29:10,159
year Robin Hood painted this amazing
833
00:29:10,159 --> 00:29:12,600
picture come use our application we will
834
00:29:12,600 --> 00:29:14,519
give you access to the markets we
835
00:29:14,519 --> 00:29:17,240
promise we will give you a retail
836
00:29:17,240 --> 00:29:20,039
investor a fair chance of interacting
837
00:29:20,039 --> 00:29:22,039
with the world of
838
00:29:22,039 --> 00:29:24,880
Finance Psy but not this asset this
839
00:29:24,880 --> 00:29:27,240
asset this asset or this asset the 2008
840
00:29:27,240 --> 00:29:29,440
financial crisis remember that shady
841
00:29:29,440 --> 00:29:30,960
deals behind closed doors combined with
842
00:29:30,960 --> 00:29:32,640
lies about financial product brought the
843
00:29:32,640 --> 00:29:35,000
world to its economic knees how are you
844
00:29:35,000 --> 00:29:36,919
us hyperinflation in Zimbabwe
845
00:29:36,919 --> 00:29:39,159
hyperinflation in Brazil fair enough
846
00:29:39,159 --> 00:29:41,559
history is a Relentless lesson of
847
00:29:41,559 --> 00:29:44,159
trustworthy entities being notorious
848
00:29:44,159 --> 00:29:46,039
promise Breakers we finally have a way
849
00:29:46,039 --> 00:29:48,559
to fix it with smart contracts now
850
00:29:48,559 --> 00:29:50,120
before I jump into smart contracts a lot
851
00:29:50,120 --> 00:29:52,720
of people might be thinking hey cool and
852
00:29:52,720 --> 00:29:55,840
all however we have systems in place to
853
00:29:55,840 --> 00:29:57,720
protect against a lot of these things
854
00:29:57,720 --> 00:29:59,720
which is is true and which is great and
855
00:29:59,720 --> 00:30:01,919
that is a very helpful step forward but
856
00:30:01,919 --> 00:30:04,440
these systems often break ones in 2008
857
00:30:04,440 --> 00:30:06,120
definitely didn't work the ones with the
858
00:30:06,120 --> 00:30:07,880
Robin Hood crisis definitely didn't work
859
00:30:07,880 --> 00:30:10,279
and even if these systems apply and you
860
00:30:10,279 --> 00:30:12,440
go to court to try to work them out
861
00:30:12,440 --> 00:30:14,480
maybe you're in court for years before
862
00:30:14,480 --> 00:30:16,039
you actually see a resolution and by
863
00:30:16,039 --> 00:30:18,720
that time what you needed the money for
864
00:30:18,720 --> 00:30:21,159
is long gone so what is this technology
865
00:30:21,159 --> 00:30:23,600
what is this tool that can fix this
866
00:30:23,600 --> 00:30:25,799
fundamental problem in our agreements
867
00:30:25,799 --> 00:30:28,039
today this tool is smart contracts and
868
00:30:28,039 --> 00:30:30,240
this tool is what the blockchain was
869
00:30:30,240 --> 00:30:31,919
built for now I'm going to give you a
870
00:30:31,919 --> 00:30:33,919
quick overview of what a smart contract
871
00:30:33,919 --> 00:30:36,000
is however I'm leaving some links in the
872
00:30:36,000 --> 00:30:37,799
description for more in-depth
873
00:30:37,799 --> 00:30:39,919
explanations but the basics of them is a
874
00:30:39,919 --> 00:30:42,320
smart contract is an agreement contract
875
00:30:42,320 --> 00:30:44,880
or a set of instructions deployed on a
876
00:30:44,880 --> 00:30:47,000
decentralized blockchain and once the
877
00:30:47,000 --> 00:30:48,760
contract or set of instructions is
878
00:30:48,760 --> 00:30:51,320
deployed it cannot be altered it
879
00:30:51,320 --> 00:30:53,600
automatically executes and everyone can
880
00:30:53,600 --> 00:30:55,679
see the terms of the agreement the real
881
00:30:55,679 --> 00:30:57,200
basics of it is that the code is
882
00:30:57,200 --> 00:30:59,559
executed by decentralized Collective
883
00:30:59,559 --> 00:31:01,159
like a group of people but a group of
884
00:31:01,159 --> 00:31:02,960
people running a certain software this
885
00:31:02,960 --> 00:31:05,399
means that no one person or entity can
886
00:31:05,399 --> 00:31:07,080
actually alter any of these agreements
887
00:31:07,080 --> 00:31:08,960
or change the terms of the arrangement
888
00:31:08,960 --> 00:31:10,840
in these traditional agreements whoever
889
00:31:10,840 --> 00:31:13,039
owns the contract whoever owns the
890
00:31:13,039 --> 00:31:15,080
execution of the contract can flip a
891
00:31:15,080 --> 00:31:17,240
switch and say n we're not going to do
892
00:31:17,240 --> 00:31:19,159
that anymore in smart contracts in web 3
893
00:31:19,159 --> 00:31:21,320
in blockchain you no longer can do that
894
00:31:21,320 --> 00:31:23,080
typically these smart contracts are in a
895
00:31:23,080 --> 00:31:25,159
decentralized blockchain and used in
896
00:31:25,159 --> 00:31:27,000
combination with a decentralized Oracle
897
00:31:27,000 --> 00:31:29,080
Network to get the real world assets and
898
00:31:29,080 --> 00:31:30,679
information and if these words sound
899
00:31:30,679 --> 00:31:32,440
like I'm Conjuring up a magic spell well
900
00:31:32,440 --> 00:31:33,919
again check the links in the description
901
00:31:33,919 --> 00:31:35,039
if you want to learn more about the
902
00:31:35,039 --> 00:31:36,679
technical implications if you're not a
903
00:31:36,679 --> 00:31:37,799
technical person and you're not
904
00:31:37,799 --> 00:31:39,519
interested in getting to the Integrity
905
00:31:39,519 --> 00:31:42,000
you can kind of think of it like https I
906
00:31:42,000 --> 00:31:43,519
bet the vast majority of you don't even
907
00:31:43,519 --> 00:31:45,880
know what https stands for and yet you
908
00:31:45,880 --> 00:31:47,679
use it every single day whenever you log
909
00:31:47,679 --> 00:31:49,360
onto the internet so how does this fix
910
00:31:49,360 --> 00:31:51,440
the McDonald's Monopoly issue in its
911
00:31:51,440 --> 00:31:53,440
traditional form the lottery was
912
00:31:53,440 --> 00:31:56,200
executed behind closed doors somebody
913
00:31:56,200 --> 00:31:58,360
operated and owned the code and the
914
00:31:58,360 --> 00:31:59,880
contracts and the agreements that ran
915
00:31:59,880 --> 00:32:01,840
the lottery and they had the power to
916
00:32:01,840 --> 00:32:03,840
alter it and nobody other than the
917
00:32:03,840 --> 00:32:05,880
people internal on the lottery could
918
00:32:05,880 --> 00:32:08,200
audit this altering happening now if the
919
00:32:08,200 --> 00:32:10,720
code for this Lottery was deployed onto
920
00:32:10,720 --> 00:32:13,240
a blockchain every time a hacker
921
00:32:13,240 --> 00:32:15,080
attempted to alter it everyone would be
922
00:32:15,080 --> 00:32:17,200
notified not only that but you couldn't
923
00:32:17,200 --> 00:32:18,840
even alter it because the terms of a
924
00:32:18,840 --> 00:32:20,720
smart contract cannot be altered once
925
00:32:20,720 --> 00:32:22,600
deployed combine that smart contract
926
00:32:22,600 --> 00:32:24,360
with a chain link vrf Oracle to get a
927
00:32:24,360 --> 00:32:27,279
verifiably random number and Presto you
928
00:32:27,279 --> 00:32:29,320
now have a perfectly decentralized
929
00:32:29,320 --> 00:32:31,600
unalterable agreement that is impossible
930
00:32:31,600 --> 00:32:33,559
to hack commit fraud or manipulate we
931
00:32:33,559 --> 00:32:36,120
have just saved the public between 13
932
00:32:36,120 --> 00:32:39,919
million and $24 million just by fixing
933
00:32:39,919 --> 00:32:42,679
the issue of trust how does this fix
934
00:32:42,679 --> 00:32:44,200
Robin Hood well the problem with Robin
935
00:32:44,200 --> 00:32:46,240
Hood is already fixed right again the
936
00:32:46,240 --> 00:32:48,080
problem is that there's a centralized
937
00:32:48,080 --> 00:32:50,760
body that can flip a switch at any time
938
00:32:50,760 --> 00:32:52,519
and say yeah you can't access these
939
00:32:52,519 --> 00:32:54,240
markets anymore we're breaking our
940
00:32:54,240 --> 00:32:56,360
promise of actually giving you access to
941
00:32:56,360 --> 00:32:58,360
the markets this is already fixed with
942
00:32:58,360 --> 00:33:00,200
something called decentralized exchanges
943
00:33:00,200 --> 00:33:02,240
and these exist today one of these
944
00:33:02,240 --> 00:33:04,200
exchanges is one called Unis swap you
945
00:33:04,200 --> 00:33:06,679
can swap erc20 tokens which are kind of
946
00:33:06,679 --> 00:33:08,919
the equivalent of stocks but some aren't
947
00:33:08,919 --> 00:33:10,320
some are it's a little confusing I won't
948
00:33:10,320 --> 00:33:12,240
get into that here either but it doesn't
949
00:33:12,240 --> 00:33:14,240
have that centralized body that can flip
950
00:33:14,240 --> 00:33:17,200
a switch and ruin access to the markets
951
00:33:17,200 --> 00:33:19,120
and had these investors been on a
952
00:33:19,120 --> 00:33:21,120
decentralized exchange it would have
953
00:33:21,120 --> 00:33:23,720
saved them hundreds of millions of
954
00:33:23,720 --> 00:33:25,120
dollars and it would have prevented
955
00:33:25,120 --> 00:33:27,039
fraudulent Market manipulation how does
956
00:33:27,039 --> 00:33:28,480
it fix run of the banks with
957
00:33:28,480 --> 00:33:30,279
transparency built in and automated
958
00:33:30,279 --> 00:33:32,159
solvency checks you can build a bank
959
00:33:32,159 --> 00:33:33,960
like smart contract that has insolvency
960
00:33:33,960 --> 00:33:35,919
checks built in that make it impossible
961
00:33:35,919 --> 00:33:38,440
to get there insolvent means broke as
962
00:33:38,440 --> 00:33:41,320
any agreement or any history lesson
963
00:33:41,320 --> 00:33:42,960
where there was a trust assumption that
964
00:33:42,960 --> 00:33:45,679
was broken smart contracts can be
965
00:33:45,679 --> 00:33:48,000
applied to and should be applied to
966
00:33:48,000 --> 00:33:49,720
especially in a time where big money
967
00:33:49,720 --> 00:33:52,600
runs owns and controls everything we
968
00:33:52,600 --> 00:33:54,799
desperately need to move to a world
969
00:33:54,799 --> 00:33:56,720
where some self-interested centralized
970
00:33:56,720 --> 00:33:58,960
entity can't flip us switch and ruin
971
00:33:58,960 --> 00:34:00,679
people's access to the services that
972
00:34:00,679 --> 00:34:03,200
they need we can move away from a world
973
00:34:03,200 --> 00:34:05,799
that is brand-based to a world that is
974
00:34:05,799 --> 00:34:07,919
math-based right now if you interact
975
00:34:07,919 --> 00:34:09,919
with a service that you don't like or
976
00:34:09,919 --> 00:34:12,079
that they break their promise the only
977
00:34:12,079 --> 00:34:14,320
thing you can do is walk down the street
978
00:34:14,320 --> 00:34:15,839
to the next service that's going to make
979
00:34:15,839 --> 00:34:17,679
the same set of promises and you have to
980
00:34:17,679 --> 00:34:18,879
hope and pray that they're actually
981
00:34:18,879 --> 00:34:21,320
going to keep it we can move from that
982
00:34:21,320 --> 00:34:23,079
to a world where we can just look at the
983
00:34:23,079 --> 00:34:26,000
math and say oh okay 1+ 1 equal 2 this
984
00:34:26,000 --> 00:34:27,359
is what this agreement is going to do
985
00:34:27,359 --> 00:34:30,720
for me every single time guaranteed
986
00:34:30,720 --> 00:34:32,679
because it's a decentralized autonomous
987
00:34:32,679 --> 00:34:35,280
agent has no incentive to be evil and
988
00:34:35,280 --> 00:34:36,839
everything is transparent and out in the
989
00:34:36,839 --> 00:34:38,720
open I'm a big company and if it was
990
00:34:38,720 --> 00:34:41,480
better for me for 1+ 1 to equal three
991
00:34:41,480 --> 00:34:42,839
maybe I would go behind some closed
992
00:34:42,839 --> 00:34:44,480
doors and fudge some numbers and come
993
00:34:44,480 --> 00:34:47,599
back out and be like hey 1+ 1 equals 3
994
00:34:47,599 --> 00:34:48,879
but with smart contracts that's
995
00:34:48,879 --> 00:34:51,720
impossible doing the right thing is
996
00:34:51,720 --> 00:34:53,760
infrastructural now given the choice
997
00:34:53,760 --> 00:34:55,679
between two agreements one where you
998
00:34:55,679 --> 00:34:57,720
have to trust a single centralized
999
00:34:57,720 --> 00:34:58,960
entity that they're going to do the
1000
00:34:58,960 --> 00:35:01,400
right thing for you versus a
1001
00:35:01,400 --> 00:35:04,280
decentralized untable collective which
1002
00:35:04,280 --> 00:35:06,040
one are you going to choose I'm picking
1003
00:35:06,040 --> 00:35:07,800
the one that can't screw me over every
1004
00:35:07,800 --> 00:35:10,640
single time for every agreement I can
1005
00:35:10,640 --> 00:35:12,520
apply it to now this technology is
1006
00:35:12,520 --> 00:35:14,640
relatively new but we have already seen
1007
00:35:14,640 --> 00:35:16,920
it Rel landscape entire markets and
1008
00:35:16,920 --> 00:35:18,960
continue to do so the traditional
1009
00:35:18,960 --> 00:35:20,680
Financial world is already getting its
1010
00:35:20,680 --> 00:35:23,800
lunch eaten by defy or decentralized
1011
00:35:23,800 --> 00:35:25,760
Finance there's already over $200
1012
00:35:25,760 --> 00:35:27,960
billion of people's money in these
1013
00:35:27,960 --> 00:35:30,440
protocols to help have a more fair more
1014
00:35:30,440 --> 00:35:32,440
accountable more transparent Financial
1015
00:35:32,440 --> 00:35:34,520
system this D5 movement is one of the
1016
00:35:34,520 --> 00:35:36,240
main reasons I got into this space
1017
00:35:36,240 --> 00:35:39,040
because we desperately need to move away
1018
00:35:39,040 --> 00:35:41,160
from where we are right now and end
1019
00:35:41,160 --> 00:35:43,079
people's chances for wealth being sucked
1020
00:35:43,079 --> 00:35:44,920
up by some group that's bending the
1021
00:35:44,920 --> 00:35:46,960
rules in their favor and smart contracts
1022
00:35:46,960 --> 00:35:49,000
are a ticket to that better World more
1023
00:35:49,000 --> 00:35:50,800
and more Industries are also coming over
1024
00:35:50,800 --> 00:35:52,240
to Smart contracts and blockchain
1025
00:35:52,240 --> 00:35:53,680
because of all the Innovations and
1026
00:35:53,680 --> 00:35:55,319
because of all the advantages that it
1027
00:35:55,319 --> 00:35:57,640
has as we grow and as we get better we
1028
00:35:57,640 --> 00:35:59,800
we get closer to this vision of having
1029
00:35:59,800 --> 00:36:03,000
this concept fulfilled trust minimized
1030
00:36:03,000 --> 00:36:04,920
agreements these smart contracts are
1031
00:36:04,920 --> 00:36:07,119
minimizing the trust that we need to
1032
00:36:07,119 --> 00:36:08,760
give other people in order for these
1033
00:36:08,760 --> 00:36:10,480
agreements to be executed if trust
1034
00:36:10,480 --> 00:36:12,000
minimized agreements is too confusing
1035
00:36:12,000 --> 00:36:14,720
for you just say unbreakable promises
1036
00:36:14,720 --> 00:36:16,480
now I got to be honest with you guys
1037
00:36:16,480 --> 00:36:18,000
blockchains and smart contracts and
1038
00:36:18,000 --> 00:36:19,440
cryptocurrencies can actually do more
1039
00:36:19,440 --> 00:36:21,319
than just trust minimized agreements
1040
00:36:21,319 --> 00:36:23,319
what they have Security benefits uptime
1041
00:36:23,319 --> 00:36:25,160
benefits execution speed benefits and a
1042
00:36:25,160 --> 00:36:26,680
whole lot more but it's a lot easier to
1043
00:36:26,680 --> 00:36:28,079
just learn about one and learn the other
1044
00:36:28,079 --> 00:36:29,240
ones later right it's kind of like
1045
00:36:29,240 --> 00:36:31,520
sprinkles on top so this is why we are
1046
00:36:31,520 --> 00:36:33,040
here this is why we're building this
1047
00:36:33,040 --> 00:36:35,800
future and this is why we are so excited
1048
00:36:35,800 --> 00:36:38,040
about
1049
00:36:38,040 --> 00:36:40,960
it last year 2022 there were a lot of
1050
00:36:40,960 --> 00:36:43,040
issues with a couple different companies
1051
00:36:43,040 --> 00:36:46,640
like for example spf's FTX platform the
1052
00:36:46,640 --> 00:36:48,359
thing to me that's most frustrating
1053
00:36:48,359 --> 00:36:50,359
about that situation is that FTX
1054
00:36:50,359 --> 00:36:52,680
platform wasn't anything that I just
1055
00:36:52,680 --> 00:36:54,640
talked about it wasn't decentralized it
1056
00:36:54,640 --> 00:36:57,119
wasn't trustless it wasn't transparent
1057
00:36:57,119 --> 00:36:59,359
it was purely a traditional web 2
1058
00:36:59,359 --> 00:37:01,560
company pretending to be web 3 and just
1059
00:37:01,560 --> 00:37:03,920
using the cryptocurrency part of web 3
1060
00:37:03,920 --> 00:37:05,560
but not actually using the smart
1061
00:37:05,560 --> 00:37:07,280
contracts and we're doing a much better
1062
00:37:07,280 --> 00:37:09,280
job as a community getting rid of the
1063
00:37:09,280 --> 00:37:10,599
Bad actors and this is something that's
1064
00:37:10,599 --> 00:37:12,440
incredibly important for you when
1065
00:37:12,440 --> 00:37:14,079
working with protocols and when building
1066
00:37:14,079 --> 00:37:15,839
protocols I want you to be incredibly
1067
00:37:15,839 --> 00:37:17,440
successful here but I want you to be
1068
00:37:17,440 --> 00:37:18,839
incredibly successful because you're
1069
00:37:18,839 --> 00:37:20,960
making a ton of value a lot of these
1070
00:37:20,960 --> 00:37:22,920
platforms that we saw collapsing last
1071
00:37:22,920 --> 00:37:24,839
year were not creating value they were
1072
00:37:24,839 --> 00:37:26,839
stealing value they were siphoning value
1073
00:37:26,839 --> 00:37:29,800
they were faking having value and as you
1074
00:37:29,800 --> 00:37:31,680
learn and as you build smart contracts
1075
00:37:31,680 --> 00:37:34,119
yourself it'll start to become innately
1076
00:37:34,119 --> 00:37:36,160
aware of what protocols and what
1077
00:37:36,160 --> 00:37:39,280
companies are centralized and are not
1078
00:37:39,280 --> 00:37:42,760
the ethos of web 3 and the ones that are
1079
00:37:42,760 --> 00:37:45,240
we are building verifiable trust
1080
00:37:45,240 --> 00:37:47,119
minimized agreements unbreakable
1081
00:37:47,119 --> 00:37:49,160
promises and if you can't verify those
1082
00:37:49,160 --> 00:37:51,599
promises then it's not trust minimized
1083
00:37:51,599 --> 00:37:53,880
it's not web 3 it's not what this
1084
00:37:53,880 --> 00:37:55,680
industry is for that's what I want you
1085
00:37:55,680 --> 00:37:58,400
to do as you finish this course is be a
1086
00:37:58,400 --> 00:38:01,560
force for good unfortunately because a
1087
00:38:01,560 --> 00:38:03,200
lot of people haven't taken my course
1088
00:38:03,200 --> 00:38:04,920
not everybody understands the difference
1089
00:38:04,920 --> 00:38:07,599
between a legitimate project and a token
1090
00:38:07,599 --> 00:38:09,040
that's just meant to pump somebody's
1091
00:38:09,040 --> 00:38:11,760
bags as this space continues to grow and
1092
00:38:11,760 --> 00:38:13,359
as people like yourself take courses
1093
00:38:13,359 --> 00:38:15,319
like this we will get to continue to
1094
00:38:15,319 --> 00:38:17,760
push real legitimate projects forward
1095
00:38:17,760 --> 00:38:19,880
and wash out the projects that aren't
1096
00:38:19,880 --> 00:38:23,079
actually contributing to web
1097
00:38:23,160 --> 00:38:26,400
3 even in just this introduction part
1098
00:38:26,400 --> 00:38:28,599
we've learned a ton so let's do a quick
1099
00:38:28,599 --> 00:38:30,680
summary of what we've learned so far
1100
00:38:30,680 --> 00:38:32,440
Bitcoin was the first protocol to take
1101
00:38:32,440 --> 00:38:34,520
this blockchain technology into the
1102
00:38:34,520 --> 00:38:35,640
Limelight and take these
1103
00:38:35,640 --> 00:38:37,520
cryptocurrencies into the mainstream
1104
00:38:37,520 --> 00:38:39,839
Bitcoin is a sort of digital gold or a
1105
00:38:39,839 --> 00:38:42,160
store of value able to make transactions
1106
00:38:42,160 --> 00:38:44,400
between users in a decentralized manner
1107
00:38:44,400 --> 00:38:45,720
ethereum and other smart contract
1108
00:38:45,720 --> 00:38:47,160
platforms take this blockchain
1109
00:38:47,160 --> 00:38:49,640
technology one step further enabling
1110
00:38:49,640 --> 00:38:51,200
people to make smart contracts in
1111
00:38:51,200 --> 00:38:53,640
decentralized trust minimized agreements
1112
00:38:53,640 --> 00:38:55,440
these smart contracts and decentralized
1113
00:38:55,440 --> 00:38:57,440
applications can access an inter
1114
00:38:57,440 --> 00:38:59,200
interact with the real world using
1115
00:38:59,200 --> 00:39:01,119
something called decentralized Oracle
1116
00:39:01,119 --> 00:39:03,200
networks chain link is a decentralized
1117
00:39:03,200 --> 00:39:05,079
network that allows us to build these
1118
00:39:05,079 --> 00:39:07,480
hybrid smart contracts which combines
1119
00:39:07,480 --> 00:39:10,599
our onchain logic with our offchain
1120
00:39:10,599 --> 00:39:12,720
decentralized data and decentralized
1121
00:39:12,720 --> 00:39:15,079
computation giving rise to our logic
1122
00:39:15,079 --> 00:39:17,079
being completely decentralized and our
1123
00:39:17,079 --> 00:39:18,880
data and external computation being
1124
00:39:18,880 --> 00:39:21,119
completely decentralized giving us all
1125
00:39:21,119 --> 00:39:23,160
the features that traditional agreements
1126
00:39:23,160 --> 00:39:25,599
and traditional contracts have now these
1127
00:39:25,599 --> 00:39:27,440
digital currencies like ethereum and
1128
00:39:27,440 --> 00:39:29,839
Bitcoin have value even without the
1129
00:39:29,839 --> 00:39:32,079
smart contract part having a censorship
1130
00:39:32,079 --> 00:39:34,400
resistant decentralized store of value
1131
00:39:34,400 --> 00:39:36,359
is immeasurably powerful in its own
1132
00:39:36,359 --> 00:39:37,839
right we have some links in the GitHub
1133
00:39:37,839 --> 00:39:39,359
repository that'll teach you how this
1134
00:39:39,359 --> 00:39:41,440
decentralized store value flips
1135
00:39:41,440 --> 00:39:43,359
traditional Finance on its head and it's
1136
00:39:43,359 --> 00:39:44,800
another one of the great reasons for
1137
00:39:44,800 --> 00:39:46,960
building smart contracts but again the
1138
00:39:46,960 --> 00:39:49,200
easiest way to boil it down is trust
1139
00:39:49,200 --> 00:39:53,119
minimized agreements or unbreakable
1140
00:39:53,599 --> 00:39:55,760
promises but let's also go into some of
1141
00:39:55,760 --> 00:39:56,920
these other features that smart
1142
00:39:56,920 --> 00:39:58,640
contracts have over our traditional
1143
00:39:58,640 --> 00:40:00,480
environment the first feature of course
1144
00:40:00,480 --> 00:40:02,200
is that they are decentralized and they
1145
00:40:02,200 --> 00:40:04,280
have no centralized intermediary the
1146
00:40:04,280 --> 00:40:05,960
different individuals that run one of
1147
00:40:05,960 --> 00:40:07,880
these blockchains are known as node
1148
00:40:07,880 --> 00:40:10,000
operators and it's the combination of
1149
00:40:10,000 --> 00:40:12,119
all these thousands of node operators
1150
00:40:12,119 --> 00:40:14,000
running the same software running these
1151
00:40:14,000 --> 00:40:16,240
algorithms running these smart contracts
1152
00:40:16,240 --> 00:40:18,160
that make the network decentralized
1153
00:40:18,160 --> 00:40:19,760
we'll dive deeper into how that works
1154
00:40:19,760 --> 00:40:21,960
later the next feature is transparency
1155
00:40:21,960 --> 00:40:23,960
and flexibility in these decentralized
1156
00:40:23,960 --> 00:40:26,599
networks since all these individual node
1157
00:40:26,599 --> 00:40:28,839
operators run this software everybody
1158
00:40:28,839 --> 00:40:30,680
can see everything that's happening on
1159
00:40:30,680 --> 00:40:32,839
chain meaning there's no Shady deals
1160
00:40:32,839 --> 00:40:34,800
there's no weird things happening
1161
00:40:34,800 --> 00:40:37,119
anything that's going to be unfair
1162
00:40:37,119 --> 00:40:39,160
people would be able to see and just not
1163
00:40:39,160 --> 00:40:41,599
use everybody has perfect information
1164
00:40:41,599 --> 00:40:44,319
and has to play by the same rules now
1165
00:40:44,319 --> 00:40:45,880
additionally this doesn't mean that
1166
00:40:45,880 --> 00:40:47,920
there's no privacy the blockchain is
1167
00:40:47,920 --> 00:40:49,960
pseudo Anonymous meaning that you aren't
1168
00:40:49,960 --> 00:40:52,839
necessarily tied to an identity in real
1169
00:40:52,839 --> 00:40:54,760
life they also have the feature of speed
1170
00:40:54,760 --> 00:40:56,400
and efficiency for those of you who have
1171
00:40:56,400 --> 00:40:58,680
ever tried to do a bank transfer or send
1172
00:40:58,680 --> 00:41:00,760
money across Seas you know it sometimes
1173
00:41:00,760 --> 00:41:04,119
can take 2 to 3 weeks when in fact all
1174
00:41:04,119 --> 00:41:06,359
these banks are really doing is basic
1175
00:41:06,359 --> 00:41:08,400
math they're subtracting money from your
1176
00:41:08,400 --> 00:41:10,480
balance and adding it to some other
1177
00:41:10,480 --> 00:41:12,680
balance why does it take so long in the
1178
00:41:12,680 --> 00:41:14,680
blockchain all of these transactions
1179
00:41:14,680 --> 00:41:17,200
happen instantly another instance for
1180
00:41:17,200 --> 00:41:19,040
those in the financial world today know
1181
00:41:19,040 --> 00:41:20,839
that clearing houses and settlement days
1182
00:41:20,839 --> 00:41:23,280
can take a long time in the blockchain
1183
00:41:23,280 --> 00:41:24,760
there's no need for any of that because
1184
00:41:24,760 --> 00:41:26,920
they happen instantly this obviously is
1185
00:41:26,920 --> 00:41:29,079
much quicker but it also makes for much
1186
00:41:29,079 --> 00:41:30,880
more efficient interactions with each
1187
00:41:30,880 --> 00:41:33,480
other security and immutability again
1188
00:41:33,480 --> 00:41:36,240
immutable means that it can't be changed
1189
00:41:36,240 --> 00:41:38,640
once a smart contract is deployed that's
1190
00:41:38,640 --> 00:41:40,720
it whatever is in the code is going to
1191
00:41:40,720 --> 00:41:42,680
be in the code Forever they cannot be
1192
00:41:42,680 --> 00:41:44,640
altered or tampered with in any way this
1193
00:41:44,640 --> 00:41:46,760
means that the security is much easier
1194
00:41:46,760 --> 00:41:48,319
whereas in a centralized World somebody
1195
00:41:48,319 --> 00:41:50,160
can hack into the server jump out the
1196
00:41:50,160 --> 00:41:52,240
database and change some numbers you
1197
00:41:52,240 --> 00:41:53,960
can't do that in the blockchain world
1198
00:41:53,960 --> 00:41:55,960
and since it's decentralized in order to
1199
00:41:55,960 --> 00:41:58,200
hack the blockchain you you'd have to
1200
00:41:58,200 --> 00:42:00,599
take over half of the nodes as opposed
1201
00:42:00,599 --> 00:42:02,280
to in the centralized world where you
1202
00:42:02,280 --> 00:42:04,240
only have to take over one in the
1203
00:42:04,240 --> 00:42:06,160
regular world if your computer and your
1204
00:42:06,160 --> 00:42:08,960
backup computer go down all of your data
1205
00:42:08,960 --> 00:42:11,640
is gone in the blockchain world if your
1206
00:42:11,640 --> 00:42:13,280
computer and your backup computer go
1207
00:42:13,280 --> 00:42:16,079
down all your data is safe because it's
1208
00:42:16,079 --> 00:42:17,760
being run on all these other
1209
00:42:17,760 --> 00:42:20,079
decentralized nodes and even if a few
1210
00:42:20,079 --> 00:42:22,160
hundred nodes or if a few thousand nodes
1211
00:42:22,160 --> 00:42:24,040
go down it doesn't matter because as
1212
00:42:24,040 --> 00:42:25,839
long as one node has a copy of the
1213
00:42:25,839 --> 00:42:28,440
blockchain you're good to go hacking a
1214
00:42:28,440 --> 00:42:31,200
blockchain is nearly impossible and
1215
00:42:31,200 --> 00:42:33,280
Leaps and Bounds more difficult than
1216
00:42:33,280 --> 00:42:35,240
hacking a centralized server not only
1217
00:42:35,240 --> 00:42:37,280
that but this is safer in the asset
1218
00:42:37,280 --> 00:42:39,839
sense as well all you need to access
1219
00:42:39,839 --> 00:42:41,760
your credentials and your information
1220
00:42:41,760 --> 00:42:44,359
and your assets is your private key
1221
00:42:44,359 --> 00:42:46,359
which is basically your password for all
1222
00:42:46,359 --> 00:42:48,160
of this and as we've discussed in the
1223
00:42:48,160 --> 00:42:50,119
video these smart contracts remove this
1224
00:42:50,119 --> 00:42:51,800
counterparty risk remove this
1225
00:42:51,800 --> 00:42:54,000
centralized intermediary remove these
1226
00:42:54,000 --> 00:42:56,280
trust gateways that we have to do in web
1227
00:42:56,280 --> 00:42:58,480
2 when we engage with users and
1228
00:42:58,480 --> 00:43:00,599
individuals they don't always have our
1229
00:43:00,599 --> 00:43:02,760
best interests at heart smart contracts
1230
00:43:02,760 --> 00:43:04,480
remove this counterparty risk because
1231
00:43:04,480 --> 00:43:06,640
once one of these contracts is created
1232
00:43:06,640 --> 00:43:08,559
they can't go in and they can't alter it
1233
00:43:08,559 --> 00:43:10,480
and they can't let greed or ego or
1234
00:43:10,480 --> 00:43:11,880
anything else get the better of them and
1235
00:43:11,880 --> 00:43:13,960
alter the terms of the deal and as we
1236
00:43:13,960 --> 00:43:16,200
said this gives rise to these trust
1237
00:43:16,200 --> 00:43:17,880
minimized agreements or these
1238
00:43:17,880 --> 00:43:20,400
programmatic unbreakable promises we
1239
00:43:20,400 --> 00:43:22,839
move away from brand-based agreements to
1240
00:43:22,839 --> 00:43:24,599
math-based agreements where we can look
1241
00:43:24,599 --> 00:43:26,440
at the cryptography we can look right at
1242
00:43:26,440 --> 00:43:29,040
the code and see exactly what something
1243
00:43:29,040 --> 00:43:30,440
is going to do and how it's going to
1244
00:43:30,440 --> 00:43:32,800
execute versus having to rely on a human
1245
00:43:32,800 --> 00:43:35,200
being doing the right thing with smart
1246
00:43:35,200 --> 00:43:37,440
contracts and decentralized hybrid smart
1247
00:43:37,440 --> 00:43:40,079
contracts doing the right thing is
1248
00:43:40,079 --> 00:43:42,200
infrastructural all these pieces boil
1249
00:43:42,200 --> 00:43:44,160
down to us having the freedom to
1250
00:43:44,160 --> 00:43:46,240
interact the way we want to interact
1251
00:43:46,240 --> 00:43:48,160
without having to be afraid that
1252
00:43:48,160 --> 00:43:49,640
interacting like that is going to screw
1253
00:43:49,640 --> 00:43:52,040
us over this trust minimize peace these
1254
00:43:52,040 --> 00:43:55,400
unbreakable promises make interactions
1255
00:43:55,400 --> 00:43:57,559
so much better in the purely to World
1256
00:43:57,559 --> 00:44:00,000
we're constantly bombarded with messages
1257
00:44:00,000 --> 00:44:02,920
of projects and protocols pushing us to
1258
00:44:02,920 --> 00:44:04,960
move or act in the direction that makes
1259
00:44:04,960 --> 00:44:07,079
them more profitable versus in the smart
1260
00:44:07,079 --> 00:44:08,960
contract space we can see everything
1261
00:44:08,960 --> 00:44:11,400
transparently and we can even engage and
1262
00:44:11,400 --> 00:44:14,119
interact and be partially owners of the
1263
00:44:14,119 --> 00:44:16,400
protocols and the interactions that we
1264
00:44:16,400 --> 00:44:19,880
decide that we want to be a part
1265
00:44:20,720 --> 00:44:23,319
of so smart contracts have been around
1266
00:44:23,319 --> 00:44:25,359
for a few years now and what have they
1267
00:44:25,359 --> 00:44:27,319
generated for what industries have come
1268
00:44:27,319 --> 00:44:28,800
about due to these smart contract
1269
00:44:28,800 --> 00:44:30,359
platforms being around well you've
1270
00:44:30,359 --> 00:44:31,599
probably heard of some of these and some
1271
00:44:31,599 --> 00:44:32,960
of these we've already mentioned but
1272
00:44:32,960 --> 00:44:35,480
let's give you a quick refresher defi
1273
00:44:35,480 --> 00:44:38,319
defi stands for decentralized finance
1274
00:44:38,319 --> 00:44:40,559
and it gives users the ability to engage
1275
00:44:40,559 --> 00:44:42,440
with finance and markets without having
1276
00:44:42,440 --> 00:44:44,480
to go through a centralized intermediary
1277
00:44:44,480 --> 00:44:46,160
for example like we said with Robin Hood
1278
00:44:46,160 --> 00:44:48,119
you'd no longer have to trust that Robin
1279
00:44:48,119 --> 00:44:49,520
Hood would continue to give you access
1280
00:44:49,520 --> 00:44:51,720
to the markets you instead would be able
1281
00:44:51,720 --> 00:44:54,040
to see in the smart contract yes I have
1282
00:44:54,040 --> 00:44:56,000
access to the markets or in the 2008
1283
00:44:56,000 --> 00:44:58,200
financial crisis you never have to trust
1284
00:44:58,200 --> 00:45:00,079
that these groups and institutions are
1285
00:45:00,079 --> 00:45:01,559
giving you the correct things on the
1286
00:45:01,559 --> 00:45:03,400
back end you can see everything
1287
00:45:03,400 --> 00:45:05,640
transparently right on the blockchain
1288
00:45:05,640 --> 00:45:07,240
you can engage with things like money
1289
00:45:07,240 --> 00:45:09,160
markets and sophisticated Financial
1290
00:45:09,160 --> 00:45:12,400
products easy effectively and securely
1291
00:45:12,400 --> 00:45:14,359
if you're really excited about defi we
1292
00:45:14,359 --> 00:45:16,440
have a ton of defi examples showing you
1293
00:45:16,440 --> 00:45:17,839
how to build and interact with these
1294
00:45:17,839 --> 00:45:20,280
protocols in coming lessons Dows or
1295
00:45:20,280 --> 00:45:22,559
decentralized autonomous organizations
1296
00:45:22,559 --> 00:45:23,800
are another group that we've already
1297
00:45:23,800 --> 00:45:25,800
mentioned Dows are groups that are
1298
00:45:25,800 --> 00:45:28,200
governed completely centralized by a set
1299
00:45:28,200 --> 00:45:30,160
of instructions or smart contracts on
1300
00:45:30,160 --> 00:45:32,079
chain there are some massive benefits
1301
00:45:32,079 --> 00:45:34,240
here where engagement is much easier the
1302
00:45:34,240 --> 00:45:35,680
rules are black and white and you can
1303
00:45:35,680 --> 00:45:37,760
see everything directly on chain voting
1304
00:45:37,760 --> 00:45:39,480
and governance technology is completely
1305
00:45:39,480 --> 00:45:41,559
decentralized and the blockchain space
1306
00:45:41,559 --> 00:45:43,359
is one of the big ones pushing how we
1307
00:45:43,359 --> 00:45:45,000
can evolve politics and how we can
1308
00:45:45,000 --> 00:45:46,559
evolve governance to make it more
1309
00:45:46,559 --> 00:45:48,599
efficient fair and reasonable and you
1310
00:45:48,599 --> 00:45:50,359
better know it we have some examples of
1311
00:45:50,359 --> 00:45:51,920
how to build Dows and how to work with
1312
00:45:51,920 --> 00:45:53,839
Dows in coming lessons so be sure to
1313
00:45:53,839 --> 00:45:56,520
watch those nfts stand for non-fungible
1314
00:45:56,520 --> 00:45:58,680
tokens and can really be kind of
1315
00:45:58,680 --> 00:46:00,800
described as digital art or just a
1316
00:46:00,800 --> 00:46:03,200
unique asset they can do so much more
1317
00:46:03,200 --> 00:46:05,200
but we'll keep it high level for now
1318
00:46:05,200 --> 00:46:07,240
projects like board apes and crypt punks
1319
00:46:07,240 --> 00:46:09,319
have revolutionized the way that people
1320
00:46:09,319 --> 00:46:11,119
get paid for their work show off their
1321
00:46:11,119 --> 00:46:13,400
creativity status and so much more and
1322
00:46:13,400 --> 00:46:15,559
yes of course we have lessons showing
1323
00:46:15,559 --> 00:46:17,800
you how to create and interact with nfts
1324
00:46:17,800 --> 00:46:19,640
as well so many other groups and so many
1325
00:46:19,640 --> 00:46:21,559
other Industries are being created as a
1326
00:46:21,559 --> 00:46:24,000
result of this insane technology and
1327
00:46:24,000 --> 00:46:25,480
maybe after finishing the journey with
1328
00:46:25,480 --> 00:46:27,760
us here you go out and you'll be the one
1329
00:46:27,760 --> 00:46:30,319
to Pioneer the next industry or the next
1330
00:46:30,319 --> 00:46:32,839
billion dooll idea you've learned so
1331
00:46:32,839 --> 00:46:34,920
much already but now that we've learned
1332
00:46:34,920 --> 00:46:37,240
a lot of this highlevel information
1333
00:46:37,240 --> 00:46:39,800
let's finally jump in and let's make
1334
00:46:39,800 --> 00:46:42,000
your first transaction and let's get you
1335
00:46:42,000 --> 00:46:44,559
set up to interact with this new world
1336
00:46:44,559 --> 00:46:46,079
in this next section we're going to get
1337
00:46:46,079 --> 00:46:47,960
you a wallet and we're going to show you
1338
00:46:47,960 --> 00:46:50,319
exactly what a transaction looks like
1339
00:46:50,319 --> 00:46:54,280
and feels like let's dive
1340
00:46:55,440 --> 00:46:58,359
in this is the ethereum website
1341
00:46:58,359 --> 00:47:01,079
ethereum.org we are going to make a
1342
00:47:01,079 --> 00:47:03,480
transaction on a test ethereum
1343
00:47:03,480 --> 00:47:05,319
blockchain I'll explain what that means
1344
00:47:05,319 --> 00:47:07,480
in a little bit this is going to be our
1345
00:47:07,480 --> 00:47:09,520
first ever transaction that's made on
1346
00:47:09,520 --> 00:47:11,559
the blockchain and this process of
1347
00:47:11,559 --> 00:47:13,520
making a transaction is going to work
1348
00:47:13,520 --> 00:47:16,839
the exact same across all evm compatible
1349
00:47:16,839 --> 00:47:19,880
blockchains and layer 2s like arbitrum
1350
00:47:19,880 --> 00:47:23,280
ethereum ZK sync and Etc I'll explain
1351
00:47:23,280 --> 00:47:25,680
what evm means in the future for now
1352
00:47:25,680 --> 00:47:27,800
just follow along and have fun running
1353
00:47:27,800 --> 00:47:30,800
your first transaction now in order for
1354
00:47:30,800 --> 00:47:32,839
us to send a transaction on any of these
1355
00:47:32,839 --> 00:47:35,160
evm chains the first thing that we need
1356
00:47:35,160 --> 00:47:38,359
to do is set up a wallet so I'm going to
1357
00:47:38,359 --> 00:47:40,160
go to metamask because it's one of the
1358
00:47:40,160 --> 00:47:41,880
most popular wallets and one of the
1359
00:47:41,880 --> 00:47:44,119
easiest wallets to use I'm using the
1360
00:47:44,119 --> 00:47:46,000
brave browser but it works for Chrome or
1361
00:47:46,000 --> 00:47:48,760
Firefox or really any other popular
1362
00:47:48,760 --> 00:47:50,520
browsers out there and it's just going
1363
00:47:50,520 --> 00:47:53,280
to be an extension in the top right hand
1364
00:47:53,280 --> 00:47:54,960
of our browser it's going to make it
1365
00:47:54,960 --> 00:47:57,079
very easy to see anything to do with our
1366
00:47:57,079 --> 00:47:59,640
wallets and our transactions very easily
1367
00:47:59,640 --> 00:48:01,359
and it's going to store all of our evm
1368
00:48:01,359 --> 00:48:03,240
based currencies and evm based
1369
00:48:03,240 --> 00:48:05,040
transactions so I'm going to go ahead
1370
00:48:05,040 --> 00:48:07,680
and hit add to Brave ADD extension
1371
00:48:07,680 --> 00:48:09,760
although Brave does also come jam-packed
1372
00:48:09,760 --> 00:48:11,880
with its own wallet so now we come to
1373
00:48:11,880 --> 00:48:13,680
the get started page and I'm going to go
1374
00:48:13,680 --> 00:48:16,960
ahead and select create a new wallet
1375
00:48:16,960 --> 00:48:19,240
sure we'll agree to help out metamask
1376
00:48:19,240 --> 00:48:20,800
now we're going to create our password
1377
00:48:20,800 --> 00:48:22,800
make sure it's really secure for the
1378
00:48:22,800 --> 00:48:24,920
purpose of this demo mine's going to be
1379
00:48:24,920 --> 00:48:26,319
kind of mediocre now I'm going to
1380
00:48:26,319 --> 00:48:27,280
preface it
1381
00:48:27,280 --> 00:48:29,160
this wallet that you're making right now
1382
00:48:29,160 --> 00:48:31,040
as you follow along with me this is
1383
00:48:31,040 --> 00:48:33,520
going to be your development wallet so
1384
00:48:33,520 --> 00:48:35,079
if you want to make the password a
1385
00:48:35,079 --> 00:48:36,920
little bit weak just so that you can
1386
00:48:36,920 --> 00:48:39,240
test things out very quickly go for it
1387
00:48:39,240 --> 00:48:41,680
just know we're never ever going to put
1388
00:48:41,680 --> 00:48:43,800
real money into this wallet it's good if
1389
00:48:43,800 --> 00:48:46,200
you treat this as if it is a real wallet
1390
00:48:46,200 --> 00:48:47,520
that way you'll get used to and you'll
1391
00:48:47,520 --> 00:48:50,079
get familiar with good wallet safety you
1392
00:48:50,079 --> 00:48:51,680
will then get a video like this which
1393
00:48:51,680 --> 00:48:53,480
will teach you about the secret recovery
1394
00:48:53,480 --> 00:48:55,839
phrase which we saw a little bit earlier
1395
00:48:55,839 --> 00:48:57,799
when we were creating our wet let's
1396
00:48:57,799 --> 00:49:00,119
watch this video metamask is a new way
1397
00:49:00,119 --> 00:49:02,720
to connect to sites and applications on
1398
00:49:02,720 --> 00:49:04,760
traditional websites a central database
1399
00:49:04,760 --> 00:49:06,799
or bank is responsible for controlling
1400
00:49:06,799 --> 00:49:08,760
and recovering your accounts but on
1401
00:49:08,760 --> 00:49:11,079
metamask all of the Power belongs to the
1402
00:49:11,079 --> 00:49:13,880
holder of a master key whoever holds the
1403
00:49:13,880 --> 00:49:16,280
key controls the accounts your secret
1404
00:49:16,280 --> 00:49:19,079
recovery phrase is your master key it's
1405
00:49:19,079 --> 00:49:21,280
a series of 12 words that are generated
1406
00:49:21,280 --> 00:49:23,240
when you first set up metamask which
1407
00:49:23,240 --> 00:49:25,160
allow you to recover your wallet and
1408
00:49:25,160 --> 00:49:27,640
funds if you ever lose ACC access it's
1409
00:49:27,640 --> 00:49:29,520
important that you secure your wallet by
1410
00:49:29,520 --> 00:49:31,920
keeping your secret recovery phrase very
1411
00:49:31,920 --> 00:49:34,880
safe and very secret if anyone gets
1412
00:49:34,880 --> 00:49:36,599
access to it they will have the master
1413
00:49:36,599 --> 00:49:39,040
key to your wallet and can freely access
1414
00:49:39,040 --> 00:49:41,680
and take all of your funds to secure
1415
00:49:41,680 --> 00:49:43,520
your metamask wallet you'll want to
1416
00:49:43,520 --> 00:49:46,119
safely save your secret recovery phrase
1417
00:49:46,119 --> 00:49:48,880
you can write it down hide it somewhere
1418
00:49:48,880 --> 00:49:51,720
put it in a safe deposit box or use a
1419
00:49:51,720 --> 00:49:54,480
secure password manager some users even
1420
00:49:54,480 --> 00:49:56,880
engrave their phrase onto a metal plate
1421
00:49:56,880 --> 00:49:59,480
nobody not even the team at metamask can
1422
00:49:59,480 --> 00:50:01,400
help you recover your wallet if you lose
1423
00:50:01,400 --> 00:50:03,599
your secret recovery phrase if you
1424
00:50:03,599 --> 00:50:05,160
haven't written down your secret
1425
00:50:05,160 --> 00:50:06,920
recovery phrase and stored it somewhere
1426
00:50:06,920 --> 00:50:10,760
safe do it now we'll wait and remember
1427
00:50:10,760 --> 00:50:12,839
never share your secret recovery phrase
1428
00:50:12,839 --> 00:50:16,280
with anyone not even us if anyone ever
1429
00:50:16,280 --> 00:50:18,520
asks you for it they're trying to scam
1430
00:50:18,520 --> 00:50:21,079
you that's it now you know what a secret
1431
00:50:21,079 --> 00:50:23,240
recovery phrase is and how to keep your
1432
00:50:23,240 --> 00:50:25,880
wallet safe and secure awesome so that
1433
00:50:25,880 --> 00:50:28,440
was a great introduction to keeping your
1434
00:50:28,440 --> 00:50:30,520
wallet safe we'll talk a little bit more
1435
00:50:30,520 --> 00:50:32,000
about safety with our wallets in the
1436
00:50:32,000 --> 00:50:34,480
future let's go ahead and select secure
1437
00:50:34,480 --> 00:50:36,640
my wallet now this is where we need to
1438
00:50:36,640 --> 00:50:39,200
write down our secret recovery phrase
1439
00:50:39,200 --> 00:50:41,559
and save it in a very secure place it
1440
00:50:41,559 --> 00:50:43,440
gives us some tips here like a password
1441
00:50:43,440 --> 00:50:47,119
manager a safety deposit box or split it
1442
00:50:47,119 --> 00:50:49,760
up and keep it in multiple secret places
1443
00:50:49,760 --> 00:50:51,640
for the purposes of this video I'm going
1444
00:50:51,640 --> 00:50:53,400
to be showing you the secret recovery
1445
00:50:53,400 --> 00:50:54,920
phrase because I'm not going to put any
1446
00:50:54,920 --> 00:50:56,400
real money into this but you should
1447
00:50:56,400 --> 00:50:58,280
never never ever do this additionally
1448
00:50:58,280 --> 00:51:01,160
you'll sometimes hear pneumonic as a
1449
00:51:01,160 --> 00:51:03,599
synonym for secret recovery phrase the
1450
00:51:03,599 --> 00:51:05,040
main takeaway from all this is you
1451
00:51:05,040 --> 00:51:07,799
should never share any of this this is
1452
00:51:07,799 --> 00:51:10,520
for you only if you show this secret
1453
00:51:10,520 --> 00:51:12,280
phrase to anybody else they will have
1454
00:51:12,280 --> 00:51:14,839
access to not just one account but every
1455
00:51:14,839 --> 00:51:17,720
account that you make in metamask so be
1456
00:51:17,720 --> 00:51:19,200
absolutely certain to not share this
1457
00:51:19,200 --> 00:51:21,000
with anybody so again I know I'm
1458
00:51:21,000 --> 00:51:22,760
belaboring the point a little bit but
1459
00:51:22,760 --> 00:51:23,680
everything that we're going to do in
1460
00:51:23,680 --> 00:51:25,119
this tutorial we're going to do with
1461
00:51:25,119 --> 00:51:28,119
fake money and fake make assets and
1462
00:51:28,119 --> 00:51:30,200
never put actual money into this account
1463
00:51:30,200 --> 00:51:31,680
that we're making here once you get
1464
00:51:31,680 --> 00:51:33,559
familiar with using metamask and working
1465
00:51:33,559 --> 00:51:35,520
with the tools and stank secure then you
1466
00:51:35,520 --> 00:51:36,880
can go ahead and create a separate
1467
00:51:36,880 --> 00:51:38,960
metamask that will have real funds in it
1468
00:51:38,960 --> 00:51:40,040
if you want to put real money in
1469
00:51:40,040 --> 00:51:41,640
different metamask a lot of browsers
1470
00:51:41,640 --> 00:51:43,359
have a profile option and maybe you can
1471
00:51:43,359 --> 00:51:45,520
make a new profile install metamask on
1472
00:51:45,520 --> 00:51:47,880
that different profile call that profile
1473
00:51:47,880 --> 00:51:49,920
real money profile or something and
1474
00:51:49,920 --> 00:51:51,559
that's where you will store your money
1475
00:51:51,559 --> 00:51:53,319
but for this video for this tutorial the
1476
00:51:53,319 --> 00:51:55,480
mamass that you are using is going to be
1477
00:51:55,480 --> 00:51:58,440
specifically for are testing things out
1478
00:51:58,440 --> 00:52:00,160
and you will never store real money to
1479
00:52:00,160 --> 00:52:02,480
it I'm going to harp on that a lot more
1480
00:52:02,480 --> 00:52:04,040
in this course so even if you're coming
1481
00:52:04,040 --> 00:52:05,920
here and you have a wallet I highly
1482
00:52:05,920 --> 00:52:07,920
recommend still making a brand new one
1483
00:52:07,920 --> 00:52:10,160
for this tutorial just in case you don't
1484
00:52:10,160 --> 00:52:12,119
accidentally code something or do
1485
00:52:12,119 --> 00:52:13,720
something atomous and give away your
1486
00:52:13,720 --> 00:52:16,119
funds if this is your first wallet then
1487
00:52:16,119 --> 00:52:18,720
great but again when you're working with
1488
00:52:18,720 --> 00:52:20,160
real money if you lose access to the
1489
00:52:20,160 --> 00:52:21,880
secret phrase you will lose access to
1490
00:52:21,880 --> 00:52:23,359
all your money so be sure to write this
1491
00:52:23,359 --> 00:52:25,040
down promise me that you won't use real
1492
00:52:25,040 --> 00:52:27,000
money for this course great I'm going to
1493
00:52:27,000 --> 00:52:28,799
hit copy to clipboard for now and we're
1494
00:52:28,799 --> 00:52:30,880
going to go ahead and hit next now we
1495
00:52:30,880 --> 00:52:32,960
need to confirm by adding our seed
1496
00:52:32,960 --> 00:52:35,280
phrase back in we can go ahead and hit
1497
00:52:35,280 --> 00:52:37,680
confirm and we now have created our
1498
00:52:37,680 --> 00:52:40,640
wallet let's go ahead and clict got it
1499
00:52:40,640 --> 00:52:43,040
awesome now we can see the interface of
1500
00:52:43,040 --> 00:52:45,079
our metamask full screen and depending
1501
00:52:45,079 --> 00:52:47,200
on your browser what you can normally do
1502
00:52:47,200 --> 00:52:48,880
is hit this little puzzle piece on your
1503
00:52:48,880 --> 00:52:51,440
browser and select this pin button so
1504
00:52:51,440 --> 00:52:54,000
now we can pin our metamask into the top
1505
00:52:54,000 --> 00:52:56,240
of our browser and we can click it like
1506
00:52:56,240 --> 00:52:57,040
so
1507
00:52:57,040 --> 00:52:58,559
and we can see it give a little drop
1508
00:52:58,559 --> 00:53:00,839
down like this and we can see the same
1509
00:53:00,839 --> 00:53:02,760
information in this little drop down as
1510
00:53:02,760 --> 00:53:04,799
there is on the full screen now even if
1511
00:53:04,799 --> 00:53:07,200
you lose access to that page now that
1512
00:53:07,200 --> 00:53:10,119
this is bookmarked in your browser you
1513
00:53:10,119 --> 00:53:12,480
can select your metamask select these
1514
00:53:12,480 --> 00:53:15,760
three dots and hit expand view to reach
1515
00:53:15,760 --> 00:53:17,960
this tab now additionally what we can do
1516
00:53:17,960 --> 00:53:19,680
in here is we can actually go up to our
1517
00:53:19,680 --> 00:53:22,160
accounts and we can actually create
1518
00:53:22,160 --> 00:53:24,119
multiple accounts by hitting create
1519
00:53:24,119 --> 00:53:26,000
account and if you wanted to you could
1520
00:53:26,000 --> 00:53:27,280
give it a name here I'm just going to
1521
00:53:27,280 --> 00:53:29,400
leave it as default for account two and
1522
00:53:29,400 --> 00:53:32,280
now we have two separate accounts we
1523
00:53:32,280 --> 00:53:35,720
have an account zero with an address and
1524
00:53:35,720 --> 00:53:38,079
an account two with an address as well
1525
00:53:38,079 --> 00:53:40,720
both of these accounts actually share
1526
00:53:40,720 --> 00:53:43,559
that same secret phrase so anybody with
1527
00:53:43,559 --> 00:53:45,160
access to the secret phrase can actually
1528
00:53:45,160 --> 00:53:47,119
have access to both accounts however
1529
00:53:47,119 --> 00:53:49,319
they have different private keys and
1530
00:53:49,319 --> 00:53:50,520
that's what makes them different we'll
1531
00:53:50,520 --> 00:53:51,720
talk a little bit more about that in the
1532
00:53:51,720 --> 00:53:53,200
future if somebody gets access to a
1533
00:53:53,200 --> 00:53:55,000
private key they'll get access to a
1534
00:53:55,000 --> 00:53:56,640
single account if they get access access
1535
00:53:56,640 --> 00:53:58,200
to the secret phrase they'll get access
1536
00:53:58,200 --> 00:54:00,160
to all the accounts that you make even
1537
00:54:00,160 --> 00:54:01,480
you know if you made a third one they'd
1538
00:54:01,480 --> 00:54:03,119
get access to this one as well now if
1539
00:54:03,119 --> 00:54:04,559
you look up in the top right of the
1540
00:54:04,559 --> 00:54:06,160
screen here you'll see this section that
1541
00:54:06,160 --> 00:54:08,760
says ethereum mainnet this is our
1542
00:54:08,760 --> 00:54:10,680
networks Tab and if you click it you can
1543
00:54:10,680 --> 00:54:12,920
see all the different networks that our
1544
00:54:12,920 --> 00:54:15,319
metamask has access to ethereum mainnet
1545
00:54:15,319 --> 00:54:17,440
is the main network of ethereum and this
1546
00:54:17,440 --> 00:54:20,319
is where real money is spent and used
1547
00:54:20,319 --> 00:54:21,680
for this course we're not going to be
1548
00:54:21,680 --> 00:54:23,440
working with ethereum mainnet we're
1549
00:54:23,440 --> 00:54:24,480
instead going to be working with
1550
00:54:24,480 --> 00:54:26,720
something called a test net for both
1551
00:54:26,720 --> 00:54:29,440
engineers and non-engineers we often
1552
00:54:29,440 --> 00:54:32,079
need a place to test or simulate our
1553
00:54:32,079 --> 00:54:34,359
transactions and for the developers here
1554
00:54:34,359 --> 00:54:35,720
throughout this course we are going to
1555
00:54:35,720 --> 00:54:37,680
teach you another technique for testing
1556
00:54:37,680 --> 00:54:40,319
out your transactions on a local network
1557
00:54:40,319 --> 00:54:42,040
and a local network is actually going to
1558
00:54:42,040 --> 00:54:44,480
be the preferred way we do our testing
1559
00:54:44,480 --> 00:54:46,640
and our simulations however it's still
1560
00:54:46,640 --> 00:54:48,400
really important to see end to end what
1561
00:54:48,400 --> 00:54:50,520
a real transaction looks like and that's
1562
00:54:50,520 --> 00:54:52,559
what a test net will do for us it
1563
00:54:52,559 --> 00:54:55,720
simulates exactly what a mainnet or a
1564
00:54:55,720 --> 00:54:58,200
live money Network would look like
1565
00:54:58,200 --> 00:55:00,200
however there's no real money at stake
1566
00:55:00,200 --> 00:55:01,480
and we don't actually have to spend any
1567
00:55:01,480 --> 00:55:03,319
money to see some of the test Nets that
1568
00:55:03,319 --> 00:55:05,400
come default with metamask we can hit
1569
00:55:05,400 --> 00:55:07,920
the show/hide button which will bring us
1570
00:55:07,920 --> 00:55:10,960
to the settings page of metamask we can
1571
00:55:10,960 --> 00:55:13,760
turn on show test networks and if we
1572
00:55:13,760 --> 00:55:15,520
scroll back up now if we hit our
1573
00:55:15,520 --> 00:55:17,520
networks tab actually let's go ahead
1574
00:55:17,520 --> 00:55:19,280
close out of settings now if we hit this
1575
00:55:19,280 --> 00:55:22,240
drop down we can see gelli test Network
1576
00:55:22,240 --> 00:55:24,720
sapoia test Network and Linea gorelli
1577
00:55:24,720 --> 00:55:26,720
test Network these Networks networks are
1578
00:55:26,720 --> 00:55:29,280
test networks that resemble ethereum or
1579
00:55:29,280 --> 00:55:33,440
polygon or Linea or arbitrum or optimism
1580
00:55:33,440 --> 00:55:36,559
or ZK sync or any other evm compatible
1581
00:55:36,559 --> 00:55:38,039
chain that we want to work with and
1582
00:55:38,039 --> 00:55:40,680
again we'll Define evm in the future and
1583
00:55:40,680 --> 00:55:42,160
we can actually switch the network that
1584
00:55:42,160 --> 00:55:43,920
we're working on simply by clicking
1585
00:55:43,920 --> 00:55:45,559
another Network so let's switch to
1586
00:55:45,559 --> 00:55:48,680
sapoia we can see our Network changed up
1587
00:55:48,680 --> 00:55:51,200
here and now we can see we have zero SEO
1588
00:55:51,200 --> 00:55:54,200
eth so on eth mainnet this new account
1589
00:55:54,200 --> 00:55:57,400
has zero ethereum and on the sapoia test
1590
00:55:57,400 --> 00:56:00,480
Network we also have zero sapoia eth
1591
00:56:00,480 --> 00:56:01,960
which makes sense because this is a
1592
00:56:01,960 --> 00:56:04,039
brand new wallet and we haven't put any
1593
00:56:04,039 --> 00:56:06,079
money into this brand new account yet so
1594
00:56:06,079 --> 00:56:08,280
of course we have zero at the time of
1595
00:56:08,280 --> 00:56:09,920
recording sapoia is one of the most
1596
00:56:09,920 --> 00:56:12,119
popular test networks out there so we're
1597
00:56:12,119 --> 00:56:14,160
going to be working mainly with sapoia
1598
00:56:14,160 --> 00:56:16,400
throughout this course however test Nets
1599
00:56:16,400 --> 00:56:18,200
often change because again they're run
1600
00:56:18,200 --> 00:56:19,680
out of the goodness of people's hearts
1601
00:56:19,680 --> 00:56:21,480
and sometimes people stop running them
1602
00:56:21,480 --> 00:56:22,920
you should absolutely have either the
1603
00:56:22,920 --> 00:56:25,200
web3 dev. education site up or the
1604
00:56:25,200 --> 00:56:27,319
GitHub reposit associated with this
1605
00:56:27,319 --> 00:56:30,119
course and an important note sometimes
1606
00:56:30,119 --> 00:56:32,559
you'll see this as the chain Excel org
1607
00:56:32,559 --> 00:56:34,880
Foundry FL course we recently renamed it
1608
00:56:34,880 --> 00:56:37,240
to The cyphon Foundry F course so this
1609
00:56:37,240 --> 00:56:39,000
is the correct link but if you see chain
1610
00:56:39,000 --> 00:56:41,119
excl org that's fine as well and you
1611
00:56:41,119 --> 00:56:43,160
should scroll down to the recommended
1612
00:56:43,160 --> 00:56:45,920
test Nets section to make sure you're on
1613
00:56:45,920 --> 00:56:48,119
the most up-to-date test net at the time
1614
00:56:48,119 --> 00:56:49,960
of recording like I said we're working
1615
00:56:49,960 --> 00:56:51,839
with sepolia throughout this course we
1616
00:56:51,839 --> 00:56:53,200
are going to show you how to work with
1617
00:56:53,200 --> 00:56:54,799
different test Nets and different
1618
00:56:54,799 --> 00:56:56,480
networks as well because because it's
1619
00:56:56,480 --> 00:56:58,480
incredibly important to do so the
1620
00:56:58,480 --> 00:57:00,079
blockchain world is moving into a
1621
00:57:00,079 --> 00:57:02,280
multi-chain world and especially with
1622
00:57:02,280 --> 00:57:04,280
the popularity of l2s which help
1623
00:57:04,280 --> 00:57:06,760
ethereum scale learning the differences
1624
00:57:06,760 --> 00:57:08,200
between different chains and different
1625
00:57:08,200 --> 00:57:10,760
l2s is incredibly important now same as
1626
00:57:10,760 --> 00:57:12,319
ethereum what we can do is we can
1627
00:57:12,319 --> 00:57:14,559
actually go to sepolia etherscan so
1628
00:57:14,559 --> 00:57:18,720
we'll go to sepolia etherscan.io and we
1629
00:57:18,720 --> 00:57:20,799
can grab our address from metamask by
1630
00:57:20,799 --> 00:57:23,160
clicking and copying the address here
1631
00:57:23,160 --> 00:57:25,760
pasting it into the sapoia Explorer and
1632
00:57:25,760 --> 00:57:28,000
same as ethereum we can see our account
1633
00:57:28,000 --> 00:57:30,559
balance we have zero eth there are no
1634
00:57:30,559 --> 00:57:33,160
transactions no token transfers nothing
1635
00:57:33,160 --> 00:57:34,880
because obviously it's a brand new
1636
00:57:34,880 --> 00:57:36,559
wallet now I'm showing you this because
1637
00:57:36,559 --> 00:57:38,280
pretty soon we're going to send our
1638
00:57:38,280 --> 00:57:41,079
first ever blockchain transaction if
1639
00:57:41,079 --> 00:57:42,280
you've never sent a blockchain
1640
00:57:42,280 --> 00:57:44,039
transaction before we're going to do it
1641
00:57:44,039 --> 00:57:45,880
on this test net to give you some
1642
00:57:45,880 --> 00:57:47,640
confidence as what a transaction
1643
00:57:47,640 --> 00:57:49,079
actually looks like when you do move
1644
00:57:49,079 --> 00:57:50,960
over to a main net and I'm showing you
1645
00:57:50,960 --> 00:57:52,839
this site now because you're going to
1646
00:57:52,839 --> 00:57:55,000
see when we send a transaction a lot of
1647
00:57:55,000 --> 00:57:57,160
this information is going to get updated
1648
00:57:57,160 --> 00:57:59,839
now just remember like I said earlier a
1649
00:57:59,839 --> 00:58:01,240
test net is run out of the goodness of
1650
00:58:01,240 --> 00:58:03,640
people's hearts so please use the
1651
00:58:03,640 --> 00:58:05,720
transactions sparingly once you send
1652
00:58:05,720 --> 00:58:07,680
your first transaction here try not to
1653
00:58:07,680 --> 00:58:09,720
send too many more as one as good enough
1654
00:58:09,720 --> 00:58:12,000
for you to see what's going on anyways
1655
00:58:12,000 --> 00:58:14,039
and in order for us to simulate one of
1656
00:58:14,039 --> 00:58:15,760
these transactions we're going to go to
1657
00:58:15,760 --> 00:58:18,640
a faucet for a testnet testnets have
1658
00:58:18,640 --> 00:58:20,960
this thing called faucets which allow us
1659
00:58:20,960 --> 00:58:23,839
to get some free sapoia eth so that we
1660
00:58:23,839 --> 00:58:25,880
can test out sending transactions and
1661
00:58:25,880 --> 00:58:27,920
receiving transactions if you go to the
1662
00:58:27,920 --> 00:58:29,920
GitHub associated with this course or
1663
00:58:29,920 --> 00:58:31,280
web3 dev.
1664
00:58:31,280 --> 00:58:33,680
education we can scroll down to this
1665
00:58:33,680 --> 00:58:36,520
testet faucets section and select one of
1666
00:58:36,520 --> 00:58:39,000
the links to go to one of these test net
1667
00:58:39,000 --> 00:58:41,280
faucets right now the recommended faucet
1668
00:58:41,280 --> 00:58:43,160
that we're working with is faucets.
1669
00:58:43,160 --> 00:58:44,960
chain. link But be sure to use the
1670
00:58:44,960 --> 00:58:49,039
GitHub repo or web 3d. education to be
1671
00:58:49,039 --> 00:58:51,319
most up toate what this is going to do
1672
00:58:51,319 --> 00:58:53,760
is we're going to ask this faucet site
1673
00:58:53,760 --> 00:58:56,760
to send us testnet ethereum and this is
1674
00:58:56,760 --> 00:58:58,720
why this test net ethereum isn't worth
1675
00:58:58,720 --> 00:59:00,480
any real money since we can get it for
1676
00:59:00,480 --> 00:59:02,599
free anytime that we want these
1677
00:59:02,599 --> 00:59:04,640
obviously don't exist on mainnet you
1678
00:59:04,640 --> 00:59:07,880
can't get free mainnet ethereum via a
1679
00:59:07,880 --> 00:59:10,000
faucet now what we can do is we can
1680
00:59:10,000 --> 00:59:12,440
actually connect our wallet to this site
1681
00:59:12,440 --> 00:59:15,280
and we can get some free test net sapoia
1682
00:59:15,280 --> 00:59:17,400
eth this will make it so that in our
1683
00:59:17,400 --> 00:59:19,160
balance here we'll actually have some
1684
00:59:19,160 --> 00:59:22,240
seoa eth to play with so to do this what
1685
00:59:22,240 --> 00:59:23,200
we're going to do is we're going to go
1686
00:59:23,200 --> 00:59:25,400
ahead and hit connect wallet accept the
1687
00:59:25,400 --> 00:59:27,280
chain link terms of service I've already
1688
00:59:27,280 --> 00:59:29,200
read them our metamask is going to pop
1689
00:59:29,200 --> 00:59:32,280
up to connect it to this website now get
1690
00:59:32,280 --> 00:59:33,839
familiar with this interface because
1691
00:59:33,839 --> 00:59:36,680
this is how websites will interact with
1692
00:59:36,680 --> 00:59:38,240
our wallet and interact with the
1693
00:59:38,240 --> 00:59:41,240
blockchain connecting our account to the
1694
00:59:41,240 --> 00:59:43,480
site will first select the specific
1695
00:59:43,480 --> 00:59:44,799
account that we want to connect we're
1696
00:59:44,799 --> 00:59:46,359
just going to choose account one we'll
1697
00:59:46,359 --> 00:59:48,760
hit next and then we'll go ahead and hit
1698
00:59:48,760 --> 00:59:51,640
connect and now we can see our wallet
1699
00:59:51,640 --> 00:59:53,280
address in the top right and we can see
1700
00:59:53,280 --> 00:59:55,640
that we're connected on the ethereum
1701
00:59:55,640 --> 00:59:58,079
supp a test net if we go up to our
1702
00:59:58,079 --> 00:59:59,799
wallet and we actually switch to
1703
00:59:59,799 --> 01:00:02,400
ethereum mainnet you can see that the
1704
01:00:02,400 --> 01:00:04,160
website has actually changed this little
1705
01:00:04,160 --> 01:00:06,440
drop down to ethereum name net and if we
1706
01:00:06,440 --> 01:00:08,880
go in here we can actually switch to
1707
01:00:08,880 --> 01:00:11,480
ethereum sapoia and our metamask will
1708
01:00:11,480 --> 01:00:14,079
pop up with this switch Network button
1709
01:00:14,079 --> 01:00:15,839
which will help us switch the network
1710
01:00:15,839 --> 01:00:18,760
for us so now we're back on sapoia test
1711
01:00:18,760 --> 01:00:20,599
Network connecting to these websites is
1712
01:00:20,599 --> 01:00:23,119
how we give these websites a way to
1713
01:00:23,119 --> 01:00:25,599
interact and connect with our wallets we
1714
01:00:25,599 --> 01:00:27,599
can go and select this hit these three
1715
01:00:27,599 --> 01:00:29,799
dots and hit disconnect this account but
1716
01:00:29,799 --> 01:00:32,240
don't worry anytime we want to send a
1717
01:00:32,240 --> 01:00:35,160
transaction the website has to ask us if
1718
01:00:35,160 --> 01:00:37,359
we want to send a transaction so just by
1719
01:00:37,359 --> 01:00:39,319
connecting to the site it won't actually
1720
01:00:39,319 --> 01:00:41,359
send a bunch of transactions for us and
1721
01:00:41,359 --> 01:00:43,000
if we scroll down we can see our wallet
1722
01:00:43,000 --> 01:00:45,200
address is placed right here and we can
1723
01:00:45,200 --> 01:00:47,920
see we can request test link and we can
1724
01:00:47,920 --> 01:00:50,359
also request test eth for now we don't
1725
01:00:50,359 --> 01:00:51,839
need any test link so we're going to
1726
01:00:51,839 --> 01:00:53,760
leave that off but in the future we will
1727
01:00:53,760 --> 01:00:55,319
come back to the site to get some test
1728
01:00:55,319 --> 01:00:57,680
link for now we're just going to get 0.1
1729
01:00:57,680 --> 01:00:59,920
test ethereum and if all goes well we
1730
01:00:59,920 --> 01:01:01,960
should hopefully see it in our sapoia e
1731
01:01:01,960 --> 01:01:04,200
here in order for us to get this test
1732
01:01:04,200 --> 01:01:06,359
ethereum we do have to log in Via
1733
01:01:06,359 --> 01:01:08,440
Twitter if you don't have a Twitter you
1734
01:01:08,440 --> 01:01:10,599
can use any of the other facets in the
1735
01:01:10,599 --> 01:01:13,559
test Nets facets area of the GitHub such
1736
01:01:13,559 --> 01:01:16,960
as the Alchemy seoa faucet or the sapoia
1737
01:01:16,960 --> 01:01:18,920
proof of work faucet but if you are on
1738
01:01:18,920 --> 01:01:20,359
Twitter now is a great time to give me a
1739
01:01:20,359 --> 01:01:22,119
follow maybe give me a shout out and
1740
01:01:22,119 --> 01:01:25,280
maybe say hey sending my first
1741
01:01:25,280 --> 01:01:26,839
transaction
1742
01:01:26,839 --> 01:01:30,559
thanks Patrick Alpha C or not whatever
1743
01:01:30,559 --> 01:01:32,720
you want to do just some light Shilling
1744
01:01:32,720 --> 01:01:34,920
of my own Twitter account anyways we can
1745
01:01:34,920 --> 01:01:37,440
log on Via Twitter we can authorize this
1746
01:01:37,440 --> 01:01:40,160
app verify that we're human give our AI
1747
01:01:40,160 --> 01:01:42,920
overlords The Prompt here oh make sure
1748
01:01:42,920 --> 01:01:44,440
we don't select the link and let's go
1749
01:01:44,440 --> 01:01:46,720
ahead and send the request now what's
1750
01:01:46,720 --> 01:01:48,480
going to happen is it's going to give us
1751
01:01:48,480 --> 01:01:51,079
this transaction hash on sapoia and
1752
01:01:51,079 --> 01:01:53,480
after a delay we'll see it go from
1753
01:01:53,480 --> 01:01:55,520
initiating to waiting for confirmation
1754
01:01:55,520 --> 01:01:58,400
to token transferred and we'll see a
1755
01:01:58,400 --> 01:02:00,440
transaction hash and if we click the
1756
01:02:00,440 --> 01:02:02,920
transaction hash we'll see a transaction
1757
01:02:02,920 --> 01:02:05,319
that was sent to our address so this
1758
01:02:05,319 --> 01:02:06,920
will be the first transaction that we
1759
01:02:06,920 --> 01:02:09,119
get to see and there's a ton of
1760
01:02:09,119 --> 01:02:11,640
information here but the most important
1761
01:02:11,640 --> 01:02:14,799
piece is if we open up our metamask now
1762
01:02:14,799 --> 01:02:18,640
we can see we now have 0.1 spolia eth in
1763
01:02:18,640 --> 01:02:20,799
our account and if we copy the address
1764
01:02:20,799 --> 01:02:23,640
again we paste it into here we can see
1765
01:02:23,640 --> 01:02:26,359
now we have a 0.1 eth balance
1766
01:02:26,359 --> 01:02:27,839
you might have to wait several minutes
1767
01:02:27,839 --> 01:02:29,279
for the transaction to finish going
1768
01:02:29,279 --> 01:02:30,960
through and if you accidentally refresh
1769
01:02:30,960 --> 01:02:33,119
your browser again we can go ahead and
1770
01:02:33,119 --> 01:02:35,200
just select our metamask copy our
1771
01:02:35,200 --> 01:02:37,599
address and paste it into ether scan or
1772
01:02:37,599 --> 01:02:39,720
just view it right in our metamask here
1773
01:02:39,720 --> 01:02:41,039
and if you missed that piece about the
1774
01:02:41,039 --> 01:02:43,520
transaction data if we go back to ethers
1775
01:02:43,520 --> 01:02:45,279
scan with our address remember we're on
1776
01:02:45,279 --> 01:02:47,799
sepolia ether scan and we scroll down we
1777
01:02:47,799 --> 01:02:50,279
can see this most recent transaction
1778
01:02:50,279 --> 01:02:52,400
hash that just occurred and we can click
1779
01:02:52,400 --> 01:02:54,319
the link here and we can see that detail
1780
01:02:54,319 --> 01:02:57,079
about the transaction again here now
1781
01:02:57,079 --> 01:02:58,960
importantly remember though this is on
1782
01:02:58,960 --> 01:03:01,720
sapoia if we switch back to mainnet
1783
01:03:01,720 --> 01:03:04,640
ethereum you'll see we have zero eth on
1784
01:03:04,640 --> 01:03:07,400
mainnet ethereum if we switch to gly
1785
01:03:07,400 --> 01:03:10,119
test Network you'll see we have zero gly
1786
01:03:10,119 --> 01:03:13,039
eth on that network if we switch to
1787
01:03:13,039 --> 01:03:15,839
Linea gelli eth or any other network
1788
01:03:15,839 --> 01:03:18,599
other than sapoia you'll see that seoa
1789
01:03:18,599 --> 01:03:21,559
is the only one that has the 0.1 sapoia
1790
01:03:21,559 --> 01:03:23,920
eth if you want to practice working with
1791
01:03:23,920 --> 01:03:26,520
a different test net feel free to scroll
1792
01:03:26,520 --> 01:03:29,079
up back to the faucet select a different
1793
01:03:29,079 --> 01:03:31,440
test net and try to get test net in one
1794
01:03:31,440 --> 01:03:33,319
of these different test Nets just be
1795
01:03:33,319 --> 01:03:35,680
sure to take a look at what test Nets
1796
01:03:35,680 --> 01:03:37,799
your metamask comes with since some of
1797
01:03:37,799 --> 01:03:39,880
the networks this faucet is compatible
1798
01:03:39,880 --> 01:03:42,440
with don't come built into our metamask
1799
01:03:42,440 --> 01:03:44,720
but again like I said in the future I'll
1800
01:03:44,720 --> 01:03:46,880
teach you how to add these different
1801
01:03:46,880 --> 01:03:49,160
networks to our metamask in the future
1802
01:03:49,160 --> 01:03:51,599
but huge congratulations you received
1803
01:03:51,599 --> 01:03:53,960
your first transaction because again
1804
01:03:53,960 --> 01:03:57,039
this faucet is US asking them to send us
1805
01:03:57,039 --> 01:03:59,319
money it's not us sending money it's
1806
01:03:59,319 --> 01:04:01,520
them sending money to us and if this is
1807
01:04:01,520 --> 01:04:02,680
the first transaction that you've ever
1808
01:04:02,680 --> 01:04:04,079
sent you should be proud of yourself
1809
01:04:04,079 --> 01:04:05,720
already give yourself a big Pat in the
1810
01:04:05,720 --> 01:04:07,359
back and here's a picture of me holding
1811
01:04:07,359 --> 01:04:09,279
a cat with that cat's face all over my
1812
01:04:09,279 --> 01:04:12,160
pajamas as of congratulations now once
1813
01:04:12,160 --> 01:04:14,960
more let's grab our address paste it
1814
01:04:14,960 --> 01:04:18,119
into ether scan here and scroll down and
1815
01:04:18,119 --> 01:04:19,599
we're going to learn a little bit more
1816
01:04:19,599 --> 01:04:21,279
about what actually went down what
1817
01:04:21,279 --> 01:04:23,359
actually happened in this transaction
1818
01:04:23,359 --> 01:04:24,960
you can see on ether scan it gives us
1819
01:04:24,960 --> 01:04:28,079
some basic detail details it says from
1820
01:04:28,079 --> 01:04:30,839
and to from is going to be another
1821
01:04:30,839 --> 01:04:32,680
address a different address an address
1822
01:04:32,680 --> 01:04:35,319
controlled by the foset and two is
1823
01:04:35,319 --> 01:04:37,960
obviously going to be our address and if
1824
01:04:37,960 --> 01:04:39,720
we select this transaction hash we can
1825
01:04:39,720 --> 01:04:41,839
see even more details in here
1826
01:04:41,839 --> 01:04:43,279
understanding all these different fields
1827
01:04:43,279 --> 01:04:44,720
is essential to becoming a smart
1828
01:04:44,720 --> 01:04:47,279
contract developer and even just a web3
1829
01:04:47,279 --> 01:04:49,960
or ethereum or blockchain user so let's
1830
01:04:49,960 --> 01:04:51,480
learn a bit of the basics of what's
1831
01:04:51,480 --> 01:04:53,400
actually going down in this transaction
1832
01:04:53,400 --> 01:04:55,319
the first field on this page is the
1833
01:04:55,319 --> 01:04:57,319
trans action hash you can even see a
1834
01:04:57,319 --> 01:04:58,720
little question mark here which tells
1835
01:04:58,720 --> 01:05:00,799
you a little bit more about it it's a
1836
01:05:00,799 --> 01:05:03,680
unique identifier for this specific
1837
01:05:03,680 --> 01:05:06,599
transaction on this network so this
1838
01:05:06,599 --> 01:05:08,920
specific transaction hash we can even
1839
01:05:08,920 --> 01:05:11,960
copy and paste this into the address bar
1840
01:05:11,960 --> 01:05:13,839
and we'll get the exact same transaction
1841
01:05:13,839 --> 01:05:16,480
back this is the only transaction in the
1842
01:05:16,480 --> 01:05:18,200
entire blockchain that will have this
1843
01:05:18,200 --> 01:05:19,799
transaction hash it's the unique
1844
01:05:19,799 --> 01:05:22,240
identifier it identifies the transaction
1845
01:05:22,240 --> 01:05:25,359
of sending 0.1 eth from the faucet
1846
01:05:25,359 --> 01:05:28,440
address add to our address we can see
1847
01:05:28,440 --> 01:05:30,839
the status of this was successful we can
1848
01:05:30,839 --> 01:05:32,680
see the block number and the number of
1849
01:05:32,680 --> 01:05:34,480
block confirmations which we will
1850
01:05:34,480 --> 01:05:36,520
explain in the future we can see the
1851
01:05:36,520 --> 01:05:38,960
time stamp which of course is when this
1852
01:05:38,960 --> 01:05:41,400
transaction occurred we can see the from
1853
01:05:41,400 --> 01:05:44,160
and to who initialized the transaction
1854
01:05:44,160 --> 01:05:47,039
and who it was sent to if we select this
1855
01:05:47,039 --> 01:05:49,799
from and open this in a new tab we can
1856
01:05:49,799 --> 01:05:51,680
see some details about who actually sent
1857
01:05:51,680 --> 01:05:54,000
us this test eth and if we go back to
1858
01:05:54,000 --> 01:05:56,160
the transaction detail and keep going we
1859
01:05:56,160 --> 01:05:58,559
can see the value here which again if we
1860
01:05:58,559 --> 01:06:01,680
roll over it's the value of ether or
1861
01:06:01,680 --> 01:06:04,240
testnet ether and then in parentheses
1862
01:06:04,240 --> 01:06:06,760
the Fiat value or the dollar value which
1863
01:06:06,760 --> 01:06:08,520
of course since this is a test net it's
1864
01:06:08,520 --> 01:06:10,720
always going to be zero the value of
1865
01:06:10,720 --> 01:06:15,000
this transaction was 0.1
1866
01:06:15,160 --> 01:06:17,920
e now what's underneath this value thing
1867
01:06:17,920 --> 01:06:20,160
this transaction fee and this gas price
1868
01:06:20,160 --> 01:06:22,240
thing what are these if we zoom in a lot
1869
01:06:22,240 --> 01:06:24,440
more to these pieces here and we roll
1870
01:06:24,440 --> 01:06:26,720
over transaction fee we can see it says
1871
01:06:26,720 --> 01:06:28,880
it's the amount paid to the block
1872
01:06:28,880 --> 01:06:31,760
producer for processing the transaction
1873
01:06:31,760 --> 01:06:33,680
and then gas price is going to be the
1874
01:06:33,680 --> 01:06:36,520
cost per unit of gas specified for the
1875
01:06:36,520 --> 01:06:39,160
transaction in ether or guay the higher
1876
01:06:39,160 --> 01:06:41,359
the gas price the higher the chance of
1877
01:06:41,359 --> 01:06:43,520
getting included in a block I'm going to
1878
01:06:43,520 --> 01:06:45,079
explain that in a little bit but if we
1879
01:06:45,079 --> 01:06:47,079
scroll down even more let's Zoom back
1880
01:06:47,079 --> 01:06:49,680
out and we click click to show more we
1881
01:06:49,680 --> 01:06:51,960
can see even more details about this
1882
01:06:51,960 --> 01:06:53,599
transaction for now we're just going to
1883
01:06:53,599 --> 01:06:55,720
click to show less and just focus on the
1884
01:06:55,720 --> 01:06:57,960
details that are here so let's talk
1885
01:06:57,960 --> 01:07:00,160
about just the concept of transaction
1886
01:07:00,160 --> 01:07:02,160
fees and gas for a second because they
1887
01:07:02,160 --> 01:07:03,720
are important concepts for you to
1888
01:07:03,720 --> 01:07:05,440
understand remember how I said that
1889
01:07:05,440 --> 01:07:07,480
these blockchains are actually run by a
1890
01:07:07,480 --> 01:07:09,559
group of different nodes well the
1891
01:07:09,559 --> 01:07:11,079
question is what's their economic
1892
01:07:11,079 --> 01:07:12,640
incentive to keep running these
1893
01:07:12,640 --> 01:07:14,480
blockchains are they running them out of
1894
01:07:14,480 --> 01:07:16,079
the goodness of their heart well on a
1895
01:07:16,079 --> 01:07:17,960
real Network these nodes actually get
1896
01:07:17,960 --> 01:07:19,839
paid a little bit of ether for
1897
01:07:19,839 --> 01:07:21,920
processing transactions whenever you
1898
01:07:21,920 --> 01:07:24,359
send a transaction there is a node
1899
01:07:24,359 --> 01:07:26,480
sometimes referred to as a minor or a
1900
01:07:26,480 --> 01:07:27,960
validator depending on the network
1901
01:07:27,960 --> 01:07:30,119
you're on who gets paid a little bit of
1902
01:07:30,119 --> 01:07:33,079
the Native currency of the blockchain to
1903
01:07:33,079 --> 01:07:35,359
process that transaction for ethereum
1904
01:07:35,359 --> 01:07:37,559
they obviously get paid in ethereum or
1905
01:07:37,559 --> 01:07:39,359
for test ethereum they get paid in test
1906
01:07:39,359 --> 01:07:41,480
ethereum which again the test ethereum
1907
01:07:41,480 --> 01:07:43,400
is worth nothing which is why I said
1908
01:07:43,400 --> 01:07:44,559
they're running them out of the goodness
1909
01:07:44,559 --> 01:07:45,960
of their heart if you're sending a
1910
01:07:45,960 --> 01:07:47,880
transaction on the polygon Network
1911
01:07:47,880 --> 01:07:49,480
they're going to get paid in madic the
1912
01:07:49,480 --> 01:07:51,760
native token of polygon if you send a
1913
01:07:51,760 --> 01:07:54,039
transaction on an L2 like arbitrum or
1914
01:07:54,039 --> 01:07:56,319
optimism you're going to get paid an eth
1915
01:07:56,319 --> 01:07:59,000
which is the native token of those l2s
1916
01:07:59,000 --> 01:08:00,920
this payment is obviously to incentivize
1917
01:08:00,920 --> 01:08:03,079
people to continue to run nodes and they
1918
01:08:03,079 --> 01:08:06,319
get paid more the more gas you use so
1919
01:08:06,319 --> 01:08:08,720
what is gas gas is a unit of
1920
01:08:08,720 --> 01:08:10,640
computational measurement the more
1921
01:08:10,640 --> 01:08:12,839
complex your transaction is the more gas
1922
01:08:12,839 --> 01:08:14,880
you have to pay for example if we hit
1923
01:08:14,880 --> 01:08:17,400
more details just really quickly and I
1924
01:08:17,400 --> 01:08:19,279
zoom in a little bit more we can see
1925
01:08:19,279 --> 01:08:22,239
this section here gas limit and usage by
1926
01:08:22,239 --> 01:08:24,239
transaction this means that when we sent
1927
01:08:24,239 --> 01:08:26,839
this transaction we limited it to a
1928
01:08:26,839 --> 01:08:30,120
maximum of 60,000 gas but in total we
1929
01:08:30,120 --> 01:08:34,040
only used 21,000 gas this 21,000 gas
1930
01:08:34,040 --> 01:08:36,440
represents how complex this transaction
1931
01:08:36,440 --> 01:08:39,040
was it was 21,000 gas units worth of
1932
01:08:39,040 --> 01:08:41,120
complexity now for simple things like
1933
01:08:41,120 --> 01:08:43,400
sending ether the units of gas are
1934
01:08:43,400 --> 01:08:46,159
usually pretty small for example 21,000
1935
01:08:46,159 --> 01:08:48,279
units of gas is actually a really small
1936
01:08:48,279 --> 01:08:50,640
amount of gas being sent but maybe for
1937
01:08:50,640 --> 01:08:52,359
more complex transactions like minting
1938
01:08:52,359 --> 01:08:55,520
an nft depositing some funds into a D5
1939
01:08:55,520 --> 01:08:57,960
protocol or deploying a smart contract
1940
01:08:57,960 --> 01:08:59,679
those are typically going to be more
1941
01:08:59,679 --> 01:09:01,440
expensive transactions because they're
1942
01:09:01,440 --> 01:09:03,920
more complicated they have to do more
1943
01:09:03,920 --> 01:09:06,159
stuff in the future we'll introduce you
1944
01:09:06,159 --> 01:09:09,440
to this concept of evm codes or op codes
1945
01:09:09,440 --> 01:09:11,960
and if you break down a transaction to
1946
01:09:11,960 --> 01:09:13,880
the lowest level this assembly op code
1947
01:09:13,880 --> 01:09:16,319
stuff you can actually see exactly how
1948
01:09:16,319 --> 01:09:19,640
much each op code costs in terms of gas
1949
01:09:19,640 --> 01:09:21,719
don't worry about this at all right now
1950
01:09:21,719 --> 01:09:23,159
just know that these transactions are
1951
01:09:23,159 --> 01:09:25,640
broken down into many many many many
1952
01:09:25,640 --> 01:09:27,920
very very small instructions and each
1953
01:09:27,920 --> 01:09:30,440
instruction has a specific amount of gas
1954
01:09:30,440 --> 01:09:32,520
the more instructions usually means more
1955
01:09:32,520 --> 01:09:34,719
gas like I said we'll explain this much
1956
01:09:34,719 --> 01:09:36,440
later in the course don't worry about
1957
01:09:36,440 --> 01:09:37,759
this too much here but just know that we
1958
01:09:37,759 --> 01:09:40,239
use 21,000 gas now if you take this gas
1959
01:09:40,239 --> 01:09:43,640
used and multiply it by the gas price in
1960
01:09:43,640 --> 01:09:47,319
eth instead of guay so we'll take 21,000
1961
01:09:47,319 --> 01:09:51,159
and multiply it by this gas price in eth
1962
01:09:51,159 --> 01:09:54,600
not in guay and hit enter we'll see the
1963
01:09:54,600 --> 01:09:58,040
total trans transaction fee of the
1964
01:09:58,040 --> 01:09:59,719
transaction and you can see that this
1965
01:09:59,719 --> 01:10:02,280
number does indeed match the transaction
1966
01:10:02,280 --> 01:10:04,840
fee for you to understand how much eth
1967
01:10:04,840 --> 01:10:07,080
you're going to pay for your transaction
1968
01:10:07,080 --> 01:10:11,040
you multiply the gas price times the gas
1969
01:10:11,040 --> 01:10:15,040
used transaction fee equals gas price
1970
01:10:15,040 --> 01:10:17,920
times gas used so this means that
1971
01:10:17,920 --> 01:10:23,560
whoever sent us this 0.1 e also paid
1972
01:10:23,719 --> 01:10:26,080
0.525 blah blah blah
1973
01:10:26,080 --> 01:10:30,080
eth to a blockchain node to a validator
1974
01:10:30,080 --> 01:10:32,920
on the sapoia ethereum test net now each
1975
01:10:32,920 --> 01:10:35,640
blockchain has their own unique way of
1976
01:10:35,640 --> 01:10:37,520
calculating how much transaction fee
1977
01:10:37,520 --> 01:10:39,679
someone's actually going to pay for most
1978
01:10:39,679 --> 01:10:42,800
evm chains this is the simple algorithm
1979
01:10:42,800 --> 01:10:45,920
it's going to be gas used times gas
1980
01:10:45,920 --> 01:10:47,239
price after we understand how the
1981
01:10:47,239 --> 01:10:49,480
blockchain works more in depth I'll
1982
01:10:49,480 --> 01:10:51,000
explain to you what the rest of these
1983
01:10:51,000 --> 01:10:53,320
values stand for for now just know that
1984
01:10:53,320 --> 01:10:55,440
anytime you make a transaction on chain
1985
01:10:55,440 --> 01:10:57,280
you have to pay the validators or the
1986
01:10:57,280 --> 01:10:59,920
blockchain nodes a little bit of gas or
1987
01:10:59,920 --> 01:11:01,760
a little bit of the Native token of the
1988
01:11:01,760 --> 01:11:04,320
blockchain which in our case is eth so
1989
01:11:04,320 --> 01:11:06,520
you have to pay a little bit of eth to
1990
01:11:06,520 --> 01:11:08,719
the blockchain nodes providing or
1991
01:11:08,719 --> 01:11:11,280
sending the transaction sometimes I'll
1992
01:11:11,280 --> 01:11:14,080
refer to this just as transaction gas
1993
01:11:14,080 --> 01:11:15,640
let's look at an example of this
1994
01:11:15,640 --> 01:11:18,560
ourselves if we pull up our metamask we
1995
01:11:18,560 --> 01:11:20,920
go ahead and hit expand view as we know
1996
01:11:20,920 --> 01:11:22,719
we have two different accounts in here
1997
01:11:22,719 --> 01:11:25,360
we have account one and account two
1998
01:11:25,360 --> 01:11:29,400
count 1 has 0.1 spolia eth Count 2 has
1999
01:11:29,400 --> 01:11:32,400
zolia eth if I send
2000
01:11:32,400 --> 01:11:35,640
0.05 from account one to account two how
2001
01:11:35,640 --> 01:11:37,120
much do you think I'll have left in
2002
01:11:37,120 --> 01:11:39,280
account one let's go ahead and do this
2003
01:11:39,280 --> 01:11:40,520
and this is going to be the first
2004
01:11:40,520 --> 01:11:42,800
transaction that you send on the
2005
01:11:42,800 --> 01:11:44,600
blockchain which is incredibly exciting
2006
01:11:44,600 --> 01:11:46,360
as well let's go ahead and hit this send
2007
01:11:46,360 --> 01:11:48,679
button in our metamask we'll hit send
2008
01:11:48,679 --> 01:11:50,880
we'll hit transfer between my accounts
2009
01:11:50,880 --> 01:11:53,679
we'll select account two and we'll say
2010
01:11:53,679 --> 01:11:57,760
0.05 suppo eth so we started with 0.1
2011
01:11:57,760 --> 01:12:01,320
aoia eth and we're going to send 0.05 to
2012
01:12:01,320 --> 01:12:04,080
account two we'll scroll down we'll hit
2013
01:12:04,080 --> 01:12:06,280
next we can see some information here
2014
01:12:06,280 --> 01:12:07,560
about what's actually going on we can
2015
01:12:07,560 --> 01:12:10,000
see some gas information which metamask
2016
01:12:10,000 --> 01:12:11,920
automatically prompted for us and it
2017
01:12:11,920 --> 01:12:13,639
even gives us the total amount that
2018
01:12:13,639 --> 01:12:16,040
we're going to be paying in eth it's
2019
01:12:16,040 --> 01:12:19,159
adding this 0.05 eth to the estimated
2020
01:12:19,159 --> 01:12:20,600
amount of gas that we actually have to
2021
01:12:20,600 --> 01:12:22,560
spend so that at the bottom it says the
2022
01:12:22,560 --> 01:12:24,560
amount plus the gas fee is the two of
2023
01:12:24,560 --> 01:12:25,679
those combined
2024
01:12:25,679 --> 01:12:27,400
the value that we're sending plus the
2025
01:12:27,400 --> 01:12:29,679
gas fee and additionally in metamask if
2026
01:12:29,679 --> 01:12:32,000
you select this here you can get some
2027
01:12:32,000 --> 01:12:34,120
more information about editing our gas
2028
01:12:34,120 --> 01:12:36,400
fees the amount of gas that you choose
2029
01:12:36,400 --> 01:12:38,600
to spend can be different depending on
2030
01:12:38,600 --> 01:12:40,400
how many people are making transactions
2031
01:12:40,400 --> 01:12:42,239
with the blockchain the more people are
2032
01:12:42,239 --> 01:12:44,360
sending transactions at the same time
2033
01:12:44,360 --> 01:12:46,560
the more expensive gas costs are going
2034
01:12:46,560 --> 01:12:48,719
to be so if a lot of other people are
2035
01:12:48,719 --> 01:12:50,920
also sending transactions right now the
2036
01:12:50,920 --> 01:12:53,440
gas price is going to be higher if a lot
2037
01:12:53,440 --> 01:12:55,199
of people are sending transactions that
2038
01:12:55,199 --> 01:12:56,239
means there's not going to be enough
2039
01:12:56,239 --> 01:12:57,960
space for everyone's transaction to get
2040
01:12:57,960 --> 01:13:00,040
through so in order to throttle that
2041
01:13:00,040 --> 01:13:02,320
they increase the gas price that's a bit
2042
01:13:02,320 --> 01:13:03,920
of an oversimplification of what's
2043
01:13:03,920 --> 01:13:06,159
happening but if you take that
2044
01:13:06,159 --> 01:13:08,440
understanding that'll pretty much work
2045
01:13:08,440 --> 01:13:10,880
if you want to specify exactly how much
2046
01:13:10,880 --> 01:13:12,760
gas you want to spend you can clict the
2047
01:13:12,760 --> 01:13:15,199
advanced tab if you select zero gas
2048
01:13:15,199 --> 01:13:16,760
there's a high likelihood that your
2049
01:13:16,760 --> 01:13:18,760
transaction will never go through so
2050
01:13:18,760 --> 01:13:19,960
we're just going to go with the default
2051
01:13:19,960 --> 01:13:22,800
which is usually a good idea so let's go
2052
01:13:22,800 --> 01:13:26,239
ahead and confirm we now see a send
2053
01:13:26,239 --> 01:13:28,840
transaction in our Q in the activity tab
2054
01:13:28,840 --> 01:13:30,719
of our metamask which shows us that we
2055
01:13:30,719 --> 01:13:33,080
have a transaction currently sending and
2056
01:13:33,080 --> 01:13:34,960
if we click on it and click view on
2057
01:13:34,960 --> 01:13:37,679
block Explorer it'll actually open us up
2058
01:13:37,679 --> 01:13:40,679
on ether scan and we'll see well mine
2059
01:13:40,679 --> 01:13:42,159
was a little bit quick but normally
2060
01:13:42,159 --> 01:13:44,360
we'll see a little indexing Tab and we
2061
01:13:44,360 --> 01:13:45,800
won't see this having gone through we'll
2062
01:13:45,800 --> 01:13:48,239
see it as like indexing or sending or
2063
01:13:48,239 --> 01:13:50,199
something like that but after a little
2064
01:13:50,199 --> 01:13:52,000
bit it'll actually finish sending you
2065
01:13:52,000 --> 01:13:53,880
might have to wait a minute or so for
2066
01:13:53,880 --> 01:13:55,639
this to actually finish going through
2067
01:13:55,639 --> 01:13:57,560
but it looks like mine was really quick
2068
01:13:57,560 --> 01:13:59,600
and same as our last transaction this
2069
01:13:59,600 --> 01:14:01,360
has a lot of the same information and if
2070
01:14:01,360 --> 01:14:03,800
we scroll down we'll see that of course
2071
01:14:03,800 --> 01:14:06,040
we send a different amount of eth
2072
01:14:06,040 --> 01:14:08,520
0.05 and we have a different transaction
2073
01:14:08,520 --> 01:14:10,880
fee now if we pull up our metamask what
2074
01:14:10,880 --> 01:14:12,199
do you think that we're going to see
2075
01:14:12,199 --> 01:14:13,600
we're going to go ahead and click expand
2076
01:14:13,600 --> 01:14:16,400
view again and we see account one says
2077
01:14:16,400 --> 01:14:20,719
0.05 and account two also says 0.05 hm
2078
01:14:20,719 --> 01:14:22,080
that's kind of odd I thought we spent
2079
01:14:22,080 --> 01:14:24,120
some gas well if we click on the big
2080
01:14:24,120 --> 01:14:26,000
accounts button we see exactly how much
2081
01:14:26,000 --> 01:14:27,960
eth is in each account you can see we
2082
01:14:27,960 --> 01:14:29,040
have
2083
01:14:29,040 --> 01:14:32,400
0.499 in account one and 0.05 in account
2084
01:14:32,400 --> 01:14:35,600
2 and we can see in our activity history
2085
01:14:35,600 --> 01:14:39,719
our account one recently sent 0.05 eth
2086
01:14:39,719 --> 01:14:42,880
and account two recently received 0.05
2087
01:14:42,880 --> 01:14:45,239
saoa eth now here's the best part of all
2088
01:14:45,239 --> 01:14:46,760
this even if you don't want to become a
2089
01:14:46,760 --> 01:14:49,040
developer you just learned the basics of
2090
01:14:49,040 --> 01:14:51,600
sending a transaction and interacting
2091
01:14:51,600 --> 01:14:53,840
with sites using your metamask
2092
01:14:53,840 --> 01:14:55,120
congratulations now here's here
2093
01:14:55,120 --> 01:14:56,480
something that's incredibly exciting
2094
01:14:56,480 --> 01:14:58,440
with just this little bit of information
2095
01:14:58,440 --> 01:15:00,080
you now know how to interact with
2096
01:15:00,080 --> 01:15:01,320
blockchains and interact with the
2097
01:15:01,320 --> 01:15:03,440
ethereum protocol so if you don't want
2098
01:15:03,440 --> 01:15:06,360
to learn how to code anything you can go
2099
01:15:06,360 --> 01:15:07,679
and you can start interacting with
2100
01:15:07,679 --> 01:15:09,360
ethereum and interacting with protocols
2101
01:15:09,360 --> 01:15:11,880
with just this much information however
2102
01:15:11,880 --> 01:15:12,920
I know most of you guys are here to
2103
01:15:12,920 --> 01:15:14,920
learn how to code so let's look under
2104
01:15:14,920 --> 01:15:16,760
the hood of ethereum and what is
2105
01:15:16,760 --> 01:15:17,719
actually going on with these
2106
01:15:17,719 --> 01:15:19,800
transactions and with these gas and with
2107
01:15:19,800 --> 01:15:21,679
these blockchains and what's really
2108
01:15:21,679 --> 01:15:23,760
going on let's learn all the
2109
01:15:23,760 --> 01:15:25,400
fundamentals of a blockchain now if you
2110
01:15:25,400 --> 01:15:26,560
want to just go ahead and jump into the
2111
01:15:26,560 --> 01:15:28,880
coding go ahead and grab a timestamp
2112
01:15:28,880 --> 01:15:31,600
from the description however learning
2113
01:15:31,600 --> 01:15:33,080
exactly how the blockchain works is
2114
01:15:33,080 --> 01:15:35,080
going to make you an incredibly powerful
2115
01:15:35,080 --> 01:15:38,560
developer so let's take a look at that
2116
01:15:38,560 --> 01:15:40,480
first so we're going to be going through
2117
01:15:40,480 --> 01:15:42,440
this blockchain demo on this site right
2118
01:15:42,440 --> 01:15:44,440
here now the creator of the site has a
2119
01:15:44,440 --> 01:15:46,159
fantastic video and a fantastic walkthr
2120
01:15:46,159 --> 01:15:49,280
blockchain 101 it is right on their site
2121
01:15:49,280 --> 01:15:50,480
so if you're looking for another
2122
01:15:50,480 --> 01:15:52,159
explanation definitely check out his
2123
01:15:52,159 --> 01:15:54,159
video it is absolutely fantastic but the
2124
01:15:54,159 --> 01:15:55,800
first thing that we really need to do in
2125
01:15:55,800 --> 01:15:57,360
order to understand blockchain in order
2126
01:15:57,360 --> 01:15:59,120
to really anything and everything that's
2127
01:15:59,120 --> 01:16:00,679
going on here we first really need to
2128
01:16:00,679 --> 01:16:03,840
understand this shot 256 hash or hashing
2129
01:16:03,840 --> 01:16:05,679
just kind of in general let's first
2130
01:16:05,679 --> 01:16:07,960
understand what a hash is a hash is a
2131
01:16:07,960 --> 01:16:11,000
unique fixed length string meant to
2132
01:16:11,000 --> 01:16:13,199
identify any piece of data they are
2133
01:16:13,199 --> 01:16:15,199
created by putting some piece of data
2134
01:16:15,199 --> 01:16:19,239
into a hash function in this example the
2135
01:16:19,239 --> 01:16:21,960
hashing algorithm used is Shaw 256 now
2136
01:16:21,960 --> 01:16:24,120
ethereum actually uses uh this uh this
2137
01:16:24,120 --> 01:16:26,000
right here for its hashing algorithm
2138
01:16:26,000 --> 01:16:29,239
which isn't quite um Shaw 256 but is in
2139
01:16:29,239 --> 01:16:31,639
kind of this sha family but it's it's
2140
01:16:31,639 --> 01:16:33,480
really just another way to Hash things
2141
01:16:33,480 --> 01:16:35,639
and uh the specific hash algorithm
2142
01:16:35,639 --> 01:16:38,600
doesn't matter uh so much so uh this
2143
01:16:38,600 --> 01:16:40,520
example uses Shaw 256 but you can
2144
01:16:40,520 --> 01:16:42,120
imagine it's the same as the ethereum
2145
01:16:42,120 --> 01:16:43,320
hash they're just going to you know
2146
01:16:43,320 --> 01:16:45,760
result in a different hash so what's
2147
01:16:45,760 --> 01:16:47,880
going to happen in this application here
2148
01:16:47,880 --> 01:16:51,639
is whatever data or whatever information
2149
01:16:51,639 --> 01:16:54,199
we put into this data section here as
2150
01:16:54,199 --> 01:16:55,520
you can see below
2151
01:16:55,520 --> 01:16:59,000
this hash changes so what's happening is
2152
01:16:59,000 --> 01:17:01,880
this data is running through this Shaw
2153
01:17:01,880 --> 01:17:05,320
256 hash algorithm and it's outputting
2154
01:17:05,320 --> 01:17:08,880
this unique hash so this hash is a
2155
01:17:08,880 --> 01:17:11,400
unique fixed length string that's going
2156
01:17:11,400 --> 01:17:13,719
to identify like a blank data piece here
2157
01:17:13,719 --> 01:17:15,120
right so if I put in you know my name
2158
01:17:15,120 --> 01:17:17,639
like you know Patrick Collins this is
2159
01:17:17,639 --> 01:17:20,000
the hash that's going to represent
2160
01:17:20,000 --> 01:17:22,480
Patrick Hollins right and you can see
2161
01:17:22,480 --> 01:17:25,040
even when I put you know tons and tons
2162
01:17:25,040 --> 01:17:28,920
of data in here the length of the string
2163
01:17:28,920 --> 01:17:32,480
doesn't change right so it's always
2164
01:17:32,480 --> 01:17:34,760
going to be the same amount we can put
2165
01:17:34,760 --> 01:17:36,440
almost any amount of data in here there
2166
01:17:36,440 --> 01:17:38,960
is an upper limit on the max size of the
2167
01:17:38,960 --> 01:17:42,040
data but for all intents purposes we can
2168
01:17:42,040 --> 01:17:43,920
pretty much put any length in here and
2169
01:17:43,920 --> 01:17:45,320
you'll see too that you know every time
2170
01:17:45,320 --> 01:17:48,080
I type in Patrick Collins this hash is
2171
01:17:48,080 --> 01:17:50,239
always going to be this 7 e5b right I'm
2172
01:17:50,239 --> 01:17:51,639
going to delete it I'm going to do
2173
01:17:51,639 --> 01:17:54,840
Patrick Collins again you 7 e5b it's
2174
01:17:54,840 --> 01:17:56,639
it's always this this unique hash is
2175
01:17:56,639 --> 01:17:58,639
always going to be unique right it's
2176
01:17:58,639 --> 01:18:00,159
always going to be this fixed length
2177
01:18:00,159 --> 01:18:02,920
string here so now we can take this idea
2178
01:18:02,920 --> 01:18:04,040
right of putting this data in here and
2179
01:18:04,040 --> 01:18:07,080
we can move on to uh this concept of a
2180
01:18:07,080 --> 01:18:09,360
block so with this block concept we're
2181
01:18:09,360 --> 01:18:10,880
going to take the exact same thing with
2182
01:18:10,880 --> 01:18:12,880
this hash this this data section right
2183
01:18:12,880 --> 01:18:14,560
but instead of having everything just
2184
01:18:14,560 --> 01:18:17,080
being in this this singular data area
2185
01:18:17,080 --> 01:18:18,360
right here we're going to split this
2186
01:18:18,360 --> 01:18:21,760
data up into block nuns and data so all
2187
01:18:21,760 --> 01:18:22,639
so what we're going to do is we're
2188
01:18:22,639 --> 01:18:25,040
actually going to Hash all three of
2189
01:18:25,040 --> 01:18:26,600
these to get to get this hash right
2190
01:18:26,600 --> 01:18:27,560
we're going to put all three of these
2191
01:18:27,560 --> 01:18:28,639
we're going to say all three of these
2192
01:18:28,639 --> 01:18:31,120
are combined uh together we're going to
2193
01:18:31,120 --> 01:18:32,639
put every all three of them into this
2194
01:18:32,639 --> 01:18:35,280
hashing algorithm uh to figure it out so
2195
01:18:35,280 --> 01:18:37,400
if I type a bunch of stuff here we can
2196
01:18:37,400 --> 01:18:40,760
see that block one with nuns you know
2197
01:18:40,760 --> 01:18:42,600
this nuns and this data we're going to
2198
01:18:42,600 --> 01:18:44,520
get this hash and as you can see
2199
01:18:44,520 --> 01:18:47,679
actually the screen turns red this block
2200
01:18:47,679 --> 01:18:50,679
turned red now what happens when I hit
2201
01:18:50,679 --> 01:18:51,719
this mind
2202
01:18:51,719 --> 01:18:53,800
button when I hit this mind button it's
2203
01:18:53,800 --> 01:18:55,159
actually G to take some time it's going
2204
01:18:55,159 --> 01:18:57,280
to think for a little bit and we can see
2205
01:18:57,280 --> 01:18:59,960
that the nuns here actually changed
2206
01:18:59,960 --> 01:19:01,440
right the nuns is different from what it
2207
01:19:01,440 --> 01:19:05,440
was before and this hash now starts with
2208
01:19:05,440 --> 01:19:08,239
four zeros okay and then it the back
2209
01:19:08,239 --> 01:19:10,120
turned green when we're talking about
2210
01:19:10,120 --> 01:19:11,560
mining we're talking about minors
2211
01:19:11,560 --> 01:19:13,639
solving some type of very difficult
2212
01:19:13,639 --> 01:19:15,920
problem that takes a lot of time to do
2213
01:19:15,920 --> 01:19:18,760
now in this example here the problem
2214
01:19:18,760 --> 01:19:20,639
that the miners had to solve was they
2215
01:19:20,639 --> 01:19:24,159
had to find a nuns or or a value in this
2216
01:19:24,159 --> 01:19:26,199
nuns section section that when hashed
2217
01:19:26,199 --> 01:19:29,040
with at block number one with this data
2218
01:19:29,040 --> 01:19:31,800
it would start with four zeros so the
2219
01:19:31,800 --> 01:19:33,560
problem here the minor had to solve was
2220
01:19:33,560 --> 01:19:35,159
to start with four zeros and the only
2221
01:19:35,159 --> 01:19:37,440
way for them to really do that is kind
2222
01:19:37,440 --> 01:19:39,120
of this Brute Force you know trying
2223
01:19:39,120 --> 01:19:40,600
stuff so they tried one okay one didn't
2224
01:19:40,600 --> 01:19:43,120
work okay two nope two didn't work three
2225
01:19:43,120 --> 01:19:45,760
no four five six okay five well that
2226
01:19:45,760 --> 01:19:46,880
started with one zero but that's not
2227
01:19:46,880 --> 01:19:48,920
four and they have to keep trying all
2228
01:19:48,920 --> 01:19:51,520
these numbers until they uh get to this
2229
01:19:51,520 --> 01:19:56,280
one where you know let's hit mine again
2230
01:19:56,280 --> 01:19:58,199
where it has four zeros at the top at
2231
01:19:58,199 --> 01:20:01,520
the start now this specific problem
2232
01:20:01,520 --> 01:20:03,360
changes blockchain to blockchain right
2233
01:20:03,360 --> 01:20:04,920
ethereum has a different problem for
2234
01:20:04,920 --> 01:20:07,480
miners to solve um Bitcoin has different
2235
01:20:07,480 --> 01:20:09,000
problems for minor solv but this concept
2236
01:20:09,000 --> 01:20:10,440
is going to be the same and since
2237
01:20:10,440 --> 01:20:13,159
etherium is proof of stake now nodes
2238
01:20:13,159 --> 01:20:14,880
actually take turns solving these
2239
01:20:14,880 --> 01:20:16,600
problems again we're not going to go too
2240
01:20:16,600 --> 01:20:18,480
deep into that right now though so they
2241
01:20:18,480 --> 01:20:21,440
have to take um one block is going to be
2242
01:20:21,440 --> 01:20:23,920
this this uh this concept is going to be
2243
01:20:23,920 --> 01:20:26,159
all this data it's going to be the block
2244
01:20:26,159 --> 01:20:28,520
number and it's going to be this nuns
2245
01:20:28,520 --> 01:20:31,239
right and so this nuns is the solution
2246
01:20:31,239 --> 01:20:33,080
um is is going to be the the number that
2247
01:20:33,080 --> 01:20:34,840
they use to get like the solution to the
2248
01:20:34,840 --> 01:20:37,880
problem right so if I go to one here you
2249
01:20:37,880 --> 01:20:39,760
know and I do this
2250
01:20:39,760 --> 01:20:43,040
again we going to hit mine and the nuns
2251
01:20:43,040 --> 01:20:47,320
has changed right it went from one to
2252
01:20:50,440 --> 01:20:53,120
33,100 and so that's what's happening
2253
01:20:53,120 --> 01:20:55,440
when uh blockchain minor ERS are mining
2254
01:20:55,440 --> 01:20:57,320
they're going through this process this
2255
01:20:57,320 --> 01:20:59,639
very computationally intensive process
2256
01:20:59,639 --> 01:21:02,120
of trying to find a nun that fulfills
2257
01:21:02,120 --> 01:21:04,080
whatever the problem is so that's really
2258
01:21:04,080 --> 01:21:05,880
it actually so that's a block and and
2259
01:21:05,880 --> 01:21:06,920
that's really what's happening when
2260
01:21:06,920 --> 01:21:08,800
miners are mining they're just looking
2261
01:21:08,800 --> 01:21:10,600
there's trial and error Brute Force
2262
01:21:10,600 --> 01:21:13,400
trying to find this nut so so now that
2263
01:21:13,400 --> 01:21:14,920
we know what a block is let's go to the
2264
01:21:14,920 --> 01:21:16,719
next step and figure out okay well
2265
01:21:16,719 --> 01:21:19,639
what's a blockchain so here we have an
2266
01:21:19,639 --> 01:21:22,040
example of what a blockchain is going to
2267
01:21:22,040 --> 01:21:24,600
look like right we have a combination
2268
01:21:24,600 --> 01:21:26,040
you know we have back here in the block
2269
01:21:26,040 --> 01:21:27,800
section we have one what one block looks
2270
01:21:27,800 --> 01:21:30,719
like now here we have multiple different
2271
01:21:30,719 --> 01:21:32,080
blocks right each one of these
2272
01:21:32,080 --> 01:21:34,040
represents a different block but we have
2273
01:21:34,040 --> 01:21:36,120
an additional column here or we have
2274
01:21:36,120 --> 01:21:38,480
additional uh variable here so like
2275
01:21:38,480 --> 01:21:40,760
before you know we have block nuns and
2276
01:21:40,760 --> 01:21:43,360
data right we have block nuns data but
2277
01:21:43,360 --> 01:21:45,880
we also have this thing called previous
2278
01:21:45,880 --> 01:21:47,360
right and so this is actually going to
2279
01:21:47,360 --> 01:21:50,600
be pointing to the previous hash of the
2280
01:21:50,600 --> 01:21:52,719
last block so for example if we go to
2281
01:21:52,719 --> 01:21:55,040
the the last block in this blockchain it
2282
01:21:55,040 --> 01:21:57,400
says previous is 00 ae8 and if we look
2283
01:21:57,400 --> 01:21:59,520
at the hash of block number four it's
2284
01:21:59,520 --> 01:22:02,639
000000 ae8 and then we look at its
2285
01:22:02,639 --> 01:22:06,400
previous it's 4 Z's B9 we have 4 zos B9
2286
01:22:06,400 --> 01:22:08,880
and so on all the way back to our first
2287
01:22:08,880 --> 01:22:11,280
block which has previous of just all
2288
01:22:11,280 --> 01:22:13,639
zeros right and so the block with the
2289
01:22:13,639 --> 01:22:16,159
previous of all zeros is going to be
2290
01:22:16,159 --> 01:22:17,920
known as The Genesis block so you've
2291
01:22:17,920 --> 01:22:19,239
probably heard that before the Genesis
2292
01:22:19,239 --> 01:22:20,760
Block it's the first block in the
2293
01:22:20,760 --> 01:22:23,000
blockchain where the previous hash
2294
01:22:23,000 --> 01:22:24,960
points to a hash that uh doesn't
2295
01:22:24,960 --> 01:22:26,880
actually exist now as you can imagine
2296
01:22:26,880 --> 01:22:28,400
kind of the same as how this block
2297
01:22:28,400 --> 01:22:30,719
worked how the block nuts and data all
2298
01:22:30,719 --> 01:22:32,840
go through the hashing algorithm in the
2299
01:22:32,840 --> 01:22:35,679
blockchain the block nuns data and
2300
01:22:35,679 --> 01:22:37,400
previous hash all go through this
2301
01:22:37,400 --> 01:22:39,520
hashing algorithm to figure out you know
2302
01:22:39,520 --> 01:22:42,040
what the hash is okay so if we go to
2303
01:22:42,040 --> 01:22:43,639
over here you know for example if I type
2304
01:22:43,639 --> 01:22:46,000
in you know Patrick obviously this is
2305
01:22:46,000 --> 01:22:47,760
now no longer valid right because this
2306
01:22:47,760 --> 01:22:50,199
nuns uh combined with the block the data
2307
01:22:50,199 --> 01:22:52,000
and the previous hash aren't going to
2308
01:22:52,000 --> 01:22:54,679
solve you know our problem of having 4
2309
01:22:54,679 --> 01:22:56,360
at the at the start right so I'm going
2310
01:22:56,360 --> 01:22:58,120
to go and fix that and and that's that's
2311
01:22:58,120 --> 01:22:59,639
kind of an easy way to to see it being
2312
01:22:59,639 --> 01:23:02,920
broken but but let's take a look if I
2313
01:23:02,920 --> 01:23:05,440
break this block right here what happens
2314
01:23:05,440 --> 01:23:07,400
if I if I break the data in here if I do
2315
01:23:07,400 --> 01:23:10,199
like Patrick in here you can see that
2316
01:23:10,199 --> 01:23:13,159
both of these are now read both of these
2317
01:23:13,159 --> 01:23:16,199
are now invalid right because the block
2318
01:23:16,199 --> 01:23:18,120
hash with the nuns hash with the new
2319
01:23:18,120 --> 01:23:20,239
data which is my name Patrick hashed
2320
01:23:20,239 --> 01:23:23,360
withe hashed with the previous block is
2321
01:23:23,360 --> 01:23:25,040
now a brand new
2322
01:23:25,040 --> 01:23:28,159
right and this block is still pointing
2323
01:23:28,159 --> 01:23:30,159
to this previous hash right here right
2324
01:23:30,159 --> 01:23:32,320
is pointing to this previous block and
2325
01:23:32,320 --> 01:23:35,159
now it is wrong and it is messed up and
2326
01:23:35,159 --> 01:23:37,760
now um and now its Nuns with this
2327
01:23:37,760 --> 01:23:40,760
previous hash is also wrong right and
2328
01:23:40,760 --> 01:23:42,560
this is where when we talk about uh
2329
01:23:42,560 --> 01:23:44,639
blockchains being immutable this is
2330
01:23:44,639 --> 01:23:47,199
exactly how it's immutable right because
2331
01:23:47,199 --> 01:23:49,280
I go back and I change anything you know
2332
01:23:49,280 --> 01:23:52,760
if I just typed a right here the entire
2333
01:23:52,760 --> 01:23:54,960
blockchain is now invalidated because
2334
01:23:54,960 --> 01:23:58,000
none of these are going to have uh Nunes
2335
01:23:58,000 --> 01:24:00,560
that solve this equation anymore so this
2336
01:24:00,560 --> 01:24:02,120
is why blockchains are immutable is
2337
01:24:02,120 --> 01:24:05,080
because anytime you change one thing you
2338
01:24:05,080 --> 01:24:07,920
ruin the rest of the blockchain okay so
2339
01:24:07,920 --> 01:24:09,480
however though you know if if an a was
2340
01:24:09,480 --> 01:24:11,600
here originally we can go ahead and mine
2341
01:24:11,600 --> 01:24:13,440
these we can mine all these but as you
2342
01:24:13,440 --> 01:24:15,239
can see you know this is going to start
2343
01:24:15,239 --> 01:24:17,199
getting very uh computationally
2344
01:24:17,199 --> 01:24:20,120
expensive because I have to go redo uh
2345
01:24:20,120 --> 01:24:22,239
basically the entire blockchain uh and
2346
01:24:22,239 --> 01:24:23,800
the farther and farther down the line
2347
01:24:23,800 --> 01:24:25,440
you get the harder and harder it becomes
2348
01:24:25,440 --> 01:24:27,760
to you know rehash and and redo all
2349
01:24:27,760 --> 01:24:29,159
these different blockchains here now
2350
01:24:29,159 --> 01:24:30,280
this makes a lot of sense right so we
2351
01:24:30,280 --> 01:24:31,400
have this blockchain it's really hard to
2352
01:24:31,400 --> 01:24:32,560
change something in the past but if we
2353
01:24:32,560 --> 01:24:35,040
do we can just go ahead and remine it
2354
01:24:35,040 --> 01:24:36,520
now if I'm the one who controls the
2355
01:24:36,520 --> 01:24:37,920
blockchain right if I'm the one who
2356
01:24:37,920 --> 01:24:39,199
controls this you know and I want to
2357
01:24:39,199 --> 01:24:40,480
change something in the past well okay
2358
01:24:40,480 --> 01:24:42,360
great all I got to do is change this
2359
01:24:42,360 --> 01:24:44,520
data here and then you know mine each
2360
01:24:44,520 --> 01:24:45,800
one of these you know obviously it's
2361
01:24:45,800 --> 01:24:47,320
going to be very computationally
2362
01:24:47,320 --> 01:24:48,520
expensive but it's something that I can
2363
01:24:48,520 --> 01:24:52,119
do right if I'm the one who owns the
2364
01:24:52,119 --> 01:24:54,560
blockchain now here's where the
2365
01:24:54,560 --> 01:24:56,600
decentralized nature or the distributed
2366
01:24:56,600 --> 01:24:59,639
nature really uh makes it incredibly
2367
01:24:59,639 --> 01:25:01,280
powerful so we're going to go to the
2368
01:25:01,280 --> 01:25:03,600
distributed tab here which I also refer
2369
01:25:03,600 --> 01:25:05,719
to as the decentralized tab here and
2370
01:25:05,719 --> 01:25:07,520
it's going to show us what a blockchain
2371
01:25:07,520 --> 01:25:10,360
looks like uh in a decentralized manner
2372
01:25:10,360 --> 01:25:12,400
so we have this exact same uh initial
2373
01:25:12,400 --> 01:25:14,000
setup here we have distributed
2374
01:25:14,000 --> 01:25:15,280
blockchain we have you know the our
2375
01:25:15,280 --> 01:25:16,560
first blockchain which is kind of
2376
01:25:16,560 --> 01:25:18,520
exactly as the one from here but we also
2377
01:25:18,520 --> 01:25:21,400
have more than one so we have Pier a
2378
01:25:21,400 --> 01:25:23,600
pier B and Pier C and when people are
2379
01:25:23,600 --> 01:25:24,760
talking about Pier to to peer
2380
01:25:24,760 --> 01:25:26,520
peer-to-peer transactions they're really
2381
01:25:26,520 --> 01:25:28,360
talking uh this is kind of that concept
2382
01:25:28,360 --> 01:25:29,920
that they're talking about right so we
2383
01:25:29,920 --> 01:25:32,159
have a number of different peers who
2384
01:25:32,159 --> 01:25:33,639
running this blockchain technology
2385
01:25:33,639 --> 01:25:35,360
they're all weighted equally right each
2386
01:25:35,360 --> 01:25:37,600
one of these tiers or each one of these
2387
01:25:37,600 --> 01:25:40,000
nodes each one of these entities running
2388
01:25:40,000 --> 01:25:40,840
a
2389
01:25:40,840 --> 01:25:43,840
blockchain has the exact same power as
2390
01:25:43,840 --> 01:25:46,320
anybody else right so the way that we
2391
01:25:46,320 --> 01:25:49,440
can tell very easily which blockchain is
2392
01:25:49,440 --> 01:25:51,719
correct or which ones are correct are by
2393
01:25:51,719 --> 01:25:55,159
looking at this end hash here right by
2394
01:25:55,159 --> 01:25:57,239
looking at where we are uh in the
2395
01:25:57,239 --> 01:25:59,159
blockchain because again remember
2396
01:25:59,159 --> 01:26:01,199
because again remember this this hash
2397
01:26:01,199 --> 01:26:03,520
that this this in this last block here
2398
01:26:03,520 --> 01:26:06,760
is going to Encompass all of the blocks
2399
01:26:06,760 --> 01:26:09,480
from before right because this last hash
2400
01:26:09,480 --> 01:26:11,320
is going to have the previous hash here
2401
01:26:11,320 --> 01:26:13,440
which includes the previous hash here
2402
01:26:13,440 --> 01:26:14,840
which this hash includes the previous
2403
01:26:14,840 --> 01:26:17,400
hash here and which so this last hash is
2404
01:26:17,400 --> 01:26:19,760
encompasses everything in here right and
2405
01:26:19,760 --> 01:26:21,679
we can look we can look at the hash of
2406
01:26:21,679 --> 01:26:24,840
Pier C which is four zeros and then E4 B
2407
01:26:24,840 --> 01:26:26,880
we can look at the latest hash of Pier B
2408
01:26:26,880 --> 01:26:30,199
which is 4's e4b and then Pier a which
2409
01:26:30,199 --> 01:26:33,880
is 4 e4b so all of these peers all of
2410
01:26:33,880 --> 01:26:36,320
these nodes all of these decentralized
2411
01:26:36,320 --> 01:26:38,960
you know these independent um all these
2412
01:26:38,960 --> 01:26:40,960
independent users running this
2413
01:26:40,960 --> 01:26:42,760
blockchain software they're all matched
2414
01:26:42,760 --> 01:26:44,440
up it's very easy for their nodes to
2415
01:26:44,440 --> 01:26:46,600
look at each other and say hey great we
2416
01:26:46,600 --> 01:26:49,840
are all matched up now what let's say
2417
01:26:49,840 --> 01:26:52,159
that a decides that you know something
2418
01:26:52,159 --> 01:26:53,639
happened on the blockchain that they
2419
01:26:53,639 --> 01:26:55,199
didn't like and they wanted to go back
2420
01:26:55,199 --> 01:26:57,280
and change something right so let's say
2421
01:26:57,280 --> 01:26:59,600
they change here you know obviously uh
2422
01:26:59,600 --> 01:27:00,719
the rest of their blockchain is
2423
01:27:00,719 --> 01:27:02,600
invalidated and they have to spend a lot
2424
01:27:02,600 --> 01:27:04,239
of computational power to catch up to
2425
01:27:04,239 --> 01:27:06,239
speed so let's go ahead and humor it
2426
01:27:06,239 --> 01:27:07,800
let's say that they they did they ended
2427
01:27:07,800 --> 01:27:10,280
up catching up uh they ended up catching
2428
01:27:10,280 --> 01:27:12,119
up you know they ended up mining
2429
01:27:12,119 --> 01:27:14,760
everything and now they have a valid
2430
01:27:14,760 --> 01:27:16,840
blockchain right it solves the equation
2431
01:27:16,840 --> 01:27:20,480
awesome however in block number three
2432
01:27:20,480 --> 01:27:23,159
there's something new right this is here
2433
01:27:23,159 --> 01:27:24,440
and it shouldn't have been here this is
2434
01:27:24,440 --> 01:27:27,080
something that perer a put in by
2435
01:27:27,080 --> 01:27:30,560
themselves all that happens now is we
2436
01:27:30,560 --> 01:27:32,880
look at all the blockchains that are
2437
01:27:32,880 --> 01:27:34,600
running the software and we're looking
2438
01:27:34,600 --> 01:27:37,040
at all the hashes at hash at block
2439
01:27:37,040 --> 01:27:39,880
number five so per a has this new hash
2440
01:27:39,880 --> 01:27:41,800
now
2441
01:27:41,800 --> 01:27:45,800
9bc but Pier B has a different hash 00
2442
01:27:45,800 --> 01:27:48,719
e4b right so who's right is it is it
2443
01:27:48,719 --> 01:27:50,400
Pier a with their new stuff or is it
2444
01:27:50,400 --> 01:27:52,920
Pier B well that's where the
2445
01:27:52,920 --> 01:27:54,360
decentralized comes in because then we
2446
01:27:54,360 --> 01:27:56,920
can look at Pier C and Pier C also has
2447
01:27:56,920 --> 01:28:00,520
e4b so Pier B and Pier C both say hey
2448
01:28:00,520 --> 01:28:04,800
Pier a you're wrong get out right and P
2449
01:28:04,800 --> 01:28:06,239
A will stop being able to participate in
2450
01:28:06,239 --> 01:28:08,280
the mining rewards because they have
2451
01:28:08,280 --> 01:28:10,639
essentially forked uh the blockchain and
2452
01:28:10,639 --> 01:28:12,800
started their own little blockchain
2453
01:28:12,800 --> 01:28:14,520
right with their own history because
2454
01:28:14,520 --> 01:28:16,679
they're the only ones with this this
2455
01:28:16,679 --> 01:28:19,040
piece of data in block three whereas
2456
01:28:19,040 --> 01:28:22,400
Pier B and Pier C have nothing in there
2457
01:28:22,400 --> 01:28:24,199
so that really shows why uh in these
2458
01:28:24,199 --> 01:28:25,880
blockchain worlds in this decentralized
2459
01:28:25,880 --> 01:28:27,320
world there really is no centralized
2460
01:28:27,320 --> 01:28:29,400
entity you know per a you know might
2461
01:28:29,400 --> 01:28:31,000
have been maliciously motivated to
2462
01:28:31,000 --> 01:28:32,840
change you know this this block number
2463
01:28:32,840 --> 01:28:35,280
three however democracy rules right the
2464
01:28:35,280 --> 01:28:37,480
majority rules in the blockchain pier B
2465
01:28:37,480 --> 01:28:39,600
and Pier C both say Hey you know that
2466
01:28:39,600 --> 01:28:42,040
that's cute and all p a but you're wrong
2467
01:28:42,040 --> 01:28:43,679
right that that's not right now it might
2468
01:28:43,679 --> 01:28:45,360
be a little abstract that you just look
2469
01:28:45,360 --> 01:28:46,840
at data and you know us typing kind of
2470
01:28:46,840 --> 01:28:48,639
random stuff in here and think okay yeah
2471
01:28:48,639 --> 01:28:50,440
that's that's data right that makes
2472
01:28:50,440 --> 01:28:52,360
sense you know just kind of random
2473
01:28:52,360 --> 01:28:54,119
strings in here doesn't really do
2474
01:28:54,119 --> 01:28:55,360
anything for us so if we actually go
2475
01:28:55,360 --> 01:28:57,960
over to the Token section here this is
2476
01:28:57,960 --> 01:29:00,080
where everything really starts to make a
2477
01:29:00,080 --> 01:29:01,920
lot of sense so we have the exact same
2478
01:29:01,920 --> 01:29:05,280
setup here uh with Pier a pier B Pier C
2479
01:29:05,280 --> 01:29:07,520
except the difference is instead of
2480
01:29:07,520 --> 01:29:09,360
having kind of this this data section we
2481
01:29:09,360 --> 01:29:12,360
have this a TX this transaction section
2482
01:29:12,360 --> 01:29:14,600
right and this represents all the
2483
01:29:14,600 --> 01:29:17,080
transactions that are happening in this
2484
01:29:17,080 --> 01:29:19,480
block right so we're we're sending $25
2485
01:29:19,480 --> 01:29:22,719
from Darcy to Bingle or to Bingley uh
2486
01:29:22,719 --> 01:29:27,760
for uh $27 here 1922 right and it's the
2487
01:29:27,760 --> 01:29:29,800
exact same thing so this all these
2488
01:29:29,800 --> 01:29:31,679
transactions are going to get hashed in
2489
01:29:31,679 --> 01:29:34,400
the exact same way uh that the data is
2490
01:29:34,400 --> 01:29:36,239
going to get hashed and and this is why
2491
01:29:36,239 --> 01:29:37,679
it's so powerful because again you know
2492
01:29:37,679 --> 01:29:40,239
if I want to be malicious right if uh if
2493
01:29:40,239 --> 01:29:42,040
I wanted to say hey I I really wanted to
2494
01:29:42,040 --> 01:29:43,960
give Jane a lot more money from
2495
01:29:43,960 --> 01:29:46,400
Elizabeth so I'm p and I go back and I
2496
01:29:46,400 --> 01:29:48,639
change it to 100 well now you know not
2497
01:29:48,639 --> 01:29:51,320
only do I does my whole blockchain uh
2498
01:29:51,320 --> 01:29:53,320
get invalided because that was so far uh
2499
01:29:53,320 --> 01:29:55,480
so long ago but I'm not going to match
2500
01:29:55,480 --> 01:29:57,520
any of these other chains right and so
2501
01:29:57,520 --> 01:29:59,960
my blockchain is going to be excluded
2502
01:29:59,960 --> 01:30:02,000
from the overall blockchain so and let's
2503
01:30:02,000 --> 01:30:04,000
let's go ahead and fix this and it's the
2504
01:30:04,000 --> 01:30:06,119
same thing if down here if I I become
2505
01:30:06,119 --> 01:30:08,400
malicious and I want to send you know I
2506
01:30:08,400 --> 01:30:12,040
want uh Miss Audrey to have less money
2507
01:30:12,040 --> 01:30:13,600
maybe I want to send a dollar and I go
2508
01:30:13,600 --> 01:30:16,440
ahead and M it the same thing here this
2509
01:30:16,440 --> 01:30:22,000
hash now this 2a1 is not going to match
2510
01:30:22,000 --> 01:30:24,920
pib's pb's hash of BBA and it's not
2511
01:30:24,920 --> 01:30:27,880
going to match PC's hash of BBA as well
2512
01:30:27,880 --> 01:30:29,639
so the two of them are going to say hey
2513
01:30:29,639 --> 01:30:32,119
this your blockchain is invalid it's not
2514
01:30:32,119 --> 01:30:33,639
matching the majority you know you're
2515
01:30:33,639 --> 01:30:37,080
out right so that's really how uh these
2516
01:30:37,080 --> 01:30:40,040
blockchains work at a low level and it
2517
01:30:40,040 --> 01:30:42,040
all goes back to this this understanding
2518
01:30:42,040 --> 01:30:44,320
this hash idea and using it in this very
2519
01:30:44,320 --> 01:30:46,480
sophisticated manner uh to kind of
2520
01:30:46,480 --> 01:30:48,960
cryptographically prove um you know
2521
01:30:48,960 --> 01:30:51,159
where where stuff lies now the way the
2522
01:30:51,159 --> 01:30:52,679
blockchain works is you instead of
2523
01:30:52,679 --> 01:30:54,440
random stuff put in this data section
2524
01:30:54,440 --> 01:30:56,159
it's actually going to be solidity code
2525
01:30:56,159 --> 01:30:58,480
in here to finding ways to interact with
2526
01:30:58,480 --> 01:30:59,920
different blocks and different protocols
2527
01:30:59,920 --> 01:31:02,520
that are on chain or as we've said
2528
01:31:02,520 --> 01:31:04,440
before different smart
2529
01:31:04,440 --> 01:31:07,040
contracts now the next question that you
2530
01:31:07,040 --> 01:31:09,960
might be asking is okay well how do I
2531
01:31:09,960 --> 01:31:13,600
know how can I be sure that I'm the one
2532
01:31:13,600 --> 01:31:14,920
uh you know let's say this is let's say
2533
01:31:14,920 --> 01:31:17,320
I'm Darcy right how can I be sure that I
2534
01:31:17,320 --> 01:31:18,920
was that Darcy was the one to actually
2535
01:31:18,920 --> 01:31:21,000
send this money here how do we know that
2536
01:31:21,000 --> 01:31:24,520
Darcy sent $25 to uh Bing
2537
01:31:24,520 --> 01:31:27,159
well this is where we get into private
2538
01:31:27,159 --> 01:31:28,840
keys and public keys and that's what
2539
01:31:28,840 --> 01:31:30,880
we're going to go into now let's just do
2540
01:31:30,880 --> 01:31:33,080
a quick recap of what we've learned in
2541
01:31:33,080 --> 01:31:34,960
this section so far right we've learned
2542
01:31:34,960 --> 01:31:37,840
that ethereum actually runs on this Kack
2543
01:31:37,840 --> 01:31:40,719
256 but you know we used shot6 for this
2544
01:31:40,719 --> 01:31:42,639
demo it doesn't really matter we're just
2545
01:31:42,639 --> 01:31:45,440
talking about hashing algorithms so
2546
01:31:45,440 --> 01:31:48,320
again a hash is a unique fixed length
2547
01:31:48,320 --> 01:31:51,760
string meant to identify any piece of
2548
01:31:51,760 --> 01:31:55,000
data a hash algorithm or a hash function
2549
01:31:55,000 --> 01:31:57,239
is a function or algorithm that computes
2550
01:31:57,239 --> 01:32:00,960
any type of data into a unique hash
2551
01:32:00,960 --> 01:32:02,760
mining is going to be the process of
2552
01:32:02,760 --> 01:32:05,000
finding the solution to the blockchain
2553
01:32:05,000 --> 01:32:06,960
problem in our example the problem was
2554
01:32:06,960 --> 01:32:08,560
finding a hash that starts with four
2555
01:32:08,560 --> 01:32:11,239
zeros nodes get paid for mining
2556
01:32:11,239 --> 01:32:13,080
different blocks and the problem is
2557
01:32:13,080 --> 01:32:14,280
going to be different blockchain to
2558
01:32:14,280 --> 01:32:16,600
blockchain a block in a blockchain is
2559
01:32:16,600 --> 01:32:18,840
basically a combination of a block nuns
2560
01:32:18,840 --> 01:32:20,840
transaction and a previous hash to
2561
01:32:20,840 --> 01:32:23,520
create this unique hash for this block
2562
01:32:23,520 --> 01:32:25,639
and again depending on the blockchain
2563
01:32:25,639 --> 01:32:27,400
implementation this might have a couple
2564
01:32:27,400 --> 01:32:28,600
other fields or might have different
2565
01:32:28,600 --> 01:32:30,119
fields but this is essentially what's
2566
01:32:30,119 --> 01:32:32,400
going on blockchains are decentralized
2567
01:32:32,400 --> 01:32:34,920
and distributed because many independent
2568
01:32:34,920 --> 01:32:36,360
users are going to run this blockchain
2569
01:32:36,360 --> 01:32:38,000
software and they will check and they
2570
01:32:38,000 --> 01:32:39,560
will compare against each other to see
2571
01:32:39,560 --> 01:32:41,639
which blockchains are acting honestly
2572
01:32:41,639 --> 01:32:43,880
and which ones are acting maliciously in
2573
01:32:43,880 --> 01:32:46,679
the blockchain world majority rules the
2574
01:32:46,679 --> 01:32:49,199
nuns here is the answer used or the
2575
01:32:49,199 --> 01:32:52,600
number used to get this hash now nuns is
2576
01:32:52,600 --> 01:32:54,320
kind of an overloaded term it's actually
2577
01:32:54,320 --> 01:32:56,239
used for a number of different reasons
2578
01:32:56,239 --> 01:32:57,920
in this case we're using it to solve
2579
01:32:57,920 --> 01:32:59,480
this problem of getting you know four or
2580
01:32:59,480 --> 01:33:01,520
five zeros at the stop of the hash
2581
01:33:01,520 --> 01:33:03,920
however in ethereum it'll also be often
2582
01:33:03,920 --> 01:33:05,960
used as the number of transactions from
2583
01:33:05,960 --> 01:33:09,239
a given
2584
01:33:09,440 --> 01:33:11,239
address so now we're going to talk a
2585
01:33:11,239 --> 01:33:12,400
little bit about signing these
2586
01:33:12,400 --> 01:33:14,199
transactions and and private keys and
2587
01:33:14,199 --> 01:33:16,040
and some other cryptography pieces right
2588
01:33:16,040 --> 01:33:18,040
because in this blockchain demo here we
2589
01:33:18,040 --> 01:33:19,520
can see we have all these these
2590
01:33:19,520 --> 01:33:20,880
fantastic transactions right all these
2591
01:33:20,880 --> 01:33:22,840
things went through but how do we know
2592
01:33:22,840 --> 01:33:25,119
that it was dar see who is the one to
2593
01:33:25,119 --> 01:33:28,360
send $25 uh to Bingley right how do we
2594
01:33:28,360 --> 01:33:30,800
know that actually happened and this is
2595
01:33:30,800 --> 01:33:32,960
where all those pieces that we just
2596
01:33:32,960 --> 01:33:35,880
learned about uh in our our test net in
2597
01:33:35,880 --> 01:33:37,320
our metamask account are really going to
2598
01:33:37,320 --> 01:33:39,040
start to to come to life here a little
2599
01:33:39,040 --> 01:33:41,760
bit here so here we have an example of
2600
01:33:41,760 --> 01:33:45,280
public and private Keys okay at the top
2601
01:33:45,280 --> 01:33:47,119
we have this private key right that was
2602
01:33:47,119 --> 01:33:49,520
that was randomly generated uh a private
2603
01:33:49,520 --> 01:33:51,440
key is is you know as it kind of states
2604
01:33:51,440 --> 01:33:53,159
is a key that you really want to keep
2605
01:33:53,159 --> 01:33:54,600
secret because you're going to be using
2606
01:33:54,600 --> 01:33:56,880
this uh as kind of your your secret
2607
01:33:56,880 --> 01:33:58,960
password for all your transactions right
2608
01:33:58,960 --> 01:34:02,320
I can really pick you know any any any
2609
01:34:02,320 --> 01:34:04,639
private key anything that I want and
2610
01:34:04,639 --> 01:34:07,560
with it uh this algorithm they're going
2611
01:34:07,560 --> 01:34:08,840
to use an algorithm you know for
2612
01:34:08,840 --> 01:34:10,400
ethereum and Bitcoin they both use this
2613
01:34:10,400 --> 01:34:12,840
elliptic curve digital signature uh
2614
01:34:12,840 --> 01:34:14,880
algorithm it's it's a variant of just a
2615
01:34:14,880 --> 01:34:16,920
digital signature algorithm and it's
2616
01:34:16,920 --> 01:34:18,560
going to create this this public key
2617
01:34:18,560 --> 01:34:20,360
right I'm really not going to go at all
2618
01:34:20,360 --> 01:34:22,239
into kind of this digital signature
2619
01:34:22,239 --> 01:34:24,440
algorithm but just know it does use some
2620
01:34:24,440 --> 01:34:26,760
of these uh some of the hash uh
2621
01:34:26,760 --> 01:34:28,400
knowledge that we just learned combined
2622
01:34:28,400 --> 01:34:30,719
with some other pieces uh to kind of get
2623
01:34:30,719 --> 01:34:32,320
this this public here so I'm not going
2624
01:34:32,320 --> 01:34:34,080
to go too deep into it but we have this
2625
01:34:34,080 --> 01:34:36,320
private key that we create and we get
2626
01:34:36,320 --> 01:34:38,840
this public key now this public key we
2627
01:34:38,840 --> 01:34:41,080
want everybody to have access to right
2628
01:34:41,080 --> 01:34:42,600
this is yeah whole world can see this
2629
01:34:42,600 --> 01:34:45,440
this private key we really want it to be
2630
01:34:45,440 --> 01:34:46,960
uh private we don't want people to see
2631
01:34:46,960 --> 01:34:49,199
this we're going to use this private key
2632
01:34:49,199 --> 01:34:51,719
as like a password to quote unquote
2633
01:34:51,719 --> 01:34:54,320
digitally sign transactions and then
2634
01:34:54,320 --> 01:34:57,440
people can verify them with this public
2635
01:34:57,440 --> 01:34:58,679
key so let's let's see what this
2636
01:34:58,679 --> 01:34:59,920
actually looks like let's pick a a
2637
01:34:59,920 --> 01:35:01,560
random key a more secure key right
2638
01:35:01,560 --> 01:35:03,239
because the longer it is the the more
2639
01:35:03,239 --> 01:35:05,480
secure it's going to be and if we go to
2640
01:35:05,480 --> 01:35:08,560
signatures now right um let's say we
2641
01:35:08,560 --> 01:35:11,159
have this uh this message that we want
2642
01:35:11,159 --> 01:35:13,520
right we say high world right we want
2643
01:35:13,520 --> 01:35:15,159
this to be the message what's going to
2644
01:35:15,159 --> 01:35:17,440
happen is this private key that we've
2645
01:35:17,440 --> 01:35:20,239
created we can use to sign this data
2646
01:35:20,239 --> 01:35:21,719
right remember how in the blockchain
2647
01:35:21,719 --> 01:35:23,719
demo you know we were kind of We Were
2648
01:35:23,719 --> 01:35:25,840
hashing stuff right we were we're using
2649
01:35:25,840 --> 01:35:28,400
this uh shade 256 hash to to get this
2650
01:35:28,400 --> 01:35:30,199
hash well we're doing something similar
2651
01:35:30,199 --> 01:35:32,119
but instead of hashing we're we're using
2652
01:35:32,119 --> 01:35:34,159
this digital signature algorithm to
2653
01:35:34,159 --> 01:35:37,119
create this message signature now what's
2654
01:35:37,119 --> 01:35:39,440
really powerful about how this uh this
2655
01:35:39,440 --> 01:35:42,040
algorithm works is that you can create
2656
01:35:42,040 --> 01:35:44,400
this message signature with your private
2657
01:35:44,400 --> 01:35:47,199
key but somebody else can't derive your
2658
01:35:47,199 --> 01:35:49,920
private key from the message signature
2659
01:35:49,920 --> 01:35:51,400
and that's what makes this really really
2660
01:35:51,400 --> 01:35:54,119
powerful however if we go to verify by
2661
01:35:54,119 --> 01:35:56,119
using this public key right uh and so
2662
01:35:56,119 --> 01:35:59,159
this is the this is that 0403 this is
2663
01:35:59,159 --> 01:36:02,040
that same public key using this uh using
2664
01:36:02,040 --> 01:36:05,040
this public key anybody can verify oh
2665
01:36:05,040 --> 01:36:06,920
let's go ahead and sign it again anybody
2666
01:36:06,920 --> 01:36:11,280
can verify that this signature is yours
2667
01:36:11,280 --> 01:36:14,199
right so you have a public a private key
2668
01:36:14,199 --> 01:36:16,400
just for you so you can sign things and
2669
01:36:16,400 --> 01:36:18,679
a public key that anybody can verify
2670
01:36:18,679 --> 01:36:20,719
something right so anybody can verify
2671
01:36:20,719 --> 01:36:22,159
this and let's say somebody tries to
2672
01:36:22,159 --> 01:36:24,840
fake a transaction from you they say Hey
2673
01:36:24,840 --> 01:36:27,560
you know this is this is this is their
2674
01:36:27,560 --> 01:36:29,679
transaction um all they have to do is
2675
01:36:29,679 --> 01:36:33,560
verify that this signature against your
2676
01:36:33,560 --> 01:36:36,560
uh public key and very easily this whole
2677
01:36:36,560 --> 01:36:38,679
thing turns red because uh it isn't
2678
01:36:38,679 --> 01:36:40,520
verified right the the algorithm says
2679
01:36:40,520 --> 01:36:42,880
Hey uhuh that's wrong so we can go ahead
2680
01:36:42,880 --> 01:36:45,440
and take that into transactions in this
2681
01:36:45,440 --> 01:36:47,360
exact same way so if I want to send
2682
01:36:47,360 --> 01:36:51,320
money you know if I want to send $400
2683
01:36:51,320 --> 01:36:54,000
from you know my address to another
2684
01:36:54,000 --> 01:36:57,280
address using my private key I can sign
2685
01:36:57,280 --> 01:36:59,719
that transaction and anybody else in the
2686
01:36:59,719 --> 01:37:02,840
world can then verify this transaction
2687
01:37:02,840 --> 01:37:04,719
right and this is why when people say
2688
01:37:04,719 --> 01:37:06,320
hide your keys you know protect your
2689
01:37:06,320 --> 01:37:08,600
keys this is what we're talking about in
2690
01:37:08,600 --> 01:37:12,679
our accounts here right if we go to uh
2691
01:37:12,679 --> 01:37:14,520
settings and again the only reason that
2692
01:37:14,520 --> 01:37:16,960
I'm showing you guys my pneumonic and my
2693
01:37:16,960 --> 01:37:19,159
private key is because this is a uh this
2694
01:37:19,159 --> 01:37:20,840
is a dumpster account I'm going to throw
2695
01:37:20,840 --> 01:37:22,280
this away at the end of this video or
2696
01:37:22,280 --> 01:37:23,719
I'm just not going to put any real money
2697
01:37:23,719 --> 01:37:27,600
it um
2698
01:37:27,600 --> 01:37:30,639
but when we look at our our our metamask
2699
01:37:30,639 --> 01:37:32,960
here we have this numic phrase which
2700
01:37:32,960 --> 01:37:36,560
allows us to easily get these different
2701
01:37:36,560 --> 01:37:38,920
private keys right so uh pneumonic
2702
01:37:38,920 --> 01:37:41,679
phrase combined uh with you know uh
2703
01:37:41,679 --> 01:37:43,440
whatever account number will get us a
2704
01:37:43,440 --> 01:37:45,080
private key so pneumonic phrase combined
2705
01:37:45,080 --> 01:37:47,159
with one we're going to get this private
2706
01:37:47,159 --> 01:37:48,800
key and this is when we look at Account
2707
01:37:48,800 --> 01:37:52,960
Details export private key
2708
01:37:55,080 --> 01:37:57,119
confirm this is going to be the private
2709
01:37:57,119 --> 01:37:59,360
key that we're going to use to sign our
2710
01:37:59,360 --> 01:38:01,679
transactions right this if anybody else
2711
01:38:01,679 --> 01:38:03,520
gets access to this private key they
2712
01:38:03,520 --> 01:38:06,080
then can sign transactions for us and
2713
01:38:06,080 --> 01:38:07,920
they can send transactions for us and
2714
01:38:07,920 --> 01:38:10,159
that's why we want to keep these private
2715
01:38:10,159 --> 01:38:12,280
so uh it works the exact same way right
2716
01:38:12,280 --> 01:38:14,520
so this is why it's so important to hide
2717
01:38:14,520 --> 01:38:16,159
your private keys and hide your newonics
2718
01:38:16,159 --> 01:38:20,679
now your ethereum address is actually uh
2719
01:38:20,679 --> 01:38:23,840
a piece
2720
01:38:24,199 --> 01:38:26,080
uh is actually a piece of your public
2721
01:38:26,080 --> 01:38:28,960
key now to get our address in ethereum
2722
01:38:28,960 --> 01:38:30,440
all we have to do is take this public
2723
01:38:30,440 --> 01:38:32,000
key that we've created with our private
2724
01:38:32,000 --> 01:38:34,440
key hash it using that same ethereum
2725
01:38:34,440 --> 01:38:36,320
hashing algorithm and then take the last
2726
01:38:36,320 --> 01:38:38,199
20 bytes and that's how we'll actually
2727
01:38:38,199 --> 01:38:41,520
derive to our um to our address here now
2728
01:38:41,520 --> 01:38:44,199
knowing the exact methodology of how to
2729
01:38:44,199 --> 01:38:45,880
get the address doesn't really matter
2730
01:38:45,880 --> 01:38:47,080
because it could change blockchain to
2731
01:38:47,080 --> 01:38:49,480
blockchain and could even change e two
2732
01:38:49,480 --> 01:38:50,719
um but just know that that is
2733
01:38:50,719 --> 01:38:52,480
essentially how kind of these addresses
2734
01:38:52,480 --> 01:38:55,040
are derived right there some derivative
2735
01:38:55,040 --> 01:38:56,520
of the public key right because the
2736
01:38:56,520 --> 01:38:58,920
public key is public and you know uh
2737
01:38:58,920 --> 01:39:00,599
using the public key in kind of any
2738
01:39:00,599 --> 01:39:03,360
public way is is totally fine um but not
2739
01:39:03,360 --> 01:39:05,440
the private key so that is how we sign
2740
01:39:05,440 --> 01:39:07,280
our transactions note though this isn't
2741
01:39:07,280 --> 01:39:09,639
how we send the transactions so so this
2742
01:39:09,639 --> 01:39:11,000
is just going to sign it create a
2743
01:39:11,000 --> 01:39:12,760
transaction for us to send uh we'll
2744
01:39:12,760 --> 01:39:14,960
learn later on how to send these
2745
01:39:14,960 --> 01:39:16,639
transactions so that was a lot of
2746
01:39:16,639 --> 01:39:18,320
information there too let's do a quick
2747
01:39:18,320 --> 01:39:20,719
recap your public key is derived by
2748
01:39:20,719 --> 01:39:23,400
using a digital signature algorithm on
2749
01:39:23,400 --> 01:39:25,520
on your private key right and you want
2750
01:39:25,520 --> 01:39:27,760
to keep your private key private at all
2751
01:39:27,760 --> 01:39:29,119
times because you're going to use your
2752
01:39:29,119 --> 01:39:32,639
private key to sign transactions signing
2753
01:39:32,639 --> 01:39:34,199
transactions with your private key you
2754
01:39:34,199 --> 01:39:36,040
are the only one who can actually do
2755
01:39:36,040 --> 01:39:38,440
this because you can't get the private
2756
01:39:38,440 --> 01:39:41,480
key from a message signature however
2757
01:39:41,480 --> 01:39:44,000
using your public key you can anybody
2758
01:39:44,000 --> 01:39:46,440
can very easily verify that a signature
2759
01:39:46,440 --> 01:39:48,840
that's signed by you is in fact signed
2760
01:39:48,840 --> 01:39:51,599
by you in our metamask our private keys
2761
01:39:51,599 --> 01:39:53,480
are located in this Account Details
2762
01:39:53,480 --> 01:39:55,920
section you just hit uh show Private
2763
01:39:55,920 --> 01:39:57,599
keys and type in your password and
2764
01:39:57,599 --> 01:40:00,199
you'll get your your private key here
2765
01:40:00,199 --> 01:40:03,000
and the address of your account is
2766
01:40:03,000 --> 01:40:05,840
derived from this private key uh it's
2767
01:40:05,840 --> 01:40:08,199
derived from this public key so if you
2768
01:40:08,199 --> 01:40:10,280
think about it your private key creates
2769
01:40:10,280 --> 01:40:12,520
your public key which then can create
2770
01:40:12,520 --> 01:40:14,440
your address and there's a little
2771
01:40:14,440 --> 01:40:15,360
barrier
2772
01:40:15,360 --> 01:40:18,760
here or a big barrier here because your
2773
01:40:18,760 --> 01:40:20,119
private key you want to keep private and
2774
01:40:20,119 --> 01:40:21,679
your public key and your address can all
2775
01:40:21,679 --> 01:40:23,320
be public information now remember
2776
01:40:23,320 --> 01:40:24,840
remember how in our metamask we were
2777
01:40:24,840 --> 01:40:27,560
able to actually create new accounts
2778
01:40:27,560 --> 01:40:29,320
mine says account six cuz I've created
2779
01:40:29,320 --> 01:40:31,599
actually a few but how was it actually
2780
01:40:31,599 --> 01:40:33,960
creating those accounts well now that we
2781
01:40:33,960 --> 01:40:35,480
know all this if we go back to our
2782
01:40:35,480 --> 01:40:37,719
blockchain demo here what our metamask
2783
01:40:37,719 --> 01:40:39,920
is doing is essentially taking our
2784
01:40:39,920 --> 01:40:42,440
pneumonic or or that multi-word secret
2785
01:40:42,440 --> 01:40:44,400
phrase and then just hashing it with
2786
01:40:44,400 --> 01:40:47,880
some number so secret phrase plus 0 gets
2787
01:40:47,880 --> 01:40:49,360
this and it'll set this as your private
2788
01:40:49,360 --> 01:40:52,040
key and for our account one that'll be
2789
01:40:52,040 --> 01:40:54,199
the private key or maybe it's plus one
2790
01:40:54,199 --> 01:40:55,679
the exact algorithm that it's using
2791
01:40:55,679 --> 01:40:57,760
doesn't matter but if you want to create
2792
01:40:57,760 --> 01:40:59,639
a new private key where you just hit
2793
01:40:59,639 --> 01:41:01,320
this create account button the way it
2794
01:41:01,320 --> 01:41:03,520
actually picks this account is by taking
2795
01:41:03,520 --> 01:41:05,119
this secret phrase and then just
2796
01:41:05,119 --> 01:41:07,639
changing this number so if I go if I'm
2797
01:41:07,639 --> 01:41:10,280
in my metamask I do create account this
2798
01:41:10,280 --> 01:41:11,719
right now I'm on account six because
2799
01:41:11,719 --> 01:41:13,280
like I said I made a whole bunch if I
2800
01:41:13,280 --> 01:41:15,560
make account six right it's as if we
2801
01:41:15,560 --> 01:41:18,719
just did the secret phrase plus six and
2802
01:41:18,719 --> 01:41:20,719
created this new hash or this new
2803
01:41:20,719 --> 01:41:22,880
private key and created this new hash
2804
01:41:22,880 --> 01:41:25,400
and it uses this to make a private key
2805
01:41:25,400 --> 01:41:27,840
and this is why in your metamask if you
2806
01:41:27,840 --> 01:41:29,639
share that secret phrase if you share
2807
01:41:29,639 --> 01:41:31,639
that pneumonic device they will have
2808
01:41:31,639 --> 01:41:33,599
access to all the accounts that you ever
2809
01:41:33,599 --> 01:41:35,360
created however if you share your
2810
01:41:35,360 --> 01:41:37,520
private key it will just give them
2811
01:41:37,520 --> 01:41:39,599
access to that single account secret
2812
01:41:39,599 --> 01:41:41,480
phrase has access to all the accounts
2813
01:41:41,480 --> 01:41:43,880
created in your metamask or your wallet
2814
01:41:43,880 --> 01:41:45,599
your private key is access to that
2815
01:41:45,599 --> 01:41:47,560
single account and then the public key
2816
01:41:47,560 --> 01:41:49,639
or address anybody can have access to
2817
01:41:49,639 --> 01:41:51,560
and it's cool for anybody to have access
2818
01:41:51,560 --> 01:41:52,920
to so when I'm thinking about the
2819
01:41:52,920 --> 01:41:55,920
security of my metamask or my wallet
2820
01:41:55,920 --> 01:41:57,480
this is kind of the order that I think
2821
01:41:57,480 --> 01:41:59,599
of it in the seed phrase or pneumonic or
2822
01:41:59,599 --> 01:42:01,599
secret phrase is incredibly important
2823
01:42:01,599 --> 01:42:03,360
protect this at all costs because if
2824
01:42:03,360 --> 01:42:05,000
somebody else gets access to this they
2825
01:42:05,000 --> 01:42:06,639
will have access to all of your accounts
2826
01:42:06,639 --> 01:42:08,080
the second most important is the private
2827
01:42:08,080 --> 01:42:09,520
key because if somebody gets access to
2828
01:42:09,520 --> 01:42:11,239
that they will get access to a single
2829
01:42:11,239 --> 01:42:12,719
account and then your public key or
2830
01:42:12,719 --> 01:42:17,000
address which whatever it's public
2831
01:42:30,920 --> 01:42:32,239
now that we know a little bit more about
2832
01:42:32,239 --> 01:42:33,960
what's going on underneath the hood of
2833
01:42:33,960 --> 01:42:35,880
these blockchains let's go back at our
2834
01:42:35,880 --> 01:42:37,920
transactions and look at this gas thing
2835
01:42:37,920 --> 01:42:39,280
again and we'll look to see what's
2836
01:42:39,280 --> 01:42:41,040
actually happening here gas in
2837
01:42:41,040 --> 01:42:42,840
particular can be a little bit tricky to
2838
01:42:42,840 --> 01:42:44,599
wrap your head around so if you don't
2839
01:42:44,599 --> 01:42:46,920
get it right away don't worry as we go
2840
01:42:46,920 --> 01:42:48,599
through examples it'll start to make
2841
01:42:48,599 --> 01:42:50,960
more sense so before I was saying let's
2842
01:42:50,960 --> 01:42:52,760
just look at this transaction fee bit
2843
01:42:52,760 --> 01:42:54,199
which is the cost associated with
2844
01:42:54,199 --> 01:42:56,040
running this transaction if I scroll
2845
01:42:56,040 --> 01:42:57,800
over this on ether scan I can see this
2846
01:42:57,800 --> 01:42:59,960
thing that says Block Base fee per gas
2847
01:42:59,960 --> 01:43:02,679
plus Max prity fee per gas times the gas
2848
01:43:02,679 --> 01:43:04,480
use which might be a little bit
2849
01:43:04,480 --> 01:43:06,440
confusing here let's actually break down
2850
01:43:06,440 --> 01:43:08,679
what's going on on ethereum with EIP
2851
01:43:08,679 --> 01:43:11,280
1559 in place and again this is going to
2852
01:43:11,280 --> 01:43:13,000
be specific to ethereum as every
2853
01:43:13,000 --> 01:43:14,280
blockchain might do it a little bit
2854
01:43:14,280 --> 01:43:16,159
differently but if we click to see more
2855
01:43:16,159 --> 01:43:17,679
we can see a number of useful values
2856
01:43:17,679 --> 01:43:20,679
here we can see gas limit is 21,000 and
2857
01:43:20,679 --> 01:43:21,840
usage is
2858
01:43:21,840 --> 01:43:25,679
21,000 so this transaction used 21,000
2859
01:43:25,679 --> 01:43:30,159
gas and we sent 21,000 gas along with it
2860
01:43:30,159 --> 01:43:32,080
sometimes when sending a transaction
2861
01:43:32,080 --> 01:43:33,400
depending on when it's sent and
2862
01:43:33,400 --> 01:43:34,800
depending on what these Specific
2863
01:43:34,800 --> 01:43:36,639
Instructions are it might actually use
2864
01:43:36,639 --> 01:43:38,199
way more gas than what you want it to
2865
01:43:38,199 --> 01:43:40,080
use so with your transactions you can
2866
01:43:40,080 --> 01:43:42,199
actually set a limit hey I don't want to
2867
01:43:42,199 --> 01:43:44,960
use more than x amount of gas I don't
2868
01:43:44,960 --> 01:43:47,400
want to do more than x computational
2869
01:43:47,400 --> 01:43:49,239
units and in fact if we go to our
2870
01:43:49,239 --> 01:43:52,119
metamask and we click Send to transfer
2871
01:43:52,119 --> 01:43:53,920
between accounts again
2872
01:43:53,920 --> 01:43:57,080
and we pick you know 0.01 e or something
2873
01:43:57,080 --> 01:43:59,119
next can actually hit this little button
2874
01:43:59,119 --> 01:44:01,800
here go to Advanced and we can actually
2875
01:44:01,800 --> 01:44:04,679
edit some specifics of this transaction
2876
01:44:04,679 --> 01:44:06,599
one of them is going to be the gas limit
2877
01:44:06,599 --> 01:44:08,760
we can change this gas limit to maybe
2878
01:44:08,760 --> 01:44:13,159
2200 2300 or more or even less since
2879
01:44:13,159 --> 01:44:16,119
sending ethereum takes exactly 21,000
2880
01:44:16,119 --> 01:44:18,360
gas metam Mass just defaults to setting
2881
01:44:18,360 --> 01:44:20,159
into that but we also see these other
2882
01:44:20,159 --> 01:44:22,320
interesting things we see a priority fee
2883
01:44:22,320 --> 01:44:24,159
and a Max base
2884
01:44:24,159 --> 01:44:26,960
fee let's reject this transaction and
2885
01:44:26,960 --> 01:44:29,159
let's look back at ether scan to talk
2886
01:44:29,159 --> 01:44:31,239
about these So currently in ethereum
2887
01:44:31,239 --> 01:44:34,880
according to e EIP 1559 every
2888
01:44:34,880 --> 01:44:36,679
transaction on ethereum comes with
2889
01:44:36,679 --> 01:44:39,080
something called the base fee this is
2890
01:44:39,080 --> 01:44:41,760
the minimum gas price you need to set to
2891
01:44:41,760 --> 01:44:43,800
include your transaction and you'll
2892
01:44:43,800 --> 01:44:45,159
notice that these are priced in
2893
01:44:45,159 --> 01:44:49,199
something called guay so what is aay if
2894
01:44:49,199 --> 01:44:51,800
we come to the site ethon converter.com
2895
01:44:51,800 --> 01:44:53,360
and again there's a link to this in the
2896
01:44:53,360 --> 01:44:56,320
GitHub repository we scroll down we can
2897
01:44:56,320 --> 01:45:00,159
see whey guay and ether if I put one
2898
01:45:00,159 --> 01:45:03,360
ether in here I can see how much one
2899
01:45:03,360 --> 01:45:05,920
ether is in terms of guay and in terms
2900
01:45:05,920 --> 01:45:09,719
of wayy one ether is equal to one 2 3 4
2901
01:45:09,719 --> 01:45:13,639
5 6 7 8 nine nine zeros so that's that's
2902
01:45:13,639 --> 01:45:16,159
one billion guay is going to be one
2903
01:45:16,159 --> 01:45:20,360
ether and then 1 2 3 4 5 6 7 8 9 10 11
2904
01:45:20,360 --> 01:45:23,639
12 13 14 15 16 17 18
2905
01:45:23,639 --> 01:45:26,639
and then 18 zos is away these are just
2906
01:45:26,639 --> 01:45:28,719
easier ways of referring to really
2907
01:45:28,719 --> 01:45:31,199
really small amounts of ethereum so if
2908
01:45:31,199 --> 01:45:34,080
we look at our gas fees we see that the
2909
01:45:34,080 --> 01:45:37,320
base fee is
2910
01:45:38,560 --> 01:45:41,199
0.00004 gay and this obviously would be
2911
01:45:41,199 --> 01:45:43,239
an even smaller number if this was in
2912
01:45:43,239 --> 01:45:45,880
units of way so if we take this number
2913
01:45:45,880 --> 01:45:48,639
and we put it into our calculator we can
2914
01:45:48,639 --> 01:45:53,800
see that this is equal to 40 way or 0.
2915
01:45:53,800 --> 01:45:56,560
a whole bunch of zeros for ether the max
2916
01:45:56,560 --> 01:45:58,960
fee here refers to the maximum gas fee
2917
01:45:58,960 --> 01:46:01,199
that we're willing to pay for this
2918
01:46:01,199 --> 01:46:03,639
transaction and you can actually see
2919
01:46:03,639 --> 01:46:06,800
that our Max fee is a little bit higher
2920
01:46:06,800 --> 01:46:09,000
than what we actually ended up paying
2921
01:46:09,000 --> 01:46:11,520
our Max fee was 2.21 32 something
2922
01:46:11,520 --> 01:46:13,840
something and the gas price we actually
2923
01:46:13,840 --> 01:46:16,159
paid was up here now your transaction
2924
01:46:16,159 --> 01:46:17,480
might of course be a little bit
2925
01:46:17,480 --> 01:46:19,199
different then additionally we have a
2926
01:46:19,199 --> 01:46:21,560
Max priority fee this is going to be the
2927
01:46:21,560 --> 01:46:23,520
max gas fee that we're willing to to pay
2928
01:46:23,520 --> 01:46:25,320
plus the max tip that we're willing to
2929
01:46:25,320 --> 01:46:27,960
give to miners now currently in ethereum
2930
01:46:27,960 --> 01:46:30,719
this base fee ends up getting burnt and
2931
01:46:30,719 --> 01:46:32,960
we can see on ether scan exactly how
2932
01:46:32,960 --> 01:46:34,679
much is getting burnt here and if we
2933
01:46:34,679 --> 01:46:37,920
pull up our calculator again we can grab
2934
01:46:37,920 --> 01:46:40,719
this gas fee multiply it by the amount
2935
01:46:40,719 --> 01:46:43,760
of gas we used and we can see that this
2936
01:46:43,760 --> 01:46:45,960
is indeed how much ethereum we actually
2937
01:46:45,960 --> 01:46:48,040
ended up burning we go back to ethereum
2938
01:46:48,040 --> 01:46:50,119
converter paste it in we can see that
2939
01:46:50,119 --> 01:46:53,440
these two numbers are indeed equ
2940
01:46:53,440 --> 01:46:55,280
this means whenever you send a
2941
01:46:55,280 --> 01:46:57,840
transaction a little bit of ethereum is
2942
01:46:57,840 --> 01:47:00,599
removed from circulation forever or it's
2943
01:47:00,599 --> 01:47:02,760
considered burnt So currently in
2944
01:47:02,760 --> 01:47:04,800
ethereum part of your ethereum part of
2945
01:47:04,800 --> 01:47:07,159
your transaction fee actually gets burnt
2946
01:47:07,159 --> 01:47:09,440
and then the other part goes directly to
2947
01:47:09,440 --> 01:47:11,679
miners so to figure out exactly how much
2948
01:47:11,679 --> 01:47:15,960
went to minors we could do this number
2949
01:47:15,960 --> 01:47:18,520
minus the burnt amount and this is how
2950
01:47:18,520 --> 01:47:20,840
much ethereum was paid to an ethereum
2951
01:47:20,840 --> 01:47:22,960
minor for this transaction you'll see
2952
01:47:22,960 --> 01:47:26,560
down here transaction type 2 EIP 1559
2953
01:47:26,560 --> 01:47:29,679
this is the EIP 1559 version of these
2954
01:47:29,679 --> 01:47:31,159
transactions like I said every
2955
01:47:31,159 --> 01:47:32,719
blockchain is going to have a different
2956
01:47:32,719 --> 01:47:35,760
fee burning and and fee and gas process
2957
01:47:35,760 --> 01:47:36,760
and they're all going to be a little bit
2958
01:47:36,760 --> 01:47:38,719
different but the sum of it is
2959
01:47:38,719 --> 01:47:41,159
blockchains have limited block space for
2960
01:47:41,159 --> 01:47:43,719
transactions the gas price that costs
2961
01:47:43,719 --> 01:47:45,520
for your transaction to be included in
2962
01:47:45,520 --> 01:47:48,040
one of these blocks changes based off
2963
01:47:48,040 --> 01:47:50,159
how much demand there is the base gas
2964
01:47:50,159 --> 01:47:52,400
fee for ethereum will go up and down
2965
01:47:52,400 --> 01:47:54,480
depending depending on how many people
2966
01:47:54,480 --> 01:47:56,960
are sending transactions and how many
2967
01:47:56,960 --> 01:47:59,280
people want to be included in a block if
2968
01:47:59,280 --> 01:48:01,199
a ton of people want to be included in a
2969
01:48:01,199 --> 01:48:04,199
block that means a ton of gas is
2970
01:48:04,199 --> 01:48:06,040
obviously going to get burnt we've left
2971
01:48:06,040 --> 01:48:08,320
a link to a video in the GitHub
2972
01:48:08,320 --> 01:48:10,480
repository with this section from this
2973
01:48:10,480 --> 01:48:13,000
YouTuber who does an amazing job
2974
01:48:13,000 --> 01:48:16,239
breaking down this EIP 1559 and more
2975
01:48:16,239 --> 01:48:18,719
about how this gas model actually works
2976
01:48:18,719 --> 01:48:20,560
I highly recommend you pause this video
2977
01:48:20,560 --> 01:48:22,880
and watch that video to understand more
2978
01:48:22,880 --> 01:48:25,000
the base fee gets programmatically
2979
01:48:25,000 --> 01:48:27,400
algorithmically adjusted to try to
2980
01:48:27,400 --> 01:48:31,040
Target for all the blocks to be 50% full
2981
01:48:31,040 --> 01:48:33,639
if they're more than 50% full this base
2982
01:48:33,639 --> 01:48:35,719
fee automatically goes up if they're
2983
01:48:35,719 --> 01:48:38,560
less than 50% full this base fee goes
2984
01:48:38,560 --> 01:48:40,840
down now this is a lot of the basics of
2985
01:48:40,840 --> 01:48:42,599
how this transaction works and it can be
2986
01:48:42,599 --> 01:48:44,320
a little confusing so let's do a quick
2987
01:48:44,320 --> 01:48:46,280
refresher of everything in here there's
2988
01:48:46,280 --> 01:48:48,920
a unique transaction hash that uniquely
2989
01:48:48,920 --> 01:48:52,080
identifies this transaction on this
2990
01:48:52,080 --> 01:48:54,880
blockchain we can see the status we can
2991
01:48:54,880 --> 01:48:57,239
see the block number that it's confirmed
2992
01:48:57,239 --> 01:48:59,360
on one other thing we want to look at if
2993
01:48:59,360 --> 01:49:01,520
we scroll up we see block number and
2994
01:49:01,520 --> 01:49:04,119
block confirmations this is how many
2995
01:49:04,119 --> 01:49:07,119
blocks have been mined since this block
2996
01:49:07,119 --> 01:49:09,119
was included like we saw with our
2997
01:49:09,119 --> 01:49:10,800
blockchain demo the longer the
2998
01:49:10,800 --> 01:49:12,840
blockchain gets the harder it is to
2999
01:49:12,840 --> 01:49:14,719
tamper with and the more secure it is
3000
01:49:14,719 --> 01:49:16,760
typically you'll see some processes say
3001
01:49:16,760 --> 01:49:19,360
they'll only do something after 20 block
3002
01:49:19,360 --> 01:49:22,080
confirmations 30 Block confirmations or
3003
01:49:22,080 --> 01:49:24,199
or Etc the reason that they wait for
3004
01:49:24,199 --> 01:49:25,760
these block confirmations is because
3005
01:49:25,760 --> 01:49:27,199
they want to make sure that that
3006
01:49:27,199 --> 01:49:29,239
transaction is actually included and we
3007
01:49:29,239 --> 01:49:31,880
can actually see the block that our
3008
01:49:31,880 --> 01:49:34,080
transaction was included in and all the
3009
01:49:34,080 --> 01:49:36,000
other transactions with it different
3010
01:49:36,000 --> 01:49:38,440
details about how much gas was used the
3011
01:49:38,440 --> 01:49:41,400
gas limit Etc time stamp is when the
3012
01:49:41,400 --> 01:49:44,239
transaction happened we can see from and
3013
01:49:44,239 --> 01:49:46,840
to we can see the value and then we can
3014
01:49:46,840 --> 01:49:49,280
see the transaction fee which we see
3015
01:49:49,280 --> 01:49:51,400
right here is Block Base fee per gas
3016
01:49:51,400 --> 01:49:53,679
plus the max priority fee per gas times
3017
01:49:53,679 --> 01:49:55,760
the gas used and we see all the details
3018
01:49:55,760 --> 01:49:58,199
of the gas down here gas price is the
3019
01:49:58,199 --> 01:50:01,719
cost of one unit of gas gas limit is the
3020
01:50:01,719 --> 01:50:04,199
max amount of units of gas that we're
3021
01:50:04,199 --> 01:50:06,520
willing to pay in this transaction the
3022
01:50:06,520 --> 01:50:09,040
usage is how many actually got used the
3023
01:50:09,040 --> 01:50:11,360
base fee is going to be the base Network
3024
01:50:11,360 --> 01:50:16,000
fee per gas so 40 way per one gas used
3025
01:50:16,000 --> 01:50:18,840
the max gas is the max gas price we're
3026
01:50:18,840 --> 01:50:21,480
willing to pay and Max priority is going
3027
01:50:21,480 --> 01:50:23,760
to be the max gas price plus the tip
3028
01:50:23,760 --> 01:50:25,239
that we give to Miners and then we can
3029
01:50:25,239 --> 01:50:27,040
see how much is burnt and then we see
3030
01:50:27,040 --> 01:50:29,440
transaction savings which which is the
3031
01:50:29,440 --> 01:50:31,159
difference between how much was actually
3032
01:50:31,159 --> 01:50:34,000
used or paid for and then returned so
3033
01:50:34,000 --> 01:50:36,800
for example in this transaction the gas
3034
01:50:36,800 --> 01:50:39,000
price we ended up picking was a little
3035
01:50:39,000 --> 01:50:41,800
less than our Max gas price here so the
3036
01:50:41,800 --> 01:50:43,920
gas price we ended up using was a little
3037
01:50:43,920 --> 01:50:46,599
less than our Max priority fee here so
3038
01:50:46,599 --> 01:50:48,679
we had some savings compared to that we
3039
01:50:48,679 --> 01:50:51,320
can also see that this was an EIP 1559
3040
01:50:51,320 --> 01:50:53,840
transaction we can see our nuns here
3041
01:50:53,840 --> 01:50:56,560
which was nuns zero because the
3042
01:50:56,560 --> 01:50:58,159
transaction that I'm showing is our
3043
01:50:58,159 --> 01:51:00,239
first nuns and then of course we can see
3044
01:51:00,239 --> 01:51:02,639
the input data for transactions that are
3045
01:51:02,639 --> 01:51:04,760
just sending ethereum the input data is
3046
01:51:04,760 --> 01:51:06,400
going to be blank but you'll see that
3047
01:51:06,400 --> 01:51:08,320
when we get to Smart contracts the input
3048
01:51:08,320 --> 01:51:09,960
data is not going to be blank and it's
3049
01:51:09,960 --> 01:51:11,440
going to be one of the most important
3050
01:51:11,440 --> 01:51:13,960
features of these transactions you'll
3051
01:51:13,960 --> 01:51:16,159
also notice that there's a state tab
3052
01:51:16,159 --> 01:51:18,679
this is an advanced Tab and it shows the
3053
01:51:18,679 --> 01:51:21,040
different states that are changed based
3054
01:51:21,040 --> 01:51:22,760
off of this transaction where we're
3055
01:51:22,760 --> 01:51:24,480
going to ignore this one for now now
3056
01:51:24,480 --> 01:51:26,400
that we know how the blockchain itself
3057
01:51:26,400 --> 01:51:28,480
Works under the hood let's talk about
3058
01:51:28,480 --> 01:51:31,040
some blockchain fundamentals and we
3059
01:51:31,040 --> 01:51:32,880
actually covered all these topics in a
3060
01:51:32,880 --> 01:51:34,760
previous free code Camp video so let's
3061
01:51:34,760 --> 01:51:36,840
go to
3062
01:51:36,840 --> 01:51:39,320
that if the first time you listen to
3063
01:51:39,320 --> 01:51:41,079
this some of these Concepts seem a
3064
01:51:41,079 --> 01:51:43,440
little bit hard to grasp don't worry
3065
01:51:43,440 --> 01:51:46,159
about it as we continue and as we move
3066
01:51:46,159 --> 01:51:47,920
on with this course they'll start to
3067
01:51:47,920 --> 01:51:49,719
make more sense when you see them used
3068
01:51:49,719 --> 01:51:52,000
in real examples I definitely would
3069
01:51:52,000 --> 01:51:54,079
recommend going back and rewatching and
3070
01:51:54,079 --> 01:51:56,040
Rel listening to the parts that you
3071
01:51:56,040 --> 01:51:58,239
don't quite get and asking questions in
3072
01:51:58,239 --> 01:52:00,119
the discussions tab of the GitHub
3073
01:52:00,119 --> 01:52:02,079
repository awesome so now that we know
3074
01:52:02,079 --> 01:52:03,920
all the cryptography pieces and all the
3075
01:52:03,920 --> 01:52:05,280
little nitty-gritties of how the
3076
01:52:05,280 --> 01:52:07,280
blockchain actually works and how our
3077
01:52:07,280 --> 01:52:08,719
signatures work and how everything
3078
01:52:08,719 --> 01:52:10,599
sticks together let's talk a little bit
3079
01:52:10,599 --> 01:52:13,360
about how this works in actuality and
3080
01:52:13,360 --> 01:52:15,239
what's really going on now for a lot of
3081
01:52:15,239 --> 01:52:17,040
this each different blockchain has
3082
01:52:17,040 --> 01:52:18,599
slightly different algorithms and
3083
01:52:18,599 --> 01:52:20,920
slightly different metrics and criteria
3084
01:52:20,920 --> 01:52:23,000
for doing a lot of this stuff so when
3085
01:52:23,000 --> 01:52:25,000
we're talking about these specific
3086
01:52:25,000 --> 01:52:27,199
implementations keep in mind the exact
3087
01:52:27,199 --> 01:52:28,480
algorithm might be a little bit
3088
01:52:28,480 --> 01:52:30,480
different but the concepts are all still
3089
01:52:30,480 --> 01:52:32,840
going to be exactly the same hashing and
3090
01:52:32,840 --> 01:52:34,639
hash function is going to be the same no
3091
01:52:34,639 --> 01:52:36,520
matter where you look a decentralized
3092
01:52:36,520 --> 01:52:38,239
blockchain is going to be the same no
3093
01:52:38,239 --> 01:52:40,159
matter where you look how it's actually
3094
01:52:40,159 --> 01:52:41,880
implemented is going to be a little bit
3095
01:52:41,880 --> 01:52:43,719
different now traditionally when you run
3096
01:52:43,719 --> 01:52:46,119
an application you know be it a website
3097
01:52:46,119 --> 01:52:47,719
or something that connects to some
3098
01:52:47,719 --> 01:52:50,040
server you are interacting with a
3099
01:52:50,040 --> 01:52:53,040
centralized entity and unlike how we saw
3100
01:52:53,040 --> 01:52:54,719
with the blockchain with multiple
3101
01:52:54,719 --> 01:52:57,079
different peers it's going to be run by
3102
01:52:57,079 --> 01:52:59,119
a single centralized group now it still
3103
01:52:59,119 --> 01:53:01,119
could be run on many different servers
3104
01:53:01,119 --> 01:53:02,719
but all those servers are still going to
3105
01:53:02,719 --> 01:53:05,159
be controlled by the same centralized
3106
01:53:05,159 --> 01:53:08,199
group blockchains as we saw run on a
3107
01:53:08,199 --> 01:53:10,880
network of different independent nodes
3108
01:53:10,880 --> 01:53:13,239
when we saw Pier a pier B Pier C those
3109
01:53:13,239 --> 01:53:15,440
were different examples of different
3110
01:53:15,440 --> 01:53:17,920
independent users running the blockchain
3111
01:53:17,920 --> 01:53:20,239
technology on their own node now when I
3112
01:53:20,239 --> 01:53:22,119
use the term node I'm usually referring
3113
01:53:22,119 --> 01:53:24,480
to a single instance of a decentralized
3114
01:53:24,480 --> 01:53:26,639
system so when I say a single node when
3115
01:53:26,639 --> 01:53:28,079
I'm talking about a blockchain I'm
3116
01:53:28,079 --> 01:53:29,760
talking about one of those perer A's
3117
01:53:29,760 --> 01:53:31,719
Pier B's perer C's running that
3118
01:53:31,719 --> 01:53:33,440
blockchain software I'm talking about
3119
01:53:33,440 --> 01:53:35,840
one server running this technology and
3120
01:53:35,840 --> 01:53:37,639
again it's this network it's this
3121
01:53:37,639 --> 01:53:39,280
combination of these nodes interacting
3122
01:53:39,280 --> 01:53:41,360
with each other that creates this entire
3123
01:53:41,360 --> 01:53:43,320
blockchain what makes these so potent
3124
01:53:43,320 --> 01:53:45,760
too is that anybody can join the network
3125
01:53:45,760 --> 01:53:47,679
and that's why there's decentralized the
3126
01:53:47,679 --> 01:53:49,239
barrier to entry is a little bit of
3127
01:53:49,239 --> 01:53:50,679
Hardware requirements you getting the
3128
01:53:50,679 --> 01:53:52,880
correct materials to run the software
3129
01:53:52,880 --> 01:53:54,520
and then you running the software
3130
01:53:54,520 --> 01:53:55,960
anybody can join these networks and
3131
01:53:55,960 --> 01:53:57,400
participate and that's what makes it
3132
01:53:57,400 --> 01:53:59,719
truly decentralized in fact you can go
3133
01:53:59,719 --> 01:54:01,520
to GitHub right now and run your own
3134
01:54:01,520 --> 01:54:04,199
ethereum node in a few seconds now in
3135
01:54:04,199 --> 01:54:05,960
the traditional World applications are
3136
01:54:05,960 --> 01:54:08,280
run by centralized entities and if that
3137
01:54:08,280 --> 01:54:10,639
entity goes down or is maliciously
3138
01:54:10,639 --> 01:54:13,199
bribed or decides that they want to shut
3139
01:54:13,199 --> 01:54:15,639
off they just can't because they're the
3140
01:54:15,639 --> 01:54:18,400
ones that control everything blockchains
3141
01:54:18,400 --> 01:54:20,920
by contrast don't have this problem if
3142
01:54:20,920 --> 01:54:23,280
one node or one entity that runs several
3143
01:54:23,280 --> 01:54:25,960
nodes goes down since there are so many
3144
01:54:25,960 --> 01:54:28,480
other independent nodes running that it
3145
01:54:28,480 --> 01:54:30,239
doesn't matter the blockchain and the
3146
01:54:30,239 --> 01:54:32,440
system will persist so long as there is
3147
01:54:32,440 --> 01:54:35,119
at least one node always running and
3148
01:54:35,119 --> 01:54:36,920
luckily for us most of the most popular
3149
01:54:36,920 --> 01:54:39,599
chains like Bitcoin and ethereum have
3150
01:54:39,599 --> 01:54:41,520
thousands and thousands of nodes and as
3151
01:54:41,520 --> 01:54:43,800
we showed in our demo if one node acts
3152
01:54:43,800 --> 01:54:46,960
maliciously all the other nodes will
3153
01:54:46,960 --> 01:54:49,159
ignore that node and kick that out or or
3154
01:54:49,159 --> 01:54:51,320
even punish it in some systems because
3155
01:54:51,320 --> 01:54:53,119
they can easily check everybody else's
3156
01:54:53,119 --> 01:54:55,719
note and see okay this one is out of
3157
01:54:55,719 --> 01:54:57,760
sync with the majority and yes majority
3158
01:54:57,760 --> 01:54:59,320
rules when it comes to the blockchain
3159
01:54:59,320 --> 01:55:01,719
each blockchain keeps a full list of
3160
01:55:01,719 --> 01:55:03,800
every transaction and interaction that's
3161
01:55:03,800 --> 01:55:05,880
happened on that blockchain and we saw
3162
01:55:05,880 --> 01:55:08,480
if a node tries to act maliciously then
3163
01:55:08,480 --> 01:55:09,840
all their hashes are going to be way out
3164
01:55:09,840 --> 01:55:11,000
of whack and they're not going to match
3165
01:55:11,000 --> 01:55:12,880
everybody else this gives blockchains
3166
01:55:12,880 --> 01:55:15,079
this incredibly potent immutability
3167
01:55:15,079 --> 01:55:17,400
trait where nothing can be changed or
3168
01:55:17,400 --> 01:55:19,239
corrupted so in essence we can think of
3169
01:55:19,239 --> 01:55:21,800
a blockchain as a decentralized database
3170
01:55:21,800 --> 01:55:23,920
and with ethereum it has an extra
3171
01:55:23,920 --> 01:55:26,360
additional feature where it also can do
3172
01:55:26,360 --> 01:55:29,040
computation in a decentralized manner
3173
01:55:29,040 --> 01:55:31,320
now let's talk consensus proof of work
3174
01:55:31,320 --> 01:55:32,920
and proof of stake because you've
3175
01:55:32,920 --> 01:55:34,520
probably heard these before and they're
3176
01:55:34,520 --> 01:55:36,239
really important to how these
3177
01:55:36,239 --> 01:55:37,960
blockchains actually work when we went
3178
01:55:37,960 --> 01:55:39,639
through that blockchain example and we
3179
01:55:39,639 --> 01:55:41,679
did that mining feature this is what's
3180
01:55:41,679 --> 01:55:44,880
known as proof of work proof of work and
3181
01:55:44,880 --> 01:55:47,360
proof of stake fall under this umbrella
3182
01:55:47,360 --> 01:55:50,040
of consensus and consensus is a really
3183
01:55:50,040 --> 01:55:51,239
important topic when it comes to
3184
01:55:51,239 --> 01:55:53,560
blockchains consensus is defined as the
3185
01:55:53,560 --> 01:55:56,119
mechanism used to reach an agreement on
3186
01:55:56,119 --> 01:55:58,320
the state or a single value on the
3187
01:55:58,320 --> 01:56:00,679
blockchain especially in a decentralized
3188
01:56:00,679 --> 01:56:02,480
system I briefly alluded to this
3189
01:56:02,480 --> 01:56:04,239
consensus mechanism in our blockchain
3190
01:56:04,239 --> 01:56:06,480
example when I said if one changes
3191
01:56:06,480 --> 01:56:09,239
something and the other two don't then
3192
01:56:09,239 --> 01:56:11,079
majority Will Rule and kick that one out
3193
01:56:11,079 --> 01:56:13,480
this is part of that consensus mechanism
3194
01:56:13,480 --> 01:56:15,960
now very roughly a consensus protocol in
3195
01:56:15,960 --> 01:56:18,040
a blockchain or decentralized system can
3196
01:56:18,040 --> 01:56:20,239
be broken down into two pieces a chain
3197
01:56:20,239 --> 01:56:22,280
selection algorithm and a civil
3198
01:56:22,280 --> 01:56:24,320
resistance mechanism that mining piece
3199
01:56:24,320 --> 01:56:26,480
that we were doing or or the proof of
3200
01:56:26,480 --> 01:56:28,960
work algorithm is what's known as a syil
3201
01:56:28,960 --> 01:56:30,679
resistance mechanism and this is what
3202
01:56:30,679 --> 01:56:33,400
ethereum and Bitcoin currently use
3203
01:56:33,400 --> 01:56:34,800
please note that depending on when
3204
01:56:34,800 --> 01:56:36,960
you're watching this if eth 2 is out
3205
01:56:36,960 --> 01:56:39,719
then it's no longer proof of
3206
01:56:39,719 --> 01:56:42,000
work now proof of work is known as a
3207
01:56:42,000 --> 01:56:44,000
civil resistance mechanism because it
3208
01:56:44,000 --> 01:56:46,000
defines a way to figure out who is the
3209
01:56:46,000 --> 01:56:48,079
block author which node is going to be
3210
01:56:48,079 --> 01:56:50,320
the node who did the work to find that
3211
01:56:50,320 --> 01:56:52,920
mine and be the author of that block so
3212
01:56:52,920 --> 01:56:54,639
all the other nodes can verify that it's
3213
01:56:54,639 --> 01:56:56,320
accurate civil resistance is a
3214
01:56:56,320 --> 01:56:58,920
blockchain's ability to defend against
3215
01:56:58,920 --> 01:57:01,159
users creating a large number of pseudo
3216
01:57:01,159 --> 01:57:03,119
Anonymous identities to gain a
3217
01:57:03,119 --> 01:57:04,880
disproportionately advantageous
3218
01:57:04,880 --> 01:57:07,719
influence over said system and in
3219
01:57:07,719 --> 01:57:09,360
layman's turns it's basically a way for
3220
01:57:09,360 --> 01:57:10,679
a blockchain to defend against somebody
3221
01:57:10,679 --> 01:57:12,639
making a bunch of fake blockchains so
3222
01:57:12,639 --> 01:57:14,360
that they can get more and more rewards
3223
01:57:14,360 --> 01:57:15,840
now there are two types of civil
3224
01:57:15,840 --> 01:57:17,280
resistance mechanisms that we're going
3225
01:57:17,280 --> 01:57:19,639
to talk about here namely proof of work
3226
01:57:19,639 --> 01:57:21,719
and proof of stake let's talk about
3227
01:57:21,719 --> 01:57:23,239
proof of work work a little bit more in
3228
01:57:23,239 --> 01:57:25,480
depth first in proof of work this is Cil
3229
01:57:25,480 --> 01:57:27,320
resistant because a single node has to
3230
01:57:27,320 --> 01:57:29,239
go through a very computationally
3231
01:57:29,239 --> 01:57:32,119
expensive uh process called mining which
3232
01:57:32,119 --> 01:57:33,960
we demonstrated earlier to figure out
3233
01:57:33,960 --> 01:57:35,400
the answer to the blockchain's riddle of
3234
01:57:35,400 --> 01:57:37,400
finding that correct nuns or or whatever
3235
01:57:37,400 --> 01:57:39,079
the blockchain system has in place in
3236
01:57:39,079 --> 01:57:41,119
proof of work this works because no
3237
01:57:41,119 --> 01:57:42,760
matter how many pseudo Anonymous
3238
01:57:42,760 --> 01:57:45,040
accounts you make each one still has to
3239
01:57:45,040 --> 01:57:46,880
undergo this very computationally
3240
01:57:46,880 --> 01:57:49,440
expensive activity of finding the answer
3241
01:57:49,440 --> 01:57:51,320
to the proof of work problem or the
3242
01:57:51,320 --> 01:57:53,520
proof of work riddle which again in our
3243
01:57:53,520 --> 01:57:55,560
demonstration it was finding a Nuns with
3244
01:57:55,560 --> 01:57:57,960
that first four zeros but again each
3245
01:57:57,960 --> 01:57:59,920
blockchain might change the riddle or or
3246
01:57:59,920 --> 01:58:01,239
change the problem to be a little bit
3247
01:58:01,239 --> 01:58:02,520
different in fact some of these
3248
01:58:02,520 --> 01:58:03,920
blockchains make this riddle
3249
01:58:03,920 --> 01:58:06,159
intentionally hard or intentionally easy
3250
01:58:06,159 --> 01:58:08,239
to change What's called the block time
3251
01:58:08,239 --> 01:58:09,880
the block time is how long it takes
3252
01:58:09,880 --> 01:58:11,679
between blocks being published and it's
3253
01:58:11,679 --> 01:58:13,360
proportional to how hard these
3254
01:58:13,360 --> 01:58:15,440
algorithms are so these problems
3255
01:58:15,440 --> 01:58:17,679
actually can change depending on how
3256
01:58:17,679 --> 01:58:19,400
long they want the block time to be if a
3257
01:58:19,400 --> 01:58:21,560
system wants the block time to be very
3258
01:58:21,560 --> 01:58:23,960
very long they just make the problem
3259
01:58:23,960 --> 01:58:25,560
very very hard if they want to be very
3260
01:58:25,560 --> 01:58:27,719
short they make the problem a lot easier
3261
01:58:27,719 --> 01:58:29,440
we'll talk about cibil attacks in a
3262
01:58:29,440 --> 01:58:30,880
little bit and how they can affect the
3263
01:58:30,880 --> 01:58:32,920
system but with proof of work it's a
3264
01:58:32,920 --> 01:58:34,560
verifiable way to figure out who the
3265
01:58:34,560 --> 01:58:37,119
block author is and be civil resistant
3266
01:58:37,119 --> 01:58:38,880
now you need to combine this with a
3267
01:58:38,880 --> 01:58:40,800
chain selection rule create this
3268
01:58:40,800 --> 01:58:42,599
consensus now there's some consensus
3269
01:58:42,599 --> 01:58:44,400
protocols that have more features but
3270
01:58:44,400 --> 01:58:45,840
very very roughly these are the two
3271
01:58:45,840 --> 01:58:47,480
pieces that we're going to look at the
3272
01:58:47,480 --> 01:58:49,119
second piece is going to be a chain
3273
01:58:49,119 --> 01:58:51,679
selection role how do we know which
3274
01:58:51,679 --> 01:58:53,400
block chain is actually the real
3275
01:58:53,400 --> 01:58:55,199
blockchain and the true blockchain now
3276
01:58:55,199 --> 01:58:57,400
on bitcoin and ethereum they both use a
3277
01:58:57,400 --> 01:58:59,520
form of consensus called Nakamoto
3278
01:58:59,520 --> 01:59:01,639
consensus and this is a combination of
3279
01:59:01,639 --> 01:59:05,360
proof of work and longest chain
3280
01:59:05,360 --> 01:59:07,960
roll the decentralized network decides
3281
01:59:07,960 --> 01:59:09,840
that whichever blockchain has the
3282
01:59:09,840 --> 01:59:11,599
longest chain or the most number of
3283
01:59:11,599 --> 01:59:13,800
blocks on it is going to be the chain
3284
01:59:13,800 --> 01:59:15,960
that they use this makes a lot of sense
3285
01:59:15,960 --> 01:59:17,920
because every additional block that a
3286
01:59:17,920 --> 01:59:19,560
chain is behind it's going to take more
3287
01:59:19,560 --> 01:59:22,520
and more computation for it to come up
3288
01:59:22,520 --> 01:59:23,760
that's why when we saw in our
3289
01:59:23,760 --> 01:59:25,599
transaction we actually saw
3290
01:59:25,599 --> 01:59:27,159
confirmations the number of
3291
01:59:27,159 --> 01:59:28,760
confirmations is the number of
3292
01:59:28,760 --> 01:59:31,679
additional blocks added on after our
3293
01:59:31,679 --> 01:59:33,560
transaction went through in a block so
3294
01:59:33,560 --> 01:59:35,560
if we see confirmations as two it means
3295
01:59:35,560 --> 01:59:37,360
that the block that our transaction was
3296
01:59:37,360 --> 01:59:40,079
in has two blocks ahead of it in the
3297
01:59:40,079 --> 01:59:42,079
longest chain now I do want to point out
3298
01:59:42,079 --> 01:59:44,199
that a lot of people use proof of work
3299
01:59:44,199 --> 01:59:46,360
as a consensus protocol and I do want to
3300
01:59:46,360 --> 01:59:48,440
say that this is a little bit inaccurate
3301
01:59:48,440 --> 01:59:49,840
but sometimes people use it
3302
01:59:49,840 --> 01:59:52,480
interchangeably proof of work is a piece
3303
01:59:52,480 --> 01:59:54,880
of the overall consensus protocol which
3304
01:59:54,880 --> 01:59:57,760
in Bitcoin and ethereum 1's current case
3305
01:59:57,760 --> 02:00:00,800
is Nakamoto consensus nakomo consensus
3306
02:00:00,800 --> 02:00:03,040
is a combination of proof of work and
3307
02:00:03,040 --> 02:00:06,119
this longest chain rule both equally and
3308
02:00:06,119 --> 02:00:08,560
very very important now proof of work
3309
02:00:08,560 --> 02:00:10,560
also tells us where these transaction
3310
02:00:10,560 --> 02:00:12,800
fees and these block rewards go to
3311
02:00:12,800 --> 02:00:13,800
remember how when we made this
3312
02:00:13,800 --> 02:00:16,639
transaction we had to talk about gas and
3313
02:00:16,639 --> 02:00:19,199
a transaction fee so who's getting paid
3314
02:00:19,199 --> 02:00:20,960
who is getting this transaction and this
3315
02:00:20,960 --> 02:00:22,800
transaction fee is going to the miners
3316
02:00:22,800 --> 02:00:25,079
or the validators in a proof of work
3317
02:00:25,079 --> 02:00:27,079
Network they're called Miners And in the
3318
02:00:27,079 --> 02:00:29,400
proof of stake Network they're called
3319
02:00:29,400 --> 02:00:31,040
validators there are a little bit
3320
02:00:31,040 --> 02:00:32,320
different and we'll get into that when
3321
02:00:32,320 --> 02:00:33,880
we talk about proof of stake in this
3322
02:00:33,880 --> 02:00:36,040
proof of Works system all these nodes
3323
02:00:36,040 --> 02:00:38,199
are competing against each other to find
3324
02:00:38,199 --> 02:00:40,360
the answer to the blockchain riddle
3325
02:00:40,360 --> 02:00:42,599
remember in our example it was to find a
3326
02:00:42,599 --> 02:00:44,920
hash that has four zeros at the start
3327
02:00:44,920 --> 02:00:46,560
and again depending on the blockchain
3328
02:00:46,560 --> 02:00:47,920
implementation that riddle is going to
3329
02:00:47,920 --> 02:00:49,960
be a little bit different but all the
3330
02:00:49,960 --> 02:00:52,960
nodes are trying as many as possible to
3331
02:00:52,960 --> 02:00:55,679
try to get this answer first why because
3332
02:00:55,679 --> 02:00:57,719
the first node to figure out the answer
3333
02:00:57,719 --> 02:00:59,320
to the blockchain re is going to get
3334
02:00:59,320 --> 02:01:00,760
that transaction fee they're going to
3335
02:01:00,760 --> 02:01:02,440
get paid from that now when a node gets
3336
02:01:02,440 --> 02:01:03,960
paid they actually get paid in two
3337
02:01:03,960 --> 02:01:06,119
different ways one is going to be with a
3338
02:01:06,119 --> 02:01:08,079
transaction fee and another piece is
3339
02:01:08,079 --> 02:01:09,920
going to be the block reward remember
3340
02:01:09,920 --> 02:01:12,000
how we talked about alternating the gas
3341
02:01:12,000 --> 02:01:14,040
price or the guay on our transaction
3342
02:01:14,040 --> 02:01:15,679
well that's the transaction fee that
3343
02:01:15,679 --> 02:01:17,400
we're going to pay to these blockchain
3344
02:01:17,400 --> 02:01:19,599
nodes for including our transaction the
3345
02:01:19,599 --> 02:01:21,920
block reward is given to these nodes
3346
02:01:21,920 --> 02:01:23,679
from the protocol from the blockchain
3347
02:01:23,679 --> 02:01:25,599
itself you've probably heard of the
3348
02:01:25,599 --> 02:01:28,199
Bitcoin having before the having is
3349
02:01:28,199 --> 02:01:30,520
referring to this block reward getting
3350
02:01:30,520 --> 02:01:32,199
cut in half and it's supposed to be cut
3351
02:01:32,199 --> 02:01:35,239
in half roughly every four years this
3352
02:01:35,239 --> 02:01:37,560
block reward increases the circulating
3353
02:01:37,560 --> 02:01:39,400
amount of whatever cryptocurrency that
3354
02:01:39,400 --> 02:01:41,000
is being rewarded for example on
3355
02:01:41,000 --> 02:01:42,840
ethereum the Block reward is giving out
3356
02:01:42,840 --> 02:01:44,719
ethereum and on bitcoin the block reward
3357
02:01:44,719 --> 02:01:46,920
is giving out Bitcoin so these nodes are
3358
02:01:46,920 --> 02:01:48,440
competing against each other to be the
3359
02:01:48,440 --> 02:01:50,679
first one to find this transaction to be
3360
02:01:50,679 --> 02:01:52,520
the first one to find the answer to this
3361
02:01:52,520 --> 02:01:54,560
problem so that they can be the ones to
3362
02:01:54,560 --> 02:01:57,119
win both this block reward and your
3363
02:01:57,119 --> 02:01:59,280
transaction fee some blockchains like
3364
02:01:59,280 --> 02:02:01,840
Bitcoin for example have a set time when
3365
02:02:01,840 --> 02:02:03,360
they're no longer going to give out
3366
02:02:03,360 --> 02:02:05,440
block rewards and the miners or the
3367
02:02:05,440 --> 02:02:07,320
nodes are only going to get paid from
3368
02:02:07,320 --> 02:02:10,040
transaction fees now this gas fee again
3369
02:02:10,040 --> 02:02:12,159
is paid by whoever initialized the
3370
02:02:12,159 --> 02:02:14,520
transaction when we got our funds from
3371
02:02:14,520 --> 02:02:16,719
the faucet there was some server and
3372
02:02:16,719 --> 02:02:18,880
somebody else was paying the transaction
3373
02:02:18,880 --> 02:02:22,000
fee for us however when we sent ether
3374
02:02:22,000 --> 02:02:24,040
from one account to another our first
3375
02:02:24,040 --> 02:02:26,159
account actually paid some transaction
3376
02:02:26,159 --> 02:02:29,239
fee to send that ether in proof of stake
3377
02:02:29,239 --> 02:02:31,040
there's also a gas fee but it's paid out
3378
02:02:31,040 --> 02:02:33,440
to validators instead of Miners and
3379
02:02:33,440 --> 02:02:35,040
we'll talk about that in a little bit
3380
02:02:35,040 --> 02:02:36,360
now let's talk about two types of
3381
02:02:36,360 --> 02:02:37,719
attacks that can happen in these
3382
02:02:37,719 --> 02:02:39,239
blockchain worlds let's talk about the
3383
02:02:39,239 --> 02:02:41,280
first one being the cibil attack the
3384
02:02:41,280 --> 02:02:43,040
cibil attack is when a user creates a
3385
02:02:43,040 --> 02:02:45,040
whole bunch of pseudo Anonymous accounts
3386
02:02:45,040 --> 02:02:47,560
to try to influence a network now
3387
02:02:47,560 --> 02:02:49,679
obviously on bitcoin and ethereum this
3388
02:02:49,679 --> 02:02:51,560
is really really difficult because the
3389
02:02:51,560 --> 02:02:53,320
user needs to do all this work in proof
3390
02:02:53,320 --> 02:02:55,639
of work or have a ton of collateral in
3391
02:02:55,639 --> 02:02:57,119
proof of stake which again we'll talk
3392
02:02:57,119 --> 02:02:59,159
about in a bit the other more prevalent
3393
02:02:59,159 --> 02:03:02,040
attack is what's known as a 51% attack
3394
02:03:02,040 --> 02:03:03,639
now as we saw as part of our consensus
3395
02:03:03,639 --> 02:03:05,880
protocol these blockchains are going to
3396
02:03:05,880 --> 02:03:08,239
agree that the longest chain is the one
3397
02:03:08,239 --> 02:03:10,079
that they're going to go with so long as
3398
02:03:10,079 --> 02:03:12,440
it matches up with 51% of the rest of
3399
02:03:12,440 --> 02:03:14,840
the network this means that if you have
3400
02:03:14,840 --> 02:03:17,040
the longest chain and you have more than
3401
02:03:17,040 --> 02:03:19,280
51% of the rest of the network you can
3402
02:03:19,280 --> 02:03:21,400
do what's called a fork in the network
3403
02:03:21,400 --> 02:03:23,280
and bring the network onto your now
3404
02:03:23,280 --> 02:03:25,480
longest chain now Cil attacks obviously
3405
02:03:25,480 --> 02:03:27,199
are when a single node or a single
3406
02:03:27,199 --> 02:03:30,000
entity tries to affect the decentral of
3407
02:03:30,000 --> 02:03:32,000
the network by pretending to be multiple
3408
02:03:32,000 --> 02:03:33,599
different people although they're just
3409
02:03:33,599 --> 02:03:35,639
the same person or entity and like I
3410
02:03:35,639 --> 02:03:37,040
said it's really difficult to do in
3411
02:03:37,040 --> 02:03:38,760
proof of work and proof of stake so you
3412
02:03:38,760 --> 02:03:40,239
can see now that blockchains are very
3413
02:03:40,239 --> 02:03:42,760
Democratic whichever blockchain has the
3414
02:03:42,760 --> 02:03:44,920
most Buy in and is the longest is the
3415
02:03:44,920 --> 02:03:46,599
blockchain that the whole system is
3416
02:03:46,599 --> 02:03:48,639
going to corroborate when nodes produce
3417
02:03:48,639 --> 02:03:50,360
a new block and add it to the longest
3418
02:03:50,360 --> 02:03:52,280
chain the other nodes will follow this
3419
02:03:52,280 --> 02:03:53,440
longest chain that the rest of the
3420
02:03:53,440 --> 02:03:55,119
network is agreeing with ADD those
3421
02:03:55,119 --> 02:03:57,599
blocks to their chain and follow up so
3422
02:03:57,599 --> 02:03:59,400
very small reorganizations are actually
3423
02:03:59,400 --> 02:04:01,559
pretty common when a blockchain picks a
3424
02:04:01,559 --> 02:04:03,119
block from a different longest chain
3425
02:04:03,119 --> 02:04:05,559
puts it on and then has to swap it out
3426
02:04:05,559 --> 02:04:07,639
for another block and continue with a
3427
02:04:07,639 --> 02:04:09,320
different blockchain however if a group
3428
02:04:09,320 --> 02:04:11,119
of nodes had enough nodes or enough
3429
02:04:11,119 --> 02:04:13,800
power they could essentially be 51% of
3430
02:04:13,800 --> 02:04:16,239
the network and influence the network in
3431
02:04:16,239 --> 02:04:18,199
whatever direction that they wanted this
3432
02:04:18,199 --> 02:04:20,800
is what's known as a 51% attack and it's
3433
02:04:20,800 --> 02:04:21,880
happened on blockchains like like
3434
02:04:21,880 --> 02:04:24,360
ethereum classic which is not ethereum
3435
02:04:24,360 --> 02:04:26,440
this is why the bigger a blockchain is
3436
02:04:26,440 --> 02:04:28,159
the more decentralized and the more
3437
02:04:28,159 --> 02:04:30,320
secure it becomes so after you watch
3438
02:04:30,320 --> 02:04:31,679
this video and you become a blockchain
3439
02:04:31,679 --> 02:04:33,559
engineering expert I definitely
3440
02:04:33,559 --> 02:04:35,000
recommend you run a note as well because
3441
02:04:35,000 --> 02:04:36,880
you are going to increase the security
3442
02:04:36,880 --> 02:04:39,040
of the network as a whole by running a
3443
02:04:39,040 --> 02:04:41,000
node so proof of work is fantastic
3444
02:04:41,000 --> 02:04:42,480
because it allows us to very easily
3445
02:04:42,480 --> 02:04:44,559
protect against these Cil attacks and
3446
02:04:44,559 --> 02:04:46,639
keep our blockchains decentralized and
3447
02:04:46,639 --> 02:04:49,159
secure however it has some drawbacks as
3448
02:04:49,159 --> 02:04:51,280
well proof of work costs a lot of
3449
02:04:51,280 --> 02:04:52,199
electric
3450
02:04:52,199 --> 02:04:53,679
because every single node is running as
3451
02:04:53,679 --> 02:04:56,119
fast as they can to win this race to get
3452
02:04:56,119 --> 02:04:58,639
the rewards this leads to obviously an
3453
02:04:58,639 --> 02:05:00,679
environmental impact now since proof of
3454
02:05:00,679 --> 02:05:02,320
work in Nakamoto consensus a lot of
3455
02:05:02,320 --> 02:05:04,520
other protocols have taken this idea and
3456
02:05:04,520 --> 02:05:06,079
gone in a different direction with a
3457
02:05:06,079 --> 02:05:08,079
different civil resistance protocol a
3458
02:05:08,079 --> 02:05:09,760
lot of them with the intention to be a
3459
02:05:09,760 --> 02:05:11,800
lot more environmentally friendly and
3460
02:05:11,800 --> 02:05:13,679
the most popular one right now is proof
3461
02:05:13,679 --> 02:05:15,440
of stake there are some chains that are
3462
02:05:15,440 --> 02:05:17,000
already using this proof of stake
3463
02:05:17,000 --> 02:05:19,559
protocol and that are live and thriving
3464
02:05:19,559 --> 02:05:22,159
some of them are like Avalanche Sal
3465
02:05:22,159 --> 02:05:24,400
polygon polka
3466
02:05:24,400 --> 02:05:27,040
dot so let's talk about proof of stake
3467
02:05:27,040 --> 02:05:28,800
now again this is a different civil
3468
02:05:28,800 --> 02:05:30,639
resistance mechanism instead of solving
3469
02:05:30,639 --> 02:05:32,599
this difficult problem proof of stake
3470
02:05:32,599 --> 02:05:34,559
nodes put up some collateral that
3471
02:05:34,559 --> 02:05:37,400
they're going to behave honestly AKA
3472
02:05:37,400 --> 02:05:40,199
they stake in the example of ethereum 2
3473
02:05:40,199 --> 02:05:42,960
nodes put up some ethereum as a stake
3474
02:05:42,960 --> 02:05:44,480
that they're going to behave honestly in
3475
02:05:44,480 --> 02:05:46,400
the network if they misbehaved in the
3476
02:05:46,400 --> 02:05:48,599
network they are going to be slashed or
3477
02:05:48,599 --> 02:05:50,840
removed some of their stake obviously
3478
02:05:50,840 --> 02:05:52,320
this is a very good civil resistance
3479
02:05:52,320 --> 02:05:54,199
mechanism because if you try to create a
3480
02:05:54,199 --> 02:05:56,520
whole bunch of anonymous accounts then
3481
02:05:56,520 --> 02:05:58,079
each one of those accounts you have to
3482
02:05:58,079 --> 02:06:00,559
put up some stake and if you misbehave
3483
02:06:00,559 --> 02:06:02,320
you're going to run the risk of losing
3484
02:06:02,320 --> 02:06:03,599
all the money that you put up as
3485
02:06:03,599 --> 02:06:06,440
collateral in this system miners are
3486
02:06:06,440 --> 02:06:08,040
actually called validators because
3487
02:06:08,040 --> 02:06:09,599
they're no longer binding anything
3488
02:06:09,599 --> 02:06:11,000
they're actually just validating other
3489
02:06:11,000 --> 02:06:13,280
nodes now unlike proof of work which
3490
02:06:13,280 --> 02:06:14,840
every node is racing to be the first one
3491
02:06:14,840 --> 02:06:17,000
to find the Block in proof of stake
3492
02:06:17,000 --> 02:06:19,280
nodes are actually randomly chosen to
3493
02:06:19,280 --> 02:06:21,199
propose the new block and then the rest
3494
02:06:21,199 --> 02:06:23,719
of the validators will validate if that
3495
02:06:23,719 --> 02:06:26,159
note has proposed the block honestly as
3496
02:06:26,159 --> 02:06:27,920
we saw with our cryptography lesson it's
3497
02:06:27,920 --> 02:06:29,920
usually very easy for other notes to
3498
02:06:29,920 --> 02:06:33,000
verify if a proposal or a transaction is
3499
02:06:33,000 --> 02:06:35,000
honest now proof of stake obviously has
3500
02:06:35,000 --> 02:06:36,920
some pros and cons as well Pros are that
3501
02:06:36,920 --> 02:06:38,880
again it is a great civil resistance
3502
02:06:38,880 --> 02:06:40,559
mechanism and a great way to figure out
3503
02:06:40,559 --> 02:06:42,760
who the author of a block should be the
3504
02:06:42,760 --> 02:06:44,800
other Pros are that it's way less
3505
02:06:44,800 --> 02:06:46,760
computationally expensive to figure out
3506
02:06:46,760 --> 02:06:48,920
the new block because instead of every
3507
02:06:48,920 --> 02:06:50,679
single note on the network trying to do
3508
02:06:50,679 --> 02:06:53,559
this only one node needs to do this and
3509
02:06:53,559 --> 02:06:54,880
then the rest of the nodes just need to
3510
02:06:54,880 --> 02:06:56,719
validate it the cons are that it's
3511
02:06:56,719 --> 02:06:58,400
usually considered a slightly less
3512
02:06:58,400 --> 02:07:00,719
decentralized Network due to The Upfront
3513
02:07:00,719 --> 02:07:02,880
staking costs it costs to participate
3514
02:07:02,880 --> 02:07:04,239
now this gets into a little bit of a
3515
02:07:04,239 --> 02:07:05,840
philosophical battle on how
3516
02:07:05,840 --> 02:07:08,000
decentralized is decentralized enough
3517
02:07:08,000 --> 02:07:09,480
and I think that's up to the community
3518
02:07:09,480 --> 02:07:11,480
to decide and as we progress I think
3519
02:07:11,480 --> 02:07:13,040
we'll learn more and more about how
3520
02:07:13,040 --> 02:07:15,199
decentralized is decentralized enough
3521
02:07:15,199 --> 02:07:17,119
the general consensus amongst blockchain
3522
02:07:17,119 --> 02:07:18,800
Engineers though is that proof of stake
3523
02:07:18,800 --> 02:07:21,000
is very very decentralized and very
3524
02:07:21,000 --> 02:07:23,000
secure now there's another term that
3525
02:07:23,000 --> 02:07:24,559
might be the first time you heard it a
3526
02:07:24,559 --> 02:07:26,400
layer one we're going to talk about
3527
02:07:26,400 --> 02:07:28,280
layer ones and layer twos in terms of
3528
02:07:28,280 --> 02:07:30,599
scalability really quickly as well a
3529
02:07:30,599 --> 02:07:33,280
layer one refers to any base layer
3530
02:07:33,280 --> 02:07:35,520
blockchain implementation bitcoin's a
3531
02:07:35,520 --> 02:07:37,679
layer one ethereum's a layer one
3532
02:07:37,679 --> 02:07:39,960
Avalanche is a layer one these are the
3533
02:07:39,960 --> 02:07:42,599
base layer blockchain Solutions a layer
3534
02:07:42,599 --> 02:07:46,119
two is any application that is added on
3535
02:07:46,119 --> 02:07:48,280
top of a layer one added on top of a
3536
02:07:48,280 --> 02:07:50,199
blockchain some examples of layer twos
3537
02:07:50,199 --> 02:07:52,719
are going to be chain link arbitrum or
3538
02:07:52,719 --> 02:07:55,400
optimism arbitrum and optimism are very
3539
02:07:55,400 --> 02:07:57,159
interesting because they are layer twos
3540
02:07:57,159 --> 02:07:59,639
that also look to solve this scalability
3541
02:07:59,639 --> 02:08:01,559
issue arbitrum and optimism are what's
3542
02:08:01,559 --> 02:08:04,920
known as rollups and they roll up their
3543
02:08:04,920 --> 02:08:07,040
transactions into a layer one like
3544
02:08:07,040 --> 02:08:08,559
ethereum we're not going to go too deep
3545
02:08:08,559 --> 02:08:10,400
into rollups and how they actually work
3546
02:08:10,400 --> 02:08:12,000
but all you really need to know is that
3547
02:08:12,000 --> 02:08:13,320
they solve some of the scalability
3548
02:08:13,320 --> 02:08:15,280
issues by being another blockchain that
3549
02:08:15,280 --> 02:08:17,639
people can make transactions on still on
3550
02:08:17,639 --> 02:08:20,679
kind of this base ethereum layer now
3551
02:08:20,679 --> 02:08:22,400
they're different from side chains
3552
02:08:22,400 --> 02:08:24,119
because side chains derive their
3553
02:08:24,119 --> 02:08:26,239
security from their own protocols
3554
02:08:26,239 --> 02:08:28,639
rollups derive their security from the
3555
02:08:28,639 --> 02:08:30,639
base layers so arbitrum and optimism for
3556
02:08:30,639 --> 02:08:32,079
example is going to be just about as
3557
02:08:32,079 --> 02:08:33,920
secure as ethereum there's some
3558
02:08:33,920 --> 02:08:35,400
fantastic guys in there that go a little
3559
02:08:35,400 --> 02:08:37,079
bit deeper into rollups and I've left a
3560
02:08:37,079 --> 02:08:38,599
link in the description for you all
3561
02:08:38,599 --> 02:08:41,000
right so we just talked about a lot of
3562
02:08:41,000 --> 02:08:43,320
stuff so let's do a quick recap before
3563
02:08:43,320 --> 02:08:45,480
moving on civil attacks are prevented
3564
02:08:45,480 --> 02:08:47,320
due to protocols like proof of work and
3565
02:08:47,320 --> 02:08:49,960
proof of stake 51% attacks grow
3566
02:08:49,960 --> 02:08:51,840
increasingly harder with the size of
3567
02:08:51,840 --> 02:08:53,840
blockchain so you should run a node
3568
02:08:53,840 --> 02:08:55,920
consensus is the mechanism that allows a
3569
02:08:55,920 --> 02:08:57,920
blockchain to agree upon what the state
3570
02:08:57,920 --> 02:09:00,079
of the blockchain is sharding and
3571
02:09:00,079 --> 02:09:02,559
rollups are solutions to scalability
3572
02:09:02,559 --> 02:09:05,719
issues on layer ones a layer one is any
3573
02:09:05,719 --> 02:09:07,480
base blockchain implementation like
3574
02:09:07,480 --> 02:09:09,320
Bitcoin or ethereum a blockchain
3575
02:09:09,320 --> 02:09:11,119
scalability problem is that there's not
3576
02:09:11,119 --> 02:09:12,960
always enough block space for the amount
3577
02:09:12,960 --> 02:09:14,920
of transactions that want to get in them
3578
02:09:14,920 --> 02:09:17,520
this leads to very high gas prices and
3579
02:09:17,520 --> 02:09:19,679
again gas prices are how much it costs
3580
02:09:19,679 --> 02:09:22,280
to interact with a blockchain
3581
02:09:22,280 --> 02:09:24,920
so that's it for the blockchain basics
3582
02:09:24,920 --> 02:09:27,440
and the blockchain explainers with just
3583
02:09:27,440 --> 02:09:30,199
this information you now can go off into
3584
02:09:30,199 --> 02:09:32,159
the world and start working with
3585
02:09:32,159 --> 02:09:33,559
blockchains and interacting with
3586
02:09:33,559 --> 02:09:36,040
blockchains with at least some level of
3587
02:09:36,040 --> 02:09:38,040
knowledge as to what's going on you
3588
02:09:38,040 --> 02:09:40,040
should be incredibly proud of yourself
3589
02:09:40,040 --> 02:09:43,119
for just making it this far definitely
3590
02:09:43,119 --> 02:09:44,639
be sure to give yourself a pat on the
3591
02:09:44,639 --> 02:09:46,679
back and Round of Applause now that
3592
02:09:46,679 --> 02:09:48,119
we've gotten a lot of the basics and the
3593
02:09:48,119 --> 02:09:50,400
fundamentals out of the way let's start
3594
02:09:50,400 --> 02:09:53,239
jumping into the coding aspect this is
3595
02:09:53,239 --> 02:09:55,119
where you're going to learn how to
3596
02:09:55,119 --> 02:09:56,840
actually build these smart contracts how
3597
02:09:56,840 --> 02:09:58,360
to build these trust minimized
3598
02:09:58,360 --> 02:10:00,639
agreements in these blockchains and in
3599
02:10:00,639 --> 02:10:03,239
these smart contract platforms this next
3600
02:10:03,239 --> 02:10:05,840
section this solidity Basics the
3601
02:10:05,840 --> 02:10:07,960
solidity fundamentals section will give
3602
02:10:07,960 --> 02:10:10,440
you all the skills to start actually
3603
02:10:10,440 --> 02:10:13,119
coding solidity and understanding how
3604
02:10:13,119 --> 02:10:15,199
these smart contracts work underneath
3605
02:10:15,199 --> 02:10:17,760
the hood so at this point absolutely
3606
02:10:17,760 --> 02:10:19,719
give yourself a high five maybe say hi
3607
02:10:19,719 --> 02:10:21,360
in the GitHub discussions maybe say hi
3608
02:10:21,360 --> 02:10:22,880
high in the community on Twitter on
3609
02:10:22,880 --> 02:10:25,639
Reddit Etc and be proud of just making
3610
02:10:25,639 --> 02:10:28,000
it this far the journey has really only
3611
02:10:28,000 --> 02:10:30,119
just begun but you've already learned so
3612
02:10:30,119 --> 02:10:32,760
much let's begin the next section and
3613
02:10:32,760 --> 02:10:35,559
let's jump into the
3614
02:10:49,760 --> 02:10:51,599
code now that we're going to to the
3615
02:10:51,599 --> 02:10:53,520
coding part I need to stress to
3616
02:10:53,520 --> 02:10:56,599
absolutely use the GitHub repository or
3617
02:10:56,599 --> 02:10:59,360
web3 dev. education associated with this
3618
02:10:59,360 --> 02:11:01,280
course if you're on the GitHub repo
3619
02:11:01,280 --> 02:11:04,000
right now and you scroll down to lesson
3620
02:11:04,000 --> 02:11:05,920
two and this is going to look a little
3621
02:11:05,920 --> 02:11:07,599
bit different when you come to it you
3622
02:11:07,599 --> 02:11:10,040
can click on the GitHub repo associated
3623
02:11:10,040 --> 02:11:12,360
with this lesson this will have all the
3624
02:11:12,360 --> 02:11:13,480
code that we're actually going to be
3625
02:11:13,480 --> 02:11:16,599
working with for this section as well as
3626
02:11:16,599 --> 02:11:18,360
a read me section which is going to have
3627
02:11:18,360 --> 02:11:20,320
a lot of notes on how to actually work
3628
02:11:20,320 --> 02:11:22,639
with the code and instead of making
3629
02:11:22,639 --> 02:11:24,880
issues and discussions on this
3630
02:11:24,880 --> 02:11:27,199
repository here if you have an issue
3631
02:11:27,199 --> 02:11:29,440
please use the discussions tab of The
3632
02:11:29,440 --> 02:11:32,320
Foundry full course here or use any of
3633
02:11:32,320 --> 02:11:34,119
the areas that we've laid out in the
3634
02:11:34,119 --> 02:11:36,119
questions section we're going to teach
3635
02:11:36,119 --> 02:11:37,880
you how to ask questions so that they
3636
02:11:37,880 --> 02:11:39,440
have the highest probability of being
3637
02:11:39,440 --> 02:11:41,159
answered by either somebody else in the
3638
02:11:41,159 --> 02:11:44,559
community by an AI or by a forum
3639
02:11:44,559 --> 02:11:45,880
additionally please be sure to check out
3640
02:11:45,880 --> 02:11:49,360
web 3d. for more information as well I
3641
02:11:49,360 --> 02:11:50,960
highly recommend that you pause the
3642
02:11:50,960 --> 02:11:54,320
video right now and make accounts for
3643
02:11:54,320 --> 02:11:56,880
first of all GitHub and then at least
3644
02:11:56,880 --> 02:11:58,880
stack exchange ethereum additionally
3645
02:11:58,880 --> 02:12:00,760
chat gbt is a great resource to make an
3646
02:12:00,760 --> 02:12:03,480
account for just remember that it will
3647
02:12:03,480 --> 02:12:05,360
often get things wrong and isn't quite
3648
02:12:05,360 --> 02:12:07,679
up to date find you don't need to make
3649
02:12:07,679 --> 02:12:09,880
an account for but it often gets things
3650
02:12:09,880 --> 02:12:12,000
wrong sometimes as well typically for
3651
02:12:12,000 --> 02:12:13,920
each coding section I'll give you a
3652
02:12:13,920 --> 02:12:15,480
brief rundown of what we're actually
3653
02:12:15,480 --> 02:12:17,639
going to be building and in this lesson
3654
02:12:17,639 --> 02:12:19,360
we're going to be building this exact
3655
02:12:19,360 --> 02:12:20,559
smart contract and we're going to be
3656
02:12:20,559 --> 02:12:22,800
building your first smart contract ever
3657
02:12:22,800 --> 02:12:24,400
and we're going to deploy it to a
3658
02:12:24,400 --> 02:12:26,639
blockchain at the end of this section
3659
02:12:26,639 --> 02:12:28,199
you are going to have deployed your
3660
02:12:28,199 --> 02:12:30,599
first smart contract ever so be sure to
3661
02:12:30,599 --> 02:12:32,159
get to the end so you can deploy your
3662
02:12:32,159 --> 02:12:34,000
first smart contract we're going to be
3663
02:12:34,000 --> 02:12:37,159
using something called an IDE called
3664
02:12:37,159 --> 02:12:39,599
remix to deploy and interact and work
3665
02:12:39,599 --> 02:12:41,559
with this smart contract which is going
3666
02:12:41,559 --> 02:12:43,520
to be very exciting it's highly
3667
02:12:43,520 --> 02:12:45,440
recommended to get the best experience
3668
02:12:45,440 --> 02:12:47,320
out of this is for you to follow along
3669
02:12:47,320 --> 02:12:49,559
and you to code with me you can change
3670
02:12:49,559 --> 02:12:51,760
my speed on the YouTube video if I'm
3671
02:12:51,760 --> 02:12:54,520
coding too fast or I'm coding too slow
3672
02:12:54,520 --> 02:12:56,159
but you taking the time to write out the
3673
02:12:56,159 --> 02:12:58,280
code as I code along with you is going
3674
02:12:58,280 --> 02:13:01,520
to ingrain the knowledge into your brain
3675
02:13:01,520 --> 02:13:03,520
repetition is the mother of skill and I
3676
02:13:03,520 --> 02:13:05,079
want to make sure you come out the other
3677
02:13:05,079 --> 02:13:07,840
side with skill actually code this we're
3678
02:13:07,840 --> 02:13:10,000
going to be using a tool called remix
3679
02:13:10,000 --> 02:13:12,040
you can either Google search it or you
3680
02:13:12,040 --> 02:13:13,920
can just come to the GitHub repo or web
3681
02:13:13,920 --> 02:13:16,960
3d. education and click this link to
3682
02:13:16,960 --> 02:13:20,360
remix which will pop open the remix web
3683
02:13:20,360 --> 02:13:22,679
ID so let's go ahead let's jump in and
3684
02:13:22,679 --> 02:13:24,679
let's learn to deploy our first smart
3685
02:13:24,679 --> 02:13:27,119
contract at the end of this lesson you
3686
02:13:27,119 --> 02:13:29,159
will have deployed your first smart
3687
02:13:29,159 --> 02:13:31,079
contract you'll have written your first
3688
02:13:31,079 --> 02:13:33,679
bit of solidity and we are very excited
3689
02:13:33,679 --> 02:13:36,679
to get through this
3690
02:13:38,280 --> 02:13:41,800
part welcome to the remix IDE or the
3691
02:13:41,800 --> 02:13:44,000
integrated development environment this
3692
02:13:44,000 --> 02:13:45,840
is where we're going to learn to write a
3693
02:13:45,840 --> 02:13:48,079
lot of our code in the beginning if you
3694
02:13:48,079 --> 02:13:49,840
want you can go ahead and accept to help
3695
02:13:49,840 --> 02:13:51,719
out remix here and if you've never been
3696
02:13:51,719 --> 02:13:53,400
to the remix website before it'll give
3697
02:13:53,400 --> 02:13:55,320
you a tutorial walkthr of some of the
3698
02:13:55,320 --> 02:13:57,440
features that remix has to offer for
3699
02:13:57,440 --> 02:13:59,520
example it has a solidity compiler
3700
02:13:59,520 --> 02:14:01,520
solidity is the programming language
3701
02:14:01,520 --> 02:14:03,159
that we're going to be using in this
3702
02:14:03,159 --> 02:14:06,159
course to code our smart contracts where
3703
02:14:06,159 --> 02:14:07,639
and we need to compile them when we've
3704
02:14:07,639 --> 02:14:09,119
written the solidity we'll learn about
3705
02:14:09,119 --> 02:14:11,639
that in a little bit we have a tab here
3706
02:14:11,639 --> 02:14:12,920
where we can actually deploy our
3707
02:14:12,920 --> 02:14:15,559
contracts to a blockchain and we have
3708
02:14:15,559 --> 02:14:17,679
all these different folders and scripts
3709
02:14:17,679 --> 02:14:19,960
since we can actually write JavaScript
3710
02:14:19,960 --> 02:14:22,719
and typescript in remix as well but
3711
02:14:22,719 --> 02:14:24,159
don't worry about those too much for now
3712
02:14:24,159 --> 02:14:25,559
because I'm going to be explaining
3713
02:14:25,559 --> 02:14:27,559
everything that we're going to do remix
3714
02:14:27,559 --> 02:14:29,079
is an incredibly powerful tool because
3715
02:14:29,079 --> 02:14:30,679
it has a lot of features that will allow
3716
02:14:30,679 --> 02:14:33,320
us to really see and visualize what our
3717
02:14:33,320 --> 02:14:35,360
smart contracts do eventually we're
3718
02:14:35,360 --> 02:14:37,639
going to move off of remix to a local
3719
02:14:37,639 --> 02:14:39,960
development environment however remix is
3720
02:14:39,960 --> 02:14:42,040
a tool still used by some of the top
3721
02:14:42,040 --> 02:14:43,679
Auditors and smart contract developers
3722
02:14:43,679 --> 02:14:45,400
in the space when they want to quickly
3723
02:14:45,400 --> 02:14:47,480
check something out and additionally
3724
02:14:47,480 --> 02:14:49,040
it's fantastic for learning the
3725
02:14:49,040 --> 02:14:51,360
fundamentals of solidity the left hand
3726
02:14:51,360 --> 02:14:52,719
side is where we're actually going to
3727
02:14:52,719 --> 02:14:55,040
start interacting with remix if we bring
3728
02:14:55,040 --> 02:14:57,440
our Mouse up to the top this little file
3729
02:14:57,440 --> 02:14:58,800
explorer is where we're going to have
3730
02:14:58,800 --> 02:15:00,040
all of our files and where we're going
3731
02:15:00,040 --> 02:15:01,719
to write our solidity or our smart
3732
02:15:01,719 --> 02:15:03,599
contract code if you want you can leave
3733
02:15:03,599 --> 02:15:04,960
all these folders in here but I'm
3734
02:15:04,960 --> 02:15:06,360
actually going to go ahead and delete
3735
02:15:06,360 --> 02:15:08,440
everything so that there's less for me
3736
02:15:08,440 --> 02:15:10,480
to work with or or deal with so I'm just
3737
02:15:10,480 --> 02:15:12,400
going to go ahead and rightclick and
3738
02:15:12,400 --> 02:15:14,679
delete everything in here just so I can
3739
02:15:14,679 --> 02:15:17,040
start completely from scratch again if
3740
02:15:17,040 --> 02:15:19,040
you want to leave all of these in here
3741
02:15:19,040 --> 02:15:21,199
feel free to do so doesn't matter I just
3742
02:15:21,199 --> 02:15:23,760
think it's cluttering up my mental space
3743
02:15:23,760 --> 02:15:26,119
a little bit now we have a blank remix
3744
02:15:26,119 --> 02:15:27,360
project and the first thing that we're
3745
02:15:27,360 --> 02:15:30,000
going to want to do is create our first
3746
02:15:30,000 --> 02:15:32,480
file to start writing and deploying our
3747
02:15:32,480 --> 02:15:34,239
solidity smart contract we're going to
3748
02:15:34,239 --> 02:15:36,199
go ahead and click the create new file
3749
02:15:36,199 --> 02:15:40,480
right here and type in simple storage.
3750
02:15:40,480 --> 02:15:43,079
Soul doou tells our compiler that this
3751
02:15:43,079 --> 02:15:45,559
is going to be a solidity contract a
3752
02:15:45,559 --> 02:15:47,599
solidity file and we're going to be
3753
02:15:47,599 --> 02:15:50,079
writing solidity inside of this file
3754
02:15:50,079 --> 02:15:51,880
which again solidity is the most popular
3755
02:15:51,880 --> 02:15:53,920
smart contract programming language and
3756
02:15:53,920 --> 02:15:56,159
you'll see we actually get popped up a
3757
02:15:56,159 --> 02:15:58,280
simple storage. Soul on the right hand
3758
02:15:58,280 --> 02:16:00,239
side which you can type in and actually
3759
02:16:00,239 --> 02:16:03,040
write our solidity code now right below
3760
02:16:03,040 --> 02:16:05,679
the file explorer button is a little
3761
02:16:05,679 --> 02:16:07,920
search icon which allows us to search
3762
02:16:07,920 --> 02:16:09,360
for different code in all of our
3763
02:16:09,360 --> 02:16:12,239
contracts so for example if I type in
3764
02:16:12,239 --> 02:16:15,040
hello in here and I copy that paste that
3765
02:16:15,040 --> 02:16:17,719
into the search bar hit enter we can see
3766
02:16:17,719 --> 02:16:20,480
that it found this line hello in our
3767
02:16:20,480 --> 02:16:22,599
simple storage. let's go ahead and
3768
02:16:22,599 --> 02:16:24,920
delete that right below that search icon
3769
02:16:24,920 --> 02:16:27,239
is this solidity compiler and you'll see
3770
02:16:27,239 --> 02:16:29,280
a bunch of different stuff pop up which
3771
02:16:29,280 --> 02:16:31,119
tells us about our compiler
3772
02:16:31,119 --> 02:16:33,240
configuration and we can see even more
3773
02:16:33,240 --> 02:16:34,840
advanced configuration if we hit the
3774
02:16:34,840 --> 02:16:36,599
dropdown we're not going to hit that for
3775
02:16:36,599 --> 02:16:38,359
now let's go ahead and double click this
3776
02:16:38,359 --> 02:16:40,479
solidity compiler over here so we can
3777
02:16:40,479 --> 02:16:43,479
just see the simple storage. soulle I'm
3778
02:16:43,479 --> 02:16:45,160
also going to click this hide terminal
3779
02:16:45,160 --> 02:16:47,439
button so that we just see our simple
3780
02:16:47,439 --> 02:16:49,439
storage. soulle now the first thing that
3781
02:16:49,439 --> 02:16:51,519
we want to do in all of our solidity in
3782
02:16:51,519 --> 02:16:53,760
smart contracts is write the solidity
3783
02:16:53,760 --> 02:16:54,960
version that we're going to be working
3784
02:16:54,960 --> 02:16:57,160
with solidity is a constantly changing
3785
02:16:57,160 --> 02:16:59,280
language and we want to be very specific
3786
02:16:59,280 --> 02:17:00,359
about what version we're going to be
3787
02:17:00,359 --> 02:17:02,399
using to write our smart contract as
3788
02:17:02,399 --> 02:17:04,479
each version does different things to
3789
02:17:04,479 --> 02:17:05,960
write your version you're going to do
3790
02:17:05,960 --> 02:17:08,679
pragma solidity and then type your
3791
02:17:08,679 --> 02:17:10,439
version for most of this course we're
3792
02:17:10,439 --> 02:17:12,880
going to be using
3793
02:17:14,280 --> 02:17:16,599
0.819 as that's the most current
3794
02:17:16,599 --> 02:17:18,679
addition of solidity however getting
3795
02:17:18,679 --> 02:17:20,240
used to working with different versions
3796
02:17:20,240 --> 02:17:22,679
of solidity is really good for you as
3797
02:17:22,679 --> 02:17:23,880
you're going to be working with
3798
02:17:23,880 --> 02:17:26,040
different versions of solidity no matter
3799
02:17:26,040 --> 02:17:27,800
where you go certain versions of
3800
02:17:27,800 --> 02:17:29,920
solidity are considered more stable than
3801
02:17:29,920 --> 02:17:31,639
other versions right now there's a
3802
02:17:31,639 --> 02:17:33,160
popular tool called Slither which
3803
02:17:33,160 --> 02:17:35,160
recommends using
3804
02:17:35,160 --> 02:17:38,760
0.818 so if you want to default to 0.818
3805
02:17:38,760 --> 02:17:40,880
for this course feel free to do so we're
3806
02:17:40,880 --> 02:17:42,040
going to be using a couple different
3807
02:17:42,040 --> 02:17:44,559
versions as we code so this line says
3808
02:17:44,559 --> 02:17:47,160
we're stated our version now these two
3809
02:17:47,160 --> 02:17:49,399
slashes here stand for what's called a
3810
02:17:49,399 --> 02:17:51,639
comment in solidity and this allows you
3811
02:17:51,639 --> 02:17:54,559
to write anything after the two slashes
3812
02:17:54,559 --> 02:17:56,800
and when we compile or run our code it
3813
02:17:56,800 --> 02:17:58,760
will just ignore what's in here so we
3814
02:17:58,760 --> 02:18:00,920
could type blah blah blah whatever we
3815
02:18:00,920 --> 02:18:04,359
want cats are cool and it doesn't matter
3816
02:18:04,359 --> 02:18:06,439
you can write anything in here I highly
3817
02:18:06,439 --> 02:18:08,479
recommend as we're going along you
3818
02:18:08,479 --> 02:18:10,160
should write comments in your own code
3819
02:18:10,160 --> 02:18:13,399
as well for you to refer to later on and
3820
02:18:13,399 --> 02:18:15,760
additionally feel free to copy all the
3821
02:18:15,760 --> 02:18:17,840
code that you write and paste it locally
3822
02:18:17,840 --> 02:18:19,719
so that just in case your browser cache
3823
02:18:19,719 --> 02:18:21,399
refreshes or something you won't lose
3824
02:18:21,399 --> 02:18:23,719
all the work you've done so so before
3825
02:18:23,719 --> 02:18:25,760
you lock off for the day copy paste this
3826
02:18:25,760 --> 02:18:27,319
into a text file so that you can have it
3827
02:18:27,319 --> 02:18:29,160
for later but a good comment for here
3828
02:18:29,160 --> 02:18:32,920
might be this is the version now writing
3829
02:18:32,920 --> 02:18:35,200
our version like this in solidity tells
3830
02:18:35,200 --> 02:18:37,080
the solidity compiler that we're only
3831
02:18:37,080 --> 02:18:40,960
allowed to use 0.818 when compiling this
3832
02:18:40,960 --> 02:18:42,679
however maybe a new version comes out
3833
02:18:42,679 --> 02:18:45,120
and we're okay to use anything newer
3834
02:18:45,120 --> 02:18:47,120
than this version to tell the compiler
3835
02:18:47,120 --> 02:18:48,840
that we add this little hat this little
3836
02:18:48,840 --> 02:18:51,240
carrot which says this contract only
3837
02:18:51,240 --> 02:18:52,599
works with
3838
02:18:52,599 --> 02:18:55,920
0.818 or anything greater than that this
3839
02:18:55,920 --> 02:19:00,080
means 0.8.9 would work when 0.820 comes
3840
02:19:00,080 --> 02:19:02,880
out that one would work however
3841
02:19:02,880 --> 02:19:06,399
0.817 would not work if we were working
3842
02:19:06,399 --> 02:19:09,359
with 0.818 or above if we don't have the
3843
02:19:09,359 --> 02:19:11,960
carrot this tells the compiler that only
3844
02:19:11,960 --> 02:19:14,519
0.818 will work with this code if we
3845
02:19:14,519 --> 02:19:16,519
want to use solidity versions within a
3846
02:19:16,519 --> 02:19:19,080
range we could do something like this we
3847
02:19:19,080 --> 02:19:20,479
could say we want our version to be
3848
02:19:20,479 --> 02:19:23,519
greater greater than or equal to
3849
02:19:23,519 --> 02:19:27,040
0.818 but less than
3850
02:19:27,040 --> 02:19:29,840
0.9.0 this would tell the compiler that
3851
02:19:29,840 --> 02:19:32,080
any version between these two is a valid
3852
02:19:32,080 --> 02:19:34,880
version for example
3853
02:19:34,880 --> 02:19:38,800
0.9.1 would not work neither would
3854
02:19:38,800 --> 02:19:41,840
0.9.0 because these are not strictly
3855
02:19:41,840 --> 02:19:43,240
less than
3856
02:19:43,240 --> 02:19:45,319
0.9.0 great so now we know how to do
3857
02:19:45,319 --> 02:19:47,439
compiler versions now the next thing
3858
02:19:47,439 --> 02:19:49,000
every smart contract needs to start with
3859
02:19:49,000 --> 02:19:51,319
is something called the spdx
3860
02:19:51,319 --> 02:19:54,359
license identifier now this actually
3861
02:19:54,359 --> 02:19:56,319
isn't required by the compiler it'll
3862
02:19:56,319 --> 02:19:58,000
actually throw a warning if we compile
3863
02:19:58,000 --> 02:19:59,960
and it won't error it's fine if you
3864
02:19:59,960 --> 02:20:01,800
don't have this however it's highly
3865
02:20:01,800 --> 02:20:03,560
recommended this is a way to make
3866
02:20:03,560 --> 02:20:06,359
licensing and sharing code and IP of
3867
02:20:06,359 --> 02:20:08,399
your contracts a lot easier from a legal
3868
02:20:08,399 --> 02:20:10,439
perspective I have a link to more about
3869
02:20:10,439 --> 02:20:12,840
how licenses work in the GitHub repo
3870
02:20:12,840 --> 02:20:14,399
associated with this section of the
3871
02:20:14,399 --> 02:20:16,920
course MIT is known as one of the most
3872
02:20:16,920 --> 02:20:19,399
permissive licenses it basically means
3873
02:20:19,399 --> 02:20:20,960
anybody can use this code and pretty
3874
02:20:20,960 --> 02:20:22,359
much do whatever they want with it I
3875
02:20:22,359 --> 02:20:23,800
wouldn't worry too much about the
3876
02:20:23,800 --> 02:20:26,040
licenses right now but let's actually go
3877
02:20:26,040 --> 02:20:27,840
back to
3878
02:20:27,840 --> 02:20:30,319
0.8.9 and on the left- hand side let's
3879
02:20:30,319 --> 02:20:32,520
scroll down to this compiler button and
3880
02:20:32,520 --> 02:20:34,840
open this back up even right now now
3881
02:20:34,840 --> 02:20:36,880
that we don't even have any code we can
3882
02:20:36,880 --> 02:20:38,439
actually go ahead and compile this
3883
02:20:38,439 --> 02:20:40,399
contract now you might see a red
3884
02:20:40,399 --> 02:20:42,120
squiggly and you might see a warning
3885
02:20:42,120 --> 02:20:44,160
here but don't worry about that for now
3886
02:20:44,160 --> 02:20:46,399
to choose our compiler version We scroll
3887
02:20:46,399 --> 02:20:48,720
up to this section and we can choose the
3888
02:20:48,720 --> 02:20:50,040
compiler version that we want to work
3889
02:20:50,040 --> 02:20:52,040
with most of the time though if you just
3890
02:20:52,040 --> 02:20:53,920
hit compile simple storage. soulle or
3891
02:20:53,920 --> 02:20:55,800
you hit this big compile button it'll
3892
02:20:55,800 --> 02:20:57,960
automatically choose the version for you
3893
02:20:57,960 --> 02:21:00,359
for example if I scroll down but I hit
3894
02:21:00,359 --> 02:21:03,560
compile it'll automatically flip up to
3895
02:21:03,560 --> 02:21:06,280
08.19 and we were able to go ahead we
3896
02:21:06,280 --> 02:21:08,280
were able to successfully compile this
3897
02:21:08,280 --> 02:21:11,080
code now it says no contract compiled
3898
02:21:11,080 --> 02:21:13,120
yet because we haven't put a contract in
3899
02:21:13,120 --> 02:21:14,319
here yet we just put the version of
3900
02:21:14,319 --> 02:21:16,319
cility that we're working with compiling
3901
02:21:16,319 --> 02:21:18,600
our code means taking our human readable
3902
02:21:18,600 --> 02:21:20,800
code and transforming it into to
3903
02:21:20,800 --> 02:21:22,680
computer readable code which is
3904
02:21:22,680 --> 02:21:24,960
essentially a bunch of zeros and ones or
3905
02:21:24,960 --> 02:21:27,439
it's bite code computer code is very
3906
02:21:27,439 --> 02:21:29,359
specific instructions for the computer
3907
02:21:29,359 --> 02:21:31,720
to use or in our case the blockchain to
3908
02:21:31,720 --> 02:21:34,399
use for our contract we'll learn later
3909
02:21:34,399 --> 02:21:36,560
about Machine level code and op codes
3910
02:21:36,560 --> 02:21:38,960
and evm codes in a much later section of
3911
02:21:38,960 --> 02:21:41,000
this course Additionally you can hit
3912
02:21:41,000 --> 02:21:43,880
command s or controls which will also
3913
02:21:43,880 --> 02:21:46,040
save and compile you'll see I kind of
3914
02:21:46,040 --> 02:21:48,240
have a trigger finger and I will out of
3915
02:21:48,240 --> 02:21:51,200
habit hit command s all the time
3916
02:21:51,200 --> 02:21:52,840
because as somebody who codes a lot I
3917
02:21:52,840 --> 02:21:54,600
need to make sure I save all the time
3918
02:21:54,600 --> 02:21:56,040
otherwise things might not work as
3919
02:21:56,040 --> 02:21:58,160
intended as you saw if we use a
3920
02:21:58,160 --> 02:22:00,040
different version of solidity and we hit
3921
02:22:00,040 --> 02:22:01,680
the compile button it'll automatically
3922
02:22:01,680 --> 02:22:04,160
flip back but for example let's say I
3923
02:22:04,160 --> 02:22:05,240
wanted to use
3924
02:22:05,240 --> 02:22:07,960
0.8.7 anything greater than that and
3925
02:22:07,960 --> 02:22:09,399
we're on compiler
3926
02:22:09,399 --> 02:22:13,040
0.8.9 and we hit compile it won't change
3927
02:22:13,040 --> 02:22:15,280
however if I use something less than
3928
02:22:15,280 --> 02:22:18,280
0.8.7 and we hit compile it'll change
3929
02:22:18,280 --> 02:22:20,280
because it wants to automatically select
3930
02:22:20,280 --> 02:22:23,080
a solidity version that is appropriate
3931
02:22:23,080 --> 02:22:25,520
for the version that you chose again I
3932
02:22:25,520 --> 02:22:27,560
want to use
3933
02:22:27,560 --> 02:22:30,680
0.818 and I'm going to hit compile and
3934
02:22:30,680 --> 02:22:32,319
we're good to go now we're going to go
3935
02:22:32,319 --> 02:22:34,200
ahead and start writing our contract and
3936
02:22:34,200 --> 02:22:35,680
to get the full screen view again we
3937
02:22:35,680 --> 02:22:37,040
just go ahead click the solidity
3938
02:22:37,040 --> 02:22:39,080
compiler so that we can just see our
3939
02:22:39,080 --> 02:22:41,160
code here to start writing our contract
3940
02:22:41,160 --> 02:22:43,080
we're going to use a keyword in solidity
3941
02:22:43,080 --> 02:22:45,800
called contract this tells solidity that
3942
02:22:45,800 --> 02:22:47,680
the next piece of code is going to be
3943
02:22:47,680 --> 02:22:49,680
the name for our contract that we're
3944
02:22:49,680 --> 02:22:51,160
going to create you can think of a
3945
02:22:51,160 --> 02:22:53,240
contract very similar to a class if
3946
02:22:53,240 --> 02:22:55,120
you're familiar with JavaScript or
3947
02:22:55,120 --> 02:22:57,319
python or Java or really any
3948
02:22:57,319 --> 02:22:59,399
object-oriented programming and we're
3949
02:22:59,399 --> 02:23:00,800
going to go ahead and give our contract
3950
02:23:00,800 --> 02:23:02,560
a name here we're going to call ours
3951
02:23:02,560 --> 02:23:05,280
simple storage and then we add this
3952
02:23:05,280 --> 02:23:08,240
little open and closed curly braces or
3953
02:23:08,240 --> 02:23:10,479
curly brackets everything inside of
3954
02:23:10,479 --> 02:23:11,880
these curly brackets is going to be
3955
02:23:11,880 --> 02:23:14,000
considered part of this contract simple
3956
02:23:14,000 --> 02:23:16,279
storage now if we hit enter we go back
3957
02:23:16,279 --> 02:23:18,439
to the compiler and hit compile we can
3958
02:23:18,439 --> 02:23:20,600
see once again this little green check
3959
02:23:20,600 --> 02:23:23,240
Mark pop up this means our compilation
3960
02:23:23,240 --> 02:23:25,800
has been successful if we were to remove
3961
02:23:25,800 --> 02:23:27,399
for example this curly brace and hit
3962
02:23:27,399 --> 02:23:29,880
compile we would see we would get this
3963
02:23:29,880 --> 02:23:32,439
error compilation failed with one error
3964
02:23:32,439 --> 02:23:33,840
and if we scroll to the bottom it'll
3965
02:23:33,840 --> 02:23:36,240
tell us where the error actually is and
3966
02:23:36,240 --> 02:23:38,439
we'll get a little red popup saying what
3967
02:23:38,439 --> 02:23:40,359
line the error is actually on we'll
3968
02:23:40,359 --> 02:23:41,880
learn about debugging these errors in a
3969
02:23:41,880 --> 02:23:43,920
little bit but let's add the curly brace
3970
02:23:43,920 --> 02:23:46,359
back go ahead back to the compiler
3971
02:23:46,359 --> 02:23:50,760
compile and we're good to go
3972
02:23:53,279 --> 02:23:54,560
hypothetically we could deploy this
3973
02:23:54,560 --> 02:23:57,200
smart contract right now this is a valid
3974
02:23:57,200 --> 02:24:00,479
contract although it doesn't do anything
3975
02:24:00,479 --> 02:24:02,880
but congratulations technically with
3976
02:24:02,880 --> 02:24:04,680
just this little piece of code you've
3977
02:24:04,680 --> 02:24:06,960
written your first smart contract I
3978
02:24:06,960 --> 02:24:08,439
spelled version wrong so we're going to
3979
02:24:08,439 --> 02:24:10,640
correct that city has many different
3980
02:24:10,640 --> 02:24:12,800
types of things that you can build in
3981
02:24:12,800 --> 02:24:14,720
these smart contracts many different
3982
02:24:14,720 --> 02:24:17,040
data types or just types if you go to
3983
02:24:17,040 --> 02:24:19,160
the solidity documentation at docs.
3984
02:24:19,160 --> 02:24:21,640
solidity l.org again link this in the
3985
02:24:21,640 --> 02:24:23,840
GitHub we can select the types section
3986
02:24:23,840 --> 02:24:25,680
on the left hand side to learn more
3987
02:24:25,680 --> 02:24:27,880
about solidity types if you want to get
3988
02:24:27,880 --> 02:24:29,600
a holistic view of all the different
3989
02:24:29,600 --> 02:24:31,120
types you can go ahead and read this
3990
02:24:31,120 --> 02:24:33,399
documentation some of the basic types
3991
02:24:33,399 --> 02:24:36,359
are going to be Boolean Boolean uent and
3992
02:24:36,359 --> 02:24:39,600
an address and bytes bytes is a lower
3993
02:24:39,600 --> 02:24:41,120
level type which we'll talk about in a
3994
02:24:41,120 --> 02:24:43,240
little bit a Boolean is some type of
3995
02:24:43,240 --> 02:24:46,120
true false value a uint is going to be
3996
02:24:46,120 --> 02:24:49,920
an unsigned integer AKA a positive whole
3997
02:24:49,920 --> 02:24:52,800
number meaning no decimals no fractions
3998
02:24:52,800 --> 02:24:56,040
a integer is going to be a signed whole
3999
02:24:56,040 --> 02:24:58,359
number meaning it could be positive or
4000
02:24:58,359 --> 02:25:00,880
negative but again is a whole number and
4001
02:25:00,880 --> 02:25:02,319
then we have an address which is going
4002
02:25:02,319 --> 02:25:05,000
to be well an address it's very similar
4003
02:25:05,000 --> 02:25:07,359
to if we open up our metamask and we
4004
02:25:07,359 --> 02:25:09,479
click this account here it's going to be
4005
02:25:09,479 --> 02:25:11,399
something like this there are some other
4006
02:25:11,399 --> 02:25:13,279
types as well and ways to create your
4007
02:25:13,279 --> 02:25:15,000
own custom types but we'll learn more
4008
02:25:15,000 --> 02:25:17,160
about that later on we can use these
4009
02:25:17,160 --> 02:25:19,040
different types to Define different
4010
02:25:19,040 --> 02:25:21,399
variables VAR variables are essentially
4011
02:25:21,399 --> 02:25:23,240
holders for different values and these
4012
02:25:23,240 --> 02:25:25,200
values can have one of these types for
4013
02:25:25,200 --> 02:25:26,800
example we could create a variable
4014
02:25:26,800 --> 02:25:30,880
called has favorite number which would
4015
02:25:30,880 --> 02:25:33,160
represent if somebody has a favorite
4016
02:25:33,160 --> 02:25:35,520
number this has favorite number could be
4017
02:25:35,520 --> 02:25:37,359
true or false either they do have a
4018
02:25:37,359 --> 02:25:39,640
favorite number or they don't to tell
4019
02:25:39,640 --> 02:25:41,800
solidity that this has favorite number
4020
02:25:41,800 --> 02:25:44,200
is a true false or a Boolean we would
4021
02:25:44,200 --> 02:25:46,439
add this Bull keyword before has
4022
02:25:46,439 --> 02:25:48,319
favorite number so this has favorite
4023
02:25:48,319 --> 02:25:49,600
number is going to be either true or
4024
02:25:49,600 --> 02:25:52,080
false and to set its value we're going
4025
02:25:52,080 --> 02:25:53,880
to give it this little equal sign and
4026
02:25:53,880 --> 02:25:56,720
say true so now has favorite number is a
4027
02:25:56,720 --> 02:25:59,040
variable that represents true we could
4028
02:25:59,040 --> 02:26:01,240
also say has favorite number is false
4029
02:26:01,240 --> 02:26:02,840
meaning that somebody doesn't have a
4030
02:26:02,840 --> 02:26:05,040
favorite number for a uent which again
4031
02:26:05,040 --> 02:26:07,920
is an unsigned integer we could say uint
4032
02:26:07,920 --> 02:26:11,800
favorite number equals 88 this means
4033
02:26:11,800 --> 02:26:13,560
that this variable favorite number is
4034
02:26:13,560 --> 02:26:16,680
going to be 88 a uint and int are
4035
02:26:16,680 --> 02:26:18,840
actually special in that we can actually
4036
02:26:18,840 --> 02:26:21,120
specify how many bits or bytes that we
4037
02:26:21,120 --> 02:26:23,600
want to use for example we could say U
4038
02:26:23,600 --> 02:26:26,680
256 U 256 specifies this variable
4039
02:26:26,680 --> 02:26:29,560
favorite number has 256 bits we're not
4040
02:26:29,560 --> 02:26:31,880
going to go over bits and bytes in depth
4041
02:26:31,880 --> 02:26:33,720
right now but if you want to get a quick
4042
02:26:33,720 --> 02:26:35,600
refresher we've left a link in the
4043
02:26:35,600 --> 02:26:37,359
GitHub repo associated with this course
4044
02:26:37,359 --> 02:26:40,200
to give you an overview of bits versus
4045
02:26:40,200 --> 02:26:42,600
bytes and how they work an easier way to
4046
02:26:42,600 --> 02:26:44,479
think about this is really just how big
4047
02:26:44,479 --> 02:26:46,120
can it get the bigger the number over
4048
02:26:46,120 --> 02:26:47,920
here the bigger this favorite number can
4049
02:26:47,920 --> 02:26:51,600
be the maximum size is a ENT 256 and if
4050
02:26:51,600 --> 02:26:54,840
you don't specify the U 256 it defaults
4051
02:26:54,840 --> 02:26:58,439
to being a u 256 so this and this are
4052
02:26:58,439 --> 02:27:01,319
the same thing this this same thing you
4053
02:27:01,319 --> 02:27:05,160
could also have 8 Bits 16 bits 64 bits
4054
02:27:05,160 --> 02:27:07,560
Etc often times it's better when we're
4055
02:27:07,560 --> 02:27:09,200
writing our code for a readability
4056
02:27:09,200 --> 02:27:12,479
standpoint to be as explicit as possible
4057
02:27:12,479 --> 02:27:14,080
so you'll see me pretty much always
4058
02:27:14,080 --> 02:27:16,319
writing U and 256 because I want to be
4059
02:27:16,319 --> 02:27:18,399
very explicit with how many bits I'm
4060
02:27:18,399 --> 02:27:20,439
using for U and 256 even even though
4061
02:27:20,439 --> 02:27:22,399
they mean the same thing instead of a u
4062
02:27:22,399 --> 02:27:25,000
256 we could also have this be an INT
4063
02:27:25,000 --> 02:27:27,600
256 and actually let's add that Boolean
4064
02:27:27,600 --> 02:27:30,120
back up here now an INT can actually be
4065
02:27:30,120 --> 02:27:32,359
positive or negative so we could have
4066
02:27:32,359 --> 02:27:35,560
our favorite number be88 if we wanted to
4067
02:27:35,560 --> 02:27:38,080
we can also have strings or text
4068
02:27:38,080 --> 02:27:39,800
variables which I didn't name up here
4069
02:27:39,800 --> 02:27:41,840
but I'll say why in just a minute we
4070
02:27:41,840 --> 02:27:43,840
could say string
4071
02:27:43,840 --> 02:27:48,319
favorite in text equals 88 let's
4072
02:27:48,319 --> 02:27:50,399
actually make this positive 88 even
4073
02:27:50,399 --> 02:27:51,800
though an INT could be positive or
4074
02:27:51,800 --> 02:27:53,920
negative I'll put this little semicolon
4075
02:27:53,920 --> 02:27:56,080
here you'll notice that at the end of
4076
02:27:56,080 --> 02:27:58,160
every one of these lines I'm adding this
4077
02:27:58,160 --> 02:28:00,439
semicolon the semicolon is how you can
4078
02:28:00,439 --> 02:28:02,279
tell solidity that a statement has
4079
02:28:02,279 --> 02:28:04,359
completed so this semicolon is saying
4080
02:28:04,359 --> 02:28:06,720
the end of this line is right here if we
4081
02:28:06,720 --> 02:28:09,319
wanted to we could put all of our code
4082
02:28:09,319 --> 02:28:11,560
on the same line like this and this
4083
02:28:11,560 --> 02:28:13,600
would compile fine it just looks really
4084
02:28:13,600 --> 02:28:16,279
ugly so we always want to put our code
4085
02:28:16,279 --> 02:28:19,200
on a new line after the semicolon a
4086
02:28:19,200 --> 02:28:20,640
string in solidity
4087
02:28:20,640 --> 02:28:22,840
is basically text that represents well
4088
02:28:22,840 --> 02:28:26,040
words so I could say 88 instead of
4089
02:28:26,040 --> 02:28:28,399
having 88 in here to tell solidity that
4090
02:28:28,399 --> 02:28:30,279
something is a string you have to put it
4091
02:28:30,279 --> 02:28:32,720
in between quotes I could put really any
4092
02:28:32,720 --> 02:28:34,840
combination of characters in here even
4093
02:28:34,840 --> 02:28:38,200
like hello or follow Patrick on Twitter
4094
02:28:38,200 --> 02:28:40,160
and let's actually do U in 256 here
4095
02:28:40,160 --> 02:28:43,279
favorite number and we'll do an in 256
4096
02:28:43,279 --> 02:28:47,000
favorite int equals 88 this way we'll
4097
02:28:47,000 --> 02:28:48,319
just have an example of all these
4098
02:28:48,319 --> 02:28:50,840
different types on screen we can also do
4099
02:28:50,840 --> 02:28:53,720
an address so we can say address my
4100
02:28:53,720 --> 02:28:56,399
address equals and we can go into our
4101
02:28:56,399 --> 02:28:59,600
metamask copy the address and paste it
4102
02:28:59,600 --> 02:29:02,080
right into remix and add that semicolon
4103
02:29:02,080 --> 02:29:04,120
and now we have our address type in
4104
02:29:04,120 --> 02:29:06,200
remix and then finally down here we're
4105
02:29:06,200 --> 02:29:10,880
going to say a bytes 32 object fav bytes
4106
02:29:10,880 --> 02:29:14,080
32 equals cat and we're going to put it
4107
02:29:14,080 --> 02:29:17,000
in quotes just like we did the string up
4108
02:29:17,000 --> 02:29:18,479
here and what's interesting about the
4109
02:29:18,479 --> 02:29:20,240
string object is that strings are
4110
02:29:20,240 --> 02:29:22,920
actually secretly just byes objects
4111
02:29:22,920 --> 02:29:26,120
specifically for text so a string can
4112
02:29:26,120 --> 02:29:28,080
actually get converted to a byes object
4113
02:29:28,080 --> 02:29:30,279
really easily because under the hood
4114
02:29:30,279 --> 02:29:32,160
they're essentially the same thing bites
4115
02:29:32,160 --> 02:29:33,840
typically look like something like xerx
4116
02:29:33,840 --> 02:29:35,520
and then a whole bunch of random numbers
4117
02:29:35,520 --> 02:29:38,240
and letters that represent the hex of
4118
02:29:38,240 --> 02:29:40,439
whatever the bites is and can often be
4119
02:29:40,439 --> 02:29:42,920
represented as strings like cat we'll
4120
02:29:42,920 --> 02:29:44,840
talk about btes more in the future
4121
02:29:44,840 --> 02:29:47,920
similar to U 256 and in 256 you can have
4122
02:29:47,920 --> 02:29:50,840
different size bytes like bytes 2 two
4123
02:29:50,840 --> 02:29:54,720
byes byes four byes 8 Etc all the way up
4124
02:29:54,720 --> 02:29:57,720
to 32 you can also have just straight up
4125
02:29:57,720 --> 02:30:00,720
bytes and not have a number after but
4126
02:30:00,720 --> 02:30:02,120
that's a slightly different type and
4127
02:30:02,120 --> 02:30:04,479
we'll go over that later as well a u
4128
02:30:04,479 --> 02:30:06,920
like this and a u 256 are the same thing
4129
02:30:06,920 --> 02:30:09,439
but a byes 32 and a byes with nothing
4130
02:30:09,439 --> 02:30:11,560
are actually different so keep that in
4131
02:30:11,560 --> 02:30:13,640
mind for now the largest bytes like I
4132
02:30:13,640 --> 02:30:15,960
was saying is actually 32 so for example
4133
02:30:15,960 --> 02:30:18,720
we can't do 8 bytes 64 and if we type
4134
02:30:18,720 --> 02:30:20,680
that in Here remix section goes hey
4135
02:30:20,680 --> 02:30:22,160
there's an issue here and if we try to
4136
02:30:22,160 --> 02:30:24,720
compile this we scroll down we'll again
4137
02:30:24,720 --> 02:30:27,399
see this little error code here and this
4138
02:30:27,399 --> 02:30:29,760
little error pop up it even gives us an
4139
02:30:29,760 --> 02:30:32,399
output declaration error identifier not
4140
02:30:32,399 --> 02:30:35,359
found or not unique it gives us the line
4141
02:30:35,359 --> 02:30:37,479
and we can say ah Whoops a Daisy this
4142
02:30:37,479 --> 02:30:40,160
should be a bytes 32 and we can go back
4143
02:30:40,160 --> 02:30:42,560
and compile this for our simple storage
4144
02:30:42,560 --> 02:30:44,439
contract let's say that we only want to
4145
02:30:44,439 --> 02:30:46,479
store a favorite number this contract is
4146
02:30:46,479 --> 02:30:47,960
going to be a contract that allows us to
4147
02:30:47,960 --> 02:30:49,560
store our favorite number and some
4148
02:30:49,560 --> 02:30:51,160
different people's favorite numbers as
4149
02:30:51,160 --> 02:30:52,800
well so we're going to go ahead and
4150
02:30:52,800 --> 02:30:55,760
delete everything except for the U 256
4151
02:30:55,760 --> 02:30:57,279
favorite number so we're going to go
4152
02:30:57,279 --> 02:30:59,560
ahead and delete everything and boom and
4153
02:30:59,560 --> 02:31:00,960
we'll pick a smaller favorite number
4154
02:31:00,960 --> 02:31:03,160
just to make it a little mentally easier
4155
02:31:03,160 --> 02:31:05,359
now these variables actually have
4156
02:31:05,359 --> 02:31:08,920
default values so for example if I don't
4157
02:31:08,920 --> 02:31:10,840
set my favorite number to anything and I
4158
02:31:10,840 --> 02:31:12,600
have a line that looks like this you'll
4159
02:31:12,600 --> 02:31:14,960
see that this actually compiles fine
4160
02:31:14,960 --> 02:31:16,720
favorite number will actually get
4161
02:31:16,720 --> 02:31:19,520
defaulted to zero and all of these types
4162
02:31:19,520 --> 02:31:22,960
have a different default value U 256 is
4163
02:31:22,960 --> 02:31:27,000
zero booleans is false Etc so saying U
4164
02:31:27,000 --> 02:31:29,399
256 favorite number and not having an
4165
02:31:29,399 --> 02:31:31,319
equal sign after here is the same as
4166
02:31:31,319 --> 02:31:34,120
doing U and 256 favorite number equals z
4167
02:31:34,120 --> 02:31:36,359
so for now let's not initialize it to
4168
02:31:36,359 --> 02:31:38,279
anything so that favorite number starts
4169
02:31:38,279 --> 02:31:40,680
off as zero and remember as you're
4170
02:31:40,680 --> 02:31:42,479
coding along here and typing along with
4171
02:31:42,479 --> 02:31:44,319
me if you get confused make sure to
4172
02:31:44,319 --> 02:31:46,000
write your own comments for example we
4173
02:31:46,000 --> 02:31:50,000
can say favorite number gets initial
4174
02:31:50,000 --> 02:31:56,279
ized to zero if no value is
4175
02:31:58,680 --> 02:32:00,840
given now let's go ahead and learn to
4176
02:32:00,840 --> 02:32:03,279
make our first function basic solidity
4177
02:32:03,279 --> 02:32:06,319
function section functions or methods
4178
02:32:06,319 --> 02:32:09,120
functions or methods are a subsection of
4179
02:32:09,120 --> 02:32:11,920
code that when called will execute a
4180
02:32:11,920 --> 02:32:14,920
very specific small piece of our entire
4181
02:32:14,920 --> 02:32:16,479
codebase if you're familiar with
4182
02:32:16,479 --> 02:32:18,240
JavaScript or python or any other
4183
02:32:18,240 --> 02:32:19,880
programming language functions in
4184
02:32:19,880 --> 02:32:22,399
validity are exactly the same functions
4185
02:32:22,399 --> 02:32:25,439
are identified by the keyword function
4186
02:32:25,439 --> 02:32:27,399
let's create a function and name it
4187
02:32:27,399 --> 02:32:29,479
store and we're going to have this
4188
02:32:29,479 --> 02:32:31,600
function be responsible for actually
4189
02:32:31,600 --> 02:32:33,760
updating our favorite number we're going
4190
02:32:33,760 --> 02:32:36,880
to store a new favorite number so you
4191
02:32:36,880 --> 02:32:38,600
first write the function keyword the
4192
02:32:38,600 --> 02:32:40,760
name of the function and then you add
4193
02:32:40,760 --> 02:32:43,040
these two parentheses whatever is in
4194
02:32:43,040 --> 02:32:45,279
between these two parentheses represents
4195
02:32:45,279 --> 02:32:47,920
what we're going to pass or send to our
4196
02:32:47,920 --> 02:32:49,840
function or the parameters that we're
4197
02:32:49,840 --> 02:32:51,640
we're going to send to our function for
4198
02:32:51,640 --> 02:32:53,600
example we need to tell our store
4199
02:32:53,600 --> 02:32:56,080
function what value it should use to
4200
02:32:56,080 --> 02:32:58,279
update favorite number so we're going to
4201
02:32:58,279 --> 02:33:00,359
tell our store function it should take a
4202
02:33:00,359 --> 02:33:02,359
un 256 and this variable that we're
4203
02:33:02,359 --> 02:33:03,640
going to pass to it we're going to call
4204
02:33:03,640 --> 02:33:06,720
underscore favorit number it's important
4205
02:33:06,720 --> 02:33:08,800
that we give it a different name than
4206
02:33:08,800 --> 02:33:10,439
favorite number up here and we'll talk
4207
02:33:10,439 --> 02:33:12,120
about that in a little bit then we're
4208
02:33:12,120 --> 02:33:13,319
going to say this is going to be a
4209
02:33:13,319 --> 02:33:14,960
public function and we'll explain that
4210
02:33:14,960 --> 02:33:17,000
soon too we want to put these little
4211
02:33:17,000 --> 02:33:19,319
curly brackets in here as well and we're
4212
02:33:19,319 --> 02:33:22,319
just going to say favorite number equals
4213
02:33:22,319 --> 02:33:25,279
underscore favorite number and without
4214
02:33:25,279 --> 02:33:27,120
going too deep into what this is doing
4215
02:33:27,120 --> 02:33:29,000
we're saying I'm not going to explain
4216
02:33:29,000 --> 02:33:31,319
public yet but we will in a minute but
4217
02:33:31,319 --> 02:33:33,399
what we're saying is whenever you call
4218
02:33:33,399 --> 02:33:36,120
this store function you're going to set
4219
02:33:36,120 --> 02:33:39,600
our favorite number variable to whatever
4220
02:33:39,600 --> 02:33:41,840
variable that we passed I'll explain why
4221
02:33:41,840 --> 02:33:43,960
we do this underscore here as well in a
4222
02:33:43,960 --> 02:33:45,840
little bit and with just this we can
4223
02:33:45,840 --> 02:33:47,680
actually start to simulate what this
4224
02:33:47,680 --> 02:33:49,800
smart contract will do and if our store
4225
02:33:49,800 --> 02:33:51,760
function will actually work correctly so
4226
02:33:51,760 --> 02:33:53,319
what we can do with just this code right
4227
02:33:53,319 --> 02:33:56,319
here is come over back to the compile
4228
02:33:56,319 --> 02:33:58,880
Tab and hit compile make sure that we
4229
02:33:58,880 --> 02:34:00,399
get this green check mark and that
4230
02:34:00,399 --> 02:34:02,560
everything looks good and then we can go
4231
02:34:02,560 --> 02:34:04,960
down to this deploy and run transactions
4232
02:34:04,960 --> 02:34:07,279
tab our deploy and run transactions tab
4233
02:34:07,279 --> 02:34:09,399
has a ton of different parameters in
4234
02:34:09,399 --> 02:34:11,720
here on how to actually deploy and run
4235
02:34:11,720 --> 02:34:13,760
with our transactions we're going to
4236
02:34:13,760 --> 02:34:15,960
deploy this contract to a simulated
4237
02:34:15,960 --> 02:34:18,000
virtual environment so we're going to
4238
02:34:18,000 --> 02:34:19,399
deploy it basically to a fake
4239
02:34:19,399 --> 02:34:20,479
environment we're not going to be
4240
02:34:20,479 --> 02:34:22,080
deploying it to a test net we're going
4241
02:34:22,080 --> 02:34:24,240
to deploy it basically in kind of an
4242
02:34:24,240 --> 02:34:26,520
imaginary world in order for us to do
4243
02:34:26,520 --> 02:34:29,279
this first make sure we're on this remix
4244
02:34:29,279 --> 02:34:31,439
VM and for us we're going to just use
4245
02:34:31,439 --> 02:34:33,880
the default which is the merge doesn't
4246
02:34:33,880 --> 02:34:35,680
really matter which one you're on just
4247
02:34:35,680 --> 02:34:38,640
so long as it's the remix VM this remix
4248
02:34:38,640 --> 02:34:41,040
VM is a fake local blockchain where we
4249
02:34:41,040 --> 02:34:42,640
don't have to wait for transactions to
4250
02:34:42,640 --> 02:34:44,560
complete and we don't have to deal with
4251
02:34:44,560 --> 02:34:46,720
any of the oddities on deploying our
4252
02:34:46,720 --> 02:34:49,359
code to a real test net or a real main
4253
02:34:49,359 --> 02:34:51,000
net and don't worry about the rest of
4254
02:34:51,000 --> 02:34:53,040
these for now we also get an account
4255
02:34:53,040 --> 02:34:55,640
here when we run on our fake remix VM we
4256
02:34:55,640 --> 02:34:57,359
get automatically given an account with
4257
02:34:57,359 --> 02:34:59,319
a different amount of ethereum for each
4258
02:34:59,319 --> 02:35:01,240
account you can think of each one of
4259
02:35:01,240 --> 02:35:03,600
these accounts similar to our metamask
4260
02:35:03,600 --> 02:35:05,720
accounts in metamask except for these
4261
02:35:05,720 --> 02:35:08,319
our fake imaginary accounts that remix
4262
02:35:08,319 --> 02:35:10,560
just gives to us for our transactions
4263
02:35:10,560 --> 02:35:11,960
including deploying contracts we're
4264
02:35:11,960 --> 02:35:14,160
given a gas limit values that we can
4265
02:35:14,160 --> 02:35:16,160
send and we can also choose our contract
4266
02:35:16,160 --> 02:35:18,000
depending on which one we've compiled
4267
02:35:18,000 --> 02:35:19,680
since we only have one contract in here
4268
02:35:19,680 --> 02:35:21,520
we only have one to choose from so on
4269
02:35:21,520 --> 02:35:23,240
the left hand side to deploy our
4270
02:35:23,240 --> 02:35:26,160
contract to this fake remix VM
4271
02:35:26,160 --> 02:35:27,439
environment we're going to go ahead and
4272
02:35:27,439 --> 02:35:29,880
collect the deploy button if we scroll
4273
02:35:29,880 --> 02:35:31,520
all the way down to the bottom now under
4274
02:35:31,520 --> 02:35:33,439
this deployed contracts we can see we
4275
02:35:33,439 --> 02:35:35,680
actually deployed a contract here simple
4276
02:35:35,680 --> 02:35:37,640
storage we can see the balance of zero
4277
02:35:37,640 --> 02:35:39,319
and we see this big orange button that
4278
02:35:39,319 --> 02:35:42,640
says store and then u56 favorite number
4279
02:35:42,640 --> 02:35:45,080
on our local blockchain this at blah
4280
02:35:45,080 --> 02:35:46,800
blah blah here this is going to be the
4281
02:35:46,800 --> 02:35:49,920
address of our contract similar to our
4282
02:35:49,920 --> 02:35:51,560
wallets how they have different
4283
02:35:51,560 --> 02:35:54,040
addresses every single contract has a
4284
02:35:54,040 --> 02:35:56,160
unique address as well and if we hit
4285
02:35:56,160 --> 02:35:58,000
this little copy button and we close
4286
02:35:58,000 --> 02:36:00,680
this we put as a comment here and we
4287
02:36:00,680 --> 02:36:02,720
paste it we can see this looks exactly
4288
02:36:02,720 --> 02:36:05,040
similar to an address such as what's in
4289
02:36:05,040 --> 02:36:06,960
our metamask and then let's go ahead and
4290
02:36:06,960 --> 02:36:08,439
open the deploy back up and we see that
4291
02:36:08,439 --> 02:36:10,200
deployed contract is still there
4292
02:36:10,200 --> 02:36:11,800
additionally if you hit this little show
4293
02:36:11,800 --> 02:36:14,279
terminal button and you pull this up we
4294
02:36:14,279 --> 02:36:15,600
can actually see we have this little
4295
02:36:15,600 --> 02:36:17,840
comment here creation of simple storage
4296
02:36:17,840 --> 02:36:19,880
pending and we have this green check
4297
02:36:19,880 --> 02:36:21,880
mark here this is notating that we
4298
02:36:21,880 --> 02:36:23,760
actually sent a transaction to deploy
4299
02:36:23,760 --> 02:36:25,960
this contract similar to sending eth
4300
02:36:25,960 --> 02:36:28,200
back and forth in order for us to deploy
4301
02:36:28,200 --> 02:36:29,880
a contract we actually have to send a
4302
02:36:29,880 --> 02:36:31,479
transaction since we're doing this on
4303
02:36:31,479 --> 02:36:33,279
the remix M this is a simulated
4304
02:36:33,279 --> 02:36:35,920
transaction a pretend transaction inside
4305
02:36:35,920 --> 02:36:37,960
of our remix environment you can even
4306
02:36:37,960 --> 02:36:40,240
hit the little drop down and see even
4307
02:36:40,240 --> 02:36:42,240
more information about this transaction
4308
02:36:42,240 --> 02:36:43,800
you'll see a lot of familiar keywords
4309
02:36:43,800 --> 02:36:47,520
like status transaction hash from to gas
4310
02:36:47,520 --> 02:36:50,279
Etc deploying a contract uses the exact
4311
02:36:50,279 --> 02:36:52,800
same process as sending a transaction
4312
02:36:52,800 --> 02:36:55,040
for just eth the main difference is we
4313
02:36:55,040 --> 02:36:57,240
populate this data or input field with a
4314
02:36:57,240 --> 02:37:00,120
ton of that bite code and if you copy
4315
02:37:00,120 --> 02:37:02,640
this input field or this data field and
4316
02:37:02,640 --> 02:37:04,720
go ahead and make a comment in here
4317
02:37:04,720 --> 02:37:08,640
you'll see it's a massive line and this
4318
02:37:08,640 --> 02:37:11,040
massive line notates all the data
4319
02:37:11,040 --> 02:37:13,120
associated with this smart contract all
4320
02:37:13,120 --> 02:37:16,080
the machine readable code remember
4321
02:37:16,080 --> 02:37:18,600
anytime we do anything that modifies any
4322
02:37:18,600 --> 02:37:20,319
value on the blockchain we actually do
4323
02:37:20,319 --> 02:37:22,840
that by sending a transaction deploying
4324
02:37:22,840 --> 02:37:25,200
a contract is modifying the blockchain
4325
02:37:25,200 --> 02:37:27,560
so we do it in a transaction which means
4326
02:37:27,560 --> 02:37:30,120
yes we spend gas now this big orange
4327
02:37:30,120 --> 02:37:32,040
button over here actually resembles our
4328
02:37:32,040 --> 02:37:34,720
function store in our smart contract and
4329
02:37:34,720 --> 02:37:36,439
if we add some numbers in here and we
4330
02:37:36,439 --> 02:37:39,319
call it again if we pull the terminal up
4331
02:37:39,319 --> 02:37:41,439
we can see transact to simple storage
4332
02:37:41,439 --> 02:37:43,960
pending and we see we sent a transaction
4333
02:37:43,960 --> 02:37:46,359
which called this store if we do this
4334
02:37:46,359 --> 02:37:48,560
again with a different number we call it
4335
02:37:48,560 --> 02:37:50,800
we can see our terminal say oh you sent
4336
02:37:50,800 --> 02:37:52,760
another another transaction to update
4337
02:37:52,760 --> 02:37:54,640
the state of the blockchain and if we
4338
02:37:54,640 --> 02:37:56,600
scroll all the way up to our account
4339
02:37:56,600 --> 02:37:58,319
you'll see that we have a little less
4340
02:37:58,319 --> 02:37:59,920
ether in our account because we had to
4341
02:37:59,920 --> 02:38:01,880
spend the gas associated with well a
4342
02:38:01,880 --> 02:38:03,640
deploying this contract and then B
4343
02:38:03,640 --> 02:38:05,600
calling these functions and then for
4344
02:38:05,600 --> 02:38:07,880
example if I add this if I add five in
4345
02:38:07,880 --> 02:38:09,359
here and hit store we'll send a
4346
02:38:09,359 --> 02:38:11,279
transaction to store five on the
4347
02:38:11,279 --> 02:38:12,920
blockchain now you might be thinking
4348
02:38:12,920 --> 02:38:15,240
okay Patrick that's pretty cool but what
4349
02:38:15,240 --> 02:38:16,760
is the value of favorite number you're
4350
02:38:16,760 --> 02:38:19,200
telling me that this function store is
4351
02:38:19,200 --> 02:38:21,160
up updating favorite number but I can't
4352
02:38:21,160 --> 02:38:23,000
really see it how do I know that
4353
02:38:23,000 --> 02:38:24,120
favorite number has actually been
4354
02:38:24,120 --> 02:38:26,600
updated to five well the reason we can't
4355
02:38:26,600 --> 02:38:28,600
see it is that the visibility of our
4356
02:38:28,600 --> 02:38:30,800
favorite number is actually defaulted to
4357
02:38:30,800 --> 02:38:33,720
internal so us not having anything here
4358
02:38:33,720 --> 02:38:35,880
or right internal are actually meaning
4359
02:38:35,880 --> 02:38:37,840
the same thing and we'll talk about
4360
02:38:37,840 --> 02:38:39,920
visibility and default visibilities in a
4361
02:38:39,920 --> 02:38:41,680
minute but in order for us to actually
4362
02:38:41,680 --> 02:38:43,840
see the value of our favorite number
4363
02:38:43,840 --> 02:38:45,560
we'll go ahead and add the public
4364
02:38:45,560 --> 02:38:47,760
keyword to this this changes the
4365
02:38:47,760 --> 02:38:49,479
visibility of favorite number to public
4366
02:38:49,479 --> 02:38:50,600
and like I said we'll talk about
4367
02:38:50,600 --> 02:38:52,359
visibility in a minute but let's go
4368
02:38:52,359 --> 02:38:54,399
ahead and compile this let's go ahead
4369
02:38:54,399 --> 02:38:56,760
and delete this contract by hitting this
4370
02:38:56,760 --> 02:38:59,720
x here and let's redeploy this contract
4371
02:38:59,720 --> 02:39:01,840
with this new public keyword so let's go
4372
02:39:01,840 --> 02:39:03,680
ahead and hit deploy and now if we
4373
02:39:03,680 --> 02:39:05,240
scroll down and we open up our simple
4374
02:39:05,240 --> 02:39:07,359
storage we actually now see a blue
4375
02:39:07,359 --> 02:39:09,880
button labeled favorite number and if we
4376
02:39:09,880 --> 02:39:13,200
click it now we can see it returns zero
4377
02:39:13,200 --> 02:39:15,359
which makes sense because we know that U
4378
02:39:15,359 --> 02:39:18,960
256 is default to Z now if I go ahead
4379
02:39:18,960 --> 02:39:21,240
and add five into here and hit the store
4380
02:39:21,240 --> 02:39:23,279
button if I pull up the terminal we'll
4381
02:39:23,279 --> 02:39:25,760
see that we went ahead and executed that
4382
02:39:25,760 --> 02:39:28,319
store function call that transaction
4383
02:39:28,319 --> 02:39:31,840
that's going to take input this five as
4384
02:39:31,840 --> 02:39:33,960
favorite number and set it to our
4385
02:39:33,960 --> 02:39:36,040
favorite number now if I hit favorite
4386
02:39:36,040 --> 02:39:37,840
number you can see it does indeed return
4387
02:39:37,840 --> 02:39:40,399
five showing that we actually updated
4388
02:39:40,399 --> 02:39:42,080
our favorite number with this function
4389
02:39:42,080 --> 02:39:43,960
call and remember though I'm going to go
4390
02:39:43,960 --> 02:39:45,160
ahead and do the skan and remember when
4391
02:39:45,160 --> 02:39:47,160
I hit X here this is just removing it
4392
02:39:47,160 --> 02:39:48,640
from this window here if you actually
4393
02:39:48,640 --> 02:39:50,000
deploy a smart contract to the
4394
02:39:50,000 --> 02:39:52,200
blockchain hitting X from this window
4395
02:39:52,200 --> 02:39:53,960
doesn't do anything because once you
4396
02:39:53,960 --> 02:39:55,640
deploy your contract it's immutable it's
4397
02:39:55,640 --> 02:39:56,960
out there and you can't just delete it
4398
02:39:56,960 --> 02:39:59,200
by clicking X and remix functions and
4399
02:39:59,200 --> 02:40:01,520
variables can have one of four different
4400
02:40:01,520 --> 02:40:04,800
visibility specifiers in solidity public
4401
02:40:04,800 --> 02:40:07,160
private external and internal if you
4402
02:40:07,160 --> 02:40:09,120
don't give one of these keywords to your
4403
02:40:09,120 --> 02:40:10,960
variables it'll get defaulted to
4404
02:40:10,960 --> 02:40:12,960
internal public functions mean that
4405
02:40:12,960 --> 02:40:14,880
they're visible externally and
4406
02:40:14,880 --> 02:40:16,600
internally and you'll see here it says
4407
02:40:16,600 --> 02:40:18,600
it creates a getter function for storage
4408
02:40:18,600 --> 02:40:21,160
slst State variables this means that
4409
02:40:21,160 --> 02:40:23,960
other people can call this function or
4410
02:40:23,960 --> 02:40:26,720
call this variable when we didn't have a
4411
02:40:26,720 --> 02:40:28,279
visibility for favorite number it
4412
02:40:28,279 --> 02:40:30,920
defaulted to internal which is why we
4413
02:40:30,920 --> 02:40:33,080
didn't see this blue number pop up
4414
02:40:33,080 --> 02:40:35,319
because internal it means that other
4415
02:40:35,319 --> 02:40:37,240
contracts and people aren't allowed to
4416
02:40:37,240 --> 02:40:39,279
call on this favorite number we have a
4417
02:40:39,279 --> 02:40:40,680
little bit more here it says it actually
4418
02:40:40,680 --> 02:40:43,080
creates a getter function for storage SL
4419
02:40:43,080 --> 02:40:45,439
State variables when we add this public
4420
02:40:45,439 --> 02:40:47,319
keyword here it's actually equivalent to
4421
02:40:47,319 --> 02:40:49,680
us making a getter for this favorite
4422
02:40:49,680 --> 02:40:52,000
number variable a getter function and
4423
02:40:52,000 --> 02:40:53,399
I'll show you exactly what the function
4424
02:40:53,399 --> 02:40:55,240
will look like in a little bit now keep
4425
02:40:55,240 --> 02:40:57,120
in mind though everything on chain is
4426
02:40:57,120 --> 02:40:59,359
technically public so setting a function
4427
02:40:59,359 --> 02:41:01,399
or variable to private isn't a good way
4428
02:41:01,399 --> 02:41:03,800
to hide what the value actually is there
4429
02:41:03,800 --> 02:41:05,000
and we'll talk a little bit more about
4430
02:41:05,000 --> 02:41:07,399
storage and visibility and and that much
4431
02:41:07,399 --> 02:41:09,240
later just remember everything on these
4432
02:41:09,240 --> 02:41:12,200
evm chains is actually public data this
4433
02:41:12,200 --> 02:41:13,640
public variable just means any other
4434
02:41:13,640 --> 02:41:15,800
contract can call this favorite number
4435
02:41:15,800 --> 02:41:17,240
and see the value what's in favorite
4436
02:41:17,240 --> 02:41:19,520
number and private means only the
4437
02:41:19,520 --> 02:41:21,479
current contract can external functions
4438
02:41:21,479 --> 02:41:24,000
mean they're only visible externally and
4439
02:41:24,000 --> 02:41:26,200
this is only for functions not for
4440
02:41:26,200 --> 02:41:28,040
variables and it means another function
4441
02:41:28,040 --> 02:41:29,520
inside this contract couldn't call an
4442
02:41:29,520 --> 02:41:31,279
external function and internal means
4443
02:41:31,279 --> 02:41:33,319
only the current contract and its child
4444
02:41:33,319 --> 02:41:34,960
contracts can call the function we'll
4445
02:41:34,960 --> 02:41:36,319
talk about child contracts and
4446
02:41:36,319 --> 02:41:39,000
inheritance in a later section so let's
4447
02:41:39,000 --> 02:41:40,479
just keep it public for now the reason
4448
02:41:40,479 --> 02:41:42,359
that we have this underscore here in
4449
02:41:42,359 --> 02:41:44,120
this parameter is because we need to
4450
02:41:44,120 --> 02:41:47,040
tell users that this variable in here is
4451
02:41:47,040 --> 02:41:48,840
different than favorite number and
4452
02:41:48,840 --> 02:41:50,359
there's a a couple different conventions
4453
02:41:50,359 --> 02:41:52,560
on naming local variables versus these
4454
02:41:52,560 --> 02:41:54,479
what's known as state variables or
4455
02:41:54,479 --> 02:41:56,840
variables outside of functions and we'll
4456
02:41:56,840 --> 02:41:59,279
go over those later in the course now
4457
02:41:59,279 --> 02:42:00,120
here's something that's really
4458
02:42:00,120 --> 02:42:01,720
interesting as well remember how I told
4459
02:42:01,720 --> 02:42:03,840
you earlier that sending ether is a
4460
02:42:03,840 --> 02:42:06,279
relatively simple transaction right well
4461
02:42:06,279 --> 02:42:07,960
let's see what happens when we call this
4462
02:42:07,960 --> 02:42:10,120
store function and we update favorite
4463
02:42:10,120 --> 02:42:12,000
number to five let's actually call it
4464
02:42:12,000 --> 02:42:13,880
one more time and we hit the little drop
4465
02:42:13,880 --> 02:42:17,160
down here let's go to gas and we'll see
4466
02:42:17,160 --> 02:42:20,560
gas actually cost 27,000 gas which is a
4467
02:42:20,560 --> 02:42:23,279
lot more than the 21,000 gas it costs to
4468
02:42:23,279 --> 02:42:25,240
just send ether between accounts
4469
02:42:25,240 --> 02:42:27,920
remember every time you update the state
4470
02:42:27,920 --> 02:42:30,840
of the blockchain it's going to cost gas
4471
02:42:30,840 --> 02:42:32,279
now what do you think will happen if we
4472
02:42:32,279 --> 02:42:34,720
do more inside of this store function
4473
02:42:34,720 --> 02:42:37,880
for example we say favorite number
4474
02:42:37,880 --> 02:42:41,920
equals itself + 1 let's go ahead and
4475
02:42:41,920 --> 02:42:44,560
compile this let's delete our old simple
4476
02:42:44,560 --> 02:42:47,080
storage let's deploy this new one
4477
02:42:47,080 --> 02:42:50,000
remember the last one cost 27 gas let's
4478
02:42:50,000 --> 02:42:52,080
pull up the terminal and remix actually
4479
02:42:52,080 --> 02:42:54,399
gives us a little tool tip and it's
4480
02:42:54,399 --> 02:42:56,640
saying an infinite gas which we know is
4481
02:42:56,640 --> 02:42:58,520
actually wrong but let's go ahead and
4482
02:42:58,520 --> 02:43:00,080
add one two 3 in here and we'll hit
4483
02:43:00,080 --> 02:43:02,600
store we'll see this transaction we'll
4484
02:43:02,600 --> 02:43:05,760
scroll down we'll see gas is actually a
4485
02:43:05,760 --> 02:43:09,040
lot more it's way more gas it's 50,000
4486
02:43:09,040 --> 02:43:11,520
gas with just adding this line here now
4487
02:43:11,520 --> 02:43:13,160
technically I'm not telling the full
4488
02:43:13,160 --> 02:43:14,800
story here because there are some other
4489
02:43:14,800 --> 02:43:16,359
gas costs associated with the first time
4490
02:43:16,359 --> 02:43:18,960
you run a function but it's still more
4491
02:43:18,960 --> 02:43:20,359
right and that's what's important here
4492
02:43:20,359 --> 02:43:22,120
so so let's go ahead and delete that
4493
02:43:22,120 --> 02:43:24,200
line and go back to our old function
4494
02:43:24,200 --> 02:43:25,800
here now let's talk about something
4495
02:43:25,800 --> 02:43:28,640
called scope for a second so if I create
4496
02:43:28,640 --> 02:43:32,720
a variable in here called U 256 test VAR
4497
02:43:32,720 --> 02:43:35,760
equals 5 and I create a new function
4498
02:43:35,760 --> 02:43:38,880
called something make it public could I
4499
02:43:38,880 --> 02:43:40,479
access the test bar and then maybe
4500
02:43:40,479 --> 02:43:42,640
change it to six or seven what about the
4501
02:43:42,640 --> 02:43:44,359
favorite number VAR what about the
4502
02:43:44,359 --> 02:43:46,279
favorite number variable could I access
4503
02:43:46,279 --> 02:43:48,120
that to seven well let's go ahead and
4504
02:43:48,120 --> 02:43:49,560
see what happens if we try to compile
4505
02:43:49,560 --> 02:43:51,479
this we try to compile we actually go
4506
02:43:51,479 --> 02:43:52,800
ahead and get an error in our
4507
02:43:52,800 --> 02:43:55,120
compilation Undeclared identifier
4508
02:43:55,120 --> 02:43:56,760
whenever you create a variable it can
4509
02:43:56,760 --> 02:43:58,840
only be viewed in the scope of where it
4510
02:43:58,840 --> 02:44:00,840
is if that's confusing just look for the
4511
02:44:00,840 --> 02:44:02,920
curly brackets the reason that our
4512
02:44:02,920 --> 02:44:06,399
something function can read the testar
4513
02:44:06,399 --> 02:44:09,399
is because this testar isn't inside of
4514
02:44:09,399 --> 02:44:11,359
the curly brackets of something the
4515
02:44:11,359 --> 02:44:13,000
reason it can't read the testar is
4516
02:44:13,000 --> 02:44:15,240
because testar was created way up here
4517
02:44:15,240 --> 02:44:18,000
inside of these curly brackets outside
4518
02:44:18,000 --> 02:44:20,840
of something but favorite number wasn't
4519
02:44:20,840 --> 02:44:22,520
created inside of these curly brackets
4520
02:44:22,520 --> 02:44:24,120
so how come it knows what favorite
4521
02:44:24,120 --> 02:44:27,479
number is well something is inside of
4522
02:44:27,479 --> 02:44:29,640
these curly brackets and favorite number
4523
02:44:29,640 --> 02:44:31,600
was created inside of all of these curly
4524
02:44:31,600 --> 02:44:34,279
brackets if favorite number was created
4525
02:44:34,279 --> 02:44:36,560
inside of here it wouldn't be able to
4526
02:44:36,560 --> 02:44:38,800
access favorite number because again
4527
02:44:38,800 --> 02:44:41,560
favorite number is inside of this scope
4528
02:44:41,560 --> 02:44:44,120
and not this scope if you create a
4529
02:44:44,120 --> 02:44:46,520
variable like testar inside of store you
4530
02:44:46,520 --> 02:44:49,279
can only access this testar inside of
4531
02:44:49,279 --> 02:44:51,040
this store function and not anywhere
4532
02:44:51,040 --> 02:44:53,319
else the easy way to know what the scope
4533
02:44:53,319 --> 02:44:54,920
of a variable is is just look for the
4534
02:44:54,920 --> 02:44:56,880
curly brackets so let's go ahead and
4535
02:44:56,880 --> 02:44:59,359
delete this something variable and let's
4536
02:44:59,359 --> 02:45:02,120
delete this test far and let's recompile
4537
02:45:02,120 --> 02:45:04,080
now like we were saying earlier when we
4538
02:45:04,080 --> 02:45:05,800
add this public keyword to favorite
4539
02:45:05,800 --> 02:45:08,080
number it's the exact same as if we
4540
02:45:08,080 --> 02:45:10,920
created a getter function to return this
4541
02:45:10,920 --> 02:45:12,479
favorite number so let's actually write
4542
02:45:12,479 --> 02:45:14,279
a function similar to what this public
4543
02:45:14,279 --> 02:45:16,040
keyword is creating so we're going to
4544
02:45:16,040 --> 02:45:19,720
say function retrieve make this a public
4545
02:45:19,720 --> 02:45:21,600
view function and we'll talk about that
4546
02:45:21,600 --> 02:45:23,960
in just a second and we'll say it
4547
02:45:23,960 --> 02:45:27,200
returns a uint 256 and we'll add the
4548
02:45:27,200 --> 02:45:30,000
curly braces here and we'll say return
4549
02:45:30,000 --> 02:45:32,680
favorit number and often times when
4550
02:45:32,680 --> 02:45:34,960
these Auto suggestions come up like this
4551
02:45:34,960 --> 02:45:36,399
you just hit enter and they will
4552
02:45:36,399 --> 02:45:39,200
automatically do it so if we do favorit
4553
02:45:39,200 --> 02:45:41,240
and then I just hit enter boom
4554
02:45:41,240 --> 02:45:43,080
automatically like that now I'm going to
4555
02:45:43,080 --> 02:45:45,160
hit command s which is equivalent to me
4556
02:45:45,160 --> 02:45:46,600
going to the compile Tab and hitting
4557
02:45:46,600 --> 02:45:49,520
compile now if I go to the deploy Tab
4558
02:45:49,520 --> 02:45:52,160
and let's deploy this contract now we
4559
02:45:52,160 --> 02:45:54,279
scroll down we now see we still have
4560
02:45:54,279 --> 02:45:56,120
that store function we have our favorite
4561
02:45:56,120 --> 02:45:57,840
number function and we have a new blue
4562
02:45:57,840 --> 02:46:00,120
button called retrieve right now they
4563
02:46:00,120 --> 02:46:01,760
both start off as zero and then
4564
02:46:01,760 --> 02:46:03,560
obviously if we update this to five by
4565
02:46:03,560 --> 02:46:06,520
calling store yep I called store these
4566
02:46:06,520 --> 02:46:08,640
now both return five since favorite
4567
02:46:08,640 --> 02:46:10,840
number is the actual variable and
4568
02:46:10,840 --> 02:46:12,640
retrieve is just returning whatever
4569
02:46:12,640 --> 02:46:14,319
favorite number is now as you can see
4570
02:46:14,319 --> 02:46:16,399
here these two functions are blue but
4571
02:46:16,399 --> 02:46:18,960
this one is Orange what's the difference
4572
02:46:18,960 --> 02:46:21,080
why are the colors different well the
4573
02:46:21,080 --> 02:46:23,479
key is actually with this view keyword
4574
02:46:23,479 --> 02:46:26,399
here solidity has a special keyword
4575
02:46:26,399 --> 02:46:29,319
which notates functions that don't
4576
02:46:29,319 --> 02:46:31,279
actually have to run or don't actually
4577
02:46:31,279 --> 02:46:33,160
have to send a transaction for you to
4578
02:46:33,160 --> 02:46:35,080
call them and those two keywords are
4579
02:46:35,080 --> 02:46:38,080
going to be View and pure a function
4580
02:46:38,080 --> 02:46:40,000
marked view means we're just going to
4581
02:46:40,000 --> 02:46:42,680
read state from the blockchain for
4582
02:46:42,680 --> 02:46:45,040
example in our retrieve function we're
4583
02:46:45,040 --> 02:46:47,040
just going to read what the favorite
4584
02:46:47,040 --> 02:46:50,760
number variable is our store function
4585
02:46:50,760 --> 02:46:53,560
isn't reading it's updating something so
4586
02:46:53,560 --> 02:46:54,800
and it's changing the state of the
4587
02:46:54,800 --> 02:46:56,240
blockchain so we have to send a
4588
02:46:56,240 --> 02:46:58,720
transaction since our retrieve function
4589
02:46:58,720 --> 02:47:00,200
doesn't have anything inside here that
4590
02:47:00,200 --> 02:47:02,319
updates anything it just returns
4591
02:47:02,319 --> 02:47:05,000
favorite number we don't need to send a
4592
02:47:05,000 --> 02:47:07,200
transaction so if you add this view
4593
02:47:07,200 --> 02:47:09,160
function in here it disallows any
4594
02:47:09,160 --> 02:47:11,840
modification of State for example I
4595
02:47:11,840 --> 02:47:14,880
couldn't add favorit number equals
4596
02:47:14,880 --> 02:47:18,040
favorit number + one if we go ahead and
4597
02:47:18,040 --> 02:47:20,439
try to compile this we'll get an error
4598
02:47:20,439 --> 02:47:22,520
function cannot be declared as view
4599
02:47:22,520 --> 02:47:24,080
because this expression potentially
4600
02:47:24,080 --> 02:47:26,279
modifies state so we'd have to remove
4601
02:47:26,279 --> 02:47:28,680
this line or we'd have to remove the
4602
02:47:28,680 --> 02:47:31,520
view keyword so view functions disallow
4603
02:47:31,520 --> 02:47:34,479
updating State your functions disallow
4604
02:47:34,479 --> 02:47:37,359
updating State and they disallow even
4605
02:47:37,359 --> 02:47:40,200
reading from state or storage this
4606
02:47:40,200 --> 02:47:41,840
favorite number here is what's known as
4607
02:47:41,840 --> 02:47:44,399
a storage variable because it's stored
4608
02:47:44,399 --> 02:47:47,200
in a place called storage we'll talk
4609
02:47:47,200 --> 02:47:49,680
about that in a later section but if
4610
02:47:49,680 --> 02:47:52,720
this was labeled pure we'd see we get a
4611
02:47:52,720 --> 02:47:55,200
little red underscore here because
4612
02:47:55,200 --> 02:47:57,240
favorite number is reading from State
4613
02:47:57,240 --> 02:47:58,840
instead of returning favorite number we
4614
02:47:58,840 --> 02:48:01,160
would return something like seven so
4615
02:48:01,160 --> 02:48:02,439
this would be an example of a pure
4616
02:48:02,439 --> 02:48:05,080
function this would be an example of a
4617
02:48:05,080 --> 02:48:07,160
view function because we're reading from
4618
02:48:07,160 --> 02:48:09,399
State again we'll explain the difference
4619
02:48:09,399 --> 02:48:11,560
a little bit later and like I was saying
4620
02:48:11,560 --> 02:48:13,760
before if we call a view or a pure
4621
02:48:13,760 --> 02:48:15,680
function we actually don't need to spend
4622
02:48:15,680 --> 02:48:17,840
gas since we're not modifying the state
4623
02:48:17,840 --> 02:48:19,279
that's why these buttons over here are
4624
02:48:19,279 --> 02:48:22,240
blue they're representing view or pure
4625
02:48:22,240 --> 02:48:23,920
functions functions that we can call
4626
02:48:23,920 --> 02:48:26,080
without having to send a transaction for
4627
02:48:26,080 --> 02:48:28,200
example if I pull up the terminal here
4628
02:48:28,200 --> 02:48:31,000
and I pull this up and I call retrieve
4629
02:48:31,000 --> 02:48:33,080
we do get another function but it's just
4630
02:48:33,080 --> 02:48:35,279
a call and it looks different than if I
4631
02:48:35,279 --> 02:48:37,240
hit the store which has this little
4632
02:48:37,240 --> 02:48:39,160
check mark they're different because the
4633
02:48:39,160 --> 02:48:41,640
store is obviously sending a transaction
4634
02:48:41,640 --> 02:48:43,640
and the retrieve is actually just making
4635
02:48:43,640 --> 02:48:45,800
a call and not sending a
4636
02:48:45,800 --> 02:48:47,720
transaction however something weird is
4637
02:48:47,720 --> 02:48:50,200
going on here if I hit retrieve and I go
4638
02:48:50,200 --> 02:48:53,240
into the details of this call I can see
4639
02:48:53,240 --> 02:48:55,160
oh what's what's this why is there an
4640
02:48:55,160 --> 02:48:58,080
execution cost it says cost only applies
4641
02:48:58,080 --> 02:48:59,720
when called by a contract what's going
4642
02:48:59,720 --> 02:49:01,880
on there the reason for that is because
4643
02:49:01,880 --> 02:49:04,240
if another function that does update
4644
02:49:04,240 --> 02:49:06,600
state that does require a transaction
4645
02:49:06,600 --> 02:49:09,600
calls retrieve that transaction does
4646
02:49:09,600 --> 02:49:12,080
need to pay the gas of reading and
4647
02:49:12,080 --> 02:49:14,479
calling this retrieve function so
4648
02:49:14,479 --> 02:49:16,439
calling a view or a pure function
4649
02:49:16,439 --> 02:49:20,800
actually does cost gas only when a gas
4650
02:49:20,800 --> 02:49:23,720
cost transaction is calling it so we can
4651
02:49:23,720 --> 02:49:25,160
go ahead and call these as much as we
4652
02:49:25,160 --> 02:49:27,600
want it costs nothing but if another
4653
02:49:27,600 --> 02:49:29,399
function that does cost gas calls it
4654
02:49:29,399 --> 02:49:31,720
it's going to cost something for example
4655
02:49:31,720 --> 02:49:33,800
if our function store here then went
4656
02:49:33,800 --> 02:49:36,479
ahead and called retrieve like this
4657
02:49:36,479 --> 02:49:38,800
since store cost gas you're telling this
4658
02:49:38,800 --> 02:49:41,080
function hey also call this retrieve
4659
02:49:41,080 --> 02:49:43,319
function which is more work for it to do
4660
02:49:43,319 --> 02:49:44,640
and since it's more work it's going to
4661
02:49:44,640 --> 02:49:47,359
cost more gas so for example if we
4662
02:49:47,359 --> 02:49:49,399
delete this contract over here let's go
4663
02:49:49,399 --> 02:49:51,319
ahead and compile this let's go ahead
4664
02:49:51,319 --> 02:49:53,319
and deploy this with this retrieve in
4665
02:49:53,319 --> 02:49:55,520
here so let's go ahead and look at these
4666
02:49:55,520 --> 02:49:57,720
These are now zero we'll store five in
4667
02:49:57,720 --> 02:49:59,920
here we'll select the drop down we can
4668
02:49:59,920 --> 02:50:02,520
see how much gas we actually sent 50,000
4669
02:50:02,520 --> 02:50:04,520
gas let's go ahead and drop this now
4670
02:50:04,520 --> 02:50:06,800
close this out let's remove the retrieve
4671
02:50:06,800 --> 02:50:10,000
line let's compile we'll hit deploy
4672
02:50:10,000 --> 02:50:12,399
simple storage these are both zero We'll
4673
02:50:12,399 --> 02:50:15,640
add five it's store pull up the terminal
4674
02:50:15,640 --> 02:50:18,040
hit the drop down look at gas it's still
4675
02:50:18,040 --> 02:50:19,800
$50,000 but it's actually a little bit
4676
02:50:19,800 --> 02:50:21,640
less than before although I'm pointing
4677
02:50:21,640 --> 02:50:23,520
at gas we really should be looking at
4678
02:50:23,520 --> 02:50:25,960
transaction cost because gas is really
4679
02:50:25,960 --> 02:50:27,880
just actually how much we're sending
4680
02:50:27,880 --> 02:50:29,920
whereas transaction cost is how much gas
4681
02:50:29,920 --> 02:50:33,040
the transaction actually cost but in any
4682
02:50:33,040 --> 02:50:35,640
case it was a little bit less without
4683
02:50:35,640 --> 02:50:38,120
the retrieve function now I've kind of
4684
02:50:38,120 --> 02:50:39,720
been glossing over this a little bit but
4685
02:50:39,720 --> 02:50:42,479
this returns keyword specifies what this
4686
02:50:42,479 --> 02:50:44,160
function is going to give us when we
4687
02:50:44,160 --> 02:50:46,680
call it so when we have this returns
4688
02:50:46,680 --> 02:50:49,000
keyword in our retrieve function here
4689
02:50:49,000 --> 02:50:50,560
we're saying whenever we call this
4690
02:50:50,560 --> 02:50:52,560
retrieve function we want to get
4691
02:50:52,560 --> 02:50:55,000
returned or we want to be given this
4692
02:50:55,000 --> 02:50:58,239
favorite number of Type U 256 we want to
4693
02:50:58,239 --> 02:51:02,239
return a unu 256 from this
4694
02:51:04,640 --> 02:51:07,800
function now our contract as is is
4695
02:51:07,800 --> 02:51:09,640
pretty good it does one thing pretty
4696
02:51:09,640 --> 02:51:12,560
well it's it allows us to store our
4697
02:51:12,560 --> 02:51:14,520
favorite number update that favorite
4698
02:51:14,520 --> 02:51:16,200
number and then view that favorite
4699
02:51:16,200 --> 02:51:18,279
number and in fact let's go ahead and
4700
02:51:18,279 --> 02:51:21,319
make this an internal variable and we'll
4701
02:51:21,319 --> 02:51:23,479
have the retrieve function be the way to
4702
02:51:23,479 --> 02:51:26,000
get this we can have this public but for
4703
02:51:26,000 --> 02:51:27,720
now we're going to set it up like this
4704
02:51:27,720 --> 02:51:28,960
and I'll tell you why we're going to set
4705
02:51:28,960 --> 02:51:31,160
it up like that in the future but what
4706
02:51:31,160 --> 02:51:32,880
if we wanted to be able to store not
4707
02:51:32,880 --> 02:51:34,680
just our favorite number but other
4708
02:51:34,680 --> 02:51:36,720
people's favorite numbers as well well
4709
02:51:36,720 --> 02:51:38,800
what we could do is we could create
4710
02:51:38,800 --> 02:51:41,640
something called an array or a list of
4711
02:51:41,640 --> 02:51:43,800
favorite numbers what we could do is we
4712
02:51:43,800 --> 02:51:47,279
could say instead of just one uent 256
4713
02:51:47,279 --> 02:51:50,120
we could have a list of un 256 called
4714
02:51:50,120 --> 02:51:54,160
list of favorite numbers this bracket
4715
02:51:54,160 --> 02:51:56,439
syntax here identifies that we have a
4716
02:51:56,439 --> 02:52:00,040
list of un 256 or a list of numbers or
4717
02:52:00,040 --> 02:52:02,560
an array of numbers an array of numbers
4718
02:52:02,560 --> 02:52:04,239
is going to look something like this
4719
02:52:04,239 --> 02:52:05,920
it's going to have maybe the first
4720
02:52:05,920 --> 02:52:07,640
element is going to be zero maybe the
4721
02:52:07,640 --> 02:52:10,200
second favorite number is going to be 78
4722
02:52:10,200 --> 02:52:11,439
maybe the third favorite number is going
4723
02:52:11,439 --> 02:52:14,600
to be 90 now arrays are very common in
4724
02:52:14,600 --> 02:52:16,279
computer science and programming and an
4725
02:52:16,279 --> 02:52:18,600
array in solidity is exactly the same as
4726
02:52:18,600 --> 02:52:20,160
an array in any other programming
4727
02:52:20,160 --> 02:52:22,120
language if you're unfamiliar with
4728
02:52:22,120 --> 02:52:24,960
arrays arrays or lists are actually zero
4729
02:52:24,960 --> 02:52:28,040
indexed so the zero here is actually at
4730
02:52:28,040 --> 02:52:31,120
index zero so we refer to this object
4731
02:52:31,120 --> 02:52:33,439
here as the zero withth object right
4732
02:52:33,439 --> 02:52:35,640
this could be 77 and this would be the
4733
02:52:35,640 --> 02:52:38,439
zero withth object the 78 is going to be
4734
02:52:38,439 --> 02:52:40,439
the first element the 90 is going to be
4735
02:52:40,439 --> 02:52:42,160
the second element and so on and so
4736
02:52:42,160 --> 02:52:43,960
forth it's very common in computer
4737
02:52:43,960 --> 02:52:45,399
science to actually start counting from
4738
02:52:45,399 --> 02:52:47,520
the number zero and arrays start
4739
02:52:47,520 --> 02:52:49,399
counting from the number Z we'll learn
4740
02:52:49,399 --> 02:52:51,640
to play around with arrays more in just
4741
02:52:51,640 --> 02:52:53,319
a minute so this list of favorite
4742
02:52:53,319 --> 02:52:56,760
numbers is great but how do we know who
4743
02:52:56,760 --> 02:52:59,160
favorite number each section is this is
4744
02:52:59,160 --> 02:53:01,200
our list of favorite numbers how do we
4745
02:53:01,200 --> 02:53:05,239
know who zero is who 78 is who 90 is ETC
4746
02:53:05,239 --> 02:53:07,279
well maybe what we would do instead of
4747
02:53:07,279 --> 02:53:08,960
just having a raw list like this let's
4748
02:53:08,960 --> 02:53:10,880
go ahead and comment this line out maybe
4749
02:53:10,880 --> 02:53:12,760
we could create a new type called a
4750
02:53:12,760 --> 02:53:14,720
person in solidity you can actually
4751
02:53:14,720 --> 02:53:17,479
create your own types using the struct
4752
02:53:17,479 --> 02:53:19,720
keyword so we're going to say struct
4753
02:53:19,720 --> 02:53:22,800
person and do little curly brackets like
4754
02:53:22,800 --> 02:53:25,279
this inside of these curly brackets we
4755
02:53:25,279 --> 02:53:27,560
can Define what this struct person
4756
02:53:27,560 --> 02:53:30,200
custom type is comprised of and we're
4757
02:53:30,200 --> 02:53:32,439
going to say for every person they're
4758
02:53:32,439 --> 02:53:36,520
going to have a u 256 favorite number
4759
02:53:36,520 --> 02:53:39,080
and a string name now something
4760
02:53:39,080 --> 02:53:41,600
important to note is oh whoops we have
4761
02:53:41,600 --> 02:53:43,600
two favorite numbers here remember what
4762
02:53:43,600 --> 02:53:46,239
we learned about scope since this
4763
02:53:46,239 --> 02:53:49,000
favorite number is inside of these curly
4764
02:53:49,000 --> 02:53:51,880
brackets these would Clash a little bit
4765
02:53:51,880 --> 02:53:53,920
so what we're going to do instead is
4766
02:53:53,920 --> 02:53:55,840
we're going to rename favorite number up
4767
02:53:55,840 --> 02:53:58,760
here to my favorite number and we're
4768
02:53:58,760 --> 02:54:00,760
going to copy paste that down here as
4769
02:54:00,760 --> 02:54:03,720
well so we're we're renaming this state
4770
02:54:03,720 --> 02:54:05,640
variable this storage variable to my
4771
02:54:05,640 --> 02:54:07,560
favorite number and just keeping it down
4772
02:54:07,560 --> 02:54:08,880
here that way we can have favorite
4773
02:54:08,880 --> 02:54:10,880
number inside of this struct in any case
4774
02:54:10,880 --> 02:54:13,720
we created this new type of type person
4775
02:54:13,720 --> 02:54:16,680
which is a combination of each person
4776
02:54:16,680 --> 02:54:18,520
has a favorite number and each person
4777
02:54:18,520 --> 02:54:20,920
also has a name now similar to how we
4778
02:54:20,920 --> 02:54:23,920
can have a u 256 a Boolean a string and
4779
02:54:23,920 --> 02:54:27,600
in 256 Etc we now have a type of person
4780
02:54:27,600 --> 02:54:30,439
and this is similar to each one of these
4781
02:54:30,439 --> 02:54:31,760
oh and we're also going to have to
4782
02:54:31,760 --> 02:54:34,040
update the retrieve down here with my
4783
02:54:34,040 --> 02:54:35,399
favorite number instead of favorite
4784
02:54:35,399 --> 02:54:37,720
number now since we have our own new
4785
02:54:37,720 --> 02:54:39,880
type we can actually create a variable
4786
02:54:39,880 --> 02:54:42,120
of type person the exact same way we
4787
02:54:42,120 --> 02:54:44,000
created a variable of type my favorite
4788
02:54:44,000 --> 02:54:47,239
number so we could say person visibility
4789
02:54:47,239 --> 02:54:50,720
will be public my friend equals and
4790
02:54:50,720 --> 02:54:52,920
we'll put person here and put some
4791
02:54:52,920 --> 02:54:54,880
parentheses here because when you're
4792
02:54:54,880 --> 02:54:56,760
working with custom types you have to
4793
02:54:56,760 --> 02:54:58,840
Define both on the left side and on the
4794
02:54:58,840 --> 02:55:01,279
right side what type it is and in here
4795
02:55:01,279 --> 02:55:03,359
we would assign a favorite number and a
4796
02:55:03,359 --> 02:55:07,560
name so we could say seven and Pat like
4797
02:55:07,560 --> 02:55:11,200
that so now Pat is going to be a person
4798
02:55:11,200 --> 02:55:13,640
with a favorite number of seven and a
4799
02:55:13,640 --> 02:55:17,239
name of Pat see the first parameter goes
4800
02:55:17,239 --> 02:55:18,880
to the first
4801
02:55:18,880 --> 02:55:21,200
item in the person struct and the second
4802
02:55:21,200 --> 02:55:23,840
parameter goes to the second item I like
4803
02:55:23,840 --> 02:55:26,279
being a little bit more explicit when
4804
02:55:26,279 --> 02:55:28,000
working with structs and actually what
4805
02:55:28,000 --> 02:55:29,760
you can do is you can put little
4806
02:55:29,760 --> 02:55:32,880
brackets here instead and you can say
4807
02:55:32,880 --> 02:55:35,720
exactly what value you're going to
4808
02:55:35,720 --> 02:55:38,760
assign to what section so I can say
4809
02:55:38,760 --> 02:55:42,279
favorite number is going to be seven and
4810
02:55:42,279 --> 02:55:45,560
name is going to be that and we can hit
4811
02:55:45,560 --> 02:55:47,800
command s or just go straight to compile
4812
02:55:47,800 --> 02:55:49,439
to see if it worked correctly get that
4813
02:55:49,439 --> 02:55:51,439
little green check mark Now by doing
4814
02:55:51,439 --> 02:55:54,000
this we've created our own type person
4815
02:55:54,000 --> 02:55:56,439
and we've created a variable named Pat
4816
02:55:56,439 --> 02:55:58,239
with a favorite number of seven and a
4817
02:55:58,239 --> 02:56:01,800
name of Pat now if we were to go ahead
4818
02:56:01,800 --> 02:56:03,760
let's delete this old simple storage and
4819
02:56:03,760 --> 02:56:06,399
let's deploy our new simple storage we
4820
02:56:06,399 --> 02:56:08,479
scroll down we now have a new blue
4821
02:56:08,479 --> 02:56:10,560
button since this is a public variable
4822
02:56:10,560 --> 02:56:12,880
called Pat and if we click the button if
4823
02:56:12,880 --> 02:56:16,319
we call this variable we'll see favorite
4824
02:56:16,319 --> 02:56:19,800
number of seven and string name Pat you
4825
02:56:19,800 --> 02:56:22,000
can also see this zero and this one
4826
02:56:22,000 --> 02:56:23,840
which shows the index of each one of
4827
02:56:23,840 --> 02:56:26,680
these variables or parameters zero is
4828
02:56:26,680 --> 02:56:29,439
for favorite number one is for name if
4829
02:56:29,439 --> 02:56:33,080
we added another one maybe bull is cool
4830
02:56:33,080 --> 02:56:35,560
bull is cool would be at index 2
4831
02:56:35,560 --> 02:56:37,640
whenever you create a custom type like
4832
02:56:37,640 --> 02:56:40,399
this solidity will automatically index
4833
02:56:40,399 --> 02:56:42,640
them similar to the way that we index
4834
02:56:42,640 --> 02:56:44,760
our list or our Rays favorite number
4835
02:56:44,760 --> 02:56:47,600
zero name one whatever is next would be
4836
02:56:47,600 --> 02:56:50,479
two EX Etc now this is great for one
4837
02:56:50,479 --> 02:56:52,120
friend but what if you have a lot of
4838
02:56:52,120 --> 02:56:54,239
friends which I know a lot of you do
4839
02:56:54,239 --> 02:56:55,439
because you're taking this course which
4840
02:56:55,439 --> 02:56:57,319
automatically means you're cool maybe
4841
02:56:57,319 --> 02:56:59,200
what if you have your friend Mariah that
4842
02:56:59,200 --> 02:57:00,960
you would like to add to our smart
4843
02:57:00,960 --> 02:57:02,560
contract like this and her favorite
4844
02:57:02,560 --> 02:57:05,760
number is 16 or maybe your friend John
4845
02:57:05,760 --> 02:57:08,279
you'd have to copy paste the line add JN
4846
02:57:08,279 --> 02:57:10,120
in here his favorite number is going to
4847
02:57:10,120 --> 02:57:13,279
be 12 so on and so forth it might get
4848
02:57:13,279 --> 02:57:15,960
very tedious to have to write variables
4849
02:57:15,960 --> 02:57:18,479
for all of these people for all these
4850
02:57:18,479 --> 02:57:20,880
friends this obviously isn't a great way
4851
02:57:20,880 --> 02:57:22,680
for us to create lists of people or
4852
02:57:22,680 --> 02:57:24,600
lists of our friends so instead of this
4853
02:57:24,600 --> 02:57:27,120
we can actually use this array syntax
4854
02:57:27,120 --> 02:57:29,640
that we just learned and create an array
4855
02:57:29,640 --> 02:57:33,399
of person or a list of persons so I'm
4856
02:57:33,399 --> 02:57:35,399
going to comment all these out for now
4857
02:57:35,399 --> 02:57:37,399
and a quick tip here if you're on a Mac
4858
02:57:37,399 --> 02:57:39,439
and you highlight a couple if you're on
4859
02:57:39,439 --> 02:57:41,840
a Mac and you hit command backslash or
4860
02:57:41,840 --> 02:57:43,600
command question mark it'll
4861
02:57:43,600 --> 02:57:45,960
automatically comment or uncomment those
4862
02:57:45,960 --> 02:57:47,840
lines if you're on a Windows I believe
4863
02:57:47,840 --> 02:57:50,800
it is control slash but you might be
4864
02:57:50,800 --> 02:57:52,439
able to Google what the actual keyboard
4865
02:57:52,439 --> 02:57:54,319
shortcut is this is a keyboard shortcut
4866
02:57:54,319 --> 02:57:56,239
I use all the time so what we're going
4867
02:57:56,239 --> 02:57:58,160
to do now is we're going to create a
4868
02:57:58,160 --> 02:58:01,160
list or an array of persons so exact
4869
02:58:01,160 --> 02:58:03,720
same as we did it up here we'll say our
4870
02:58:03,720 --> 02:58:06,439
type first is going to be type person
4871
02:58:06,439 --> 02:58:09,319
array so we're type person array then
4872
02:58:09,319 --> 02:58:11,560
we'll State our visibility which is
4873
02:58:11,560 --> 02:58:14,200
going to be public then we'll get our
4874
02:58:14,200 --> 02:58:16,720
variable name which is going to be list
4875
02:58:16,720 --> 02:58:20,120
of people like this so we've created a
4876
02:58:20,120 --> 02:58:22,840
person array with visibility public and
4877
02:58:22,840 --> 02:58:25,239
the name list of people and we'll just
4878
02:58:25,239 --> 02:58:27,560
leave it blank for now so it'll get
4879
02:58:27,560 --> 02:58:30,560
defaulted to being an empty list which
4880
02:58:30,560 --> 02:58:32,520
would look like this now if I were to go
4881
02:58:32,520 --> 02:58:34,680
ahead and deploy this let's delete the
4882
02:58:34,680 --> 02:58:39,080
last one let's compile deploy we scroll
4883
02:58:39,080 --> 02:58:42,120
down we select this we now see we have
4884
02:58:42,120 --> 02:58:43,920
our retrieve blue button and we also
4885
02:58:43,920 --> 02:58:45,920
have this blue button for list of people
4886
02:58:45,920 --> 02:58:47,640
when you create arrays with a public
4887
02:58:47,640 --> 02:58:48,640
keyword
4888
02:58:48,640 --> 02:58:50,399
instead of being able to see the whole
4889
02:58:50,399 --> 02:58:52,880
array with this list of people button
4890
02:58:52,880 --> 02:58:55,640
you actually have to put in the index of
4891
02:58:55,640 --> 02:58:57,080
the elements you want to work with and
4892
02:58:57,080 --> 02:58:59,279
you get to see that exact element it
4893
02:58:59,279 --> 02:59:01,600
wants to take a u 256 as an input
4894
02:59:01,600 --> 02:59:04,279
parameter however obviously our array is
4895
02:59:04,279 --> 02:59:06,640
blank so if we say what is the person at
4896
02:59:06,640 --> 02:59:09,239
the zeroth index it'll say well nothing
4897
02:59:09,239 --> 02:59:11,080
because you have a blank array well what
4898
02:59:11,080 --> 02:59:13,239
about the first index well nothing what
4899
02:59:13,239 --> 02:59:15,279
about the second one well nothing no
4900
02:59:15,279 --> 02:59:17,040
matter what you put in the box right now
4901
02:59:17,040 --> 02:59:19,279
it's going to return nothing we'll show
4902
02:59:19,279 --> 02:59:21,439
you how to add to this array in just a
4903
02:59:21,439 --> 02:59:24,120
second this kind of array is known as a
4904
02:59:24,120 --> 02:59:26,560
dynamic array because the size of the
4905
02:59:26,560 --> 02:59:29,200
array can actually grow and shrink in
4906
02:59:29,200 --> 02:59:31,920
solidity a dynamic array is signified by
4907
02:59:31,920 --> 02:59:33,560
what's inside of these little brackets
4908
02:59:33,560 --> 02:59:36,120
here if we added a three in here this
4909
02:59:36,120 --> 02:59:39,760
would be a static array we're saying
4910
02:59:39,760 --> 02:59:42,600
this list of people can only have a
4911
02:59:42,600 --> 02:59:45,760
maximum size of three so we can only put
4912
02:59:45,760 --> 02:59:48,600
three persons in this array
4913
02:59:48,600 --> 02:59:51,600
Dynamic array static array can have any
4914
02:59:51,600 --> 02:59:54,880
size can only go up to three any size up
4915
02:59:54,880 --> 02:59:57,399
to three any size up to four hopefully
4916
02:59:57,399 --> 02:59:59,279
you get the picture we're going to work
4917
02:59:59,279 --> 03:00:00,960
with a dynamic array because we're going
4918
03:00:00,960 --> 03:00:04,120
to want to add a arbitrary number of
4919
03:00:04,120 --> 03:00:06,840
people to this person array so let's
4920
03:00:06,840 --> 03:00:09,120
create a function that will allow us to
4921
03:00:09,120 --> 03:00:11,200
actually add people and update this
4922
03:00:11,200 --> 03:00:13,960
array and let's delete this comment so
4923
03:00:13,960 --> 03:00:16,200
below our retrieve function we'll create
4924
03:00:16,200 --> 03:00:18,840
a function add person
4925
03:00:18,840 --> 03:00:21,319
and this is going to take two variables
4926
03:00:21,319 --> 03:00:23,920
as input it's going to take the name of
4927
03:00:23,920 --> 03:00:25,720
the person that we're going to add it's
4928
03:00:25,720 --> 03:00:27,279
going to take the favorite number of the
4929
03:00:27,279 --> 03:00:29,080
person that we're going to add as well
4930
03:00:29,080 --> 03:00:33,000
as the name so we'll say string memory
4931
03:00:33,000 --> 03:00:35,000
name and I'll explain this memory
4932
03:00:35,000 --> 03:00:37,120
keyword in a little bit and we'll do
4933
03:00:37,120 --> 03:00:41,120
uint 256 unor favorite number and let's
4934
03:00:41,120 --> 03:00:44,080
do and let's do underscore name and
4935
03:00:44,080 --> 03:00:46,520
we'll make this a public function and
4936
03:00:46,520 --> 03:00:48,000
what we're going to do inside of this ad
4937
03:00:48,000 --> 03:00:49,880
person function is we're going to take
4938
03:00:49,880 --> 03:00:52,399
this list of people object and call the
4939
03:00:52,399 --> 03:00:55,439
push function on it arrays come built in
4940
03:00:55,439 --> 03:00:57,720
with a function called push which allows
4941
03:00:57,720 --> 03:01:01,439
us to add elements or add person to our
4942
03:01:01,439 --> 03:01:03,439
list of people array so what we're going
4943
03:01:03,439 --> 03:01:05,640
to do is we're going to say list of
4944
03:01:05,640 --> 03:01:08,279
people. push and we'll add these little
4945
03:01:08,279 --> 03:01:10,880
parentheses here and we're going to push
4946
03:01:10,880 --> 03:01:13,720
a new person onto this array now what we
4947
03:01:13,720 --> 03:01:15,800
could do now let's comment this out for
4948
03:01:15,800 --> 03:01:17,520
now now what we could do is we could
4949
03:01:17,520 --> 03:01:21,680
create a new person person new person
4950
03:01:21,680 --> 03:01:25,600
equals person name favorite number like
4951
03:01:25,600 --> 03:01:27,680
we did above oops excuse me these are
4952
03:01:27,680 --> 03:01:30,960
backwards person memory new person which
4953
03:01:30,960 --> 03:01:32,960
we're going to ignore that for now and
4954
03:01:32,960 --> 03:01:36,080
then just do list of people. push new
4955
03:01:36,080 --> 03:01:38,760
person we could do this this is valid
4956
03:01:38,760 --> 03:01:40,479
syntax and I'll explain this memory
4957
03:01:40,479 --> 03:01:42,680
keyword in a little bit this is going to
4958
03:01:42,680 --> 03:01:44,319
create a new person and we push to the
4959
03:01:44,319 --> 03:01:48,239
list or we could just add this person
4960
03:01:48,239 --> 03:01:51,120
right into this push piece here so we
4961
03:01:51,120 --> 03:01:52,680
could delete this line instead of
4962
03:01:52,680 --> 03:01:54,439
creating a new person on its own line we
4963
03:01:54,439 --> 03:01:57,680
could say list of people. push person
4964
03:01:57,680 --> 03:02:00,640
and then we'll add in here favorite
4965
03:02:00,640 --> 03:02:03,359
number name since we're calling this
4966
03:02:03,359 --> 03:02:05,640
person favorite number name inside of
4967
03:02:05,640 --> 03:02:07,560
this push object solidity is smart
4968
03:02:07,560 --> 03:02:10,160
enough to execute this line of code
4969
03:02:10,160 --> 03:02:13,120
first create a new person and then
4970
03:02:13,120 --> 03:02:16,040
execute this line to push our person
4971
03:02:16,040 --> 03:02:18,920
into this list of people object so this
4972
03:02:18,920 --> 03:02:21,319
function should allow us to push new
4973
03:02:21,319 --> 03:02:24,200
people into our list of people array so
4974
03:02:24,200 --> 03:02:26,439
what we can do now is let's compile this
4975
03:02:26,439 --> 03:02:28,120
let's deploy this let's delete the old
4976
03:02:28,120 --> 03:02:29,720
one we'll hit
4977
03:02:29,720 --> 03:02:33,080
deploy now we see if we call our list of
4978
03:02:33,080 --> 03:02:35,520
people at zero we'll get nothing back
4979
03:02:35,520 --> 03:02:37,960
because it starts off as a blank array
4980
03:02:37,960 --> 03:02:40,439
but now we have this new add person
4981
03:02:40,439 --> 03:02:43,000
function where we can you can kind of
4982
03:02:43,000 --> 03:02:45,359
see very faintly it takes a string name
4983
03:02:45,359 --> 03:02:48,160
and a un 256 a favorite number so we can
4984
03:02:48,160 --> 03:02:53,000
add Patrick 7 we'll hit add person which
4985
03:02:53,000 --> 03:02:54,520
if you have your terminal you'll see we
4986
03:02:54,520 --> 03:02:56,720
made a transaction and now if we hit
4987
03:02:56,720 --> 03:02:59,319
list of people at zero we see we have
4988
03:02:59,319 --> 03:03:01,560
indeed added a person to the zero withth
4989
03:03:01,560 --> 03:03:03,960
index Patrick has a favorite number of
4990
03:03:03,960 --> 03:03:07,279
seven and his name is Patrick obviously
4991
03:03:07,279 --> 03:03:10,600
if we hit one we'll get nothing back and
4992
03:03:10,600 --> 03:03:12,520
this will just stay up but if we add
4993
03:03:12,520 --> 03:03:17,359
another person maybe John 16 add person
4994
03:03:17,359 --> 03:03:20,399
now at list of people index one we now
4995
03:03:20,399 --> 03:03:23,760
see John 16 so 0o it's going to be
4996
03:03:23,760 --> 03:03:28,359
Patrick 7 1 John 16 2 is nothing so
4997
03:03:28,359 --> 03:03:30,640
nothing
4998
03:03:33,200 --> 03:03:35,200
happens now we've talked about this a
4999
03:03:35,200 --> 03:03:37,720
little bit already but if we go ahead
5000
03:03:37,720 --> 03:03:39,120
for example and maybe delete this
5001
03:03:39,120 --> 03:03:41,880
semicolon and we go to try to compile
5002
03:03:41,880 --> 03:03:43,880
and we scroll down you'll see we get
5003
03:03:43,880 --> 03:03:46,120
this error parser error expected
5004
03:03:46,120 --> 03:03:48,800
semicolon but got bracket instead and it
5005
03:03:48,800 --> 03:03:51,000
gives us this little red exclamation
5006
03:03:51,000 --> 03:03:52,680
mark and the line that it's having an
5007
03:03:52,680 --> 03:03:55,200
issue with all these red errors mean
5008
03:03:55,200 --> 03:03:57,239
that your code isn't compiling and you
5009
03:03:57,239 --> 03:03:58,560
can't actually deploy this to the
5010
03:03:58,560 --> 03:04:00,479
blockchain because solidity doesn't know
5011
03:04:00,479 --> 03:04:02,479
how to turn this human readable code
5012
03:04:02,479 --> 03:04:04,680
into machine readable code so we need to
5013
03:04:04,680 --> 03:04:07,640
add this semicolon here recompile so we
5014
03:04:07,640 --> 03:04:10,239
get no errors now interestingly though
5015
03:04:10,239 --> 03:04:12,279
if we go to the top and let's say we
5016
03:04:12,279 --> 03:04:14,800
delete this SPX license identifier and
5017
03:04:14,800 --> 03:04:18,120
now we compile we scroll down we get a
5018
03:04:18,120 --> 03:04:20,520
yellow box and it says warning instead
5019
03:04:20,520 --> 03:04:22,680
of error says warning spdx license
5020
03:04:22,680 --> 03:04:24,760
identifier not provided source file blah
5021
03:04:24,760 --> 03:04:26,800
blah blah interestingly though if we
5022
03:04:26,800 --> 03:04:29,080
compile this we actually let's delete
5023
03:04:29,080 --> 03:04:31,840
our last symbol storage we can deploy
5024
03:04:31,840 --> 03:04:35,000
this so something important to note is
5025
03:04:35,000 --> 03:04:37,080
warnings are just that they're just
5026
03:04:37,080 --> 03:04:38,680
warnings they won't prevent you from
5027
03:04:38,680 --> 03:04:41,279
deploying or compiling your code errors
5028
03:04:41,279 --> 03:04:43,160
will prevent you from deploying or
5029
03:04:43,160 --> 03:04:45,239
compiling your code now even with that
5030
03:04:45,239 --> 03:04:47,720
being said though it is good to try to
5031
03:04:47,720 --> 03:04:49,439
remove all of the warnings because the
5032
03:04:49,439 --> 03:04:51,080
warnings are generally there for a
5033
03:04:51,080 --> 03:04:52,840
reason they're warning you that you
5034
03:04:52,840 --> 03:04:54,920
might be doing something bad and
5035
03:04:54,920 --> 03:04:56,840
sometimes if you have a bug in your code
5036
03:04:56,840 --> 03:04:58,520
simply just listening to the warnings
5037
03:04:58,520 --> 03:05:00,319
would have solved it so it's best to
5038
03:05:00,319 --> 03:05:02,520
listen to the warnings here so to
5039
03:05:02,520 --> 03:05:04,279
summarize if it's red it's broken if
5040
03:05:04,279 --> 03:05:05,600
it's yellow you might want to check it
5041
03:05:05,600 --> 03:05:07,960
out and additionally when it comes to
5042
03:05:07,960 --> 03:05:09,600
these errors and These Warnings this is
5043
03:05:09,600 --> 03:05:11,760
where using our Ai and Google searching
5044
03:05:11,760 --> 03:05:13,800
skills can really come in handy let's
5045
03:05:13,800 --> 03:05:16,680
say for example I ran our code I get
5046
03:05:16,680 --> 03:05:19,040
this error I read the error and I don't
5047
03:05:19,040 --> 03:05:21,279
really understand what's going on here
5048
03:05:21,279 --> 03:05:23,520
what we can do is we could maybe copy
5049
03:05:23,520 --> 03:05:26,279
this error and use any of the search
5050
03:05:26,279 --> 03:05:28,200
features that we talked about resources
5051
03:05:28,200 --> 03:05:30,399
for this course we can use chat gbt or
5052
03:05:30,399 --> 03:05:32,800
find GitHub discussions stack exchange
5053
03:05:32,800 --> 03:05:35,080
ethereum and panum and I'll explain what
5054
03:05:35,080 --> 03:05:37,560
each one of these is good for later in
5055
03:05:37,560 --> 03:05:40,279
the course but for example let's go and
5056
03:05:40,279 --> 03:05:42,920
try out find find is an AI search engine
5057
03:05:42,920 --> 03:05:45,319
for developers what it does is it first
5058
03:05:45,319 --> 03:05:47,160
does a Google Search and then it reads
5059
03:05:47,160 --> 03:05:48,479
all those links links and based off the
5060
03:05:48,479 --> 03:05:49,840
links it reads it tries to give you an
5061
03:05:49,840 --> 03:05:51,880
answer so what we could do is we could
5062
03:05:51,880 --> 03:05:56,640
say I am getting this compiler error in
5063
03:05:56,640 --> 03:06:00,359
solidity how do I fix it we hit this
5064
03:06:00,359 --> 03:06:03,239
little dropdown put any code or context
5065
03:06:03,239 --> 03:06:06,760
here we'll paste our error this is the
5066
03:06:06,760 --> 03:06:09,560
error like this and we'll go ahead and
5067
03:06:09,560 --> 03:06:11,760
hit
5068
03:06:14,600 --> 03:06:17,600
search we get a pretty verbose response
5069
03:06:17,600 --> 03:06:19,479
on what's going on with our code we
5070
03:06:19,479 --> 03:06:21,479
could actually take this a step further
5071
03:06:21,479 --> 03:06:24,439
and we could copy our entire code base
5072
03:06:24,439 --> 03:06:27,120
and we could paste it under here we say
5073
03:06:27,120 --> 03:06:29,600
code I usually put three back ticks
5074
03:06:29,600 --> 03:06:31,680
before and after any code that I use and
5075
03:06:31,680 --> 03:06:33,760
I'll teach you why in the future well
5076
03:06:33,760 --> 03:06:35,479
let's go ahead and hit enter and
5077
03:06:35,479 --> 03:06:38,080
research it actually is able to read our
5078
03:06:38,080 --> 03:06:41,160
code and say one way to fix the error is
5079
03:06:41,160 --> 03:06:42,880
to Simply add a semicolon at the end of
5080
03:06:42,880 --> 03:06:44,439
the line where you push the new person
5081
03:06:44,439 --> 03:06:46,880
to the dynamic array list of people and
5082
03:06:46,880 --> 03:06:49,600
we can see if we do indeed get a way to
5083
03:06:49,600 --> 03:06:52,520
just copy our ad person function and we
5084
03:06:52,520 --> 03:06:55,439
can scroll down and just paste it on top
5085
03:06:55,439 --> 03:06:57,359
with it being fixed and we could also
5086
03:06:57,359 --> 03:06:58,960
say concise because it's being a little
5087
03:06:58,960 --> 03:07:01,960
too verbose for us we'll hit enter again
5088
03:07:01,960 --> 03:07:04,279
and it wasn't that concise but a lot of
5089
03:07:04,279 --> 03:07:06,399
these AI tools like I said are still in
5090
03:07:06,399 --> 03:07:08,560
beta but this was a good example of how
5091
03:07:08,560 --> 03:07:10,319
using an AI tool like this can actually
5092
03:07:10,319 --> 03:07:12,960
help you detect bugs like I said often
5093
03:07:12,960 --> 03:07:14,880
times they will still get things wrong
5094
03:07:14,880 --> 03:07:16,080
which is why it's important for you to
5095
03:07:16,080 --> 03:07:17,800
know about GitHub discussions stack
5096
03:07:17,800 --> 03:07:20,560
exchange piranha Etc later in the course
5097
03:07:20,560 --> 03:07:22,520
I'll explain more about how to ask good
5098
03:07:22,520 --> 03:07:24,960
questions how to do good AI prompting
5099
03:07:24,960 --> 03:07:26,720
how to format your questions and how to
5100
03:07:26,720 --> 03:07:28,880
search and learn more one of the key
5101
03:07:28,880 --> 03:07:30,439
pieces of being a really good software
5102
03:07:30,439 --> 03:07:32,640
engineer or a good prompt engineer is
5103
03:07:32,640 --> 03:07:33,960
less about actually knowing the
5104
03:07:33,960 --> 03:07:36,080
information and more about knowing where
5105
03:07:36,080 --> 03:07:38,720
to find the information so throughout
5106
03:07:38,720 --> 03:07:40,960
this course I want you to practice using
5107
03:07:40,960 --> 03:07:42,640
these resources because they're going to
5108
03:07:42,640 --> 03:07:44,920
help you be a much stronger developer
5109
03:07:44,920 --> 03:07:46,600
much stronger prompt engineer and just
5110
03:07:46,600 --> 03:07:47,880
be better at every thing that we're
5111
03:07:47,880 --> 03:07:50,040
going to go over in this course if find
5112
03:07:50,040 --> 03:07:53,120
or chat gbt gives you a poor answer be
5113
03:07:53,120 --> 03:07:55,000
sure to use the GitHub discussions if
5114
03:07:55,000 --> 03:07:56,439
you have a question specific to this
5115
03:07:56,439 --> 03:07:58,120
course be sure to use the GitHub
5116
03:07:58,120 --> 03:07:59,920
discussions or if you have a more
5117
03:07:59,920 --> 03:08:02,319
general question about solidity about
5118
03:08:02,319 --> 03:08:04,279
Foundry or anything like that you can
5119
03:08:04,279 --> 03:08:06,239
use one of these resources again I'll go
5120
03:08:06,239 --> 03:08:08,560
over this more later but great job
5121
03:08:08,560 --> 03:08:09,960
you've done your first bit of prompt
5122
03:08:09,960 --> 03:08:12,640
engineering
5123
03:08:15,680 --> 03:08:17,840
congratulations you don't have to
5124
03:08:17,840 --> 03:08:19,880
understand this section fully now one
5125
03:08:19,880 --> 03:08:21,520
thing that we didn't really go over and
5126
03:08:21,520 --> 03:08:23,600
we kind of glossed over was this memory
5127
03:08:23,600 --> 03:08:25,239
keyword and you'll notice if we actually
5128
03:08:25,239 --> 03:08:26,880
delete this keyword and you try to
5129
03:08:26,880 --> 03:08:30,080
compile we'll get an error data location
5130
03:08:30,080 --> 03:08:32,359
must be memory or call data for
5131
03:08:32,359 --> 03:08:34,720
parameter in function but none was given
5132
03:08:34,720 --> 03:08:36,479
now there are actually six places you
5133
03:08:36,479 --> 03:08:38,880
can store data in solidity you have the
5134
03:08:38,880 --> 03:08:43,279
stack memory storage call data code and
5135
03:08:43,279 --> 03:08:45,239
logs we're not going to go over all of
5136
03:08:45,239 --> 03:08:46,840
these areas right now but we are going
5137
03:08:46,840 --> 03:08:49,000
to go over some of the big ones which
5138
03:08:49,000 --> 03:08:53,800
are call data memory and storage and
5139
03:08:53,800 --> 03:08:54,880
this is going to be a little bit
5140
03:08:54,880 --> 03:08:56,520
Advanced here so if you don't understand
5141
03:08:56,520 --> 03:08:58,359
this section the first time don't worry
5142
03:08:58,359 --> 03:09:00,239
about it just keep pushing through it'll
5143
03:09:00,239 --> 03:09:02,239
make more sense as you go later on in
5144
03:09:02,239 --> 03:09:05,040
the course call data and memory both
5145
03:09:05,040 --> 03:09:07,520
mean that this variable is only going to
5146
03:09:07,520 --> 03:09:09,960
exist temporarily it's only going to
5147
03:09:09,960 --> 03:09:11,800
exist for the duration of the function
5148
03:09:11,800 --> 03:09:14,479
call any anytime we call AD person with
5149
03:09:14,479 --> 03:09:17,399
a different name we can only access this
5150
03:09:17,399 --> 03:09:19,479
name variable that one time that we call
5151
03:09:19,479 --> 03:09:23,000
this function if I call add name Patrick
5152
03:09:23,000 --> 03:09:25,920
7 and now I try to list of people at
5153
03:09:25,920 --> 03:09:28,000
zero obviously we see Patrick at
5154
03:09:28,000 --> 03:09:30,160
favorite number seven we can actually
5155
03:09:30,160 --> 03:09:32,600
never access that Patrick variable ever
5156
03:09:32,600 --> 03:09:35,439
again because it existed in memory it
5157
03:09:35,439 --> 03:09:37,800
existed for a very short period of time
5158
03:09:37,800 --> 03:09:40,239
just for that single call we could also
5159
03:09:40,239 --> 03:09:42,479
have call data here and we'll go ahead
5160
03:09:42,479 --> 03:09:45,680
remove this deploy the drop down and do
5161
03:09:45,680 --> 03:09:47,840
the same thing we'll add Pat
5162
03:09:47,840 --> 03:09:49,520
and actually you don't even need the
5163
03:09:49,520 --> 03:09:53,120
quotes Patrick do 88 add person we'll
5164
03:09:53,120 --> 03:09:55,920
see if it's in there sure is call data
5165
03:09:55,920 --> 03:09:58,520
and memory both mean temporary variables
5166
03:09:58,520 --> 03:10:00,399
inside of functions most variables
5167
03:10:00,399 --> 03:10:02,640
automatically default to memory
5168
03:10:02,640 --> 03:10:05,000
variables strings are a special type in
5169
03:10:05,000 --> 03:10:06,760
solidity so you have to specify memory
5170
03:10:06,760 --> 03:10:08,840
or call data and it has to do with the
5171
03:10:08,840 --> 03:10:10,760
way arrays work in memory but we'll talk
5172
03:10:10,760 --> 03:10:13,200
about that much later on the course now
5173
03:10:13,200 --> 03:10:14,880
the question obviously then follows okay
5174
03:10:14,880 --> 03:10:16,760
well if call data and memory are both
5175
03:10:16,760 --> 03:10:19,200
temporary variables why have two what's
5176
03:10:19,200 --> 03:10:21,200
the difference between these two well
5177
03:10:21,200 --> 03:10:23,080
let's try something let's have this be a
5178
03:10:23,080 --> 03:10:25,319
memory variable and in here we'll say
5179
03:10:25,319 --> 03:10:28,640
name equals cat so we're going to
5180
03:10:28,640 --> 03:10:30,680
reassign whatever people put in here to
5181
03:10:30,680 --> 03:10:32,880
Cat Let's compile this looks like it
5182
03:10:32,880 --> 03:10:35,760
compiles fine now let's do call data and
5183
03:10:35,760 --> 03:10:38,640
try to compile ah we get an error type
5184
03:10:38,640 --> 03:10:41,160
error type literal string cat is not
5185
03:10:41,160 --> 03:10:43,399
implicitly convertible to expected type
5186
03:10:43,399 --> 03:10:45,800
string call data the difference between
5187
03:10:45,800 --> 03:10:47,840
memory and call data is that
5188
03:10:47,840 --> 03:10:49,880
a memory variable can be changed it can
5189
03:10:49,880 --> 03:10:52,359
be manipulated if we pass a memory
5190
03:10:52,359 --> 03:10:55,200
variable to a function we can go
5191
03:10:55,200 --> 03:10:58,239
ahead memory and I hit and I hit command
5192
03:10:58,239 --> 03:11:02,040
s to compile this is valid solidity this
5193
03:11:02,040 --> 03:11:04,880
is not if you pass a call data variable
5194
03:11:04,880 --> 03:11:07,399
you cannot modify it call data is
5195
03:11:07,399 --> 03:11:09,640
temporary variables that cannot be
5196
03:11:09,640 --> 03:11:12,359
modified memory is temporary variables
5197
03:11:12,359 --> 03:11:15,640
that can be modified and storage is
5198
03:11:15,640 --> 03:11:19,040
permanent variables that can be modified
5199
03:11:19,040 --> 03:11:20,600
my favorite number was actually
5200
03:11:20,600 --> 03:11:22,600
implicitly converted to a storage
5201
03:11:22,600 --> 03:11:25,040
variable since it's added in this state
5202
03:11:25,040 --> 03:11:27,720
context outside of a function if you
5203
03:11:27,720 --> 03:11:29,399
create a variable that's outside of any
5204
03:11:29,399 --> 03:11:31,080
function inside of a contract it'll
5205
03:11:31,080 --> 03:11:33,439
automatically be a storage variable and
5206
03:11:33,439 --> 03:11:36,239
let's delete this line let's compile
5207
03:11:36,239 --> 03:11:38,960
let's deploy again delete this deploy we
5208
03:11:38,960 --> 03:11:40,279
know it's a permanent variable because
5209
03:11:40,279 --> 03:11:42,439
we can hit retrieve and we can always
5210
03:11:42,439 --> 03:11:44,800
access what is in favorite number so if
5211
03:11:44,800 --> 03:11:48,040
we store 1 2 3 we hit store or we can
5212
03:11:48,040 --> 03:11:51,520
hit retrieve and we can access 1 2 3 so
5213
03:11:51,520 --> 03:11:54,600
this variable 1 2 3 exists outside of
5214
03:11:54,600 --> 03:11:56,439
function calls now even though I said
5215
03:11:56,439 --> 03:11:58,479
there are more places like stack code
5216
03:11:58,479 --> 03:12:01,640
log return Etc we can only make these
5217
03:12:01,640 --> 03:12:03,760
variables call data memory or storage
5218
03:12:03,760 --> 03:12:05,279
and like I said we'll explain that later
5219
03:12:05,279 --> 03:12:07,279
in the course so let's go ahead let's
5220
03:12:07,279 --> 03:12:09,399
add this back to memory because that's
5221
03:12:09,399 --> 03:12:11,200
normally what you'll see now the next
5222
03:12:11,200 --> 03:12:12,840
question that logically follows is oh
5223
03:12:12,840 --> 03:12:14,120
okay Patrick well why do we need to put
5224
03:12:14,120 --> 03:12:16,319
memory here but we don't need to put
5225
03:12:16,319 --> 03:12:18,319
memory over here in fact if we try to
5226
03:12:18,319 --> 03:12:20,760
put memory there we'll get an error data
5227
03:12:20,760 --> 03:12:23,040
location can only be specified for array
5228
03:12:23,040 --> 03:12:25,359
struct or mapping types but memory was
5229
03:12:25,359 --> 03:12:27,520
given like I was saying earlier arrays
5230
03:12:27,520 --> 03:12:29,200
structs or mappings are considered
5231
03:12:29,200 --> 03:12:31,239
special types in solidity and the way
5232
03:12:31,239 --> 03:12:32,880
that memory management works under the
5233
03:12:32,880 --> 03:12:34,960
hood makes it so that we have to put
5234
03:12:34,960 --> 03:12:37,760
this memory keyword un 256 is known as a
5235
03:12:37,760 --> 03:12:39,720
primitive type and solidity is smart
5236
03:12:39,720 --> 03:12:41,160
enough to know where to put this
5237
03:12:41,160 --> 03:12:43,319
favorite number always under the hood
5238
03:12:43,319 --> 03:12:45,000
like we were saying earlier a string is
5239
03:12:45,000 --> 03:12:47,720
actually an array of bytes and so so as
5240
03:12:47,720 --> 03:12:49,000
we just saw with the air we need to put
5241
03:12:49,000 --> 03:12:51,040
the memory keyword for arrays so then
5242
03:12:51,040 --> 03:12:52,680
the next question is okay well what
5243
03:12:52,680 --> 03:12:54,800
about the storage variable can I put
5244
03:12:54,800 --> 03:12:56,960
that here no you can't put that here
5245
03:12:56,960 --> 03:12:59,680
either since this is a function solidity
5246
03:12:59,680 --> 03:13:01,960
is smart enough to at least know that ah
5247
03:13:01,960 --> 03:13:03,600
okay this is a temporary variable that
5248
03:13:03,600 --> 03:13:05,160
you're working with it's got to be
5249
03:13:05,160 --> 03:13:07,120
memory or call data it's not going to be
5250
03:13:07,120 --> 03:13:09,600
storage since this name is only going to
5251
03:13:09,600 --> 03:13:12,040
exist for a short duration so you got to
5252
03:13:12,040 --> 03:13:13,720
pick one of these other two so the
5253
03:13:13,720 --> 03:13:15,560
summary of this section is that strs
5254
03:13:15,560 --> 03:13:17,439
mappings and arrays need to be given
5255
03:13:17,439 --> 03:13:19,800
this memory keyword string is an array
5256
03:13:19,800 --> 03:13:21,800
of bytes so it needs this memory or call
5257
03:13:21,800 --> 03:13:24,080
data
5258
03:13:26,399 --> 03:13:28,399
keyword so this code is starting to
5259
03:13:28,399 --> 03:13:30,399
shape up it has a lot of functionality
5260
03:13:30,399 --> 03:13:32,359
here we can store variables we can add
5261
03:13:32,359 --> 03:13:35,520
people but it has a bit of an issue if
5262
03:13:35,520 --> 03:13:37,319
we have this contract and we want to say
5263
03:13:37,319 --> 03:13:39,680
oh what was Kelly's favorite number
5264
03:13:39,680 --> 03:13:40,880
let's say we have four people in the
5265
03:13:40,880 --> 03:13:43,160
array let's have Pat
5266
03:13:43,160 --> 03:13:48,120
7 John 8
5267
03:13:48,120 --> 03:13:49,920
Mariah
5268
03:13:49,920 --> 03:13:54,359
10 and Chelsea 22 or
5269
03:13:54,359 --> 03:13:57,439
232 and we asked the question ah what
5270
03:13:57,439 --> 03:13:59,520
was Chelsea's favorite number well the
5271
03:13:59,520 --> 03:14:00,880
way we would do it is we'd have to
5272
03:14:00,880 --> 03:14:03,439
actually Loop through this list of
5273
03:14:03,439 --> 03:14:05,920
people to find Chelsea so we'd say okay
5274
03:14:05,920 --> 03:14:08,680
what's at zero ah okay that's Pat that's
5275
03:14:08,680 --> 03:14:11,520
not Chelsea what's at two Ah that's John
5276
03:14:11,520 --> 03:14:13,880
what's at three Ah that's Mariah excuse
5277
03:14:13,880 --> 03:14:15,680
me what's at three Ah that's Chelsea
5278
03:14:15,680 --> 03:14:18,439
favorite number 232 okay perfect I found
5279
03:14:18,439 --> 03:14:20,880
Chelsea but obviously if we had a
5280
03:14:20,880 --> 03:14:22,880
thousand people in this array that would
5281
03:14:22,880 --> 03:14:24,960
be a very tedious process and that would
5282
03:14:24,960 --> 03:14:26,880
take a long time for us to find the
5283
03:14:26,880 --> 03:14:28,560
person that we wanted so the question
5284
03:14:28,560 --> 03:14:30,720
then is is there a better data structure
5285
03:14:30,720 --> 03:14:33,080
than a list or an array to use that
5286
03:14:33,080 --> 03:14:35,840
makes it much easier to access and find
5287
03:14:35,840 --> 03:14:37,239
the information about the people that we
5288
03:14:37,239 --> 03:14:39,560
want and the answer to this is using a
5289
03:14:39,560 --> 03:14:41,880
mapping you can think of a mapping as a
5290
03:14:41,880 --> 03:14:44,200
dictionary it's a set of keys with each
5291
03:14:44,200 --> 03:14:45,720
key returning a special set of
5292
03:14:45,720 --> 03:14:47,680
information about that key so it's
5293
03:14:47,680 --> 03:14:49,239
similar to a dictionary if you look up
5294
03:14:49,239 --> 03:14:52,000
the wordthe the wordthe will have a
5295
03:14:52,000 --> 03:14:54,239
whole bunch of text Associated only with
5296
03:14:54,239 --> 03:14:56,560
the word thee so let's create a mapping
5297
03:14:56,560 --> 03:14:58,239
type and you'll see how it works in
5298
03:14:58,239 --> 03:14:59,760
practice so we're going to create a
5299
03:14:59,760 --> 03:15:01,960
mapping like this with this mapping
5300
03:15:01,960 --> 03:15:04,479
keyword and we'll say the key is going
5301
03:15:04,479 --> 03:15:07,960
to be a string and It'll point to a uent
5302
03:15:07,960 --> 03:15:10,840
256 so this is going to be our type
5303
03:15:10,840 --> 03:15:12,640
obviously what comes after the type our
5304
03:15:12,640 --> 03:15:14,840
visibility so let's just go ahead and do
5305
03:15:14,840 --> 03:15:17,000
public for this as well and I like to be
5306
03:15:17,000 --> 03:15:18,560
very explicit with my naming so I'm
5307
03:15:18,560 --> 03:15:21,239
going to say name
5308
03:15:21,239 --> 03:15:24,960
to number signifying that this mapping
5309
03:15:24,960 --> 03:15:27,600
Maps someone's name to their favorite
5310
03:15:27,600 --> 03:15:29,560
number and now with this we have
5311
03:15:29,560 --> 03:15:31,160
essentially a dictionary where every
5312
03:15:31,160 --> 03:15:33,840
single name or every single string is
5313
03:15:33,840 --> 03:15:36,560
going to map to one number so for
5314
03:15:36,560 --> 03:15:39,279
example if we looked up Chelsea we'd
5315
03:15:39,279 --> 03:15:41,359
automatically get returned the 232 that
5316
03:15:41,359 --> 03:15:43,120
we're looking for instead of having to
5317
03:15:43,120 --> 03:15:45,560
iterate through this list so let's add
5318
03:15:45,560 --> 03:15:47,359
some capabilities to our ad person
5319
03:15:47,359 --> 03:15:50,080
function here so that we can update our
5320
03:15:50,080 --> 03:15:52,560
mapping so we have this list of people.
5321
03:15:52,560 --> 03:15:54,960
push which adds someone to the array
5322
03:15:54,960 --> 03:15:57,399
let's also update this so it will also
5323
03:15:57,399 --> 03:16:00,040
add somebody to our mapping to do that
5324
03:16:00,040 --> 03:16:04,000
we'll say name to favorite number and we
5325
03:16:04,000 --> 03:16:05,840
put these little brackets in here to
5326
03:16:05,840 --> 03:16:08,479
specify what the key is and we'll
5327
03:16:08,479 --> 03:16:12,560
saycore name and we'll assign that
5328
03:16:12,560 --> 03:16:15,960
toore favorite number what this line is
5329
03:16:15,960 --> 03:16:17,800
doing is now it's saying all right in
5330
03:16:17,800 --> 03:16:19,560
our mapping up here in our name to
5331
03:16:19,560 --> 03:16:21,880
favorite number mapping anytime you look
5332
03:16:21,880 --> 03:16:23,319
for that person's name you'll
5333
03:16:23,319 --> 03:16:24,720
automatically get their favorite number
5334
03:16:24,720 --> 03:16:27,279
back and now you have a much quicker way
5335
03:16:27,279 --> 03:16:29,560
to access people's favorite numbers just
5336
03:16:29,560 --> 03:16:31,720
by knowing their name so let's go ahead
5337
03:16:31,720 --> 03:16:33,319
let's compile
5338
03:16:33,319 --> 03:16:35,760
this let's deploy this let's delete our
5339
03:16:35,760 --> 03:16:37,720
old one we'll deploy
5340
03:16:37,720 --> 03:16:40,120
this now we have this new name to
5341
03:16:40,120 --> 03:16:42,560
favorite number blue button and so let's
5342
03:16:42,560 --> 03:16:44,040
go through the same problem so let's say
5343
03:16:44,040 --> 03:16:47,319
we have Pat 7
5344
03:16:47,319 --> 03:16:49,479
John
5345
03:16:49,479 --> 03:16:52,880
16 Mariah
5346
03:16:52,880 --> 03:16:56,600
32 Chelsea
5347
03:16:56,600 --> 03:16:59,560
232 now same thing list of people zero
5348
03:16:59,560 --> 03:17:01,720
returns Pat list of people one John so
5349
03:17:01,720 --> 03:17:04,319
on and so forth or we could just go down
5350
03:17:04,319 --> 03:17:07,880
here and let's say let's look up Chelsea
5351
03:17:07,880 --> 03:17:09,960
and we automatically get 232 we get
5352
03:17:09,960 --> 03:17:11,399
Chelsea's favorite number back
5353
03:17:11,399 --> 03:17:13,680
automatically same thing if we look up
5354
03:17:13,680 --> 03:17:17,760
Pat we get seven if we look up JN
5355
03:17:17,760 --> 03:17:21,600
we get Mariah and if we look up
5356
03:17:21,600 --> 03:17:24,720
cheesecake we get nothing back in a
5357
03:17:24,720 --> 03:17:27,080
mapping the default value for all the
5358
03:17:27,080 --> 03:17:30,040
keys is zero so if you look up a key or
5359
03:17:30,040 --> 03:17:31,720
a word that we haven't added in the
5360
03:17:31,720 --> 03:17:34,199
mapping yet it defaults to the default
5361
03:17:34,199 --> 03:17:36,720
value of whatever that type is since RS
5362
03:17:36,720 --> 03:17:40,120
is a string to U at 256 U at 256 default
5363
03:17:40,120 --> 03:17:42,399
type is zero if we look for a key that
5364
03:17:42,399 --> 03:17:46,960
we haven't added we get zero back
5365
03:17:49,199 --> 03:17:50,359
so now that we've added all this
5366
03:17:50,359 --> 03:17:52,800
functionality we're looking pretty good
5367
03:17:52,800 --> 03:17:54,920
we really like the way that our contract
5368
03:17:54,920 --> 03:17:57,960
is set up we have our my favorite number
5369
03:17:57,960 --> 03:18:00,279
which is a internal variable but we have
5370
03:18:00,279 --> 03:18:03,160
a way to read it with retrieve we have
5371
03:18:03,160 --> 03:18:06,120
our new typing person we have a public
5372
03:18:06,120 --> 03:18:08,479
list of people array we've got a public
5373
03:18:08,479 --> 03:18:10,560
name to favorite number got a way to
5374
03:18:10,560 --> 03:18:12,399
update the favorite number retrieve the
5375
03:18:12,399 --> 03:18:14,560
favorite number and add people to both
5376
03:18:14,560 --> 03:18:17,120
our list and our mapping now now in the
5377
03:18:17,120 --> 03:18:18,560
future you'll hear me say that you
5378
03:18:18,560 --> 03:18:20,120
should never do this before you write
5379
03:18:20,120 --> 03:18:22,840
any tests before you get it audited but
5380
03:18:22,840 --> 03:18:25,040
for now this is just a dummy contract
5381
03:18:25,040 --> 03:18:26,399
that we're going to deploy on a test net
5382
03:18:26,399 --> 03:18:28,080
so we don't really care but let's go
5383
03:18:28,080 --> 03:18:29,600
ahead and learn how to actually deploy
5384
03:18:29,600 --> 03:18:31,920
this to a real test net this is going to
5385
03:18:31,920 --> 03:18:33,600
simulate what deploying to a real
5386
03:18:33,600 --> 03:18:35,199
network with real money is going to look
5387
03:18:35,199 --> 03:18:37,199
like are you ready you should be this is
5388
03:18:37,199 --> 03:18:39,199
going to be incredibly exciting after
5389
03:18:39,199 --> 03:18:41,920
you do this successfully you should 100%
5390
03:18:41,920 --> 03:18:44,160
tweet about it on Twitter on LinkedIn on
5391
03:18:44,160 --> 03:18:46,120
lens protocol on whatever social media
5392
03:18:46,120 --> 03:18:47,960
you want it's important to celebrate
5393
03:18:47,960 --> 03:18:50,239
your small wins surprisingly it'll help
5394
03:18:50,239 --> 03:18:52,760
motivate you moving forward so first off
5395
03:18:52,760 --> 03:18:54,600
let's make sure this actually compiles
5396
03:18:54,600 --> 03:18:56,279
okay cool we've got a green chat Mark
5397
03:18:56,279 --> 03:18:58,279
there's no warnings there's no errors
5398
03:18:58,279 --> 03:19:00,199
fantastic now let's go back to the
5399
03:19:00,199 --> 03:19:02,640
deploy Tab and we'll delete this down
5400
03:19:02,640 --> 03:19:04,479
here and we'll scroll up and we're going
5401
03:19:04,479 --> 03:19:06,800
to change the environment we're in this
5402
03:19:06,800 --> 03:19:08,960
remix VM and we're actually going to
5403
03:19:08,960 --> 03:19:12,040
move to injected provider metamask
5404
03:19:12,040 --> 03:19:14,279
remember this remix VM is kind of this
5405
03:19:14,279 --> 03:19:18,199
fake world that remix gives to us
5406
03:19:18,199 --> 03:19:20,239
injected provider metamask means that
5407
03:19:20,239 --> 03:19:22,840
we're going to literally inject our
5408
03:19:22,840 --> 03:19:25,760
metamask into this remix we're going to
5409
03:19:25,760 --> 03:19:28,239
inject our metamask into this website
5410
03:19:28,239 --> 03:19:30,359
we're going to allow this website to
5411
03:19:30,359 --> 03:19:32,960
interact with our metamask we'll first
5412
03:19:32,960 --> 03:19:34,600
get prompted by metamask to pick the
5413
03:19:34,600 --> 03:19:36,040
account we want to use I'm going to use
5414
03:19:36,040 --> 03:19:38,160
account one and hit next and we're going
5415
03:19:38,160 --> 03:19:40,040
to go ahead and hit connect similar to
5416
03:19:40,040 --> 03:19:41,920
the way we connected to the faucet we
5417
03:19:41,920 --> 03:19:44,000
scroll up to our metamask we now see oh
5418
03:19:44,000 --> 03:19:45,560
it says your account is not connected
5419
03:19:45,560 --> 03:19:47,239
that's because I'm currently on account
5420
03:19:47,239 --> 03:19:49,840
two let's flip to account one and we do
5421
03:19:49,840 --> 03:19:52,560
indeed see that account one is connected
5422
03:19:52,560 --> 03:19:54,960
and now before where we saw kind of this
5423
03:19:54,960 --> 03:19:57,279
fake account with fake ether we see our
5424
03:19:57,279 --> 03:19:59,160
actual account with the actual amount of
5425
03:19:59,160 --> 03:20:02,199
sapoia e that we have make sure that
5426
03:20:02,199 --> 03:20:03,319
again be sure to use whatever
5427
03:20:03,319 --> 03:20:04,640
recommended test net we have in the
5428
03:20:04,640 --> 03:20:07,399
GitHub repo for us we're using sapoia
5429
03:20:07,399 --> 03:20:08,800
don't worry about the rest of these for
5430
03:20:08,800 --> 03:20:10,960
now so make sure you're on the correct
5431
03:20:10,960 --> 03:20:13,000
test net to deploy to a test net you're
5432
03:20:13,000 --> 03:20:15,439
going to need some seia eth so if you
5433
03:20:15,439 --> 03:20:17,000
haven't been to the faucet be to head
5434
03:20:17,000 --> 03:20:19,319
over to the faucet to get some suppo eth
5435
03:20:19,319 --> 03:20:20,399
remember you can find those in the
5436
03:20:20,399 --> 03:20:23,880
GitHub or web 3d. education now in remix
5437
03:20:23,880 --> 03:20:25,120
what we're going to do we're going to do
5438
03:20:25,120 --> 03:20:27,040
the exact same process we use to deploy
5439
03:20:27,040 --> 03:20:29,000
to the virtual remix environment we're
5440
03:20:29,000 --> 03:20:30,720
going to do that to deploy to the test
5441
03:20:30,720 --> 03:20:31,920
set environment so we're going to go
5442
03:20:31,920 --> 03:20:34,000
ahead hit the deploy button and metamask
5443
03:20:34,000 --> 03:20:35,760
is actually going to go ahead and pop up
5444
03:20:35,760 --> 03:20:37,160
this is similar to what we saw with the
5445
03:20:37,160 --> 03:20:38,640
blockchain example with signing
5446
03:20:38,640 --> 03:20:40,120
transactions we're actually going to
5447
03:20:40,120 --> 03:20:42,960
sign and send a transaction on the test
5448
03:20:42,960 --> 03:20:45,840
set it's similar again to us sending
5449
03:20:45,840 --> 03:20:48,040
ether to our ourselves the difference
5450
03:20:48,040 --> 03:20:50,520
here is though that our data section has
5451
03:20:50,520 --> 03:20:53,600
a ton of information here all this data
5452
03:20:53,600 --> 03:20:55,399
is associated with sending this
5453
03:20:55,399 --> 03:20:57,840
transaction but this one has all of this
5454
03:20:57,840 --> 03:21:00,080
contract information encoded in machine
5455
03:21:00,080 --> 03:21:03,239
readable code or our compiled code in
5456
03:21:03,239 --> 03:21:04,880
details we can see all the pavement
5457
03:21:04,880 --> 03:21:06,359
information associated with this
5458
03:21:06,359 --> 03:21:08,640
transaction we can see exactly how much
5459
03:21:08,640 --> 03:21:10,760
gas it's going to cost to deploy this
5460
03:21:10,760 --> 03:21:12,840
contract on chain but again we're on the
5461
03:21:12,840 --> 03:21:14,680
aoia test Network so this is fake money
5462
03:21:14,680 --> 03:21:16,319
anyways to actually deploy this we're
5463
03:21:16,319 --> 03:21:17,520
going to go go ahead and hit the confirm
5464
03:21:17,520 --> 03:21:19,520
button and now we're going to have sent
5465
03:21:19,520 --> 03:21:21,680
our function if you have the terminal up
5466
03:21:21,680 --> 03:21:24,279
you can see we have this call created
5467
03:21:24,279 --> 03:21:25,920
and it says creation of simple storage
5468
03:21:25,920 --> 03:21:27,720
pending with this view on ether scan
5469
03:21:27,720 --> 03:21:29,720
button if you click the view on ether
5470
03:21:29,720 --> 03:21:31,600
scan button you'll get brought to this
5471
03:21:31,600 --> 03:21:33,319
ether scan page with this transaction
5472
03:21:33,319 --> 03:21:35,920
going through on sepolia you'll see it's
5473
03:21:35,920 --> 03:21:38,080
currently being indexed by Ether scan
5474
03:21:38,080 --> 03:21:39,120
but there's a good chance it already
5475
03:21:39,120 --> 03:21:40,880
went through and back in remix it
5476
03:21:40,880 --> 03:21:41,960
actually goes ahead and gives us this
5477
03:21:41,960 --> 03:21:43,800
green check mark saying that we did
5478
03:21:43,800 --> 03:21:47,040
indeed deploy this contract
5479
03:21:47,040 --> 03:21:48,359
you might have to wait a few minutes for
5480
03:21:48,359 --> 03:21:49,560
this to complete because again we're
5481
03:21:49,560 --> 03:21:51,160
sending a transaction to a test net
5482
03:21:51,160 --> 03:21:53,199
blockchain and the blockchain needs to
5483
03:21:53,199 --> 03:21:55,120
actually ruce the block with our
5484
03:21:55,120 --> 03:21:57,080
transaction in it but if we wait a few
5485
03:21:57,080 --> 03:21:58,800
minutes on either scan we'll eventually
5486
03:21:58,800 --> 03:22:01,520
see a success status with block
5487
03:22:01,520 --> 03:22:04,080
confirmations on this block section here
5488
03:22:04,080 --> 03:22:05,720
and exactly the same as what we saw with
5489
03:22:05,720 --> 03:22:07,960
sending e to ourselves we see all this
5490
03:22:07,960 --> 03:22:09,279
information about the transaction
5491
03:22:09,279 --> 03:22:12,720
transaction hash status block time from
5492
03:22:12,720 --> 03:22:15,840
to blah blah Etc but if we scroll down
5493
03:22:15,840 --> 03:22:18,160
this input data field is much bigger
5494
03:22:18,160 --> 03:22:19,600
than anything we've seen before because
5495
03:22:19,600 --> 03:22:21,520
again this is all the data associated
5496
03:22:21,520 --> 03:22:23,560
with creating this contract and of
5497
03:22:23,560 --> 03:22:25,960
course we see more gas fee information
5498
03:22:25,960 --> 03:22:27,760
because again deploying a smart contract
5499
03:22:27,760 --> 03:22:29,760
to the chain is modifying the blockchain
5500
03:22:29,760 --> 03:22:32,000
so we have to spend gas now if we come
5501
03:22:32,000 --> 03:22:33,680
back to our remix and scroll down we're
5502
03:22:33,680 --> 03:22:35,920
able to see our simple storage contract
5503
03:22:35,920 --> 03:22:37,920
and we're able to copy the address that
5504
03:22:37,920 --> 03:22:40,359
it's at so if we copy this address we go
5505
03:22:40,359 --> 03:22:42,399
back to Ether scan we can even paste
5506
03:22:42,399 --> 03:22:44,560
this into the bar here and we can see
5507
03:22:44,560 --> 03:22:46,080
this contract that we went ahead and
5508
03:22:46,080 --> 03:22:48,080
deployed ether scan is smart enough to
5509
03:22:48,080 --> 03:22:50,640
know that this transaction created a new
5510
03:22:50,640 --> 03:22:52,520
contract remember this has to be on The
5511
03:22:52,520 --> 03:22:54,760
seoa Ether scan not the main net ether
5512
03:22:54,760 --> 03:22:56,560
scan because we sent this on the sepolia
5513
03:22:56,560 --> 03:22:58,080
testnet so now that we have this
5514
03:22:58,080 --> 03:22:59,640
contract created we have all the exact
5515
03:22:59,640 --> 03:23:01,279
same functions that we had in our
5516
03:23:01,279 --> 03:23:03,600
virtual environment but these functions
5517
03:23:03,600 --> 03:23:05,800
are actually on a test net with a
5518
03:23:05,800 --> 03:23:07,560
contract that we actually deployed now
5519
03:23:07,560 --> 03:23:08,880
we can do all the exact same things we
5520
03:23:08,880 --> 03:23:10,800
were doing on our fake remix environment
5521
03:23:10,800 --> 03:23:12,800
on this test environment for example we
5522
03:23:12,800 --> 03:23:14,800
can call retrieve which doesn't send a
5523
03:23:14,800 --> 03:23:16,080
transaction it just reads off the
5524
03:23:16,080 --> 03:23:17,000
blockchain
5525
03:23:17,000 --> 03:23:18,560
and we get zero same as what we got
5526
03:23:18,560 --> 03:23:21,399
before if we look up a name like Pat in
5527
03:23:21,399 --> 03:23:23,439
name to favorite number we get nothing
5528
03:23:23,439 --> 03:23:25,439
back cuz we haven't updated anything if
5529
03:23:25,439 --> 03:23:27,640
we add zero in here for list of people
5530
03:23:27,640 --> 03:23:29,920
we get nothing back as well metamask
5531
03:23:29,920 --> 03:23:31,720
didn't pop up here because these blue
5532
03:23:31,720 --> 03:23:34,399
buttons are view functions View and pure
5533
03:23:34,399 --> 03:23:36,399
functions like we said don't send
5534
03:23:36,399 --> 03:23:38,239
transactions now let's go ahead and
5535
03:23:38,239 --> 03:23:40,120
actually send a transaction let's update
5536
03:23:40,120 --> 03:23:42,199
the blockchain let's update our contract
5537
03:23:42,199 --> 03:23:44,399
by storing a new favorite number so
5538
03:23:44,399 --> 03:23:46,680
let's do 7878
5539
03:23:46,680 --> 03:23:48,439
and we'll hit store and we'll press this
5540
03:23:48,439 --> 03:23:50,160
orange button you'll see you'll get
5541
03:23:50,160 --> 03:23:51,960
prompted with metamask actually popping
5542
03:23:51,960 --> 03:23:54,239
up saying okay let's update the
5543
03:23:54,239 --> 03:23:56,800
blockchain let's send this transaction
5544
03:23:56,800 --> 03:23:58,800
and if we go ahead and hit confirm the
5545
03:23:58,800 --> 03:24:00,520
exact same thing happens we'll get this
5546
03:24:00,520 --> 03:24:02,960
transact to simple Storage storage
5547
03:24:02,960 --> 03:24:04,560
transact to simple storage. store
5548
03:24:04,560 --> 03:24:06,800
pending view an ether scan this little
5549
03:24:06,800 --> 03:24:08,880
check mark we view it we can see the
5550
03:24:08,880 --> 03:24:11,199
transaction indexing on ether scan and
5551
03:24:11,199 --> 03:24:13,080
after you wait for a little bit the
5552
03:24:13,080 --> 03:24:14,920
transaction will go through and now if
5553
03:24:14,920 --> 03:24:17,640
we hit the retrieve button we can see we
5554
03:24:17,640 --> 03:24:21,600
have now stored 7878 on chain if we copy
5555
03:24:21,600 --> 03:24:23,840
the contract address again we paste it
5556
03:24:23,840 --> 03:24:27,000
into sapoia ether scan we scroll down
5557
03:24:27,000 --> 03:24:28,920
after a few minutes we'll actually see a
5558
03:24:28,920 --> 03:24:31,319
second transaction come through we see
5559
03:24:31,319 --> 03:24:33,080
two transactions associated with this
5560
03:24:33,080 --> 03:24:35,319
contract the first transaction obviously
5561
03:24:35,319 --> 03:24:38,199
is the contract creation transaction and
5562
03:24:38,199 --> 03:24:39,920
the second transaction is us actually
5563
03:24:39,920 --> 03:24:42,279
calling the store method ether scan is
5564
03:24:42,279 --> 03:24:44,120
smart enough to know that this is the
5565
03:24:44,120 --> 03:24:46,120
store method it's not always smart
5566
03:24:46,120 --> 03:24:47,520
enough to know that but for this one
5567
03:24:47,520 --> 03:24:49,319
it's smart enough to know and we see
5568
03:24:49,319 --> 03:24:52,279
that we actually updated our contract
5569
03:24:52,279 --> 03:24:53,960
and remember in the future please use
5570
03:24:53,960 --> 03:24:55,960
these testet sparingly we're just
5571
03:24:55,960 --> 03:24:57,640
starting out and we're just learning so
5572
03:24:57,640 --> 03:24:58,760
it's okay for us to send these
5573
03:24:58,760 --> 03:25:00,439
transactions here though but let's go
5574
03:25:00,439 --> 03:25:02,239
ahead and let's keep going because named
5575
03:25:02,239 --> 03:25:03,920
a favorite number of Pat still returns
5576
03:25:03,920 --> 03:25:05,720
nothing list of people zero still
5577
03:25:05,720 --> 03:25:07,840
returns nothing so let's go to add
5578
03:25:07,840 --> 03:25:11,080
person we'll do Pat 16 we'll hit add
5579
03:25:11,080 --> 03:25:13,199
person metam Mass pops up obviously
5580
03:25:13,199 --> 03:25:14,960
because we're updating the state of our
5581
03:25:14,960 --> 03:25:17,160
contract we'll hit confirm we see
5582
03:25:17,160 --> 03:25:19,120
transact to simple storage. adderson is
5583
03:25:19,120 --> 03:25:21,720
pending it looks like it has succeeded
5584
03:25:21,720 --> 03:25:23,520
so now if we do name the favorite number
5585
03:25:23,520 --> 03:25:26,520
of Pat we see 16 get returned and if we
5586
03:25:26,520 --> 03:25:29,040
do list of people at zero we see we get
5587
03:25:29,040 --> 03:25:31,640
Pat whose favorite number is 16 and
5588
03:25:31,640 --> 03:25:33,680
guess what at this point you've
5589
03:25:33,680 --> 03:25:36,040
successfully deployed a smart contract
5590
03:25:36,040 --> 03:25:38,680
to a real test net congratulations you
5591
03:25:38,680 --> 03:25:40,040
should be incredibly excited for
5592
03:25:40,040 --> 03:25:42,120
yourself be sure to give yourself a pat
5593
03:25:42,120 --> 03:25:44,279
on the back maybe go for a walk maybe
5594
03:25:44,279 --> 03:25:45,800
have an extra cup of coffee or an ice
5595
03:25:45,800 --> 03:25:47,880
cream because additionally you've also
5596
03:25:47,880 --> 03:25:50,520
interacted with that contract with these
5597
03:25:50,520 --> 03:25:52,279
buttons and remix that allow us to send
5598
03:25:52,279 --> 03:25:54,560
transactions to update the state of our
5599
03:25:54,560 --> 03:25:56,439
contracts congratulations you're a
5600
03:25:56,439 --> 03:25:58,760
solidity developer but we've got a lot
5601
03:25:58,760 --> 03:26:01,120
more to go and like I said make sure to
5602
03:26:01,120 --> 03:26:03,080
celebrate these little wins celebrating
5603
03:26:03,080 --> 03:26:05,120
little wins will motivate you and excite
5604
03:26:05,120 --> 03:26:06,880
you to continue to move forward so be
5605
03:26:06,880 --> 03:26:08,520
sure to take the time to Pat yourself in
5606
03:26:08,520 --> 03:26:10,760
the back congratulations if you've got
5607
03:26:10,760 --> 03:26:13,080
this far there's a ton more for us to
5608
03:26:13,080 --> 03:26:15,399
learn but just you getting here is a
5609
03:26:15,399 --> 03:26:17,920
fantastic achievement in itself now here
5610
03:26:17,920 --> 03:26:19,720
if we wanted to deploy to a different
5611
03:26:19,720 --> 03:26:21,880
test net all we would have to do in our
5612
03:26:21,880 --> 03:26:24,479
metamask is switch to a different testet
5613
03:26:24,479 --> 03:26:26,760
like linear Gilli since we don't have
5614
03:26:26,760 --> 03:26:29,279
any linear Gil we actually can't deploy
5615
03:26:29,279 --> 03:26:31,120
this to a test net but if we used a
5616
03:26:31,120 --> 03:26:34,040
faucet to get more linear gorill eth
5617
03:26:34,040 --> 03:26:35,439
that's how we would deploy it
5618
03:26:35,439 --> 03:26:36,640
additionally we could do the same
5619
03:26:36,640 --> 03:26:38,279
methodology for deploying to ethereum
5620
03:26:38,279 --> 03:26:40,000
main net or any other main net that you
5621
03:26:40,000 --> 03:26:41,680
want to work with throughout this course
5622
03:26:41,680 --> 03:26:43,199
the difference here is obviously you
5623
03:26:43,199 --> 03:26:45,359
just need to buy some ethereum to
5624
03:26:45,359 --> 03:26:46,439
actually deploy this smart smart
5625
03:26:46,439 --> 03:26:48,800
contract remix will automatically update
5626
03:26:48,800 --> 03:26:50,279
to whatever Network you're working with
5627
03:26:50,279 --> 03:26:51,640
for example right here it says Ah you're
5628
03:26:51,640 --> 03:26:54,239
working on the main network but if we
5629
03:26:54,239 --> 03:26:56,319
were to switch to gelli it would say ah
5630
03:26:56,319 --> 03:26:58,040
you're working on gelli but if we were
5631
03:26:58,040 --> 03:26:59,479
to switch again it would say ah you're
5632
03:26:59,479 --> 03:27:01,279
working on lenia in the future we'll
5633
03:27:01,279 --> 03:27:02,720
learn to add different networks so you
5634
03:27:02,720 --> 03:27:04,840
can learn how to deploy to any other evm
5635
03:27:04,840 --> 03:27:08,000
compatible network that you want
5636
03:27:10,359 --> 03:27:12,479
to now I've mentioned this a couple of
5637
03:27:12,479 --> 03:27:14,760
times but whenever we compile this code
5638
03:27:14,760 --> 03:27:16,359
it compiles it down to something called
5639
03:27:16,359 --> 03:27:20,640
the evm or the ethereum virtual machine
5640
03:27:20,640 --> 03:27:22,560
don't worry too much about exactly what
5641
03:27:22,560 --> 03:27:24,800
this means but essentially the evm is a
5642
03:27:24,800 --> 03:27:27,120
standard for how to compile and how to
5643
03:27:27,120 --> 03:27:30,000
deploy smart contracts to a blockchain
5644
03:27:30,000 --> 03:27:31,960
any blockchain that is evm compatible
5645
03:27:31,960 --> 03:27:33,760
you should be able to deploy solidity
5646
03:27:33,760 --> 03:27:36,560
code to some examples of evm compatible
5647
03:27:36,560 --> 03:27:38,840
blockchains and layer 2os which again
5648
03:27:38,840 --> 03:27:40,319
we're going to go over working with
5649
03:27:40,319 --> 03:27:42,279
layer twos more in the future are going
5650
03:27:42,279 --> 03:27:46,640
to be ethereum polygon arbitrum
5651
03:27:46,640 --> 03:27:49,840
optimism ZK sync and more just note that
5652
03:27:49,840 --> 03:27:50,920
it's important to double check the
5653
03:27:50,920 --> 03:27:53,279
blockchain before you launch to it for
5654
03:27:53,279 --> 03:27:55,560
example ZK sync is zvm compatible but a
5655
03:27:55,560 --> 03:27:57,160
couple of keywords don't actually work
5656
03:27:57,160 --> 03:27:59,640
with ZK sync now let's do a quick recap
5657
03:27:59,640 --> 03:28:01,279
of everything we learned in this lesson
5658
03:28:01,279 --> 03:28:02,960
and then after we do this be absolutely
5659
03:28:02,960 --> 03:28:04,640
be certain to take a break maybe go get
5660
03:28:04,640 --> 03:28:07,000
some ice cream go get that extra coffee
5661
03:28:07,000 --> 03:28:09,000
or whatever you like to do the first
5662
03:28:09,000 --> 03:28:10,640
thing you want to do in any smart
5663
03:28:10,640 --> 03:28:12,600
contract or solidity code that you write
5664
03:28:12,600 --> 03:28:14,439
be sure to write the version that you
5665
03:28:14,439 --> 03:28:16,279
want to work with and above the the
5666
03:28:16,279 --> 03:28:18,800
version be sure to add the spdx license
5667
03:28:18,800 --> 03:28:20,439
identifier if you're not sure what
5668
03:28:20,439 --> 03:28:22,760
version to use for now just default to
5669
03:28:22,760 --> 03:28:24,600
MIT then you have to create your
5670
03:28:24,600 --> 03:28:27,279
contract object and name your contract a
5671
03:28:27,279 --> 03:28:30,040
contract is similar to a class in other
5672
03:28:30,040 --> 03:28:32,479
programming languages anything inside of
5673
03:28:32,479 --> 03:28:34,439
the curly brackets for the contract is
5674
03:28:34,439 --> 03:28:36,520
part of that contract there are many
5675
03:28:36,520 --> 03:28:39,160
different types in solidity like U 256
5676
03:28:39,160 --> 03:28:42,279
string Boolean int Etc if we want to
5677
03:28:42,279 --> 03:28:44,279
create our own type in solidity we can
5678
03:28:44,279 --> 03:28:46,359
use what's called a struct you can
5679
03:28:46,359 --> 03:28:49,199
create arrays or lists in solidity you
5680
03:28:49,199 --> 03:28:51,720
can create mappings or dictionaries or
5681
03:28:51,720 --> 03:28:54,399
hash tables in solidity where if you
5682
03:28:54,399 --> 03:28:55,840
give it a key it'll spit out the
5683
03:28:55,840 --> 03:28:57,720
variable associated with that specific
5684
03:28:57,720 --> 03:29:00,000
key we can create functions in solidity
5685
03:29:00,000 --> 03:29:02,199
that modify the state of the blockchain
5686
03:29:02,199 --> 03:29:04,199
we can also create functions in solidity
5687
03:29:04,199 --> 03:29:05,840
that don't modify the state of the
5688
03:29:05,840 --> 03:29:08,399
blockchain view and pure functions don't
5689
03:29:08,399 --> 03:29:10,080
modify the state of the blockchain we
5690
03:29:10,080 --> 03:29:11,720
can also specify different data
5691
03:29:11,720 --> 03:29:14,520
locations in our parameters of our
5692
03:29:14,520 --> 03:29:16,760
functions but we can only do for special
5693
03:29:16,760 --> 03:29:19,640
types like strings strs and arrays call
5694
03:29:19,640 --> 03:29:22,040
data and memory mean that that variable
5695
03:29:22,040 --> 03:29:24,720
is only temporary and will only exists
5696
03:29:24,720 --> 03:29:26,760
for the duration of the function call
5697
03:29:26,760 --> 03:29:28,640
Storage variables are permanent and stay
5698
03:29:28,640 --> 03:29:30,600
in the contract forever function
5699
03:29:30,600 --> 03:29:32,640
parameters can't be storage variables
5700
03:29:32,640 --> 03:29:34,160
since they're only going to exist for
5701
03:29:34,160 --> 03:29:36,000
the duration of the function call
5702
03:29:36,000 --> 03:29:37,520
whenever we hit compile in our smart
5703
03:29:37,520 --> 03:29:39,160
contracts it actually compiles our
5704
03:29:39,160 --> 03:29:42,439
solidity code down to evm compatible B
5705
03:29:42,439 --> 03:29:44,359
code or machine readable code we'll
5706
03:29:44,359 --> 03:29:45,800
learn more about those specifications
5707
03:29:45,800 --> 03:29:46,560
later
5708
03:29:46,560 --> 03:29:48,279
and last but not least congratulations
5709
03:29:48,279 --> 03:29:51,479
on your first contract
5710
03:30:09,040 --> 03:30:11,720
here all right let's get started now
5711
03:30:11,720 --> 03:30:13,760
with our lesson three remember
5712
03:30:13,760 --> 03:30:15,520
everything is in the GitHub repository
5713
03:30:15,520 --> 03:30:18,359
or the web3 dev. education we scroll
5714
03:30:18,359 --> 03:30:20,880
down once again we can scroll to lesson
5715
03:30:20,880 --> 03:30:23,479
three and again a lot of this is undone
5716
03:30:23,479 --> 03:30:25,319
but it'll be done for the actual video
5717
03:30:25,319 --> 03:30:27,239
scroll down to lesson 3 and we have
5718
03:30:27,239 --> 03:30:30,000
lesson 3 remix storage Factory all the
5719
03:30:30,000 --> 03:30:31,840
code that we're going to be working with
5720
03:30:31,840 --> 03:30:34,880
is in this remix storage Factory f23
5721
03:30:34,880 --> 03:30:37,080
GitHub repository all of the GitHub
5722
03:30:37,080 --> 03:30:39,160
repos associated with this course end
5723
03:30:39,160 --> 03:30:39,960
with
5724
03:30:39,960 --> 03:30:43,640
f23 which stands for Foundry 2023 I'm
5725
03:30:43,640 --> 03:30:46,080
going to first do a brief walkthrough of
5726
03:30:46,080 --> 03:30:47,359
what we're going to be coding for this
5727
03:30:47,359 --> 03:30:49,319
lesson so for now just sit back and
5728
03:30:49,319 --> 03:30:51,439
relax and enjoy for this lesson we're
5729
03:30:51,439 --> 03:30:52,800
going to be working with three new
5730
03:30:52,800 --> 03:30:54,960
contracts our original simple storage
5731
03:30:54,960 --> 03:30:56,840
doso which we're going to do a slate
5732
03:30:56,840 --> 03:31:00,479
modification to a new five storage. or
5733
03:31:00,479 --> 03:31:03,359
add F storage. and a storage factory.
5734
03:31:03,359 --> 03:31:06,000
soou our storage factory. is actually
5735
03:31:06,000 --> 03:31:08,080
going to be responsible for deploying
5736
03:31:08,080 --> 03:31:11,000
new simple storage contracts yes other
5737
03:31:11,000 --> 03:31:13,880
contracts can deploy contracts not only
5738
03:31:13,880 --> 03:31:15,359
is this going to be able to deploy other
5739
03:31:15,359 --> 03:31:16,640
contracts but but it's going to be able
5740
03:31:16,640 --> 03:31:19,439
to interact with other contracts as well
5741
03:31:19,439 --> 03:31:22,000
what we could do is we could deploy this
5742
03:31:22,000 --> 03:31:25,760
to a remix VM H deploy we'll compile all
5743
03:31:25,760 --> 03:31:29,080
of our code go to a remix VM scroll down
5744
03:31:29,080 --> 03:31:31,239
to select the contract we're going to
5745
03:31:31,239 --> 03:31:33,120
select storage Factory not simple
5746
03:31:33,120 --> 03:31:36,040
storage deploy this see that contract
5747
03:31:36,040 --> 03:31:37,960
that we just deployed down at the bottom
5748
03:31:37,960 --> 03:31:39,880
and you'll see our top function is this
5749
03:31:39,880 --> 03:31:41,600
function called create simple storage
5750
03:31:41,600 --> 03:31:43,560
contract where if we pull up our
5751
03:31:43,560 --> 03:31:45,359
terminal and we click create simple
5752
03:31:45,359 --> 03:31:47,080
storage contct contract you'll see we
5753
03:31:47,080 --> 03:31:49,399
get a new transaction at the bottom and
5754
03:31:49,399 --> 03:31:51,199
this transaction is the transaction that
5755
03:31:51,199 --> 03:31:53,560
we deployed a simple storage contract
5756
03:31:53,560 --> 03:31:56,239
from our storage Factory contract now we
5757
03:31:56,239 --> 03:31:58,080
can actually go ahead and interact with
5758
03:31:58,080 --> 03:32:00,439
our simple storage contract remember in
5759
03:32:00,439 --> 03:32:02,600
simple storage we have a function called
5760
03:32:02,600 --> 03:32:05,319
store which takes a favorite number we
5761
03:32:05,319 --> 03:32:07,439
can actually call this store function on
5762
03:32:07,439 --> 03:32:09,960
our simple storage contract from our
5763
03:32:09,960 --> 03:32:12,520
storage Factory contract using this F
5764
03:32:12,520 --> 03:32:15,279
store function so we'll add the index of
5765
03:32:15,279 --> 03:32:17,359
our simple store contract which since we
5766
03:32:17,359 --> 03:32:19,319
only deployed one so far it'll be at
5767
03:32:19,319 --> 03:32:21,520
inex zero and we'll say our new favorite
5768
03:32:21,520 --> 03:32:24,399
number is 1 123 and we'll hit F store
5769
03:32:24,399 --> 03:32:27,439
and we'll click SF store at 0123 SF
5770
03:32:27,439 --> 03:32:29,800
store stands for storage Factory Store
5771
03:32:29,800 --> 03:32:32,359
so we're going to store the number 123
5772
03:32:32,359 --> 03:32:35,040
on index0 and again don't worry about
5773
03:32:35,040 --> 03:32:36,359
this making too much sense yet we're
5774
03:32:36,359 --> 03:32:38,000
going to explain this all in a minute
5775
03:32:38,000 --> 03:32:41,239
now if we hit SF get of zero we'll go
5776
03:32:41,239 --> 03:32:43,080
ahead and get back 1 2 3 we're saying
5777
03:32:43,080 --> 03:32:45,040
let's get the value of the simple
5778
03:32:45,040 --> 03:32:47,160
storage contract stored at index Zer and
5779
03:32:47,160 --> 03:32:49,520
we do indeed get 1 2 3 additionally we
5780
03:32:49,520 --> 03:32:51,000
have this list of simple storage
5781
03:32:51,000 --> 03:32:54,319
contracts array or list and it's only
5782
03:32:54,319 --> 03:32:56,399
size one right now but if we type in
5783
03:32:56,399 --> 03:32:58,880
zero here we get back the address of
5784
03:32:58,880 --> 03:33:00,479
that original simple storage contract
5785
03:33:00,479 --> 03:33:02,239
that we deployed additionally in this
5786
03:33:02,239 --> 03:33:03,600
lesson we're going to learn about a ton
5787
03:33:03,600 --> 03:33:05,000
of incredibly important solidity
5788
03:33:05,000 --> 03:33:07,960
features such as Imports and inheritance
5789
03:33:07,960 --> 03:33:11,199
without further Ado let's get
5790
03:33:13,319 --> 03:33:15,399
froggy and one more time of course
5791
03:33:15,399 --> 03:33:17,080
remember all the code is available in
5792
03:33:17,080 --> 03:33:19,279
The Foundry full course f23 of the chain
5793
03:33:19,279 --> 03:33:22,439
exelor or on the web 3d. ucation site
5794
03:33:22,439 --> 03:33:24,359
once it's up so here we are back in
5795
03:33:24,359 --> 03:33:27,239
remix with our simpl storage. soulle if
5796
03:33:27,239 --> 03:33:29,040
you skipped over the last section and
5797
03:33:29,040 --> 03:33:31,000
want to get that contract just come to
5798
03:33:31,000 --> 03:33:32,680
the full repository go down to lesson
5799
03:33:32,680 --> 03:33:35,040
two go over to the code in the GitHub
5800
03:33:35,040 --> 03:33:36,520
repo associated with this course the
5801
03:33:36,520 --> 03:33:39,640
remix simple storage f23 and just copy
5802
03:33:39,640 --> 03:33:42,399
and paste everything into remix yourself
5803
03:33:42,399 --> 03:33:43,720
to make sure you've done it correctly be
5804
03:33:43,720 --> 03:33:46,040
sure to hit compile we have our simple
5805
03:33:46,040 --> 03:33:47,600
storage contract that we created in our
5806
03:33:47,600 --> 03:33:49,359
last lesson which is great it allows us
5807
03:33:49,359 --> 03:33:51,359
to store our favorite number and it
5808
03:33:51,359 --> 03:33:53,399
allows us to store a list of people who
5809
03:33:53,399 --> 03:33:54,880
have different favorite numbers also a
5810
03:33:54,880 --> 03:33:56,439
mapping and some other different
5811
03:33:56,439 --> 03:33:58,000
functionality with interacting with
5812
03:33:58,000 --> 03:34:00,279
people's favorite number but we want to
5813
03:34:00,279 --> 03:34:02,479
go even further with this we want
5814
03:34:02,479 --> 03:34:04,359
another contract to actually deploy this
5815
03:34:04,359 --> 03:34:06,080
simple storage contract for us and
5816
03:34:06,080 --> 03:34:08,160
interact with it contracts interacting
5817
03:34:08,160 --> 03:34:09,600
with each other seamlessly and
5818
03:34:09,600 --> 03:34:12,120
permissionless is a feature of smart
5819
03:34:12,120 --> 03:34:13,399
contracts and blockchain development
5820
03:34:13,399 --> 03:34:15,000
that's absolutely essential and crucial
5821
03:34:15,000 --> 03:34:16,399
and one of the reasons why blockchain
5822
03:34:16,399 --> 03:34:18,399
development is so powerful the ability
5823
03:34:18,399 --> 03:34:19,880
for contracts to interact with each
5824
03:34:19,880 --> 03:34:21,760
other seamlessly is something known as
5825
03:34:21,760 --> 03:34:23,800
composability smart contracts are
5826
03:34:23,800 --> 03:34:25,399
composable because they can easily
5827
03:34:25,399 --> 03:34:27,359
interact with each other this becomes
5828
03:34:27,359 --> 03:34:28,640
even more important when we get to
5829
03:34:28,640 --> 03:34:30,279
topics such as defi where we can have
5830
03:34:30,279 --> 03:34:31,800
incredibly complicated Financial
5831
03:34:31,800 --> 03:34:33,279
products and instruments interact with
5832
03:34:33,279 --> 03:34:34,960
each other seamlessly because they're
5833
03:34:34,960 --> 03:34:36,399
all using the same smart contract
5834
03:34:36,399 --> 03:34:37,760
interface so we're going to keep our
5835
03:34:37,760 --> 03:34:40,760
simpl storage. the exact same way it was
5836
03:34:40,760 --> 03:34:42,680
from the last lesson and we'll update it
5837
03:34:42,680 --> 03:34:44,160
in a little bit but let's go ahead and
5838
03:34:44,160 --> 03:34:46,080
create a new contract called called
5839
03:34:46,080 --> 03:34:48,880
storage factory. Soul so let's go ahead
5840
03:34:48,880 --> 03:34:50,840
and get this contract set up now we're
5841
03:34:50,840 --> 03:34:52,120
going to be doing this a lot and when we
5842
03:34:52,120 --> 03:34:54,680
work with AI pair programmer now we're
5843
03:34:54,680 --> 03:34:56,080
going to be doing this a lot and when we
5844
03:34:56,080 --> 03:34:57,800
work with AI pair programming this is
5845
03:34:57,800 --> 03:34:59,560
going to be a lot easier for us to do
5846
03:34:59,560 --> 03:35:01,239
but for now repetition is the mother
5847
03:35:01,239 --> 03:35:03,239
skill so let's keep going first thing we
5848
03:35:03,239 --> 03:35:05,000
need to do is what if you want to pause
5849
03:35:05,000 --> 03:35:07,199
the video and add the first two things
5850
03:35:07,199 --> 03:35:08,600
you should put at the top of every slity
5851
03:35:08,600 --> 03:35:11,000
smart contract right now go ahead but
5852
03:35:11,000 --> 03:35:12,479
for those of you who didn't pause let's
5853
03:35:12,479 --> 03:35:13,600
go ahead and do
5854
03:35:13,600 --> 03:35:18,000
spdx license ident to fire MIT and then
5855
03:35:18,000 --> 03:35:21,359
let's do pragma solidity
5856
03:35:21,359 --> 03:35:24,040
0.818 or 19 or whatever you want to do
5857
03:35:24,040 --> 03:35:25,720
you know what let's do 19 what do we do
5858
03:35:25,720 --> 03:35:28,399
in simple storage we did 18 let's do
5859
03:35:28,399 --> 03:35:30,680
18 and then we'll do contract so this
5860
03:35:30,680 --> 03:35:32,439
will be the third thing actually
5861
03:35:32,439 --> 03:35:36,439
contract storage Factory like this and I
5862
03:35:36,439 --> 03:35:38,680
hit command s but you can also go and
5863
03:35:38,680 --> 03:35:40,720
compile like so and I'm also just going
5864
03:35:40,720 --> 03:35:42,239
to add the carrot here meaning we're
5865
03:35:42,239 --> 03:35:44,720
going to use 0.818 but any version
5866
03:35:44,720 --> 03:35:47,120
greater than that all also works as well
5867
03:35:47,120 --> 03:35:48,560
awesome now this storage Factory
5868
03:35:48,560 --> 03:35:50,199
contract is going to be deploying a
5869
03:35:50,199 --> 03:35:52,720
simple storage contract so let's create
5870
03:35:52,720 --> 03:35:54,479
a function that can actually deploy or
5871
03:35:54,479 --> 03:35:56,439
create a simple storage contract so
5872
03:35:56,439 --> 03:36:00,399
we'll say function create simple storage
5873
03:36:00,399 --> 03:36:02,399
contract and we'll make this a public
5874
03:36:02,399 --> 03:36:03,720
function and we're going to have this
5875
03:36:03,720 --> 03:36:05,239
create simple storage contract function
5876
03:36:05,239 --> 03:36:07,600
deploy a contract and then save it to a
5877
03:36:07,600 --> 03:36:10,199
state variable or a storage variable but
5878
03:36:10,199 --> 03:36:12,160
the question is okay well how does the
5879
03:36:12,160 --> 03:36:13,960
storage Factory know what the simple
5880
03:36:13,960 --> 03:36:15,920
storage contract even looks like how
5881
03:36:15,920 --> 03:36:19,160
does this contract know about this
5882
03:36:19,160 --> 03:36:21,319
contract how does this contract know
5883
03:36:21,319 --> 03:36:23,600
that this contract even exists the first
5884
03:36:23,600 --> 03:36:25,000
way that we could do this is we can
5885
03:36:25,000 --> 03:36:27,239
actually go to our simple storage. Soul
5886
03:36:27,239 --> 03:36:29,920
contract and start highlighting from the
5887
03:36:29,920 --> 03:36:32,279
contract word and scroll all the way
5888
03:36:32,279 --> 03:36:35,000
down to the end of the contract copy it
5889
03:36:35,000 --> 03:36:38,040
command C or rightclick copy go back
5890
03:36:38,040 --> 03:36:41,199
over to storage Factory and Below pragma
5891
03:36:41,199 --> 03:36:43,800
solidity but above contract storage
5892
03:36:43,800 --> 03:36:46,439
Factory paste it in here if we go ahead
5893
03:36:46,439 --> 03:36:48,600
and command s or compile this you'll see
5894
03:36:48,600 --> 03:36:50,080
that this actually goes ahead and
5895
03:36:50,080 --> 03:36:53,199
compiles successfully huh so this is to
5896
03:36:53,199 --> 03:36:55,239
show you that yes right now in our
5897
03:36:55,239 --> 03:36:57,479
storage factory. soulle we have contract
5898
03:36:57,479 --> 03:36:59,880
simple storage which ends here and we
5899
03:36:59,880 --> 03:37:04,239
also have contract storage Factory down
5900
03:37:05,960 --> 03:37:08,479
here you're allowed to have multiple
5901
03:37:08,479 --> 03:37:11,359
contracts in the same file now this
5902
03:37:11,359 --> 03:37:13,720
isn't a best practice because we really
5903
03:37:13,720 --> 03:37:15,600
don't want to be having multiple
5904
03:37:15,600 --> 03:37:17,840
contracts in the same file when we could
5905
03:37:17,840 --> 03:37:19,880
separate them out into their own files
5906
03:37:19,880 --> 03:37:21,439
as your projects get bigger and bigger
5907
03:37:21,439 --> 03:37:23,080
if you just add all of your contracts
5908
03:37:23,080 --> 03:37:25,040
into the same file it can get really
5909
03:37:25,040 --> 03:37:27,199
really confusing really difficult to
5910
03:37:27,199 --> 03:37:29,080
jump around the code and find the places
5911
03:37:29,080 --> 03:37:30,479
where you want to add stuff so normally
5912
03:37:30,479 --> 03:37:31,960
it's best practice to keep them
5913
03:37:31,960 --> 03:37:34,040
separated like we did above but we'll
5914
03:37:34,040 --> 03:37:35,120
learn a little bit more about how to
5915
03:37:35,120 --> 03:37:36,680
keep them separate in just a minute if
5916
03:37:36,680 --> 03:37:38,960
you go down to the deploy Tab and you
5917
03:37:38,960 --> 03:37:41,439
say on the remix VM and scroll down you
5918
03:37:41,439 --> 03:37:42,880
actually have this section to choose
5919
03:37:42,880 --> 03:37:45,120
your contract we can choose either one
5920
03:37:45,120 --> 03:37:46,960
of these contracts right now and if on
5921
03:37:46,960 --> 03:37:48,319
the right side you have storagea
5922
03:37:48,319 --> 03:37:50,600
factory. in this contract section you
5923
03:37:50,600 --> 03:37:53,040
can actually choose either one simple
5924
03:37:53,040 --> 03:37:54,760
storage or storage Factory and you can
5925
03:37:54,760 --> 03:37:56,399
see they're both in storage factory.
5926
03:37:56,399 --> 03:37:58,080
soulle if on the right hand side we go
5927
03:37:58,080 --> 03:38:00,199
to simple storage and we go back to this
5928
03:38:00,199 --> 03:38:01,720
contract section we can only chose
5929
03:38:01,720 --> 03:38:03,199
simple storage because the simple
5930
03:38:03,199 --> 03:38:04,960
storage contract only has one contract
5931
03:38:04,960 --> 03:38:06,920
in it the storage Factory has both
5932
03:38:06,920 --> 03:38:09,080
simple storage and storage Factory so
5933
03:38:09,080 --> 03:38:10,800
that can get a little confusing as well
5934
03:38:10,800 --> 03:38:12,080
if you have multiple contracts in the
5935
03:38:12,080 --> 03:38:13,760
same file but let's stick with this
5936
03:38:13,760 --> 03:38:15,760
methodology for now in our storage
5937
03:38:15,760 --> 03:38:17,279
Factory and let's even close out simple
5938
03:38:17,279 --> 03:38:18,760
storage. Soul at the top just so we
5939
03:38:18,760 --> 03:38:20,720
don't get confused in our storage
5940
03:38:20,720 --> 03:38:22,560
factory. Soul let's scroll back down to
5941
03:38:22,560 --> 03:38:25,160
storage Factory because now that we have
5942
03:38:25,160 --> 03:38:27,040
our simple storage in this file we can
5943
03:38:27,040 --> 03:38:30,520
actually deploy the simple storage
5944
03:38:33,960 --> 03:38:36,199
contract so this function is going to
5945
03:38:36,199 --> 03:38:37,800
deploy a simple storage contract but
5946
03:38:37,800 --> 03:38:39,680
we're going to save it to a storage or
5947
03:38:39,680 --> 03:38:41,399
state variable and we're going to do it
5948
03:38:41,399 --> 03:38:43,279
the exact same way we've been saving any
5949
03:38:43,279 --> 03:38:45,760
variable first thing remember like
5950
03:38:45,760 --> 03:38:48,520
remember how we did U 256 public
5951
03:38:48,520 --> 03:38:50,720
favorite number this was in the format
5952
03:38:50,720 --> 03:38:53,680
type visibility name we're going to do
5953
03:38:53,680 --> 03:38:55,680
the exact same thing the type of a
5954
03:38:55,680 --> 03:38:57,520
simple storage contract is going to be
5955
03:38:57,520 --> 03:38:59,520
simple storage and the reason that
5956
03:38:59,520 --> 03:39:01,080
solidity is going to be able to identify
5957
03:39:01,080 --> 03:39:02,800
this keyword is because it's the same
5958
03:39:02,800 --> 03:39:05,800
name as contract in the same sense that
5959
03:39:05,800 --> 03:39:08,000
our struct keyword allows us to create a
5960
03:39:08,000 --> 03:39:10,479
person type the contract keyword allows
5961
03:39:10,479 --> 03:39:12,720
you to create a new type of well a type
5962
03:39:12,720 --> 03:39:15,399
of simple storage contract so simple
5963
03:39:15,399 --> 03:39:17,000
storage for now we'll just give it a
5964
03:39:17,000 --> 03:39:19,199
visibility of public and we'll give it a
5965
03:39:19,199 --> 03:39:21,800
variable name simple storage now this is
5966
03:39:21,800 --> 03:39:23,199
going to be a syntax you're going to see
5967
03:39:23,199 --> 03:39:24,560
a lot and it might be a little bit
5968
03:39:24,560 --> 03:39:25,880
confusing the first couple times you
5969
03:39:25,880 --> 03:39:27,880
read it the difference between these two
5970
03:39:27,880 --> 03:39:29,800
is very subtle the difference between
5971
03:39:29,800 --> 03:39:31,520
simple storage on the left and simple
5972
03:39:31,520 --> 03:39:33,680
storage on the right is very subtle it's
5973
03:39:33,680 --> 03:39:35,840
simply that the S is lowercased over
5974
03:39:35,840 --> 03:39:38,880
here and the S is capitalized over here
5975
03:39:38,880 --> 03:39:41,640
solidity is case sensitive so these are
5976
03:39:41,640 --> 03:39:44,439
actually different word simple storage
5977
03:39:44,439 --> 03:39:46,040
here is referring to the contract simple
5978
03:39:46,040 --> 03:39:47,399
storage here is referring to the
5979
03:39:47,399 --> 03:39:49,239
variable you'll often see people use the
5980
03:39:49,239 --> 03:39:50,680
syntax when working with contracts where
5981
03:39:50,680 --> 03:39:52,720
they name the variable the exact same as
5982
03:39:52,720 --> 03:39:55,120
the contract itself if this is confusing
5983
03:39:55,120 --> 03:39:59,000
to you you can do my simple storage
5984
03:39:59,000 --> 03:40:01,760
instead of simple storage with lowercase
5985
03:40:01,760 --> 03:40:03,960
so either one of these works it's good
5986
03:40:03,960 --> 03:40:07,080
to get used to this as such but if
5987
03:40:07,080 --> 03:40:08,840
that's confusing you can do my simple
5988
03:40:08,840 --> 03:40:10,960
storage now in our create simple storage
5989
03:40:10,960 --> 03:40:12,720
contract function we're going to say
5990
03:40:12,720 --> 03:40:17,680
simple storage equals new simple storage
5991
03:40:17,680 --> 03:40:19,680
like this this new keyword is how
5992
03:40:19,680 --> 03:40:22,720
solidity knows to deploy a contract so
5993
03:40:22,720 --> 03:40:24,359
adjust this code alone if we go to the
5994
03:40:24,359 --> 03:40:26,760
compile tab we compile this this does
5995
03:40:26,760 --> 03:40:29,319
indeed compile we can go to deploy we
5996
03:40:29,319 --> 03:40:30,680
need to make sure we're on the storage
5997
03:40:30,680 --> 03:40:32,960
factory. Soul on the right hand side
5998
03:40:32,960 --> 03:40:35,000
we'll scroll down to the contract we can
5999
03:40:35,000 --> 03:40:37,399
actually deploy our storage Factory like
6000
03:40:37,399 --> 03:40:39,399
so hitting the deploy button and
6001
03:40:39,399 --> 03:40:41,520
remember you can see the transaction in
6002
03:40:41,520 --> 03:40:43,600
the terminal here and we can scroll down
6003
03:40:43,600 --> 03:40:45,840
to the contract right now there's two
6004
03:40:45,840 --> 03:40:48,279
buttons we have our blue view function
6005
03:40:48,279 --> 03:40:50,319
simple storage because again the public
6006
03:40:50,319 --> 03:40:52,520
keyword automatically gives the variable
6007
03:40:52,520 --> 03:40:54,520
name a getter function or a view
6008
03:40:54,520 --> 03:40:56,080
function and of course we have our
6009
03:40:56,080 --> 03:40:58,279
create simple storage contract orange
6010
03:40:58,279 --> 03:40:59,680
button because it is actually a
6011
03:40:59,680 --> 03:41:01,720
transaction right now simple storage
6012
03:41:01,720 --> 03:41:04,239
returns nothing the zero the default
6013
03:41:04,239 --> 03:41:06,080
value for an address which is the zero
6014
03:41:06,080 --> 03:41:08,640
address and if we call create simple
6015
03:41:08,640 --> 03:41:11,239
storage contract we get see a green
6016
03:41:11,239 --> 03:41:13,239
check mark meaning that transaction went
6017
03:41:13,239 --> 03:41:14,960
through now if we call the simple
6018
03:41:14,960 --> 03:41:17,640
storeage blue view function we see we
6019
03:41:17,640 --> 03:41:19,359
indeed get an address here we have
6020
03:41:19,359 --> 03:41:21,560
deployed our simple storage contract
6021
03:41:21,560 --> 03:41:24,600
from another contract oh my goodness so
6022
03:41:24,600 --> 03:41:26,120
congratulations now you know how a
6023
03:41:26,120 --> 03:41:28,000
contract can deploy another contract
6024
03:41:28,000 --> 03:41:30,319
awesome
6025
03:41:32,479 --> 03:41:35,560
job but the thing is like I was saying
6026
03:41:35,560 --> 03:41:37,640
if we just add all of our contracts into
6027
03:41:37,640 --> 03:41:39,479
the same file and we have these massive
6028
03:41:39,479 --> 03:41:41,120
contracts all interweave between each
6029
03:41:41,120 --> 03:41:42,960
other and can get very cluttered and
6030
03:41:42,960 --> 03:41:44,840
very confusing so is there a better way
6031
03:41:44,840 --> 03:41:46,720
we can actually arrange and organize our
6032
03:41:46,720 --> 03:41:48,479
code other than this and this is
6033
03:41:48,479 --> 03:41:49,960
actually even a little bit redundant
6034
03:41:49,960 --> 03:41:51,159
since we already have our simple
6035
03:41:51,159 --> 03:41:53,439
storage. soulle if I change something in
6036
03:41:53,439 --> 03:41:55,359
here then I would also have to go and
6037
03:41:55,359 --> 03:41:57,239
change it in here and that's too much
6038
03:41:57,239 --> 03:41:59,520
work for me as an engineer I will work
6039
03:41:59,520 --> 03:42:02,279
incredibly hard to be incredibly lazy so
6040
03:42:02,279 --> 03:42:04,000
instead of doing this we can use what's
6041
03:42:04,000 --> 03:42:06,120
called an import if we go ahead and
6042
03:42:06,120 --> 03:42:08,640
delete our contract simple storage in
6043
03:42:08,640 --> 03:42:11,080
our storage Factory here so that now we
6044
03:42:11,080 --> 03:42:13,520
just have the storage Factory contract
6045
03:42:13,520 --> 03:42:15,279
we can go ahead and use the import key
6046
03:42:15,279 --> 03:42:17,520
word to import simple storage. soulle so
6047
03:42:17,520 --> 03:42:19,199
we can do
6048
03:42:19,199 --> 03:42:20,960
import
6049
03:42:20,960 --> 03:42:23,279
do/ simple
6050
03:42:23,279 --> 03:42:25,880
storage. and a little semicolon here
6051
03:42:25,880 --> 03:42:29,239
this import do/ simple storage. is the
6052
03:42:29,239 --> 03:42:30,800
exact same as if we had this giant
6053
03:42:30,800 --> 03:42:33,000
simple storage in here so this import
6054
03:42:33,000 --> 03:42:35,239
simple storage. soulle is a shorthand
6055
03:42:35,239 --> 03:42:37,000
version of copy pasting that simple
6056
03:42:37,000 --> 03:42:39,600
storage. soulle into this contract and
6057
03:42:39,600 --> 03:42:42,720
now we're able to have simple storage.
6058
03:42:42,720 --> 03:42:45,600
in its own file and storage Factory just
6059
03:42:45,600 --> 03:42:48,080
import it from simple storage making our
6060
03:42:48,080 --> 03:42:50,560
lives much easier it takes our path
6061
03:42:50,560 --> 03:42:52,720
package or GitHub which we'll explain in
6062
03:42:52,720 --> 03:42:55,760
a little bit and and copy paste whatever
6063
03:42:55,760 --> 03:42:58,800
in that file at the top of our file
6064
03:42:58,800 --> 03:43:00,520
literally solidity for us is copy
6065
03:43:00,520 --> 03:43:02,319
pasting everything in here and sticking
6066
03:43:02,319 --> 03:43:05,040
it up here so we can go ahead run this
6067
03:43:05,040 --> 03:43:07,960
again let's compile delete our old
6068
03:43:07,960 --> 03:43:11,239
contract run remix VM let's be sure
6069
03:43:11,239 --> 03:43:13,080
we're on storage Factory we'll go to
6070
03:43:13,080 --> 03:43:15,120
storage Factory we'll deploy it scroll
6071
03:43:15,120 --> 03:43:17,359
scroll down click here simple storage
6072
03:43:17,359 --> 03:43:19,159
starts up as nothing create simple
6073
03:43:19,159 --> 03:43:21,319
storage oh my goodness look we deployed
6074
03:43:21,319 --> 03:43:24,479
a contract huzzah great work so now that
6075
03:43:24,479 --> 03:43:25,479
we're starting to work with different
6076
03:43:25,479 --> 03:43:26,960
files there's a number of things we want
6077
03:43:26,960 --> 03:43:28,880
to consider first one is actually the
6078
03:43:28,880 --> 03:43:30,760
solidity version so right now we're
6079
03:43:30,760 --> 03:43:34,600
using 0.8.1 with no carat and in storage
6080
03:43:34,600 --> 03:43:37,760
Factor we're using 0.8.1 with a carat if
6081
03:43:37,760 --> 03:43:39,640
I were to for example move the solidity
6082
03:43:39,640 --> 03:43:42,239
version of this down to
6083
03:43:42,239 --> 03:43:45,960
0.8.6 and go to compile this with a
6084
03:43:45,960 --> 03:43:47,800
different version remix is actually
6085
03:43:47,800 --> 03:43:49,439
going to remix is actually going to
6086
03:43:49,439 --> 03:43:51,600
automatically bump this up to
6087
03:43:51,600 --> 03:43:53,920
0.8.9 or actually remix is actually
6088
03:43:53,920 --> 03:43:55,439
going to automatically bump this up to
6089
03:43:55,439 --> 03:43:57,920
0.818 if I'm on the simple storage
6090
03:43:57,920 --> 03:44:00,680
because 0.818 is the version that works
6091
03:44:00,680 --> 03:44:02,760
for simple storage and it still is
6092
03:44:02,760 --> 03:44:05,239
compatible with storage Factory however
6093
03:44:05,239 --> 03:44:06,960
if I were to take storage Factory and
6094
03:44:06,960 --> 03:44:08,199
move it to
6095
03:44:08,199 --> 03:44:10,840
0.7.5 and try to compile it's going to
6096
03:44:10,840 --> 03:44:12,399
try to compile this with
6097
03:44:12,399 --> 03:44:15,399
0.7.0 and our simple storage with 0 .
6098
03:44:15,399 --> 03:44:17,439
7.6 and it's not going to be able to do
6099
03:44:17,439 --> 03:44:18,960
it for both and so we're going to get a
6100
03:44:18,960 --> 03:44:20,840
compilation error so when working with
6101
03:44:20,840 --> 03:44:22,439
multiple files it's important to keep
6102
03:44:22,439 --> 03:44:24,760
the version of solidity in mind because
6103
03:44:24,760 --> 03:44:25,920
you want to make sure that all of your
6104
03:44:25,920 --> 03:44:28,199
contracts can actually compile together
6105
03:44:28,199 --> 03:44:29,680
so this is great and all but right from
6106
03:44:29,680 --> 03:44:31,399
the get-go I want to teach you the more
6107
03:44:31,399 --> 03:44:33,399
advanced import that you should always
6108
03:44:33,399 --> 03:44:35,800
use so this is good but we actually
6109
03:44:35,800 --> 03:44:37,520
never want to default to this we want to
6110
03:44:37,520 --> 03:44:39,439
default to something called named
6111
03:44:39,439 --> 03:44:41,520
Imports let's say our simple storage.
6112
03:44:41,520 --> 03:44:43,199
Soul contract had a ton of other
6113
03:44:43,199 --> 03:44:47,080
contracts like contract simple storage 2
6114
03:44:47,080 --> 03:44:50,359
simple storage 3 simple storage 4 and
6115
03:44:50,359 --> 03:44:52,680
these were all massive massive contracts
6116
03:44:52,680 --> 03:44:54,920
as we have this right now import simple
6117
03:44:54,920 --> 03:44:57,399
storage. would import everything from
6118
03:44:57,399 --> 03:44:59,439
here simple storage simple storage 2
6119
03:44:59,439 --> 03:45:01,880
simple storage 3 simple storage 4 and if
6120
03:45:01,880 --> 03:45:03,720
these files were incredibly big when we
6121
03:45:03,720 --> 03:45:05,720
deploy our storage Factory it would have
6122
03:45:05,720 --> 03:45:08,640
to calculate all this extra computation
6123
03:45:08,640 --> 03:45:10,439
making the deployment of our storage
6124
03:45:10,439 --> 03:45:12,279
Factory more expensive if that's
6125
03:45:12,279 --> 03:45:13,680
confusing to you don't worry about it
6126
03:45:13,680 --> 03:45:15,880
right now additionally in the future
6127
03:45:15,880 --> 03:45:17,800
these can import from weird places that
6128
03:45:17,800 --> 03:45:20,720
aren't compatible with storage Factory
6129
03:45:20,720 --> 03:45:21,920
again that's not going to make sense
6130
03:45:21,920 --> 03:45:24,239
quite yet and that's okay but in any
6131
03:45:24,239 --> 03:45:26,520
case there's a way for us to not import
6132
03:45:26,520 --> 03:45:28,880
this whole file but only a very specific
6133
03:45:28,880 --> 03:45:31,040
contract or a specific section of our
6134
03:45:31,040 --> 03:45:33,600
simple storage. sole so instead what we
6135
03:45:33,600 --> 03:45:35,880
can do is in our import statement we can
6136
03:45:35,880 --> 03:45:38,120
specify the exact contract that we want
6137
03:45:38,120 --> 03:45:40,640
to import from this file so in our
6138
03:45:40,640 --> 03:45:42,840
simple storage. soou let's say we do
6139
03:45:42,840 --> 03:45:45,279
have these other contracts in here we
6140
03:45:45,279 --> 03:45:47,120
could say we only want to import simple
6141
03:45:47,120 --> 03:45:49,720
storage not simple storage 2 not not
6142
03:45:49,720 --> 03:45:52,239
simple storage 3 not simple storage 4 by
6143
03:45:52,239 --> 03:45:55,720
saying import these little brackets here
6144
03:45:55,720 --> 03:45:58,760
simple storage from simpl storage.
6145
03:45:58,760 --> 03:46:00,800
soulle and this goes ahead and compiles
6146
03:46:00,800 --> 03:46:04,159
correctly we could also import multiple
6147
03:46:04,159 --> 03:46:06,199
contracts from our simple storage for
6148
03:46:06,199 --> 03:46:07,760
example we could do import simple
6149
03:46:07,760 --> 03:46:11,239
storage simple storage 2 from simple
6150
03:46:11,239 --> 03:46:14,199
storage. soulle this way we only import
6151
03:46:14,199 --> 03:46:16,239
the exact specific contracts that we
6152
03:46:16,239 --> 03:46:18,720
want from these other files and I
6153
03:46:18,720 --> 03:46:21,040
promise you in the future always
6154
03:46:21,040 --> 03:46:24,439
referring to named Imports instead of
6155
03:46:24,439 --> 03:46:26,439
this type of imports will save you a lot
6156
03:46:26,439 --> 03:46:28,880
of headache in the future so always
6157
03:46:28,880 --> 03:46:31,680
default to this never default to this
6158
03:46:31,680 --> 03:46:33,120
just by learning this you are already
6159
03:46:33,120 --> 03:46:35,239
better than 80% of the current solidity
6160
03:46:35,239 --> 03:46:36,680
developers so
6161
03:46:36,680 --> 03:46:39,040
congratulations but all right fantastic
6162
03:46:39,040 --> 03:46:40,920
so we've learned about Imports we're
6163
03:46:40,920 --> 03:46:43,199
able to import our simple storage from
6164
03:46:43,199 --> 03:46:45,439
simpl storage. soou We're importing it
6165
03:46:45,439 --> 03:46:48,880
in the more advanced way
6166
03:46:52,159 --> 03:46:54,319
congratulations now already here you
6167
03:46:54,319 --> 03:46:55,880
might actually start running into some
6168
03:46:55,880 --> 03:46:57,239
questions right and we're going to get
6169
03:46:57,239 --> 03:46:59,159
more and more advanced with this course
6170
03:46:59,159 --> 03:47:00,760
and you're going to have questions which
6171
03:47:00,760 --> 03:47:02,640
is a good thing if you don't understand
6172
03:47:02,640 --> 03:47:03,720
stuff that means you're thinking
6173
03:47:03,720 --> 03:47:06,120
critically and you're approaching the
6174
03:47:06,120 --> 03:47:08,319
subject matter the right way so this is
6175
03:47:08,319 --> 03:47:10,359
where we're going to jump into again
6176
03:47:10,359 --> 03:47:13,279
doing a little bit of an AI chat example
6177
03:47:13,279 --> 03:47:15,399
so for example on this line let's say
6178
03:47:15,399 --> 03:47:17,359
you're a little bit confused and you go
6179
03:47:17,359 --> 03:47:18,720
what's the difference between simple
6180
03:47:18,720 --> 03:47:21,279
storage here and simple storage here I
6181
03:47:21,279 --> 03:47:24,120
don't understand so let's learn how to
6182
03:47:24,120 --> 03:47:26,920
work with chat chbt or any AI buddy to
6183
03:47:26,920 --> 03:47:28,960
ask them to help clarify so we're going
6184
03:47:28,960 --> 03:47:31,279
to go ahead I'm going to hit command a
6185
03:47:31,279 --> 03:47:33,760
or you can just highlight everything
6186
03:47:33,760 --> 03:47:36,960
command C to copy or rightclick copy
6187
03:47:36,960 --> 03:47:39,399
we'll go over to chat gbt and in here
6188
03:47:39,399 --> 03:47:42,319
we're going to ask the question hi I'm
6189
03:47:42,319 --> 03:47:46,359
having a hard time and let's zoom in
6190
03:47:46,359 --> 03:47:49,600
understanding the difference between the
6191
03:47:49,600 --> 03:47:53,640
simple storages on this line and here's
6192
03:47:53,640 --> 03:47:56,239
where we want to be very specific when
6193
03:47:56,239 --> 03:47:57,920
we're talking with AIS so I'm going to
6194
03:47:57,920 --> 03:48:00,279
hit shift enter so that it doesn't
6195
03:48:00,279 --> 03:48:03,399
actually send the question to chat TBT
6196
03:48:03,399 --> 03:48:05,479
but I'm going to put three back ticks
6197
03:48:05,479 --> 03:48:08,359
shift enter again and actually I said
6198
03:48:08,359 --> 03:48:09,600
we're going to copy the whole thing but
6199
03:48:09,600 --> 03:48:12,479
let's just copy this this single line
6200
03:48:12,479 --> 03:48:15,680
and paste it in here shift enter again
6201
03:48:15,680 --> 03:48:17,800
three back ticks again adding this
6202
03:48:17,800 --> 03:48:21,399
delimiter tells chat gbt that this is a
6203
03:48:21,399 --> 03:48:23,680
block of code and it makes it easier for
6204
03:48:23,680 --> 03:48:26,239
chat gbt to be able to understand that
6205
03:48:26,239 --> 03:48:28,000
this is a block of code and I'll hit
6206
03:48:28,000 --> 03:48:30,960
shift enter twice and if you have a lot
6207
03:48:30,960 --> 03:48:32,399
of code you're not going to be able to
6208
03:48:32,399 --> 03:48:34,479
copy your whole contract because a lot
6209
03:48:34,479 --> 03:48:37,600
of these AIS can only understand so much
6210
03:48:37,600 --> 03:48:40,040
in a question but this is small enough
6211
03:48:40,040 --> 03:48:41,479
that we can actually just go ahead and
6212
03:48:41,479 --> 03:48:43,439
copy the whole thing bring it back over
6213
03:48:43,439 --> 03:48:47,399
to chat yout and say here is my full
6214
03:48:47,399 --> 03:48:50,319
code and then we'll do again shift enter
6215
03:48:50,319 --> 03:48:53,479
three back ticks shift enter paste shift
6216
03:48:53,479 --> 03:48:56,000
enter three back ticks so now we have a
6217
03:48:56,000 --> 03:48:59,279
little AI prompt here that we can ask in
6218
03:48:59,279 --> 03:49:02,159
chubbt and and I don't have this in here
6219
03:49:02,159 --> 03:49:04,560
yet but in the GitHub repo associated
6220
03:49:04,560 --> 03:49:06,359
with this lesson I will add this AI
6221
03:49:06,359 --> 03:49:09,000
prompt in here so let's go to the bottom
6222
03:49:09,000 --> 03:49:10,399
and I was saying you need to use shift
6223
03:49:10,399 --> 03:49:11,880
enter but I guess you could just use
6224
03:49:11,880 --> 03:49:13,359
enter that's fine let's go ahead and
6225
03:49:13,359 --> 03:49:14,720
click the send button and it'll send
6226
03:49:14,720 --> 03:49:17,120
send it the question so now it'll start
6227
03:49:17,120 --> 03:49:18,680
outputting here and let's see what it
6228
03:49:18,680 --> 03:49:20,560
says and this is where we can already
6229
03:49:20,560 --> 03:49:23,000
start to see the power of these AI
6230
03:49:23,000 --> 03:49:25,159
buddies as learning buddies we see in
6231
03:49:25,159 --> 03:49:27,399
the given code simple storage is a
6232
03:49:27,399 --> 03:49:29,960
variable of type simple storage which is
6233
03:49:29,960 --> 03:49:31,720
a contract defined in simple storage.
6234
03:49:31,720 --> 03:49:34,359
Soul tells us what the line is doing it
6235
03:49:34,359 --> 03:49:36,120
clarifies the differences a little bit
6236
03:49:36,120 --> 03:49:38,840
more and a lot of this beginner basic
6237
03:49:38,840 --> 03:49:41,359
stuff AIS are really good at once we get
6238
03:49:41,359 --> 03:49:43,199
more and more advanced AIS are going to
6239
03:49:43,199 --> 03:49:45,399
start breaking apart but but at least
6240
03:49:45,399 --> 03:49:47,080
for the beginning of this course AIS are
6241
03:49:47,080 --> 03:49:48,279
going to be incredibly helpful and
6242
03:49:48,279 --> 03:49:49,880
Incredibly good at explaining a lot of
6243
03:49:49,880 --> 03:49:51,720
these what we could do if we wanted to
6244
03:49:51,720 --> 03:49:53,520
is we could also go ahead and copy this
6245
03:49:53,520 --> 03:49:55,560
prompt we can go over to something like
6246
03:49:55,560 --> 03:49:58,279
Bard paste it in here and ask Bard the
6247
03:49:58,279 --> 03:49:59,800
same thing and here's already a good
6248
03:49:59,800 --> 03:50:01,720
example of where an AI can get things
6249
03:50:01,720 --> 03:50:04,199
wrong if we scroll down it's telling me
6250
03:50:04,199 --> 03:50:05,720
you can use simple storage variable to
6251
03:50:05,720 --> 03:50:07,439
interact with the new simple storage
6252
03:50:07,439 --> 03:50:09,359
contract for example you could call the
6253
03:50:09,359 --> 03:50:11,359
set function to set the value on stored
6254
03:50:11,359 --> 03:50:13,359
data variable or you could call the get
6255
03:50:13,359 --> 03:50:15,279
function to get the value of the stored
6256
03:50:15,279 --> 03:50:18,000
date variable uh there is no stored data
6257
03:50:18,000 --> 03:50:19,960
variable so I don't know where it's
6258
03:50:19,960 --> 03:50:21,880
getting that from so just remember keep
6259
03:50:21,880 --> 03:50:24,199
in mind that AI can get things wrong and
6260
03:50:24,199 --> 03:50:26,359
that when they do there are other forums
6261
03:50:26,359 --> 03:50:28,000
that to use as well like I said we're
6262
03:50:28,000 --> 03:50:29,199
going to be learning about them as we go
6263
03:50:29,199 --> 03:50:32,120
on like stack exchange of theum piranha
6264
03:50:32,120 --> 03:50:34,880
or like I said of course the discussions
6265
03:50:34,880 --> 03:50:38,760
for of this course so if Bard or chbt or
6266
03:50:38,760 --> 03:50:40,120
whatever AI budy you're working with
6267
03:50:40,120 --> 03:50:42,080
gives you something confusing be sure to
6268
03:50:42,080 --> 03:50:44,239
go to the GitHub discussions or ask on
6269
03:50:44,239 --> 03:50:46,640
one of these
6270
03:50:49,120 --> 03:50:51,199
forms now as you can see though right
6271
03:50:51,199 --> 03:50:53,399
now every single time we call create
6272
03:50:53,399 --> 03:50:55,000
simple storage contract we're going to
6273
03:50:55,000 --> 03:50:58,120
deploy a new simple storage contract but
6274
03:50:58,120 --> 03:50:59,640
we're going to override it in this
6275
03:50:59,640 --> 03:51:01,680
simple storage right so if we go ahead
6276
03:51:01,680 --> 03:51:04,040
and deploy this right now scroll down
6277
03:51:04,040 --> 03:51:06,399
here simple storage at the zero address
6278
03:51:06,399 --> 03:51:08,399
create okay now it's at a new address
6279
03:51:08,399 --> 03:51:10,399
create again okay now it's at a new
6280
03:51:10,399 --> 03:51:12,600
address we're not keeping track of all
6281
03:51:12,600 --> 03:51:14,600
the different addresses that this simple
6282
03:51:14,600 --> 03:51:16,560
storage contract is being deployed to so
6283
03:51:16,560 --> 03:51:18,640
let's actually create a running list of
6284
03:51:18,640 --> 03:51:19,840
all the different simple storage
6285
03:51:19,840 --> 03:51:21,720
contracts that we're deploying so
6286
03:51:21,720 --> 03:51:24,560
instead of having this variable be just
6287
03:51:24,560 --> 03:51:26,439
a single simple storage contract let's
6288
03:51:26,439 --> 03:51:28,680
have it be an array or list of simple
6289
03:51:28,680 --> 03:51:30,840
storage contracts and we'll change the
6290
03:51:30,840 --> 03:51:36,120
name to list of simple storage contracts
6291
03:51:36,120 --> 03:51:37,640
so now when we deploy it instead of
6292
03:51:37,640 --> 03:51:39,159
saving it like this we're going to do
6293
03:51:39,159 --> 03:51:41,159
what we did before in our last section
6294
03:51:41,159 --> 03:51:44,000
we'll say simple storage new simple
6295
03:51:44,000 --> 03:51:47,319
storage contract equals new simple
6296
03:51:47,319 --> 03:51:49,880
storage and then we'll push it onto our
6297
03:51:49,880 --> 03:51:53,040
Dynamic array so we'll say list of
6298
03:51:53,040 --> 03:51:58,279
simple storage contracts push new simple
6299
03:51:58,279 --> 03:52:00,920
storage contract so let's go ahead and
6300
03:52:00,920 --> 03:52:03,199
compile this okay looks good let's go
6301
03:52:03,199 --> 03:52:04,479
ahead and deploy this we'll delete our
6302
03:52:04,479 --> 03:52:06,600
old one we're on the remix VM great
6303
03:52:06,600 --> 03:52:08,760
storage Factory and look at this you can
6304
03:52:08,760 --> 03:52:10,800
even see make sure we're on storage
6305
03:52:10,800 --> 03:52:12,479
Factory okay great we'll go ahead and
6306
03:52:12,479 --> 03:52:14,680
deploy that awesome we get list of of
6307
03:52:14,680 --> 03:52:16,479
simple storage contracts which now has
6308
03:52:16,479 --> 03:52:19,880
this U 256 input which allows us to
6309
03:52:19,880 --> 03:52:22,080
choose the index of the variable we'll
6310
03:52:22,080 --> 03:52:24,399
go ahead and create simple storage now
6311
03:52:24,399 --> 03:52:26,319
we go check the zerith index we have an
6312
03:52:26,319 --> 03:52:29,120
address if we check the first index
6313
03:52:29,120 --> 03:52:31,479
nothing happens if we call create again
6314
03:52:31,479 --> 03:52:33,680
which sorry if I have the terminal up
6315
03:52:33,680 --> 03:52:36,120
I'll call create again again now there
6316
03:52:36,120 --> 03:52:38,120
is one at the first index and since I
6317
03:52:38,120 --> 03:52:39,399
called it twice there's also one at the
6318
03:52:39,399 --> 03:52:41,199
second there's nothing at the third I'll
6319
03:52:41,199 --> 03:52:42,880
hit create again there's no one at the
6320
03:52:42,880 --> 03:52:46,040
fourth oh at the third excuse me awesome
6321
03:52:46,040 --> 03:52:47,800
so now we actually have a running list
6322
03:52:47,800 --> 03:52:49,960
of all of our simple storage contracts
6323
03:52:49,960 --> 03:52:51,520
now let's learn how to actually interact
6324
03:52:51,520 --> 03:52:54,199
with other contracts from a contract for
6325
03:52:54,199 --> 03:52:55,760
now we can think of our storage Factory
6326
03:52:55,760 --> 03:52:57,840
as a sort of manager for all these other
6327
03:52:57,840 --> 03:53:00,080
contracts so let's learn how our storage
6328
03:53:00,080 --> 03:53:02,319
Factory contract can actually call the
6329
03:53:02,319 --> 03:53:04,760
store function of the simple storage
6330
03:53:04,760 --> 03:53:06,880
that it deploys so let's create a
6331
03:53:06,880 --> 03:53:09,880
function called SF store which is going
6332
03:53:09,880 --> 03:53:12,880
to stand for storage Factory Store and
6333
03:53:12,880 --> 03:53:16,080
it's going to take two variables a u 256
6334
03:53:16,080 --> 03:53:21,760
undor simple storage index and a u 256
6335
03:53:21,760 --> 03:53:26,720
uncore new simple storage number we make
6336
03:53:26,720 --> 03:53:29,080
this public like this now in order to
6337
03:53:29,080 --> 03:53:30,800
interact with a contract you're always
6338
03:53:30,800 --> 03:53:32,640
going to need two things and we're going
6339
03:53:32,640 --> 03:53:34,520
to refer to this a lot you're going to
6340
03:53:34,520 --> 03:53:36,840
need an address and you're going to need
6341
03:53:36,840 --> 03:53:40,120
the AI now this is technically a lie you
6342
03:53:40,120 --> 03:53:42,080
really just need the function selector
6343
03:53:42,080 --> 03:53:43,600
but we're going to learn that way way
6344
03:53:43,600 --> 03:53:45,760
later in the course for now just think
6345
03:53:45,760 --> 03:53:47,840
okay I always need the address and I
6346
03:53:47,840 --> 03:53:50,840
always need the ABI the ABI stands for
6347
03:53:50,840 --> 03:53:54,199
application binary interface the ABI
6348
03:53:54,199 --> 03:53:56,520
will tell our code exactly how it can
6349
03:53:56,520 --> 03:53:58,520
interact with another contract we'll go
6350
03:53:58,520 --> 03:54:00,920
deeper into the ABI later on in this
6351
03:54:00,920 --> 03:54:03,120
course but for now if you go to the
6352
03:54:03,120 --> 03:54:05,760
compile tab H compile and you scroll
6353
03:54:05,760 --> 03:54:07,520
down there's this little button at the
6354
03:54:07,520 --> 03:54:10,520
bottom that says copy abi2 clipboard or
6355
03:54:10,520 --> 03:54:12,520
you can also go to compilation details
6356
03:54:12,520 --> 03:54:14,080
you can see a ton of information about
6357
03:54:14,080 --> 03:54:16,080
the compliation details such as the bite
6358
03:54:16,080 --> 03:54:18,279
code with the op codes some metadata the
6359
03:54:18,279 --> 03:54:21,720
name but also the ABI which tells us the
6360
03:54:21,720 --> 03:54:23,720
ways we can interact with this contract
6361
03:54:23,720 --> 03:54:25,560
if we hit the drop down for the zero we
6362
03:54:25,560 --> 03:54:27,319
see there's an input create simple
6363
03:54:27,319 --> 03:54:28,720
storage contract which is one of our
6364
03:54:28,720 --> 03:54:31,040
functions and you see state mutability
6365
03:54:31,040 --> 03:54:32,239
which we'll talk about later but if we
6366
03:54:32,239 --> 03:54:34,000
had another drop down we see list of
6367
03:54:34,000 --> 03:54:35,640
simple storage contracts and the other
6368
03:54:35,640 --> 03:54:38,080
drop down we'll see SF store these as
6369
03:54:38,080 --> 03:54:40,279
you know are the buttons that we can
6370
03:54:40,279 --> 03:54:42,439
press when we deploy this contract right
6371
03:54:42,439 --> 03:54:44,680
so if I redeploy this we see those exact
6372
03:54:44,680 --> 03:54:46,000
three buttons these are the three
6373
03:54:46,000 --> 03:54:47,960
buttons that were inside of that ABI
6374
03:54:47,960 --> 03:54:49,960
this is how remix knows to put three
6375
03:54:49,960 --> 03:54:51,600
buttons here because it looks at the ABI
6376
03:54:51,600 --> 03:54:53,359
and sees that there's three buttons so
6377
03:54:53,359 --> 03:54:55,520
in our code here our compiler knows what
6378
03:54:55,520 --> 03:54:57,560
the ABI is so in our code here the
6379
03:54:57,560 --> 03:54:59,600
compiler automatically knows what the
6380
03:54:59,600 --> 03:55:01,840
ABI is because the compiler is the one
6381
03:55:01,840 --> 03:55:03,960
that generates the API and we know where
6382
03:55:03,960 --> 03:55:05,880
the address is because we have a list of
6383
03:55:05,880 --> 03:55:07,319
all of our addresses that we're keeping
6384
03:55:07,319 --> 03:55:09,479
track of up here so the reason we have
6385
03:55:09,479 --> 03:55:11,920
the ABI is because we're importing our
6386
03:55:11,920 --> 03:55:13,319
simple storage contract and actually
6387
03:55:13,319 --> 03:55:15,279
let's delete this simple storage 2 we
6388
03:55:15,279 --> 03:55:17,080
don't really need the simple storage 2
6389
03:55:17,080 --> 03:55:18,680
so when we compile simple storage we
6390
03:55:18,680 --> 03:55:21,080
automatically get the ABI for solidity
6391
03:55:21,080 --> 03:55:22,520
in the future we'll learn other ways to
6392
03:55:22,520 --> 03:55:25,000
get the API so down here let's get a
6393
03:55:25,000 --> 03:55:27,000
simple storage contract to interact with
6394
03:55:27,000 --> 03:55:29,680
from our list and to do that we'll say
6395
03:55:29,680 --> 03:55:34,239
simple storage my simple storage equals
6396
03:55:34,239 --> 03:55:39,000
list of simple storage contracts at
6397
03:55:39,000 --> 03:55:42,159
index simple storage index like this
6398
03:55:42,159 --> 03:55:44,399
since this is an array of simple storage
6399
03:55:44,399 --> 03:55:46,560
contracts we can just automatically get
6400
03:55:46,560 --> 03:55:49,439
the contract itself like this however
6401
03:55:49,439 --> 03:55:50,720
let's say that instead of this being an
6402
03:55:50,720 --> 03:55:52,439
array of simple storage contracts this
6403
03:55:52,439 --> 03:55:55,560
was an array an array of addresses a
6404
03:55:55,560 --> 03:56:00,319
list of simple storage addresses like
6405
03:56:00,319 --> 03:56:02,399
this you don't have to code along with
6406
03:56:02,399 --> 03:56:03,960
me for this section just go ahead and
6407
03:56:03,960 --> 03:56:07,040
follow along and watch if we had a list
6408
03:56:07,040 --> 03:56:09,120
of addresses and this would be to be a
6409
03:56:09,120 --> 03:56:10,720
little bit different but we had a list
6410
03:56:10,720 --> 03:56:12,840
of addresses instead we could say simple
6411
03:56:12,840 --> 03:56:16,239
storage my simple storage equals list of
6412
03:56:16,239 --> 03:56:18,880
simple storage addresses at the index
6413
03:56:18,880 --> 03:56:20,479
and then do something called type
6414
03:56:20,479 --> 03:56:23,560
casting and we'd wrap this in
6415
03:56:23,560 --> 03:56:25,920
parentheses like so let me zoom out a
6416
03:56:25,920 --> 03:56:27,479
little bit so this is something we'll
6417
03:56:27,479 --> 03:56:29,880
learn about a little bit later so
6418
03:56:29,880 --> 03:56:31,159
basically what we're doing is this list
6419
03:56:31,159 --> 03:56:32,720
of simple storage addresses simple
6420
03:56:32,720 --> 03:56:34,720
storage Index this line returns an
6421
03:56:34,720 --> 03:56:37,960
address and we're wrapping that address
6422
03:56:37,960 --> 03:56:40,880
in simple storage like so if this is a
6423
03:56:40,880 --> 03:56:42,520
little confusing for you now don't worry
6424
03:56:42,520 --> 03:56:44,239
too much about it we will learn about
6425
03:56:44,239 --> 03:56:46,319
about it more later now that we have our
6426
03:56:46,319 --> 03:56:47,920
simple storage contract we can actually
6427
03:56:47,920 --> 03:56:50,319
call the store function directly on this
6428
03:56:50,319 --> 03:56:52,960
contract so now we can say my simple
6429
03:56:52,960 --> 03:56:56,319
storage. store and we'll add the new
6430
03:56:56,319 --> 03:56:58,720
simple storage number and this is great
6431
03:56:58,720 --> 03:57:00,359
if we were to deploy this contract right
6432
03:57:00,359 --> 03:57:01,880
now though and call this SF store
6433
03:57:01,880 --> 03:57:03,520
function though we wouldn't be able to
6434
03:57:03,520 --> 03:57:06,640
read the new variable that we just
6435
03:57:06,640 --> 03:57:08,479
updated our simple storage contract with
6436
03:57:08,479 --> 03:57:10,199
so let's create a function that allows
6437
03:57:10,199 --> 03:57:12,359
us to read from our simple storage
6438
03:57:12,359 --> 03:57:14,439
contracts as well so we'll create a
6439
03:57:14,439 --> 03:57:18,080
function called SF get which will take a
6440
03:57:18,080 --> 03:57:23,239
un 256 undor simple storage index is an
6441
03:57:23,239 --> 03:57:25,880
input parameter we'll make this a public
6442
03:57:25,880 --> 03:57:29,399
view function that will return a uent
6443
03:57:29,399 --> 03:57:33,479
256 you in 256 and we'll say simple
6444
03:57:33,479 --> 03:57:36,640
storage my simple storage equals and
6445
03:57:36,640 --> 03:57:38,960
we'll use this exact same syntax that we
6446
03:57:38,960 --> 03:57:40,520
used above to get the simple storage
6447
03:57:40,520 --> 03:57:42,800
index equals list of simple storage
6448
03:57:42,800 --> 03:57:45,120
contracts at the simple storage index
6449
03:57:45,120 --> 03:57:47,920
and now we're going to do return my
6450
03:57:47,920 --> 03:57:49,960
simple storage and again if you see
6451
03:57:49,960 --> 03:57:51,760
these autocompletes that come up you can
6452
03:57:51,760 --> 03:57:55,479
just hit tab but do retrieve so perfect
6453
03:57:55,479 --> 03:57:57,279
now let's go ahead and compile we'll go
6454
03:57:57,279 --> 03:57:59,159
ahead and delete the old
6455
03:57:59,159 --> 03:58:01,319
deploy we'll make sure we're on storagea
6456
03:58:01,319 --> 03:58:03,920
factory. soul we'll hit deploy and we
6457
03:58:03,920 --> 03:58:06,800
see storage Factory down here now let's
6458
03:58:06,800 --> 03:58:08,520
go ahead run through that exact same
6459
03:58:08,520 --> 03:58:10,880
exercise so we'll pull up the terminal
6460
03:58:10,880 --> 03:58:12,720
just to see our transactions go through
6461
03:58:12,720 --> 03:58:14,760
we'll hit create simple storage let's
6462
03:58:14,760 --> 03:58:15,960
see that it's actually there at the
6463
03:58:15,960 --> 03:58:18,479
zeroth index okay cool we see an address
6464
03:58:18,479 --> 03:58:22,120
there so now let's store a new variable
6465
03:58:22,120 --> 03:58:24,680
at index0 so at this address so we'll
6466
03:58:24,680 --> 03:58:28,199
say at index0 we'll store the number 1 2
6467
03:58:28,199 --> 03:58:30,640
3 and actually before I hit this button
6468
03:58:30,640 --> 03:58:33,120
if we go down here we hit zero we get
6469
03:58:33,120 --> 03:58:35,399
nothing back right but now if I hit SF
6470
03:58:35,399 --> 03:58:37,760
store with index zero favorite number 1
6471
03:58:37,760 --> 03:58:39,960
2 3 looks like the transaction did go
6472
03:58:39,960 --> 03:58:42,920
through now if I hit SF get we go ahead
6473
03:58:42,920 --> 03:58:44,640
and get 1 2 3
6474
03:58:44,640 --> 03:58:47,040
so our storage Factory contract was able
6475
03:58:47,040 --> 03:58:49,439
to create its own simple storage
6476
03:58:49,439 --> 03:58:52,720
contract store a variable in that
6477
03:58:52,720 --> 03:58:54,439
contract from the storage Factory and we
6478
03:58:54,439 --> 03:58:56,840
were able to read back the number one
6479
03:58:56,840 --> 03:58:58,640
two 3 all from within our storage
6480
03:58:58,640 --> 03:59:00,960
Factory contract feel free to pause
6481
03:59:00,960 --> 03:59:02,640
right now and play around with adding
6482
03:59:02,640 --> 03:59:03,920
different values creating different
6483
03:59:03,920 --> 03:59:05,359
simple storage contracts so that you
6484
03:59:05,359 --> 03:59:07,159
really understand what's going on you
6485
03:59:07,159 --> 03:59:09,080
can also feel free to hit the little
6486
03:59:09,080 --> 03:59:11,199
dropdowns and read more information
6487
03:59:11,199 --> 03:59:14,080
about these transactions just as a recap
6488
03:59:14,080 --> 03:59:15,640
in our storage Factory contract we have
6489
03:59:15,640 --> 03:59:17,439
a function called create simple storage
6490
03:59:17,439 --> 03:59:19,120
contract which creates new simple
6491
03:59:19,120 --> 03:59:21,359
storage contracts from the storage
6492
03:59:21,359 --> 03:59:23,479
Factory contract the reason it's able to
6493
03:59:23,479 --> 03:59:25,720
do this is because we're importing from
6494
03:59:25,720 --> 03:59:28,319
our simpl storage. file using something
6495
03:59:28,319 --> 03:59:30,560
called named Imports we're only
6496
03:59:30,560 --> 03:59:32,560
importing simple storage we're not
6497
03:59:32,560 --> 03:59:34,279
importing anything in these other
6498
03:59:34,279 --> 03:59:38,199
contracts then we use SF store to store
6499
03:59:38,199 --> 03:59:39,840
a new number on one of those simple
6500
03:59:39,840 --> 03:59:41,920
storage contracts using the index in our
6501
03:59:41,920 --> 03:59:43,760
array it can do this because we have the
6502
03:59:43,760 --> 03:59:46,040
address address and the ABI the list of
6503
03:59:46,040 --> 03:59:47,840
simple storage contracts automatically
6504
03:59:47,840 --> 03:59:50,640
compact with the address and the ABI and
6505
03:59:50,640 --> 03:59:52,800
then finally we can read back those
6506
03:59:52,800 --> 03:59:55,120
simple storage values that we stored now
6507
03:59:55,120 --> 03:59:57,479
we can make this sfg function even more
6508
03:59:57,479 --> 04:00:00,760
condensed since this list of simple
6509
04:00:00,760 --> 04:00:02,960
storage contracts simple storage index
6510
04:00:02,960 --> 04:00:06,080
returns an object of type simple storage
6511
04:00:06,080 --> 04:00:08,439
we can actually delete this whole line
6512
04:00:08,439 --> 04:00:09,760
copy
6513
04:00:09,760 --> 04:00:12,960
this paste it here and delete this line
6514
04:00:12,960 --> 04:00:15,399
and this will work exactly the same as
6515
04:00:15,399 --> 04:00:17,680
what we had before go ahead and save or
6516
04:00:17,680 --> 04:00:19,040
compile you'll go ahead and get that
6517
04:00:19,040 --> 04:00:21,399
green check mark there this retrieve is
6518
04:00:21,399 --> 04:00:22,640
saying we're going to call the retrieve
6519
04:00:22,640 --> 04:00:26,000
function on whatever this is and this
6520
04:00:26,000 --> 04:00:28,120
whatever this is is of type simple
6521
04:00:28,120 --> 04:00:30,199
storage contract we can actually do the
6522
04:00:30,199 --> 04:00:32,600
same thing up here by deleting this part
6523
04:00:32,600 --> 04:00:34,399
copying this line except for the
6524
04:00:34,399 --> 04:00:37,040
semicolon and pasting it over the myle
6525
04:00:37,040 --> 04:00:39,880
storage and hitting save or compile
6526
04:00:39,880 --> 04:00:43,840
awesome great job so far
6527
04:00:46,359 --> 04:00:48,479
awesome now let's say you really like
6528
04:00:48,479 --> 04:00:50,439
this simple storage contract you love
6529
04:00:50,439 --> 04:00:52,520
all the functionality except for one
6530
04:00:52,520 --> 04:00:55,000
thing you wish that the store function
6531
04:00:55,000 --> 04:00:56,520
didn't just store the favorite number
6532
04:00:56,520 --> 04:00:58,520
you wish it added five so for some
6533
04:00:58,520 --> 04:01:00,080
reason you want a contract that does
6534
04:01:00,080 --> 04:01:01,760
everything this contract does but just
6535
04:01:01,760 --> 04:01:03,760
adds five whenever you call store for
6536
04:01:03,760 --> 04:01:05,239
some reason you want everyone's favorite
6537
04:01:05,239 --> 04:01:07,239
number to be five larger than what they
6538
04:01:07,239 --> 04:01:09,040
think it is well one thing we could do
6539
04:01:09,040 --> 04:01:10,680
is we could just copy paste this into a
6540
04:01:10,680 --> 04:01:12,399
new file but again that's kind of too
6541
04:01:12,399 --> 04:01:13,960
much work for me I'm a lazy engineer
6542
04:01:13,960 --> 04:01:15,680
here but let's go ahead and see how we
6543
04:01:15,680 --> 04:01:17,439
can approach this problem so let's
6544
04:01:17,439 --> 04:01:19,720
create a new file and we'll call it add
6545
04:01:19,720 --> 04:01:22,680
five storage. soul and same thing since
6546
04:01:22,680 --> 04:01:23,920
this is a new contract we're going to
6547
04:01:23,920 --> 04:01:25,199
follow the exact same tips we're going
6548
04:01:25,199 --> 04:01:30,000
to do spdx license identifier MIT we're
6549
04:01:30,000 --> 04:01:33,600
going do pragma solidity
6550
04:01:33,600 --> 04:01:35,840
0.818 let's even do the little carrot
6551
04:01:35,840 --> 04:01:38,840
here and we'll do contract add five
6552
04:01:38,840 --> 04:01:42,359
storage like so compile great looking
6553
04:01:42,359 --> 04:01:44,399
good oh I'm getting a warning
6554
04:01:44,399 --> 04:01:47,399
spdx license spelled license wrong so
6555
04:01:47,399 --> 04:01:48,960
let's spell that right okay cool looks
6556
04:01:48,960 --> 04:01:50,600
good so like I said the first thing that
6557
04:01:50,600 --> 04:01:52,159
we could do is we could copy paste
6558
04:01:52,159 --> 04:01:53,920
everything in here and then just change
6559
04:01:53,920 --> 04:01:56,080
the pieces that we don't like in our ad
6560
04:01:56,080 --> 04:01:57,840
five storage this is a little bit
6561
04:01:57,840 --> 04:02:00,000
redundant a little bit too much work and
6562
04:02:00,000 --> 04:02:02,000
we are Engineers we want to work as hard
6563
04:02:02,000 --> 04:02:04,319
as possible to be as lazy as possible so
6564
04:02:04,319 --> 04:02:06,000
how can we do that well this is where we
6565
04:02:06,000 --> 04:02:08,120
can do something called inheritance we
6566
04:02:08,120 --> 04:02:10,199
can have our ad five storage contract be
6567
04:02:10,199 --> 04:02:12,840
something called a child contract of our
6568
04:02:12,840 --> 04:02:14,479
simple storage contract
6569
04:02:14,479 --> 04:02:16,880
and we can have our ad five storage
6570
04:02:16,880 --> 04:02:19,960
inherit all of the functionality all of
6571
04:02:19,960 --> 04:02:22,080
the functionality of our simple storage
6572
04:02:22,080 --> 04:02:24,439
contract so first of course in order for
6573
04:02:24,439 --> 04:02:26,600
our ad five storage to know about our
6574
04:02:26,600 --> 04:02:28,000
symol storage contract we're going to go
6575
04:02:28,000 --> 04:02:29,920
ahead and have to import it so we're
6576
04:02:29,920 --> 04:02:31,760
going to do import and we're going to do
6577
04:02:31,760 --> 04:02:33,920
once again the named Imports because
6578
04:02:33,920 --> 04:02:36,159
we're Advanced solidity Engineers so
6579
04:02:36,159 --> 04:02:38,640
we're going to say import simple storage
6580
04:02:38,640 --> 04:02:41,600
just the simple storage contract
6581
04:02:41,600 --> 04:02:44,880
froms simple storage. soul now if this
6582
04:02:44,880 --> 04:02:46,880
do slash is confusing to you don't worry
6583
04:02:46,880 --> 04:02:48,560
we'll learn about directory structures
6584
04:02:48,560 --> 04:02:50,640
later on in the course and then we'll
6585
04:02:50,640 --> 04:02:53,880
say our contract add five storage is
6586
04:02:53,880 --> 04:02:56,439
simple storage now our ad five storage
6587
04:02:56,439 --> 04:02:58,359
is going to do what's called inherit
6588
04:02:58,359 --> 04:03:00,800
everything from simple storage and our
6589
04:03:00,800 --> 04:03:02,760
ad five storage is going to have all the
6590
04:03:02,760 --> 04:03:05,080
same functionality as simple storage we
6591
04:03:05,080 --> 04:03:06,880
can actually see this directly if we go
6592
04:03:06,880 --> 04:03:09,680
to compile let's go ahead and delete our
6593
04:03:09,680 --> 04:03:11,520
previously deployed contracts we're on
6594
04:03:11,520 --> 04:03:14,199
the remix VM let's make sure we're we've
6595
04:03:14,199 --> 04:03:16,920
selected ad five storage adiv storage.
6596
04:03:16,920 --> 04:03:19,120
Soul let's go ahead and deploy it and if
6597
04:03:19,120 --> 04:03:21,680
we scroll down we can actually see oh my
6598
04:03:21,680 --> 04:03:23,760
goodness it's got all the same buttons
6599
04:03:23,760 --> 04:03:26,120
as simple storage even though the
6600
04:03:26,120 --> 04:03:27,399
contract itself doesn't have anything
6601
04:03:27,399 --> 04:03:30,000
defined that's because we inherited all
6602
04:03:30,000 --> 04:03:32,279
of the buttons We inherited all of the
6603
04:03:32,279 --> 04:03:34,439
functionality of simple storage into ad
6604
04:03:34,439 --> 04:03:36,960
five storage if you want a contract to
6605
04:03:36,960 --> 04:03:38,560
inherit the functionality of another
6606
04:03:38,560 --> 04:03:40,520
contract you just import it in and then
6607
04:03:40,520 --> 04:03:43,199
say your contract is that other contract
6608
04:03:43,199 --> 04:03:45,040
now we can keep going though and add our
6609
04:03:45,040 --> 04:03:46,920
own custom functionality into ad five
6610
04:03:46,920 --> 04:03:49,199
storage that's not in simple storage so
6611
04:03:49,199 --> 04:03:51,520
for example we could say function say
6612
04:03:51,520 --> 04:03:54,239
hello it's going to be a public and it
6613
04:03:54,239 --> 04:03:56,880
returns a string memory and again you
6614
04:03:56,880 --> 04:03:58,800
need the memory keyword because strings
6615
04:03:58,800 --> 04:04:01,080
are special in solidity and we can just
6616
04:04:01,080 --> 04:04:04,439
say return hello like so this will be a
6617
04:04:04,439 --> 04:04:06,520
public pure it's not a view because
6618
04:04:06,520 --> 04:04:08,319
we're not reading from storage and again
6619
04:04:08,319 --> 04:04:09,760
if that dissertion is a little confusing
6620
04:04:09,760 --> 04:04:12,120
to you don't worry too much about it now
6621
04:04:12,120 --> 04:04:13,720
but if we go to deploy it it's still
6622
04:04:13,720 --> 04:04:15,920
delete our old one we'll deploy this one
6623
04:04:15,920 --> 04:04:17,680
we see we have all the functionality of
6624
04:04:17,680 --> 04:04:19,680
simple storage plus this say hello
6625
04:04:19,680 --> 04:04:22,479
function great but let's delete that for
6626
04:04:22,479 --> 04:04:24,080
now let's say instead of wanting to add
6627
04:04:24,080 --> 04:04:26,239
additional customization you actually
6628
04:04:26,239 --> 04:04:28,520
love every function in here except for
6629
04:04:28,520 --> 04:04:30,319
one remember the reason we wanted this
6630
04:04:30,319 --> 04:04:32,159
adiv storage. soulle is because we
6631
04:04:32,159 --> 04:04:33,560
actually want to change the store
6632
04:04:33,560 --> 04:04:35,760
function to have it add an additional
6633
04:04:35,760 --> 04:04:37,680
five to people's favorite numbers maybe
6634
04:04:37,680 --> 04:04:39,479
you're mischievous and you want people's
6635
04:04:39,479 --> 04:04:40,920
favorite numbers to be five greater than
6636
04:04:40,920 --> 04:04:42,720
they are well to add this ad five
6637
04:04:42,720 --> 04:04:44,439
customization to that store function we
6638
04:04:44,439 --> 04:04:46,720
can do something called overrides to do
6639
04:04:46,720 --> 04:04:48,520
overrides there are two keywords that we
6640
04:04:48,520 --> 04:04:50,399
need to be aware of those are virtual
6641
04:04:50,399 --> 04:04:52,279
and override if our were to try to
6642
04:04:52,279 --> 04:04:54,439
create a store function for our ad five
6643
04:04:54,439 --> 04:04:56,199
storage right now what do you think will
6644
04:04:56,199 --> 04:04:57,920
happen well let's try it out so let's
6645
04:04:57,920 --> 04:05:01,159
say function store un
6646
04:05:01,159 --> 04:05:03,640
256 undor new
6647
04:05:03,640 --> 04:05:06,720
number public if we try to compile this
6648
04:05:06,720 --> 04:05:08,640
right now we'll actually get an error
6649
04:05:08,640 --> 04:05:10,680
even if there's nothing in this store
6650
04:05:10,680 --> 04:05:12,920
function we roll over we say from
6651
04:05:12,920 --> 04:05:15,640
solidity type error overriding function
6652
04:05:15,640 --> 04:05:17,880
is missing override specifier and
6653
04:05:17,880 --> 04:05:20,080
remember if you get lost or confused an
6654
04:05:20,080 --> 04:05:21,319
error like this is something perfect for
6655
04:05:21,319 --> 04:05:23,720
you to ask chat TBT or maybe even find
6656
04:05:23,720 --> 04:05:27,560
we could say I am trying to compile my
6657
04:05:27,560 --> 04:05:31,800
solidity code but I'm getting this error
6658
04:05:31,800 --> 04:05:33,840
we can copy this whole error here paste
6659
04:05:33,840 --> 04:05:36,199
it in here and then in additional
6660
04:05:36,199 --> 04:05:38,560
context we'll just add the code like
6661
04:05:38,560 --> 04:05:40,920
this we'll hit search see what it gives
6662
04:05:40,920 --> 04:05:43,159
us we'll say and it looks like find was
6663
04:05:43,159 --> 04:05:45,239
able to find the answer the error
6664
04:05:45,239 --> 04:05:46,920
message indicates the function store in
6665
04:05:46,920 --> 04:05:48,479
the ad five storage contract is missing
6666
04:05:48,479 --> 04:05:50,880
the override specifier which is required
6667
04:05:50,880 --> 04:05:52,640
because it overrides a virtual function
6668
04:05:52,640 --> 04:05:54,760
from the simple storage contract thanks
6669
04:05:54,760 --> 04:05:56,279
I'll explain what find is giving us in
6670
04:05:56,279 --> 04:05:58,359
just a minute it's right we need to tell
6671
04:05:58,359 --> 04:06:01,600
solidity that it needs to override the
6672
04:06:01,600 --> 04:06:04,000
store function in simple storage we want
6673
04:06:04,000 --> 04:06:06,560
to be very explicit and say hey do this
6674
04:06:06,560 --> 04:06:08,319
store function and not what's in simple
6675
04:06:08,319 --> 04:06:10,560
storage. soole so let's go ahead and add
6676
04:06:10,560 --> 04:06:12,680
that keyword override now though if we
6677
04:06:12,680 --> 04:06:14,159
just add that keyword we go ahead and
6678
04:06:14,159 --> 04:06:16,479
try to compile we still get an error
6679
04:06:16,479 --> 04:06:18,439
trying to override a non- virtual
6680
04:06:18,439 --> 04:06:20,720
function did you forget to add virtual
6681
04:06:20,720 --> 04:06:23,040
in order for a function to be override a
6682
04:06:23,040 --> 04:06:25,439
bowl you need to add this virtual
6683
04:06:25,439 --> 04:06:27,920
keyword in the base class or the parent
6684
04:06:27,920 --> 04:06:29,920
class so in simple storage we need to
6685
04:06:29,920 --> 04:06:32,000
add virtual to store this virtual
6686
04:06:32,000 --> 04:06:33,800
keyword means that this function is
6687
04:06:33,800 --> 04:06:35,840
overridable any function that doesn't
6688
04:06:35,840 --> 04:06:38,359
have this keyword you can't override now
6689
04:06:38,359 --> 04:06:41,279
our store function is override a and
6690
04:06:41,279 --> 04:06:42,880
we've specified that we are indeed going
6691
04:06:42,880 --> 04:06:45,560
to override the store function now if we
6692
04:06:45,560 --> 04:06:47,159
go ahead and compile we'll see
6693
04:06:47,159 --> 04:06:49,120
everything compiles successfully all
6694
04:06:49,120 --> 04:06:50,960
right great so now let's just add the
6695
04:06:50,960 --> 04:06:53,600
functionality to store remember since ad
6696
04:06:53,600 --> 04:06:55,239
five storage inherits everything from
6697
04:06:55,239 --> 04:06:57,560
simple storage this means that we even
6698
04:06:57,560 --> 04:06:59,720
have access to my favorite number so
6699
04:06:59,720 --> 04:07:01,520
what we can do is we can say my favorite
6700
04:07:01,520 --> 04:07:04,159
number equals underscore new
6701
04:07:04,159 --> 04:07:07,120
number plus 5 we'll compile this and now
6702
04:07:07,120 --> 04:07:09,760
let's try it out we're on remix VM we
6703
04:07:09,760 --> 04:07:11,600
want to make sure we're with ad five
6704
04:07:11,600 --> 04:07:13,600
storage we'll delete the other ones
6705
04:07:13,600 --> 04:07:15,800
we'll deploy scroll down hit the drop
6706
04:07:15,800 --> 04:07:18,399
down retrieve currently return zero now
6707
04:07:18,399 --> 04:07:21,760
if we store two pull up the terminal to
6708
04:07:21,760 --> 04:07:22,880
make sure we're actually sending
6709
04:07:22,880 --> 04:07:25,600
transactions we'll hit store and now if
6710
04:07:25,600 --> 04:07:27,520
we hit retrieve we see we indeed get
6711
04:07:27,520 --> 04:07:31,000
seven back cuz 2 + 5 is 7 we add five we
6712
04:07:31,000 --> 04:07:33,399
hit store retrieve now returns 10 So
6713
04:07:33,399 --> 04:07:35,119
This Is How We Do inheritance and
6714
04:07:35,119 --> 04:07:37,720
override
6715
04:07:40,239 --> 04:07:42,520
functions and that's it for this section
6716
04:07:42,520 --> 04:07:44,080
you've learned a ton of incredibly
6717
04:07:44,080 --> 04:07:45,960
powerful features in solidity so let's
6718
04:07:45,960 --> 04:07:47,600
do a quick recap of what we learned this
6719
04:07:47,600 --> 04:07:49,880
section we learned that with the new
6720
04:07:49,880 --> 04:07:52,159
keyword we can actually deploy contracts
6721
04:07:52,159 --> 04:07:54,119
from other contracts we learned that we
6722
04:07:54,119 --> 04:07:55,640
can actually import other contracts
6723
04:07:55,640 --> 04:07:57,159
which is essentially the same as copy
6724
04:07:57,159 --> 04:07:59,760
pasting the code into this file we also
6725
04:07:59,760 --> 04:08:01,800
learned this thing called named Imports
6726
04:08:01,800 --> 04:08:03,680
which is going to make you look even
6727
04:08:03,680 --> 04:08:05,199
better than most of the solidity devs
6728
04:08:05,199 --> 04:08:06,600
out there we learned that we can
6729
04:08:06,600 --> 04:08:08,319
interact with other contracts so long as
6730
04:08:08,319 --> 04:08:10,199
we have the address and the ABI the
6731
04:08:10,199 --> 04:08:12,080
simple storage type automatically comes
6732
04:08:12,080 --> 04:08:14,560
with the address and the ABI so we can
6733
04:08:14,560 --> 04:08:17,159
just access it like this we didn't learn
6734
04:08:17,159 --> 04:08:18,680
too much about the ABI but we'll learn
6735
04:08:18,680 --> 04:08:20,439
more about it later we learned that if
6736
04:08:20,439 --> 04:08:22,080
we want to make a child contract and
6737
04:08:22,080 --> 04:08:23,840
inherit the functionality of some other
6738
04:08:23,840 --> 04:08:25,640
contract we can just import that
6739
04:08:25,640 --> 04:08:27,960
contract and then use the is keyword in
6740
04:08:27,960 --> 04:08:30,199
the contract declaration to override a
6741
04:08:30,199 --> 04:08:32,159
function we need the override keyword
6742
04:08:32,159 --> 04:08:34,760
and we need the base class or the parent
6743
04:08:34,760 --> 04:08:37,640
class to have the virtual keyword on the
6744
04:08:37,640 --> 04:08:39,640
function you want to override and that
6745
04:08:39,640 --> 04:08:41,560
is the end of this lesson so be sure to
6746
04:08:41,560 --> 04:08:43,600
give yourself a huge pat on the back
6747
04:08:43,600 --> 04:08:45,520
take a break breaks are good for your
6748
04:08:45,520 --> 04:08:47,720
brain go for a walk grab a coffee get
6749
04:08:47,720 --> 04:08:49,720
some ice cream go tell your friends go
6750
04:08:49,720 --> 04:08:51,560
post on Twitter you're getting more and
6751
04:08:51,560 --> 04:08:53,479
more advanced with solidity very quickly
6752
04:08:53,479 --> 04:08:55,359
so be sure to celebrate the little wins
6753
04:08:55,359 --> 04:08:57,319
to keep being excited and keep that
6754
04:08:57,319 --> 04:08:59,399
Curiosity congratulations youve
6755
04:08:59,399 --> 04:09:03,119
completed this lesson
6756
04:09:20,880 --> 04:09:22,720
all right everybody welcome back we are
6757
04:09:22,720 --> 04:09:25,319
now headed into Lesson Four this is
6758
04:09:25,319 --> 04:09:27,720
going to be our remix fundme and once
6759
04:09:27,720 --> 04:09:29,800
again you can find all the code
6760
04:09:29,800 --> 04:09:31,399
associated with this lesson in the
6761
04:09:31,399 --> 04:09:33,119
GitHub repository associated with this
6762
04:09:33,119 --> 04:09:36,560
course and also web3 dev. and let's do a
6763
04:09:36,560 --> 04:09:37,840
quick walkthrough of these contracts
6764
04:09:37,840 --> 04:09:39,119
before we actually start coding anything
6765
04:09:39,119 --> 04:09:40,279
to see what we're going to be doing
6766
04:09:40,279 --> 04:09:41,880
we're going to be creating one contract
6767
04:09:41,880 --> 04:09:44,199
funme doou we're also going to have
6768
04:09:44,199 --> 04:09:45,600
another file called price converter
6769
04:09:45,600 --> 04:09:47,119
dossou and we'll talk about that in a
6770
04:09:47,119 --> 04:09:48,760
little bit the fundme contract is going
6771
04:09:48,760 --> 04:09:50,720
to be our main contract this is going to
6772
04:09:50,720 --> 04:09:52,640
be an example of a crowdsourcing
6773
04:09:52,640 --> 04:09:54,800
application or a way to raise money you
6774
04:09:54,800 --> 04:09:56,600
can think of it as a web 3 decentralized
6775
04:09:56,600 --> 04:09:58,720
Kickstarter will allow users to send
6776
04:09:58,720 --> 04:10:02,359
ethereum polygon Avalanche Etc or really
6777
04:10:02,359 --> 04:10:04,840
any native blockchain cryptocurrency
6778
04:10:04,840 --> 04:10:06,880
into this contract and allow the owner
6779
04:10:06,880 --> 04:10:08,439
of the contract to actually withdraw all
6780
04:10:08,439 --> 04:10:10,080
the funds for them to go spend on their
6781
04:10:10,080 --> 04:10:12,319
new project and we are going to actually
6782
04:10:12,319 --> 04:10:15,080
deploy this contract to a test net and
6783
04:10:15,080 --> 04:10:17,760
remember use the test net transactions
6784
04:10:17,760 --> 04:10:19,880
sparingly but if we deploy this to a
6785
04:10:19,880 --> 04:10:22,040
test net we scroll down we actually see
6786
04:10:22,040 --> 04:10:23,920
that we have a couple of buttons and a
6787
04:10:23,920 --> 04:10:25,800
new color button we'll actually get a
6788
04:10:25,800 --> 04:10:28,760
new red button for our fund function a
6789
04:10:28,760 --> 04:10:30,520
red button indicates that a function is
6790
04:10:30,520 --> 04:10:32,520
payable and we can send native ethereum
6791
04:10:32,520 --> 04:10:34,840
or polygon or Avalanche or whatever the
6792
04:10:34,840 --> 04:10:36,479
native cryptocurrency of the blockchain
6793
04:10:36,479 --> 04:10:38,640
we're working with is We additionally
6794
04:10:38,640 --> 04:10:41,399
will indicate a minimum USD amount to
6795
04:10:41,399 --> 04:10:43,640
send to the contract so fun have to
6796
04:10:43,640 --> 04:10:45,520
spend at least $5 worth of ethereum in
6797
04:10:45,520 --> 04:10:47,479
order to call this fund contract so if
6798
04:10:47,479 --> 04:10:49,000
we go up to the value section we can
6799
04:10:49,000 --> 04:10:51,359
actually send some value with this
6800
04:10:51,359 --> 04:10:52,960
transaction and again don't worry about
6801
04:10:52,960 --> 04:10:54,800
this making sense yet but if I want to
6802
04:10:54,800 --> 04:10:57,640
send 0.01 ether I'll grab that amount in
6803
04:10:57,640 --> 04:11:00,319
way paste it into the value section here
6804
04:11:00,319 --> 04:11:01,840
I'll scroll down I'll hit the fund
6805
04:11:01,840 --> 04:11:04,680
button minimass will pop up I'll confirm
6806
04:11:04,680 --> 04:11:06,159
we can see at the top the current
6807
04:11:06,159 --> 04:11:08,239
balance of the contract is zero and
6808
04:11:08,239 --> 04:11:09,239
we'll wait a little bit for the
6809
04:11:09,239 --> 04:11:11,279
transaction to finish going through and
6810
04:11:11,279 --> 04:11:12,600
after the transaction finish is going
6811
04:11:12,600 --> 04:11:14,080
through we can see ether scan we have a
6812
04:11:14,080 --> 04:11:17,119
balance of 0.01 eth and we can also see
6813
04:11:17,119 --> 04:11:19,520
that after remix after a slight delay
6814
04:11:19,520 --> 04:11:21,040
then we can allow the owner of the
6815
04:11:21,040 --> 04:11:23,000
contract to withdraw those funds right
6816
04:11:23,000 --> 04:11:25,399
now the owner of the contract is also us
6817
04:11:25,399 --> 04:11:27,080
and after this transaction goes through
6818
04:11:27,080 --> 04:11:28,680
we'll see that balance removed from the
6819
04:11:28,680 --> 04:11:30,359
contract and it'll go back into our
6820
04:11:30,359 --> 04:11:32,560
wallet and as you just saw there if we
6821
04:11:32,560 --> 04:11:34,119
held our metamask up for long enough
6822
04:11:34,119 --> 04:11:35,640
eventually it would pop back into our
6823
04:11:35,640 --> 04:11:37,560
metamask are you excited we you should
6824
04:11:37,560 --> 04:11:38,960
be because after you complete this
6825
04:11:38,960 --> 04:11:41,040
section you'll actually know most of the
6826
04:11:41,040 --> 04:11:42,880
fundamentals of working with solidity
6827
04:11:42,880 --> 04:11:44,080
we're going to going to be going over a
6828
04:11:44,080 --> 04:11:46,319
lot of advanced features in this section
6829
04:11:46,319 --> 04:11:48,040
and I'll let you know the specific parts
6830
04:11:48,040 --> 04:11:49,960
that you don't need to fully understand
6831
04:11:49,960 --> 04:11:51,880
quite yet there's going to be a couple
6832
04:11:51,880 --> 04:11:53,920
parts where if it doesn't totally make
6833
04:11:53,920 --> 04:11:55,439
sense just keep going with the course
6834
04:11:55,439 --> 04:11:56,920
and as we get later into the course
6835
04:11:56,920 --> 04:11:58,680
you'll figure out why they make sense
6836
04:11:58,680 --> 04:12:00,080
but it might be a good idea to write
6837
04:12:00,080 --> 04:12:01,600
down the questions that you have to ask
6838
04:12:01,600 --> 04:12:04,199
either an AI on the GitHub discussions
6839
04:12:04,199 --> 04:12:07,000
or web3 education. make sure of course
6840
04:12:07,000 --> 04:12:08,680
to use the discussions Tab In The
6841
04:12:08,680 --> 04:12:11,119
Foundry full course f23 to ask questions
6842
04:12:11,119 --> 04:12:12,720
and interact with other developers who
6843
04:12:12,720 --> 04:12:14,640
are taking this same course or go to
6844
04:12:14,640 --> 04:12:17,239
web3 dev. education to learn more all
6845
04:12:17,239 --> 04:12:20,000
right let's get
6846
04:12:21,640 --> 04:12:23,560
froggy so the first thing that we want
6847
04:12:23,560 --> 04:12:25,040
to do is let's once again delete
6848
04:12:25,040 --> 04:12:26,600
everything in our remix so we can start
6849
04:12:26,600 --> 04:12:28,840
from scratch so I have the contracts
6850
04:12:28,840 --> 04:12:29,840
that we're actually going to be building
6851
04:12:29,840 --> 04:12:31,080
in here you might have the simple
6852
04:12:31,080 --> 04:12:32,920
storage the ad five extra the storage
6853
04:12:32,920 --> 04:12:34,840
Factory Etc let's go ahead right click
6854
04:12:34,840 --> 04:12:36,279
and just delete everything we're going
6855
04:12:36,279 --> 04:12:38,520
to start completely from blank here so
6856
04:12:38,520 --> 04:12:41,239
let's go ahead and delete everything in
6857
04:12:41,239 --> 04:12:43,359
here all right great so let's go ahead
6858
04:12:43,359 --> 04:12:44,359
and start creating our contract we're
6859
04:12:44,359 --> 04:12:46,279
going to call it fund. Soul one thing
6860
04:12:46,279 --> 04:12:47,439
that's really good when you actually
6861
04:12:47,439 --> 04:12:49,239
start building any code at all is to
6862
04:12:49,239 --> 04:12:51,319
First write down what you want it to do
6863
04:12:51,319 --> 04:12:53,600
so what do we want ours to do we want to
6864
04:12:53,600 --> 04:12:56,119
get funds from users into this contract
6865
04:12:56,119 --> 04:12:58,159
withdraw funds to the owner of the
6866
04:12:58,159 --> 04:12:59,840
contract or whoever has created this
6867
04:12:59,840 --> 04:13:01,960
fundme contract and then we also want to
6868
04:13:01,960 --> 04:13:04,600
set a minimum funding value in USD we
6869
04:13:04,600 --> 04:13:05,960
don't want people to be able to donate
6870
04:13:05,960 --> 04:13:07,640
just a penny so let's go ahead and set
6871
04:13:07,640 --> 04:13:08,840
this up
6872
04:13:08,840 --> 04:13:14,359
spdx license identifier identifier MIT
6873
04:13:14,359 --> 04:13:18,319
do pragma solidity carot
6874
04:13:18,319 --> 04:13:21,640
0.818 contract fund me let's go ahead
6875
04:13:21,640 --> 04:13:23,359
and delete these comments so before we
6876
04:13:23,359 --> 04:13:25,080
embark on writing all of our
6877
04:13:25,080 --> 04:13:26,479
functionality out let's just write down
6878
04:13:26,479 --> 04:13:28,600
the functions that we want to build so
6879
04:13:28,600 --> 04:13:29,920
we're probably going to want a function
6880
04:13:29,920 --> 04:13:31,640
fund which is going to be the function
6881
04:13:31,640 --> 04:13:33,600
they call to send money to our contract
6882
04:13:33,600 --> 04:13:36,399
we're going to want a function withdraw
6883
04:13:36,399 --> 04:13:38,000
which is going to be the function that
6884
04:13:38,000 --> 04:13:39,439
the owner of the contract is going to
6885
04:13:39,439 --> 04:13:40,760
use to withdraw the money that the
6886
04:13:40,760 --> 04:13:42,720
funders send us and those are going to
6887
04:13:42,720 --> 04:13:44,760
be the two main functions that our
6888
04:13:44,760 --> 04:13:46,439
contract is going to need we're going to
6889
04:13:46,439 --> 04:13:48,399
be implementing more functions than just
6890
04:13:48,399 --> 04:13:50,000
this but these are going to be the main
6891
04:13:50,000 --> 04:13:52,040
functions to interact with our protocol
6892
04:13:52,040 --> 04:13:54,080
or interact with our fundme contract
6893
04:13:54,080 --> 04:13:55,800
let's comment out withdraw for now and
6894
04:13:55,800 --> 04:13:59,000
just start focusing on
6895
04:14:00,399 --> 04:14:03,000
fund we want anyone to be able to call
6896
04:14:03,000 --> 04:14:04,840
this fund function so we're going to
6897
04:14:04,840 --> 04:14:06,600
make this public and we want this
6898
04:14:06,600 --> 04:14:08,399
function to do what well we wanted to
6899
04:14:08,399 --> 04:14:10,399
allow users to send money and we want to
6900
04:14:10,399 --> 04:14:12,199
have a minimum dollar amount that they
6901
04:14:12,199 --> 04:14:14,080
have to send so the first question we
6902
04:14:14,080 --> 04:14:16,000
need to answer is how do we send eth to
6903
04:14:16,000 --> 04:14:17,600
this contract how do we have it when a
6904
04:14:17,600 --> 04:14:19,239
user calls the Fone function eth
6905
04:14:19,239 --> 04:14:20,520
automatically gets sent into our
6906
04:14:20,520 --> 04:14:22,560
contract whenever we send a transaction
6907
04:14:22,560 --> 04:14:23,960
on the blockchain there's actually
6908
04:14:23,960 --> 04:14:26,520
always a value field that gets populated
6909
04:14:26,520 --> 04:14:27,680
and most of the time it gets sent with
6910
04:14:27,680 --> 04:14:30,520
zero even before when we called the send
6911
04:14:30,520 --> 04:14:32,680
function between our accounts when we
6912
04:14:32,680 --> 04:14:35,600
added an amount in our metamask this
6913
04:14:35,600 --> 04:14:38,000
amount value populated the value field
6914
04:14:38,000 --> 04:14:40,479
of our transaction this value field is
6915
04:14:40,479 --> 04:14:42,199
the amount of native blockchain
6916
04:14:42,199 --> 04:14:44,080
cryptocurrency that gets sent with every
6917
04:14:44,080 --> 04:14:45,840
transaction the first thing that we need
6918
04:14:45,840 --> 04:14:48,399
to do to allow a function in solidity to
6919
04:14:48,399 --> 04:14:50,479
accept this native blockchain currency
6920
04:14:50,479 --> 04:14:51,760
in the first place is to make the
6921
04:14:51,760 --> 04:14:53,479
function payable it's this payable
6922
04:14:53,479 --> 04:14:54,960
keyword that makes the function look red
6923
04:14:54,960 --> 04:14:57,560
in the remix UI just like how wallets
6924
04:14:57,560 --> 04:14:59,159
can hold funds contracts can actually
6925
04:14:59,159 --> 04:15:01,159
hold funds as well so whenever you
6926
04:15:01,159 --> 04:15:03,000
deploy a contract similar to a wallet
6927
04:15:03,000 --> 04:15:04,960
address it actually acts almost the same
6928
04:15:04,960 --> 04:15:06,399
as a wallet address you can send money
6929
04:15:06,399 --> 04:15:08,439
to it you can interact with it Etc and
6930
04:15:08,439 --> 04:15:09,680
like we did in the demo you'll see this
6931
04:15:09,680 --> 04:15:11,680
contract actually gain a balance just
6932
04:15:11,680 --> 04:15:13,680
like a wallet you can access this value
6933
04:15:13,680 --> 04:15:15,239
amount of a transaction using one of the
6934
04:15:15,239 --> 04:15:17,159
globals in solidity called
6935
04:15:17,159 --> 04:15:19,439
message. solidity has a number of these
6936
04:15:19,439 --> 04:15:21,159
globally available keywords and
6937
04:15:21,159 --> 04:15:22,840
functions and you can find these in the
6938
04:15:22,840 --> 04:15:24,920
solidity documentation one of them is
6939
04:15:24,920 --> 04:15:26,880
message. value which is the number of
6940
04:15:26,880 --> 04:15:29,000
way sent with the message if we wanted
6941
04:15:29,000 --> 04:15:31,199
users to be required to spend at least
6942
04:15:31,199 --> 04:15:33,920
one whole ether with this fund function
6943
04:15:33,920 --> 04:15:35,439
we could use something called require to
6944
04:15:35,439 --> 04:15:37,359
do so in order to do that we would add
6945
04:15:37,359 --> 04:15:40,359
this line require message. value is
6946
04:15:40,359 --> 04:15:43,720
greater than 1 E8
6947
04:15:43,720 --> 04:15:45,000
and there's a couple of things to unpack
6948
04:15:45,000 --> 04:15:48,720
here 1 E18 is equal to 1 ether which is
6949
04:15:48,720 --> 04:15:52,439
equal to 1 1 2 3 4 5 6 7 8 9 10 1 2 3 4
6950
04:15:52,439 --> 04:15:54,920
5 6 7 8 or put another way it's equal to
6951
04:15:54,920 --> 04:15:58,720
1 * 10 raised to the 18th in solidity a
6952
04:15:58,720 --> 04:16:00,680
double asri or double multiply sign is
6953
04:16:00,680 --> 04:16:03,359
how you do a power or an exponent this
6954
04:16:03,359 --> 04:16:05,359
value here is the value in way of one
6955
04:16:05,359 --> 04:16:06,840
ethereum in your smart contracts and at
6956
04:16:06,840 --> 04:16:08,479
the lowest level this is how they
6957
04:16:08,479 --> 04:16:10,199
process numbers in this giant wave
6958
04:16:10,199 --> 04:16:12,439
format so if we wanted people to be
6959
04:16:12,439 --> 04:16:14,399
forced to send at least one whole eth
6960
04:16:14,399 --> 04:16:15,520
with this fund function we would just
6961
04:16:15,520 --> 04:16:17,920
say require message. value is greater
6962
04:16:17,920 --> 04:16:20,279
than 1 E18 you can use something like
6963
04:16:20,279 --> 04:16:23,080
eth converter.com see to convert one
6964
04:16:23,080 --> 04:16:25,600
ether between ether whey and gay is
6965
04:16:25,600 --> 04:16:27,720
actually another value in between ether
6966
04:16:27,720 --> 04:16:29,880
and Wei and we saw gu actually when we
6967
04:16:29,880 --> 04:16:32,399
saw gas costs normally gas costs are
6968
04:16:32,399 --> 04:16:34,560
shown in forms of guay this required
6969
04:16:34,560 --> 04:16:36,040
keyword is a checker it's basically
6970
04:16:36,040 --> 04:16:37,720
saying hey is message. value greater
6971
04:16:37,720 --> 04:16:40,439
than 1 E18 if not then revert this
6972
04:16:40,439 --> 04:16:42,640
transaction and if we want we could add
6973
04:16:42,640 --> 04:16:44,199
a little revert message we could say
6974
04:16:44,199 --> 04:16:47,600
like didn't send enough eth we can
6975
04:16:47,600 --> 04:16:49,000
actually deploy this we can actually
6976
04:16:49,000 --> 04:16:52,680
compile and deploy this on a remix
6977
04:16:56,640 --> 04:16:59,920
vmy scroll down and if we hit fund and
6978
04:16:59,920 --> 04:17:02,600
if we pull up our terminal we hit fund
6979
04:17:02,600 --> 04:17:04,159
we actually see we get this little X
6980
04:17:04,159 --> 04:17:05,880
here meaning our transaction didn't go
6981
04:17:05,880 --> 04:17:08,000
through and if we hit the drop down oh
6982
04:17:08,000 --> 04:17:09,760
again same thing same thing we know that
6983
04:17:09,760 --> 04:17:11,199
this error is because we have this
6984
04:17:11,199 --> 04:17:12,920
require statement in here in our
6985
04:17:12,920 --> 04:17:14,720
transaction is reverting or not going
6986
04:17:14,720 --> 04:17:16,239
through so we know that with this
6987
04:17:16,239 --> 04:17:18,359
transaction we need to send at least 1
6988
04:17:18,359 --> 04:17:22,319
eth or or 1 E18 way worth of eth in the
6989
04:17:22,319 --> 04:17:24,080
value section of our transaction so if
6990
04:17:24,080 --> 04:17:26,040
we scroll up we can actually just change
6991
04:17:26,040 --> 04:17:29,119
the unit to Ether put one in here scroll
6992
04:17:29,119 --> 04:17:31,319
down and now if we hit fund oh it
6993
04:17:31,319 --> 04:17:32,439
doesn't go through because we have
6994
04:17:32,439 --> 04:17:34,279
strictly greater than so excuse me Let's
6995
04:17:34,279 --> 04:17:36,920
do let's do two now I'll scroll down
6996
04:17:36,920 --> 04:17:39,000
we'll hit fund and we see we get a green
6997
04:17:39,000 --> 04:17:40,720
check mark and we see the fundme balance
6998
04:17:40,720 --> 04:17:43,439
actually has improved to two if we
6999
04:17:43,439 --> 04:17:45,239
update the value to two again and we
7000
04:17:45,239 --> 04:17:47,239
scroll down we had fund again we see our
7001
04:17:47,239 --> 04:17:48,439
transaction went through and we have
7002
04:17:48,439 --> 04:17:50,479
four if we try to do less like let's
7003
04:17:50,479 --> 04:17:53,040
change this to way and we'll do you know
7004
04:17:53,040 --> 04:17:55,800
th way scroll down we hit fund up it
7005
04:17:55,800 --> 04:17:59,840
fails because 100 way is less than 1 E18
7006
04:17:59,840 --> 04:18:02,560
way right because 18 E18 way is this
7007
04:18:02,560 --> 04:18:05,600
much way so obviously th000 or however
7008
04:18:05,600 --> 04:18:08,000
much I put in is much less so this
7009
04:18:08,000 --> 04:18:10,000
require says if this first section is
7010
04:18:10,000 --> 04:18:11,920
false then go ahead and revert with
7011
04:18:11,920 --> 04:18:15,279
whatever this second section
7012
04:18:16,600 --> 04:18:19,119
is reverts can be a little bit confusing
7013
04:18:19,119 --> 04:18:21,040
and a little bit tricky so what is a
7014
04:18:21,040 --> 04:18:23,640
revert a revert undoes any actions that
7015
04:18:23,640 --> 04:18:25,840
have been done previously and sends the
7016
04:18:25,840 --> 04:18:27,520
remaining gas associated with that
7017
04:18:27,520 --> 04:18:29,359
transaction back so what does that
7018
04:18:29,359 --> 04:18:32,040
actually mean well let's say for example
7019
04:18:32,040 --> 04:18:34,720
in our fundme contract we have a u 256
7020
04:18:34,720 --> 04:18:37,239
public my value and let's have my value
7021
04:18:37,239 --> 04:18:39,199
initialized to one now in our fun
7022
04:18:39,199 --> 04:18:42,840
function let's say my value equals my
7023
04:18:42,840 --> 04:18:46,080
Value Plus two so every time this fun
7024
04:18:46,080 --> 04:18:48,159
function successfully goes through we
7025
04:18:48,159 --> 04:18:51,000
add two to my value however if we get to
7026
04:18:51,000 --> 04:18:53,680
a revert statement even though we added
7027
04:18:53,680 --> 04:18:56,560
two to my value previously since our
7028
04:18:56,560 --> 04:18:58,399
contract reverts this would actually
7029
04:18:58,399 --> 04:19:00,840
revert this action or reset it back to
7030
04:19:00,840 --> 04:19:03,040
its initial state so if this transaction
7031
04:19:03,040 --> 04:19:05,479
reverts my value would go back to one or
7032
04:19:05,479 --> 04:19:07,359
whatever it was previously if we compile
7033
04:19:07,359 --> 04:19:09,520
fundme we delete our previous deploys
7034
04:19:09,520 --> 04:19:11,279
we're on the remix VM we'll deploy
7035
04:19:11,279 --> 04:19:13,479
fundme we'll scroll down we have my
7036
04:19:13,479 --> 04:19:16,439
value which defaults to one if we call
7037
04:19:16,439 --> 04:19:19,800
fund right now without any value we pull
7038
04:19:19,800 --> 04:19:21,159
up our terminal we can see the
7039
04:19:21,159 --> 04:19:24,760
transaction failed my value is still one
7040
04:19:24,760 --> 04:19:26,880
even though this line technically
7041
04:19:26,880 --> 04:19:29,319
executed this line executed but then
7042
04:19:29,319 --> 04:19:31,239
this line hit and it reverted what was
7043
04:19:31,239 --> 04:19:33,640
done here so if we scroll back up though
7044
04:19:33,640 --> 04:19:36,399
we go to Ether we'll put one in for now
7045
04:19:36,399 --> 04:19:39,439
scroll back down now we'll hit fund oh
7046
04:19:39,439 --> 04:19:41,119
needs to be more than one excuse me
7047
04:19:41,119 --> 04:19:43,479
we'll add two here scroll back down now
7048
04:19:43,479 --> 04:19:45,199
we'll hit fund that transaction did go
7049
04:19:45,199 --> 04:19:47,760
through which means my value will now be
7050
04:19:47,760 --> 04:19:51,159
equal to three and again if I set value
7051
04:19:51,159 --> 04:19:54,399
to zero we call fund it reverts so my
7052
04:19:54,399 --> 04:19:56,960
value is still three so then the
7053
04:19:56,960 --> 04:19:58,520
question might be oh well did we spend
7054
04:19:58,520 --> 04:20:00,119
gas to do this if my transaction didn't
7055
04:20:00,119 --> 04:20:01,880
even go through well unfortunately the
7056
04:20:01,880 --> 04:20:04,800
answer here is yes if you send a failed
7057
04:20:04,800 --> 04:20:07,439
transaction you will spend gas because
7058
04:20:07,439 --> 04:20:09,520
computers executed this line and then
7059
04:20:09,520 --> 04:20:12,040
they executed this line and just failed
7060
04:20:12,040 --> 04:20:14,119
so users can actually specify how much
7061
04:20:14,119 --> 04:20:15,840
gas they send with every function let's
7062
04:20:15,840 --> 04:20:17,479
say there was a ton of computation after
7063
04:20:17,479 --> 04:20:19,040
this require line we would need to send
7064
04:20:19,040 --> 04:20:21,760
a ton of gas to operate and run our fund
7065
04:20:21,760 --> 04:20:23,920
function however once it gets to this
7066
04:20:23,920 --> 04:20:26,000
require line and it reverts however much
7067
04:20:26,000 --> 04:20:28,159
gas that we sent to execute the rest of
7068
04:20:28,159 --> 04:20:29,840
the computation would just get refunded
7069
04:20:29,840 --> 04:20:32,199
to whoever initiated the transaction
7070
04:20:32,199 --> 04:20:33,840
like I said sometimes the refunds and
7071
04:20:33,840 --> 04:20:34,760
some of that can be a little bit
7072
04:20:34,760 --> 04:20:37,040
confusing so again for now just know
7073
04:20:37,040 --> 04:20:40,279
that if a transaction reverts it undoes
7074
04:20:40,279 --> 04:20:42,319
anything it does previously and you can
7075
04:20:42,319 --> 04:20:45,159
consider consider the transaction failed
7076
04:20:45,159 --> 04:20:46,359
however if you send a reverted
7077
04:20:46,359 --> 04:20:48,920
transaction you will still spend gas but
7078
04:20:48,920 --> 04:20:51,279
okay let's delete this value for now
7079
04:20:51,279 --> 04:20:52,720
delete it from the global scope and
7080
04:20:52,720 --> 04:20:55,199
delete some of these like that in fact
7081
04:20:55,199 --> 04:20:57,359
every single transaction that we send
7082
04:20:57,359 --> 04:20:59,960
will have these fields it'll have a nuns
7083
04:20:59,960 --> 04:21:02,600
or the transaction count the account the
7084
04:21:02,600 --> 04:21:05,359
gas price the gas limit that we've seen
7085
04:21:05,359 --> 04:21:08,560
on ether scan a two aka the address that
7086
04:21:08,560 --> 04:21:11,199
the transaction is sent to a value which
7087
04:21:11,199 --> 04:21:12,640
is going to be this amount that we're
7088
04:21:12,640 --> 04:21:14,640
talking about we'll also have data which
7089
04:21:14,640 --> 04:21:16,600
is going to be what we send if we make a
7090
04:21:16,600 --> 04:21:19,040
function call or deploy a contract and
7091
04:21:19,040 --> 04:21:22,000
then it'll have this vrs components
7092
04:21:22,000 --> 04:21:23,359
we're not really going to go over these
7093
04:21:23,359 --> 04:21:25,119
VR ands because this is that
7094
04:21:25,119 --> 04:21:27,399
cryptographic magic that's happening
7095
04:21:27,399 --> 04:21:29,359
when a transaction is signed but just
7096
04:21:29,359 --> 04:21:31,520
know that that's in there for sending
7097
04:21:31,520 --> 04:21:33,520
value we can populate some of these
7098
04:21:33,520 --> 04:21:35,720
fields the gas limit for example is
7099
04:21:35,720 --> 04:21:38,640
populated to 21,000 data is going to be
7100
04:21:38,640 --> 04:21:41,319
empty and then that two is going to be
7101
04:21:41,319 --> 04:21:43,000
the address of the transaction want to
7102
04:21:43,000 --> 04:21:45,640
send to for a function call we can also
7103
04:21:45,640 --> 04:21:48,279
still populate the way that we want to
7104
04:21:48,279 --> 04:21:51,199
send so we can call a function and send
7105
04:21:51,199 --> 04:21:53,560
a value at the same time in remix it has
7106
04:21:53,560 --> 04:21:56,439
a little drop down here way gu finny and
7107
04:21:56,439 --> 04:21:58,359
ether we're going to ignore finny for
7108
04:21:58,359 --> 04:22:00,560
now but of course we have our whey gay
7109
04:22:00,560 --> 04:22:03,439
and ether again where one ether is worth
7110
04:22:03,439 --> 04:22:07,399
this much gay and this much
7111
04:22:08,479 --> 04:22:10,800
whey so right now our contract is pretty
7112
04:22:10,800 --> 04:22:12,960
minimal right we're requir iring the
7113
04:22:12,960 --> 04:22:15,000
message. value is greater than one whole
7114
04:22:15,000 --> 04:22:16,920
ether but we want to actually require
7115
04:22:16,920 --> 04:22:19,040
that it's less than some value like
7116
04:22:19,040 --> 04:22:21,080
let's say we want to have users spend a
7117
04:22:21,080 --> 04:22:23,880
minimum of $5 as opposed to one whole
7118
04:22:23,880 --> 04:22:26,640
ethereum so let's first specify that $5
7119
04:22:26,640 --> 04:22:27,800
we can do that at the top of our
7120
04:22:27,800 --> 04:22:31,600
contract we'll say U 256 minimum USD
7121
04:22:31,600 --> 04:22:34,680
equals 5 and we'll make this public
7122
04:22:34,680 --> 04:22:36,600
instead of internal we'll update this
7123
04:22:36,600 --> 04:22:38,319
minimum USD in the future to make this
7124
04:22:38,319 --> 04:22:40,359
more gas efficient so what we want to do
7125
04:22:40,359 --> 04:22:42,760
is we want to require that our fun
7126
04:22:42,760 --> 04:22:44,880
function requires that the message.
7127
04:22:44,880 --> 04:22:46,399
value is greater than let's say greater
7128
04:22:46,399 --> 04:22:49,359
than or equal to minimum USD however
7129
04:22:49,359 --> 04:22:51,800
minimum USD is in terms of USD or
7130
04:22:51,800 --> 04:22:54,159
dollars and message. value is in terms
7131
04:22:54,159 --> 04:22:57,439
of eth or way in terms of ethereum so
7132
04:22:57,439 --> 04:22:59,080
how do we convert the amount of ethereum
7133
04:22:59,080 --> 04:23:01,800
to its price in dollar this is where
7134
04:23:01,800 --> 04:23:04,080
oracles and chain link comes into play
7135
04:23:04,080 --> 04:23:05,760
the dollar price of an asset like
7136
04:23:05,760 --> 04:23:07,399
ethereum is something that we've
7137
04:23:07,399 --> 04:23:09,600
assigned to ethereum outside of the
7138
04:23:09,600 --> 04:23:11,479
blockchain in the real world so in order
7139
04:23:11,479 --> 04:23:13,199
to get this abstract concept of the
7140
04:23:13,199 --> 04:23:14,800
price of the Native cryptocurrency of
7141
04:23:14,800 --> 04:23:16,680
the blockchain working with so we need
7142
04:23:16,680 --> 04:23:18,479
to use a decentralized Oracle Network or
7143
04:23:18,479 --> 04:23:20,119
something called an oracle to get this
7144
04:23:20,119 --> 04:23:22,119
price so before we keep going let's
7145
04:23:22,119 --> 04:23:23,479
learn a little bit more about
7146
04:23:23,479 --> 04:23:25,800
decentralized oracles chain link and how
7147
04:23:25,800 --> 04:23:27,279
they work so that we can understand how
7148
04:23:27,279 --> 04:23:29,159
to get the price of ethereum into our
7149
04:23:29,159 --> 04:23:31,199
smart contracts as we've talked about
7150
04:23:31,199 --> 04:23:33,439
blockchains are deterministic systems
7151
04:23:33,439 --> 04:23:35,600
which means that they themselves can't
7152
04:23:35,600 --> 04:23:37,479
actually interact with real world data
7153
04:23:37,479 --> 04:23:39,439
and events they don't know what the
7154
04:23:39,439 --> 04:23:41,199
value of an ethereum is they don't know
7155
04:23:41,199 --> 04:23:42,800
what random numbers are they don't know
7156
04:23:42,800 --> 04:23:44,279
if it's sunny outside they don't know
7157
04:23:44,279 --> 04:23:45,920
the temperature they don't know who's
7158
04:23:45,920 --> 04:23:47,640
President they don't know any of this
7159
04:23:47,640 --> 04:23:50,159
information these blockchains also can't
7160
04:23:50,159 --> 04:23:52,760
do any external computation maybe you
7161
04:23:52,760 --> 04:23:54,199
have some amazing artificial
7162
04:23:54,199 --> 04:23:55,439
intelligence model that you want to
7163
04:23:55,439 --> 04:23:57,520
integrate with a smart contract smart
7164
04:23:57,520 --> 04:23:59,199
contracts by themselves can't do
7165
04:23:59,199 --> 04:24:01,040
anything with that as we've mentioned
7166
04:24:01,040 --> 04:24:02,560
this is because blockchains are
7167
04:24:02,560 --> 04:24:05,080
deterministic by Design This is so that
7168
04:24:05,080 --> 04:24:07,159
all the nodes can reach consensus if you
7169
04:24:07,159 --> 04:24:09,479
start adding variable data or random
7170
04:24:09,479 --> 04:24:12,520
data or values that return from an API
7171
04:24:12,520 --> 04:24:14,479
call different nodes could get different
7172
04:24:14,479 --> 04:24:16,119
results and they would never be able to
7173
04:24:16,119 --> 04:24:18,439
reach a consensus this is known as the
7174
04:24:18,439 --> 04:24:20,800
smart contract connectivity problem or
7175
04:24:20,800 --> 04:24:23,159
the Oracle problem and this is bad news
7176
04:24:23,159 --> 04:24:24,800
because we want our smart contracts to
7177
04:24:24,800 --> 04:24:26,880
be able to replace traditional
7178
04:24:26,880 --> 04:24:29,239
agreements and traditional agreements
7179
04:24:29,239 --> 04:24:30,920
need data and they need to interact with
7180
04:24:30,920 --> 04:24:33,080
the real world this is where chain link
7181
04:24:33,080 --> 04:24:35,840
and blockchain oracles come into place a
7182
04:24:35,840 --> 04:24:37,520
blockchain Oracle is going to be any
7183
04:24:37,520 --> 04:24:39,359
device that interacts with the offchain
7184
04:24:39,359 --> 04:24:41,119
world to provide external data or
7185
04:24:41,119 --> 04:24:43,159
computation to Smart contract
7186
04:24:43,159 --> 04:24:44,880
however the whole story doesn't even end
7187
04:24:44,880 --> 04:24:48,040
there if we use a centralized Oracle we
7188
04:24:48,040 --> 04:24:50,560
are reintroducing a point of failure
7189
04:24:50,560 --> 04:24:52,560
we've done all this work to make our
7190
04:24:52,560 --> 04:24:55,239
logic layer decentralized but if we get
7191
04:24:55,239 --> 04:24:57,000
our data through a centralized node or
7192
04:24:57,000 --> 04:24:59,359
through a centralized API or we decide
7193
04:24:59,359 --> 04:25:01,359
we want to make the API call ourselves
7194
04:25:01,359 --> 04:25:03,439
we are reintroducing these trust
7195
04:25:03,439 --> 04:25:05,319
assumptions that we've worked so hard to
7196
04:25:05,319 --> 04:25:07,680
get rid of we're essentially ruining the
7197
04:25:07,680 --> 04:25:09,239
entire purpose of building a smart
7198
04:25:09,239 --> 04:25:11,119
contract so we don't want to get our
7199
04:25:11,119 --> 04:25:13,279
data or do external computation through
7200
04:25:13,279 --> 04:25:16,080
centralized nodes those are bad news
7201
04:25:16,080 --> 04:25:18,399
chain link is the solution here chain
7202
04:25:18,399 --> 04:25:20,760
link is a decentralized Oracle Network
7203
04:25:20,760 --> 04:25:22,319
for bringing data and external
7204
04:25:22,319 --> 04:25:24,960
computation into our smart contracts as
7205
04:25:24,960 --> 04:25:26,960
we mentioned before this gives rise to
7206
04:25:26,960 --> 04:25:28,680
these hybrid smart contracts which
7207
04:25:28,680 --> 04:25:30,840
combine onchain and offchain to make
7208
04:25:30,840 --> 04:25:33,960
incredibly featur powerful applications
7209
04:25:33,960 --> 04:25:36,040
chain link is a modular decentralized
7210
04:25:36,040 --> 04:25:38,159
oracal Network that can be customized to
7211
04:25:38,159 --> 04:25:40,279
deliver any data or do any external
7212
04:25:40,279 --> 04:25:43,000
computation that you like so for example
7213
04:25:43,000 --> 04:25:45,199
a lot of people say oh I can just make
7214
04:25:45,199 --> 04:25:48,119
an https call to some
7215
04:25:48,119 --> 04:25:50,720
API and we'll be good to go the
7216
04:25:50,720 --> 04:25:52,840
blockchain nodes can't make these https
7217
04:25:52,840 --> 04:25:54,520
calls because they wouldn't be able to
7218
04:25:54,520 --> 04:25:56,359
reach consensus if they called the node
7219
04:25:56,359 --> 04:25:58,399
at different times or they did something
7220
04:25:58,399 --> 04:26:01,319
else all the consensus would be broken
7221
04:26:01,319 --> 04:26:03,399
so instead we need a decentralized
7222
04:26:03,399 --> 04:26:05,680
network of chain L oracles to do this
7223
04:26:05,680 --> 04:26:08,199
and then in transaction this network of
7224
04:26:08,199 --> 04:26:10,640
nodes will return the data to our smart
7225
04:26:10,640 --> 04:26:13,279
contracts for us now chain link networks
7226
04:26:13,279 --> 04:26:15,199
can be completely customized to bring
7227
04:26:15,199 --> 04:26:17,520
any data or any external computation
7228
04:26:17,520 --> 04:26:19,560
that you want however doing the
7229
04:26:19,560 --> 04:26:21,520
customization can be a little bit extra
7230
04:26:21,520 --> 04:26:23,040
work there are a ton of chain link
7231
04:26:23,040 --> 04:26:24,640
features that come out of the box
7232
04:26:24,640 --> 04:26:26,399
completely decentralized ready to Plug
7233
04:26:26,399 --> 04:26:27,840
and Play into your smart contract
7234
04:26:27,840 --> 04:26:30,000
applications what are those features the
7235
04:26:30,000 --> 04:26:31,520
first one is going to be chain link data
7236
04:26:31,520 --> 04:26:33,000
feeds and that's the one we're actually
7237
04:26:33,000 --> 04:26:34,520
going to be using for our application
7238
04:26:34,520 --> 04:26:36,720
here chain link data feeds currently at
7239
04:26:36,720 --> 04:26:38,479
the time of recording are powering over
7240
04:26:38,479 --> 04:26:41,000
$50 billion in the defi world the way
7241
04:26:41,000 --> 04:26:43,319
they work is a a network of train link
7242
04:26:43,319 --> 04:26:46,159
nodes gets data from different exchanges
7243
04:26:46,159 --> 04:26:48,960
and data providers and brings that data
7244
04:26:48,960 --> 04:26:50,960
through a network of decentralized chain
7245
04:26:50,960 --> 04:26:52,800
link nodes the chain link nodes use a
7246
04:26:52,800 --> 04:26:54,760
median to figure out what the actual
7247
04:26:54,760 --> 04:26:56,680
price of the asset is and then deliver
7248
04:26:56,680 --> 04:26:59,399
that in a single transaction to what's
7249
04:26:59,399 --> 04:27:01,319
called a reference contract a price feed
7250
04:27:01,319 --> 04:27:03,640
contract or a data contract on chain
7251
04:27:03,640 --> 04:27:05,800
that other smart contracts can use and
7252
04:27:05,800 --> 04:27:07,800
then those smart contracts use that that
7253
04:27:07,800 --> 04:27:09,880
pricing information to power their defi
7254
04:27:09,880 --> 04:27:12,319
application we can see an example we see
7255
04:27:12,319 --> 04:27:15,680
an example at data. chain.
7256
04:27:15,680 --> 04:27:18,359
link and you can change networks you can
7257
04:27:18,359 --> 04:27:20,359
change price feeds you can change whole
7258
04:27:20,359 --> 04:27:22,159
bunch of information to see some of the
7259
04:27:22,159 --> 04:27:24,000
most popular price feeds let's look at
7260
04:27:24,000 --> 04:27:25,680
ethusd for
7261
04:27:25,680 --> 04:27:28,600
example on ethusd we can see this whole
7262
04:27:28,600 --> 04:27:30,520
network of independent chain link node
7263
04:27:30,520 --> 04:27:32,399
operators that are each getting
7264
04:27:32,399 --> 04:27:35,040
different answers for the price of vusd
7265
04:27:35,040 --> 04:27:36,399
they're getting aggregated by the
7266
04:27:36,399 --> 04:27:38,560
network and then delivered on chain we
7267
04:27:38,560 --> 04:27:40,720
can see how often they're updated these
7268
04:27:40,720 --> 04:27:43,199
ones are updated for 05 deviation
7269
04:27:43,199 --> 04:27:46,000
threshold or a few hour heartbeat which
7270
04:27:46,000 --> 04:27:47,760
everyone hits first we can see when the
7271
04:27:47,760 --> 04:27:49,880
last update was we can see the number of
7272
04:27:49,880 --> 04:27:52,560
Oracle responses
7273
04:27:52,560 --> 04:27:55,439
Etc we can see the contract address
7274
04:27:55,439 --> 04:27:56,760
directly on
7275
04:27:56,760 --> 04:27:59,080
chain we can even look at the contract
7276
04:27:59,080 --> 04:28:01,399
on ether
7277
04:28:01,399 --> 04:28:04,560
scan we can see some of the history we
7278
04:28:04,560 --> 04:28:06,319
can see all the responses of the
7279
04:28:06,319 --> 04:28:08,439
different
7280
04:28:08,439 --> 04:28:10,439
Oracles and then at the bottom we can
7281
04:28:10,439 --> 04:28:12,560
see the different users and sponsors
7282
04:28:12,560 --> 04:28:15,439
keeping this network
7283
04:28:19,159 --> 04:28:22,479
up similar to transaction gas whenever a
7284
04:28:22,479 --> 04:28:25,159
node operator delivers data to a Smart
7285
04:28:25,159 --> 04:28:27,040
contract the chain link node operators
7286
04:28:27,040 --> 04:28:28,840
are paid a little bit of Oracle gas in
7287
04:28:28,840 --> 04:28:30,680
the chain link token right now these
7288
04:28:30,680 --> 04:28:32,520
users of the protocol are sponsoring
7289
04:28:32,520 --> 04:28:34,279
keeping these feeds up and are paying
7290
04:28:34,279 --> 04:28:35,880
the Oracle gas associated with
7291
04:28:35,880 --> 04:28:37,840
delivering this data on chain here's an
7292
04:28:37,840 --> 04:28:39,960
illustration of what the current model
7293
04:28:39,960 --> 04:28:41,760
of these data feeds look like a network
7294
04:28:41,760 --> 04:28:43,840
of these chain like nodes each reaches
7295
04:28:43,840 --> 04:28:45,720
out and gets the information about an
7296
04:28:45,720 --> 04:28:48,199
asset and then signs the data with their
7297
04:28:48,199 --> 04:28:50,520
own private key in a single transaction
7298
04:28:50,520 --> 04:28:53,399
then one node will deliver all the data
7299
04:28:53,399 --> 04:28:55,239
with all the different signatures to a
7300
04:28:55,239 --> 04:28:57,199
reference contract if that node doesn't
7301
04:28:57,199 --> 04:28:58,960
deliver the data another node will send
7302
04:28:58,960 --> 04:29:01,080
it instead reputation is incredibly
7303
04:29:01,080 --> 04:29:02,319
important when you're a chain link node
7304
04:29:02,319 --> 04:29:04,159
operator if you miss data updates if you
7305
04:29:04,159 --> 04:29:05,840
forget to send transactions you'll
7306
04:29:05,840 --> 04:29:07,119
probably be quickly kicked off these
7307
04:29:07,119 --> 04:29:08,840
networks and have no chance of making
7308
04:29:08,840 --> 04:29:10,520
any more money in the future these data
7309
04:29:10,520 --> 04:29:12,119
feeds are used by some of the largest
7310
04:29:12,119 --> 04:29:14,119
protocols in the space such as
7311
04:29:14,119 --> 04:29:17,840
synthetics Sushi swap compound and a
7312
04:29:17,840 --> 04:29:19,840
with several billion dollars each we can
7313
04:29:19,840 --> 04:29:22,600
take a look at an example over at docs.
7314
04:29:22,600 --> 04:29:24,760
chain. link work with evm contracts
7315
04:29:24,760 --> 04:29:27,479
we're going to hit evm chains scroll
7316
04:29:27,479 --> 04:29:29,119
down to data
7317
04:29:29,119 --> 04:29:31,520
feeds we'll scroll down to the solidity
7318
04:29:31,520 --> 04:29:33,760
section and we can see an example of an
7319
04:29:33,760 --> 04:29:36,439
entire contract that uses and reads from
7320
04:29:36,439 --> 04:29:37,880
one of these tring price
7321
04:29:37,880 --> 04:29:43,720
feeds we can even open this up in remix
7322
04:29:44,720 --> 04:29:47,439
and work with it in remix it looks like
7323
04:29:47,439 --> 04:29:49,319
this example is reading from a price
7324
04:29:49,319 --> 04:29:51,520
feed on coven the reason we're actually
7325
04:29:51,520 --> 04:29:53,399
going to use a test net to see this work
7326
04:29:53,399 --> 04:29:54,520
is that there's a set of chain link
7327
04:29:54,520 --> 04:29:57,040
nodes monitoring the test Network to to
7328
04:29:57,040 --> 04:29:59,000
show you exactly how this works out once
7329
04:29:59,000 --> 04:30:00,600
we get deeper into the course we'll show
7330
04:30:00,600 --> 04:30:02,199
you how to actually run tests and work
7331
04:30:02,199 --> 04:30:04,359
with Chain Lake nodes without actually
7332
04:30:04,359 --> 04:30:06,000
being on a test net which will make your
7333
04:30:06,000 --> 04:30:07,800
development much faster but I highly
7334
04:30:07,800 --> 04:30:10,119
recommend walking through this section
7335
04:30:10,119 --> 04:30:12,239
along with me so that you can see
7336
04:30:12,239 --> 04:30:14,359
firsthand how this actually works so
7337
04:30:14,359 --> 04:30:18,159
let's go ahead faucets. chain. linken
7338
04:30:18,159 --> 04:30:21,600
we're going to switch to the coven
7339
04:30:21,680 --> 04:30:23,840
Network and we're going to get some Coen
7340
04:30:23,840 --> 04:30:25,800
eth but remember look at the network
7341
04:30:25,800 --> 04:30:27,960
flag and use whatever network is in the
7342
04:30:27,960 --> 04:30:30,880
documentation so to get some Coen we're
7343
04:30:30,880 --> 04:30:32,279
going to come to the faucet we're going
7344
04:30:32,279 --> 04:30:34,439
to turn off test link we'll just stay
7345
04:30:34,439 --> 04:30:39,199
with eth I'm not a robot
7346
04:30:50,560 --> 04:30:52,920
and then send request once our Coen
7347
04:30:52,920 --> 04:30:55,080
ethereum has reached our wallet we can
7348
04:30:55,080 --> 04:30:56,800
go ahead and close and we can take a
7349
04:30:56,800 --> 04:30:59,359
look in our wallet and see that we do
7350
04:30:59,359 --> 04:31:02,239
indeed have 0.1 eth on koven now let's
7351
04:31:02,239 --> 04:31:06,159
go back to our remix we'll compile this
7352
04:31:06,159 --> 04:31:08,800
contract we go and deploy this on
7353
04:31:08,800 --> 04:31:11,000
injected web 3 and again the reason
7354
04:31:11,000 --> 04:31:12,520
we're going to use injected web 3
7355
04:31:12,520 --> 04:31:15,159
instead of JavaScript VM is that there's
7356
04:31:15,159 --> 04:31:17,800
no network of chain link nodes watching
7357
04:31:17,800 --> 04:31:19,960
our little fake JavaScript VM there are
7358
04:31:19,960 --> 04:31:21,840
network of Chain Lake nodes watching the
7359
04:31:21,840 --> 04:31:24,960
test St so we'll scroll down we'll
7360
04:31:24,960 --> 04:31:27,680
switch contract to the price consumer V3
7361
04:31:27,680 --> 04:31:31,000
and we'll hit deploy mamas will pop up
7362
04:31:31,000 --> 04:31:33,119
and after a brief delay we can see our
7363
04:31:33,119 --> 04:31:35,239
price feed consumer down here and we can
7364
04:31:35,239 --> 04:31:37,560
hit get the latest price which shows us
7365
04:31:37,560 --> 04:31:40,239
the latest price of ethereum in terms of
7366
04:31:40,239 --> 04:31:43,000
USD you may be wondering why the number
7367
04:31:43,000 --> 04:31:44,560
looks so weird that seems like a really
7368
04:31:44,560 --> 04:31:46,119
large number for the price of ethereum
7369
04:31:46,119 --> 04:31:48,119
in terms of USD and this is because
7370
04:31:48,119 --> 04:31:50,520
decimals don't actually work so well in
7371
04:31:50,520 --> 04:31:52,279
solidity and we'll get to that in a
7372
04:31:52,279 --> 04:31:54,520
little bit there's a decimals flag
7373
04:31:54,520 --> 04:31:56,600
associated with this price feed address
7374
04:31:56,600 --> 04:31:58,279
that tells us how many decimals to
7375
04:31:58,279 --> 04:32:01,359
include with this price it's also in the
7376
04:32:01,359 --> 04:32:03,199
documentation however I know that this
7377
04:32:03,199 --> 04:32:05,439
one has eight decimals so this is saying
7378
04:32:05,439 --> 04:32:07,830
the value of ethereum right now is
7379
04:32:07,830 --> 04:32:09,000
[Music]
7380
04:32:09,000 --> 04:32:11,359
$3,262 it may of course be different
7381
04:32:11,359 --> 04:32:13,199
when you go go ahead and try this now
7382
04:32:13,199 --> 04:32:14,359
there's a number of things that happen
7383
04:32:14,359 --> 04:32:16,080
in this contract that I'll explain in
7384
04:32:16,080 --> 04:32:17,920
our fundme example but if you want to
7385
04:32:17,920 --> 04:32:19,319
take a look now and see if you can
7386
04:32:19,319 --> 04:32:20,880
figure out what's going on I recommend
7387
04:32:20,880 --> 04:32:22,520
you do so price feeds are one of the
7388
04:32:22,520 --> 04:32:23,920
most powerful out of the-box
7389
04:32:23,920 --> 04:32:25,920
decentralized features you can use in
7390
04:32:25,920 --> 04:32:28,000
your smart contract to level them up
7391
04:32:28,000 --> 04:32:30,000
especially for decentralized finance if
7392
04:32:30,000 --> 04:32:31,640
you're looking for different addresses
7393
04:32:31,640 --> 04:32:33,239
of different price feeds you can check
7394
04:32:33,239 --> 04:32:35,399
the contract addresses section of the
7395
04:32:35,399 --> 04:32:37,479
documentation choose the network that
7396
04:32:37,479 --> 04:32:38,680
you
7397
04:32:38,680 --> 04:32:41,199
want and then scroll down and then look
7398
04:32:41,199 --> 04:32:43,159
some of the different addresses of the
7399
04:32:43,159 --> 04:32:45,399
different price feeds for example this
7400
04:32:45,399 --> 04:32:47,920
address will give you the price of 1 in
7401
04:32:47,920 --> 04:32:51,159
token in terms of ethereum this address
7402
04:32:51,159 --> 04:32:53,520
will give you the price of the Apple
7403
04:32:53,520 --> 04:32:56,479
stock in terms of USD and so on and so
7404
04:32:56,479 --> 04:32:58,760
forth the next decentralized application
7405
04:32:58,760 --> 04:33:00,359
right at the box is going to be chain
7406
04:33:00,359 --> 04:33:02,840
link vrf or chain link verifiable
7407
04:33:02,840 --> 04:33:04,680
Randomness function once we do our
7408
04:33:04,680 --> 04:33:06,840
Lottery example a little bit later we'll
7409
04:33:06,840 --> 04:33:08,680
talk about how Randomness can be
7410
04:33:08,680 --> 04:33:10,439
manipulated in blockchain blockchains
7411
04:33:10,439 --> 04:33:12,561
are deterministic system which by
7412
04:33:12,561 --> 04:33:14,320
definition means that they can't have
7413
04:33:14,320 --> 04:33:16,199
Randomness if you can determine what a
7414
04:33:16,199 --> 04:33:17,920
random number is it's not really random
7415
04:33:17,920 --> 04:33:19,959
anymore is it so we need a way to get a
7416
04:33:19,959 --> 04:33:21,719
provably random number by looking
7417
04:33:21,719 --> 04:33:23,879
outside of the blockchain and oracles
7418
04:33:23,879 --> 04:33:26,000
are perfectly positioned to do exactly
7419
04:33:26,000 --> 04:33:28,000
that chain link verifiable Randomness
7420
04:33:28,000 --> 04:33:29,840
function is a way to get provably a
7421
04:33:29,840 --> 04:33:32,199
random number into our smart contract to
7422
04:33:32,199 --> 04:33:33,799
guarantee fairness and guarantee
7423
04:33:33,799 --> 04:33:35,840
randomness of applications many
7424
04:33:35,840 --> 04:33:38,039
protocols like pull together axi
7425
04:33:38,039 --> 04:33:41,840
Infinity ether cards avag gois and more
7426
04:33:41,840 --> 04:33:44,439
chain link vrf for lotteries randomizing
7427
04:33:44,439 --> 04:33:47,039
nfts for gaming and for more we're going
7428
04:33:47,039 --> 04:33:49,320
to do an example of chain link vrf in a
7429
04:33:49,320 --> 04:33:51,279
later section once we get to the lottery
7430
04:33:51,279 --> 04:33:52,879
section if you want to see if you can
7431
04:33:52,879 --> 04:33:54,160
play with the randomness yourself right
7432
04:33:54,160 --> 04:33:55,879
now I recommend you're going to docs.
7433
04:33:55,879 --> 04:33:58,639
chain. link evm chains and scroll down
7434
04:33:58,639 --> 04:34:00,561
to get a random number and this will
7435
04:34:00,561 --> 04:34:02,439
teach you how to get a provably random
7436
04:34:02,439 --> 04:34:04,359
number into your applications the next
7437
04:34:04,359 --> 04:34:06,119
decentralized out ofth the box feature
7438
04:34:06,119 --> 04:34:08,639
of chain link is chain link Keepers
7439
04:34:08,639 --> 04:34:10,719
which is decentralized event driven
7440
04:34:10,719 --> 04:34:13,000
execution as you've seen in order to
7441
04:34:13,000 --> 04:34:15,039
kick off some type of transaction
7442
04:34:15,039 --> 04:34:17,000
somebody needs to spend the gas and
7443
04:34:17,000 --> 04:34:18,840
somebody needs to sit down and hit the
7444
04:34:18,840 --> 04:34:20,840
go button or hit the transact button or
7445
04:34:20,840 --> 04:34:22,520
hit the send button this is obviously a
7446
04:34:22,520 --> 04:34:24,160
centralized Vector if you have a
7447
04:34:24,160 --> 04:34:25,959
decentralized application that needs to
7448
04:34:25,959 --> 04:34:28,439
run at specific times or after specific
7449
04:34:28,439 --> 04:34:30,199
events are triggered chain link keepers
7450
04:34:30,199 --> 04:34:31,799
are the solution to this chain link
7451
04:34:31,799 --> 04:34:34,000
keepers are chain link nodes that listen
7452
04:34:34,000 --> 04:34:36,400
to a registration contract for different
7453
04:34:36,400 --> 04:34:38,879
events that you specify to fire maybe
7454
04:34:38,879 --> 04:34:40,840
you say every 10 minutes you want to do
7455
04:34:40,840 --> 04:34:43,279
something or once a week do something or
7456
04:34:43,279 --> 04:34:45,000
if the price of some asset hits some
7457
04:34:45,000 --> 04:34:47,561
number or maybe a liquidity pool is at a
7458
04:34:47,561 --> 04:34:49,799
certain level whatever event that you
7459
04:34:49,799 --> 04:34:52,000
want to code you absolutely can the
7460
04:34:52,000 --> 04:34:54,240
chain link nodes constantly listen for
7461
04:34:54,240 --> 04:34:56,439
these triggers to happen and check the
7462
04:34:56,439 --> 04:34:58,480
different contracts for these triggers
7463
04:34:58,480 --> 04:35:00,920
once a trigger returns true the chain
7464
04:35:00,920 --> 04:35:02,840
link nodes will then perform whatever
7465
04:35:02,840 --> 04:35:04,520
action that you tell the chain link
7466
04:35:04,520 --> 04:35:06,480
nodes to do we're also not going to go
7467
04:35:06,480 --> 04:35:08,080
over the chain link Keepers examples
7468
04:35:08,080 --> 04:35:09,799
right now because we're going to get to
7469
04:35:09,799 --> 04:35:11,799
them in a later module however if you
7470
04:35:11,799 --> 04:35:14,760
want to try them out go to docs. chain.
7471
04:35:14,760 --> 04:35:18,000
linkum going and go to making compatible
7472
04:35:18,000 --> 04:35:19,680
contracts and feel free to read the
7473
04:35:19,680 --> 04:35:21,480
documentation and try it out yourself
7474
04:35:21,480 --> 04:35:23,039
the last outof the-box feature of chain
7475
04:35:23,039 --> 04:35:25,400
link is the most customizable but also
7476
04:35:25,400 --> 04:35:27,439
the hardest to get correct end to end
7477
04:35:27,439 --> 04:35:29,400
reliability is the ultimate promise of
7478
04:35:29,400 --> 04:35:31,480
our smart contracts and we want and need
7479
04:35:31,480 --> 04:35:33,920
them to be able to do anything we want
7480
04:35:33,920 --> 04:35:36,680
to be able to take any input and get any
7481
04:35:36,680 --> 04:35:39,080
output chain link functions is the last
7482
04:35:39,080 --> 04:35:41,199
decentralized out of thebox tool and it
7483
04:35:41,199 --> 04:35:43,480
allows you to make any API call in a
7484
04:35:43,480 --> 04:35:45,279
decentralized context through a network
7485
04:35:45,279 --> 04:35:47,080
of chain link nodes we're not going to
7486
04:35:47,080 --> 04:35:48,920
be going over that at all in this video
7487
04:35:48,920 --> 04:35:49,879
but be sure to check out the
7488
04:35:49,879 --> 04:35:51,199
documentation if that's something that
7489
04:35:51,199 --> 04:35:53,199
you're interested in to me chain link
7490
04:35:53,199 --> 04:35:54,520
functions is going to be the future of
7491
04:35:54,520 --> 04:35:55,840
Defi and smart contracts and if you're
7492
04:35:55,840 --> 04:35:57,000
looking to make something novel and if
7493
04:35:57,000 --> 04:35:57,959
you're looking to make something that's
7494
04:35:57,959 --> 04:36:00,680
never been done before I 100% recommend
7495
04:36:00,680 --> 04:36:02,320
you check out chain link functions later
7496
04:36:02,320 --> 04:36:03,561
on after this course or whatever you
7497
04:36:03,561 --> 04:36:05,199
want to do as of filming it came out
7498
04:36:05,199 --> 04:36:06,760
about a month or two ago and people are
7499
04:36:06,760 --> 04:36:08,520
just beginning to build amazing things
7500
04:36:08,520 --> 04:36:09,879
with training functions so be sure to
7501
04:36:09,879 --> 04:36:11,760
check this out after or during the
7502
04:36:11,760 --> 04:36:13,320
course we're going to be using the chain
7503
04:36:13,320 --> 04:36:14,879
link Automation in a later section in
7504
04:36:14,879 --> 04:36:16,400
this course again if you want to try
7505
04:36:16,400 --> 04:36:17,920
these out in remix on a real test net
7506
04:36:17,920 --> 04:36:19,439
you can go to the documentation and play
7507
04:36:19,439 --> 04:36:21,799
with them
7508
04:36:23,000 --> 04:36:25,039
here now I know we haven't actually
7509
04:36:25,039 --> 04:36:26,439
written that much code but we've gone
7510
04:36:26,439 --> 04:36:28,039
over a ton so I want to do a quick
7511
04:36:28,039 --> 04:36:30,000
review in order for a function to
7512
04:36:30,000 --> 04:36:31,480
receive native blockchain token like
7513
04:36:31,480 --> 04:36:33,160
ethereum you need to mark that function
7514
04:36:33,160 --> 04:36:34,959
as payable if you want to force a
7515
04:36:34,959 --> 04:36:36,719
transaction to do something and you want
7516
04:36:36,719 --> 04:36:38,600
it to fail if that wasn't done you can
7517
04:36:38,600 --> 04:36:40,561
use a require statement a transaction
7518
04:36:40,561 --> 04:36:42,600
that reverts means it undoes any work
7519
04:36:42,600 --> 04:36:44,119
that it did previously and returns any
7520
04:36:44,119 --> 04:36:46,039
gas to the user to get the value sent
7521
04:36:46,039 --> 04:36:47,400
with a transaction you can use the
7522
04:36:47,400 --> 04:36:50,520
solidity Global message. Val chain link
7523
04:36:50,520 --> 04:36:51,920
is a technology for getting external
7524
04:36:51,920 --> 04:36:53,439
data and computation into our smart
7525
04:36:53,439 --> 04:36:55,799
contracts and most importantly getting
7526
04:36:55,799 --> 04:36:58,160
that data in a decentralized context in
7527
04:36:58,160 --> 04:36:59,359
this example we're going to be using a
7528
04:36:59,359 --> 04:37:00,840
chain link data feed or a chain link
7529
04:37:00,840 --> 04:37:03,119
price feed which is a decentralized way
7530
04:37:03,119 --> 04:37:05,000
to get pricing information from Real
7531
04:37:05,000 --> 04:37:08,279
World assets into our smart
7532
04:37:09,799 --> 04:37:11,840
contracts now in order for for us to
7533
04:37:11,840 --> 04:37:13,561
figure out if the amount of ethereum
7534
04:37:13,561 --> 04:37:15,439
sent with a transaction is greater than
7535
04:37:15,439 --> 04:37:18,320
or equal to our minimum USD of $5 we
7536
04:37:18,320 --> 04:37:20,520
need to convert the amount of ethereum
7537
04:37:20,520 --> 04:37:23,480
into its value of dollars so how are we
7538
04:37:23,480 --> 04:37:24,680
going to do that well the first thing
7539
04:37:24,680 --> 04:37:25,719
that we're going to need to do is we're
7540
04:37:25,719 --> 04:37:27,480
going to need to get the price of
7541
04:37:27,480 --> 04:37:29,359
ethereum or Avalanche or polygon or
7542
04:37:29,359 --> 04:37:30,639
whatever native blockchain token that
7543
04:37:30,639 --> 04:37:32,480
we're working with so let's create a
7544
04:37:32,480 --> 04:37:34,400
function to do that we'll create a
7545
04:37:34,400 --> 04:37:37,000
function get price and this function is
7546
04:37:37,000 --> 04:37:38,719
just going to get the price of ethereum
7547
04:37:38,719 --> 04:37:40,480
in terms of USD and then we're also
7548
04:37:40,480 --> 04:37:42,359
going to create a function called get
7549
04:37:42,359 --> 04:37:44,719
conversion rate rate which is going to
7550
04:37:44,719 --> 04:37:48,320
convert a value to its converted value
7551
04:37:48,320 --> 04:37:49,520
based off of the price for now we're
7552
04:37:49,520 --> 04:37:50,920
going to make them both public functions
7553
04:37:50,920 --> 04:37:52,320
so we can play with them test them and
7554
04:37:52,320 --> 04:37:53,920
do whatever we want with them to get the
7555
04:37:53,920 --> 04:37:55,039
price of ethereum we're going to use a
7556
04:37:55,039 --> 04:37:56,600
chain link data feed and we go through
7557
04:37:56,600 --> 04:37:57,959
the documentation to get that
7558
04:37:57,959 --> 04:37:59,920
information so in the documentation I'm
7559
04:37:59,920 --> 04:38:02,320
going to scroll down using data feeds
7560
04:38:02,320 --> 04:38:03,840
they've got an example here right and
7561
04:38:03,840 --> 04:38:05,480
solidity and if you wanted to like I
7562
04:38:05,480 --> 04:38:07,000
said you could easily open this up in
7563
04:38:07,000 --> 04:38:09,119
remix now you can see this example in
7564
04:38:09,119 --> 04:38:10,639
the documentation what's actually going
7565
04:38:10,639 --> 04:38:13,439
on working with a chain link price feed
7566
04:38:13,439 --> 04:38:14,680
there's a contract out there add an
7567
04:38:14,680 --> 04:38:16,119
address and we're going to call this
7568
04:38:16,119 --> 04:38:18,199
latest round data function on that
7569
04:38:18,199 --> 04:38:20,119
contract gives us a whole bunch of data
7570
04:38:20,119 --> 04:38:22,119
but we really only care about the price
7571
04:38:22,119 --> 04:38:23,240
so we're going to want to do the same
7572
04:38:23,240 --> 04:38:24,480
thing we want to reach out to that
7573
04:38:24,480 --> 04:38:26,160
contract that's currently storing and
7574
04:38:26,160 --> 04:38:28,160
having the price updated so since we
7575
04:38:28,160 --> 04:38:29,480
want to reach out to and work with the
7576
04:38:29,480 --> 04:38:31,160
contract we're going to need two things
7577
04:38:31,160 --> 04:38:32,719
right what are those two things well we
7578
04:38:32,719 --> 04:38:35,000
need the address and we need the AI the
7579
04:38:35,000 --> 04:38:36,279
address of the contract is going to be
7580
04:38:36,279 --> 04:38:37,959
really easy we can get the address by
7581
04:38:37,959 --> 04:38:39,439
going to the chain link documentation
7582
04:38:39,439 --> 04:38:40,760
and let's go to this price feed
7583
04:38:40,760 --> 04:38:42,039
addresses section
7584
04:38:42,039 --> 04:38:43,840
we'll scroll down we want to be on
7585
04:38:43,840 --> 04:38:47,000
ethereum okay great let's look for seia
7586
04:38:47,000 --> 04:38:48,840
looks like it's way down here and all
7587
04:38:48,840 --> 04:38:51,520
right awesome e2d great there's an e2d
7588
04:38:51,520 --> 04:38:53,359
price feed so now that we have the
7589
04:38:53,359 --> 04:38:55,400
address how do we get the ABI well
7590
04:38:55,400 --> 04:38:57,119
before with simple storage we imported
7591
04:38:57,119 --> 04:38:58,879
the entire contract from the top and we
7592
04:38:58,879 --> 04:39:01,080
compiled and we got the API like that we
7593
04:39:01,080 --> 04:39:02,719
could do that here but that's kind of a
7594
04:39:02,719 --> 04:39:04,320
lot of code and we don't actually care
7595
04:39:04,320 --> 04:39:06,439
about what the whole contract looks like
7596
04:39:06,439 --> 04:39:07,520
we only really want to know what the
7597
04:39:07,520 --> 04:39:09,039
functions are so we can call that latest
7598
04:39:09,039 --> 04:39:10,959
round data function remember if we're on
7599
04:39:10,959 --> 04:39:13,119
remix and we go down to the compilation
7600
04:39:13,119 --> 04:39:15,561
details the ABI is really just this list
7601
04:39:15,561 --> 04:39:17,561
of functions that we can call on a
7602
04:39:17,561 --> 04:39:20,199
contract the ABI itself doesn't actually
7603
04:39:20,199 --> 04:39:22,039
need to include any of the logic it just
7604
04:39:22,039 --> 04:39:23,680
needs to say hey these are the functions
7605
04:39:23,680 --> 04:39:25,520
you can interact with and here are their
7606
04:39:25,520 --> 04:39:27,600
inputs and here's whether or not they're
7607
04:39:27,600 --> 04:39:28,959
payable and here's whether or not their
7608
04:39:28,959 --> 04:39:30,920
view functions Etc like I said though
7609
04:39:30,920 --> 04:39:32,680
this kind of is a white lie you can also
7610
04:39:32,680 --> 04:39:34,080
use a function selector or some other
7611
04:39:34,080 --> 04:39:35,439
ways but we're just going to ignore that
7612
04:39:35,439 --> 04:39:38,040
for now how can we get the ABI there's a
7613
04:39:38,040 --> 04:39:39,840
concept in solidity known as the
7614
04:39:39,840 --> 04:39:41,878
interface if we go to the chain link
7615
04:39:41,878 --> 04:39:44,200
GitHub we go to smart contract kit /
7616
04:39:44,200 --> 04:39:46,280
chainlink we can see a lot of different
7617
04:39:46,280 --> 04:39:48,240
contracts in the chain link repository
7618
04:39:48,240 --> 04:39:50,560
we go to contracts SRC this might look a
7619
04:39:50,560 --> 04:39:52,040
little bit different based off of when
7620
04:39:52,040 --> 04:39:53,760
you're looking at it
7621
04:39:53,760 --> 04:39:57,240
v0.8 interfaces and we go to aggregator
7622
04:39:57,240 --> 04:39:59,638
V3 interface if we scroll down we can
7623
04:39:59,638 --> 04:40:01,680
actually see a whole bunch of function
7624
04:40:01,680 --> 04:40:03,440
declarations but none of them are
7625
04:40:03,440 --> 04:40:05,798
actually implemented it's just function
7626
04:40:05,798 --> 04:40:07,638
the name of the function some stuff
7627
04:40:07,638 --> 04:40:09,200
external view blah blah blah but then
7628
04:40:09,200 --> 04:40:10,760
just the semicolon and nothing inside of
7629
04:40:10,760 --> 04:40:13,080
them this is what's known as an
7630
04:40:13,080 --> 04:40:15,840
interface if you compile this this will
7631
04:40:15,840 --> 04:40:17,718
actually give us that ABI because it
7632
04:40:17,718 --> 04:40:19,440
defines all the different functions that
7633
04:40:19,440 --> 04:40:21,120
you can call on a contract it just
7634
04:40:21,120 --> 04:40:22,958
doesn't have any of the logic again we
7635
04:40:22,958 --> 04:40:24,200
don't really even need to know what the
7636
04:40:24,200 --> 04:40:26,680
functions do we just need to know how to
7637
04:40:26,680 --> 04:40:28,320
interact with the contract and if a
7638
04:40:28,320 --> 04:40:29,878
contract is deployed it'll have that
7639
04:40:29,878 --> 04:40:32,400
logic in its deployment so what we can
7640
04:40:32,400 --> 04:40:34,680
do is we can copy this whole thing
7641
04:40:34,680 --> 04:40:36,400
scroll all the way to the bottom hit the
7642
04:40:36,400 --> 04:40:38,360
copy button and paste it in our remix
7643
04:40:38,360 --> 04:40:39,400
now hold on though if you're following
7644
04:40:39,400 --> 04:40:41,440
along you don't have to copy paste it in
7645
04:40:41,440 --> 04:40:42,520
with me cuz I'm going to teach you
7646
04:40:42,520 --> 04:40:43,638
something in just a minute that makes
7647
04:40:43,638 --> 04:40:45,160
this a little bit easier this pasted
7648
04:40:45,160 --> 04:40:46,760
code alert comes up we're running
7649
04:40:46,760 --> 04:40:48,120
solidity code so this is going to be
7650
04:40:48,120 --> 04:40:49,560
okay since we're only working on test
7651
04:40:49,560 --> 04:40:51,200
Nets here we're going to be okay that we
7652
04:40:51,200 --> 04:40:52,600
don't have to worry about p a code alert
7653
04:40:52,600 --> 04:40:53,718
if you want to take a second to read it
7654
04:40:53,718 --> 04:40:55,240
please do but we're going to paste this
7655
04:40:55,240 --> 04:40:57,120
code in here just like we did before
7656
04:40:57,120 --> 04:40:58,798
with simple storage for now you don't
7657
04:40:58,798 --> 04:41:00,160
have to follow along I'm about to show
7658
04:41:00,160 --> 04:41:01,520
you an easier way just follow along and
7659
04:41:01,520 --> 04:41:03,480
watch now that we have this interface
7660
04:41:03,480 --> 04:41:05,440
aggregator V3 interface we can use this
7661
04:41:05,440 --> 04:41:07,560
interface to make API calls because now
7662
04:41:07,560 --> 04:41:09,840
we have the address and we have the API
7663
04:41:09,840 --> 04:41:11,878
and we can even compile this and it'll
7664
04:41:11,878 --> 04:41:14,760
compile fine so we can say aggregator V3
7665
04:41:14,760 --> 04:41:17,638
interface at address this and the
7666
04:41:17,638 --> 04:41:19,760
combination of these two give us
7667
04:41:19,760 --> 04:41:22,120
whatever code is at this address with
7668
04:41:22,120 --> 04:41:24,160
all the functions from the aggregator V3
7669
04:41:24,160 --> 04:41:25,920
interface and just to test this out we
7670
04:41:25,920 --> 04:41:28,120
can do something simple like dot version
7671
04:41:28,120 --> 04:41:29,920
since if we scroll up looks like there
7672
04:41:29,920 --> 04:41:32,200
is indeed a version function put a
7673
04:41:32,200 --> 04:41:34,760
little semicolon at the end so let's
7674
04:41:34,760 --> 04:41:36,040
actually go ahead and actually copy this
7675
04:41:36,040 --> 04:41:38,760
line give it its own function called get
7676
04:41:38,760 --> 04:41:42,240
version this we'll have this public view
7677
04:41:42,240 --> 04:41:44,360
Returns what is the version up here
7678
04:41:44,360 --> 04:41:48,440
return a un 256 return a un 256 paste
7679
04:41:48,440 --> 04:41:50,160
that line in here aggregator V3
7680
04:41:50,160 --> 04:41:52,680
interface at its address version we'll
7681
04:41:52,680 --> 04:41:55,798
say return all of that now I'm going to
7682
04:41:55,798 --> 04:41:58,000
go ahead and deploy this to the seoa
7683
04:41:58,000 --> 04:41:59,520
test net just to show you what this
7684
04:41:59,520 --> 04:42:01,400
would actually look like however I'm
7685
04:42:01,400 --> 04:42:02,680
going to recommend you don't do that for
7686
04:42:02,680 --> 04:42:04,520
now just know that this will work this
7687
04:42:04,520 --> 04:42:05,878
way you won't have to wait forever for
7688
04:42:05,878 --> 04:42:07,040
your transactions to go through on the
7689
04:42:07,040 --> 04:42:08,840
test net so to do this I'm going to go
7690
04:42:08,840 --> 04:42:10,718
ahead scroll to the top go to injected
7691
04:42:10,718 --> 04:42:13,040
metamask change the contract from
7692
04:42:13,040 --> 04:42:15,480
aggregator V3 interface to fundme going
7693
04:42:15,480 --> 04:42:17,440
to go ahead and hit deploy my metamask
7694
04:42:17,440 --> 04:42:18,760
is going to pop up I'm going to go ahead
7695
04:42:18,760 --> 04:42:20,520
and hit confirm and we're going to
7696
04:42:20,520 --> 04:42:22,280
scroll down and now we have a big blue
7697
04:42:22,280 --> 04:42:24,000
button called get version which I'm
7698
04:42:24,000 --> 04:42:25,120
going to go ahead and click and we can
7699
04:42:25,120 --> 04:42:27,878
see we get a four return because at this
7700
04:42:27,878 --> 04:42:30,120
contract address on the blockchain it
7701
04:42:30,120 --> 04:42:31,600
has the functionality for get version
7702
04:42:31,600 --> 04:42:33,718
returning 4 and for the rest of this
7703
04:42:33,718 --> 04:42:35,320
lesson I'm going to be showing you guys
7704
04:42:35,320 --> 04:42:37,680
and testing this on an actual test net
7705
04:42:37,680 --> 04:42:40,080
however I recommend that you don't test
7706
04:42:40,080 --> 04:42:42,320
all of these as I along just watch me do
7707
04:42:42,320 --> 04:42:43,680
them because again waiting for
7708
04:42:43,680 --> 04:42:45,600
transactions on a test net can be really
7709
04:42:45,600 --> 04:42:47,638
annoying sometimes a test net might be
7710
04:42:47,638 --> 04:42:49,638
having issues because again it's people
7711
04:42:49,638 --> 04:42:50,760
running them out of the goodness of
7712
04:42:50,760 --> 04:42:52,600
their heart so for this lesson just
7713
04:42:52,600 --> 04:42:54,320
follow along write the code with me and
7714
04:42:54,320 --> 04:42:56,638
then maybe at the end deploy everything
7715
04:42:56,638 --> 04:42:58,280
so this is a really easy way and a
7716
04:42:58,280 --> 04:42:59,920
common way that people use to interact
7717
04:42:59,920 --> 04:43:01,680
with other contracts outside of their
7718
04:43:01,680 --> 04:43:04,240
projects they get the interface of that
7719
04:43:04,240 --> 04:43:06,920
contract using the interface keyword
7720
04:43:06,920 --> 04:43:08,840
they compile it and the compiler
7721
04:43:08,840 --> 04:43:11,360
actually gives us an API and then you
7722
04:43:11,360 --> 04:43:13,400
just wrap an address around with that
7723
04:43:13,400 --> 04:43:15,560
interface keyword and you can call any
7724
04:43:15,560 --> 04:43:18,120
function at that address and and this is
7725
04:43:18,120 --> 04:43:19,560
one of these things as we work with more
7726
04:43:19,560 --> 04:43:21,120
and more it'll start to make more sense
7727
04:43:21,120 --> 04:43:22,280
in the beginning it might be a little
7728
04:43:22,280 --> 04:43:24,160
hard to grasp but just bear with me for
7729
04:43:24,160 --> 04:43:25,840
now the more we do it the better you'll
7730
04:43:25,840 --> 04:43:27,840
get don't get discouraged take a deep
7731
04:43:27,840 --> 04:43:31,638
breath and exhale and let's keep
7732
04:43:32,958 --> 04:43:35,638
coding and if this is confusing to you
7733
04:43:35,638 --> 04:43:37,320
this is again where we can work with our
7734
04:43:37,320 --> 04:43:39,360
AI friends or any of the forums that
7735
04:43:39,360 --> 04:43:41,440
we're working with again very soon I'm
7736
04:43:41,440 --> 04:43:43,400
about to show you how to ask really good
7737
04:43:43,400 --> 04:43:45,440
questions and make really good prompts
7738
04:43:45,440 --> 04:43:47,440
but one we could ask here is hey I'm
7739
04:43:47,440 --> 04:43:49,240
confused how does this solidity function
7740
04:43:49,240 --> 04:43:50,798
return the value four when I didn't
7741
04:43:50,798 --> 04:43:53,040
Define any logic in aggregator V3
7742
04:43:53,040 --> 04:43:56,040
interface and I just posted that code
7743
04:43:56,040 --> 04:43:58,480
from get version here because a common
7744
04:43:58,480 --> 04:44:00,200
issue that I see new developers run into
7745
04:44:00,200 --> 04:44:02,878
is they go oh wait wait how does this
7746
04:44:02,878 --> 04:44:05,360
version return four my aggregator V3
7747
04:44:05,360 --> 04:44:07,200
interface doesn't have any code in it
7748
04:44:07,200 --> 04:44:09,798
why why does putting an address in here
7749
04:44:09,798 --> 04:44:11,878
make it work like what's going going on
7750
04:44:11,878 --> 04:44:13,920
and let's see if our AI is able to help
7751
04:44:13,920 --> 04:44:17,638
us here so this is chat gbt version 3.5
7752
04:44:17,638 --> 04:44:20,040
again I prefer version 4 but this is the
7753
04:44:20,040 --> 04:44:22,878
cheaper one and it says in the code you
7754
04:44:22,878 --> 04:44:24,840
provided the get version function is
7755
04:44:24,840 --> 04:44:26,638
calling the version function of an
7756
04:44:26,638 --> 04:44:28,718
instance of the aggregator V3 interface
7757
04:44:28,718 --> 04:44:30,798
contract it appears that the contract
7758
04:44:30,798 --> 04:44:33,400
address here is being used to create an
7759
04:44:33,400 --> 04:44:35,480
instance of aggregator V3 interface the
7760
04:44:35,480 --> 04:44:37,360
aggregator V3 interface is an interface
7761
04:44:37,360 --> 04:44:39,240
contract that defines a set of functions
7762
04:44:39,240 --> 04:44:41,120
that must be implemented by another
7763
04:44:41,120 --> 04:44:43,160
contract it serves as a way to interact
7764
04:44:43,160 --> 04:44:45,200
with the contract at the given address
7765
04:44:45,200 --> 04:44:47,200
by providing a common interface the
7766
04:44:47,200 --> 04:44:49,360
version function being called in your
7767
04:44:49,360 --> 04:44:51,360
code is likely defined in the actual
7768
04:44:51,360 --> 04:44:53,840
contract that implements this uh and
7769
04:44:53,840 --> 04:44:55,320
this is pretty much correct right and so
7770
04:44:55,320 --> 04:44:57,320
it gives us some more context here this
7771
04:44:57,320 --> 04:45:00,120
is exactly correct this address has a
7772
04:45:00,120 --> 04:45:03,160
version function and US surrounding it
7773
04:45:03,160 --> 04:45:05,280
with this aggregative E3 interface like
7774
04:45:05,280 --> 04:45:07,240
typ casting it in these parentheses like
7775
04:45:07,240 --> 04:45:09,160
this is just telling our solidity
7776
04:45:09,160 --> 04:45:11,920
compiler hey there's a version function
7777
04:45:11,920 --> 04:45:15,480
at this address or there's a latest
7778
04:45:15,480 --> 04:45:17,600
round data function or all the functions
7779
04:45:17,600 --> 04:45:19,718
all the functions in this aggregator V3
7780
04:45:19,718 --> 04:45:21,958
interface are at this address if this
7781
04:45:21,958 --> 04:45:24,040
address doesn't have a version function
7782
04:45:24,040 --> 04:45:25,798
this would just break and this is a good
7783
04:45:25,798 --> 04:45:27,280
example of again where we can actually
7784
04:45:27,280 --> 04:45:29,280
follow up with these AIS they're
7785
04:45:29,280 --> 04:45:31,360
typically very good at keeping context
7786
04:45:31,360 --> 04:45:33,920
so we could even ask what would happen
7787
04:45:33,920 --> 04:45:37,798
if that contract address didn't have
7788
04:45:37,798 --> 04:45:39,638
that
7789
04:45:39,638 --> 04:45:41,360
function and we see if the
7790
04:45:41,360 --> 04:45:42,958
implementation contract at the given
7791
04:45:42,958 --> 04:45:44,760
address does not have a version function
7792
04:45:44,760 --> 04:45:46,080
or if it has a different function
7793
04:45:46,080 --> 04:45:47,680
signature calling version on the
7794
04:45:47,680 --> 04:45:49,400
contract would result in a compilation
7795
04:45:49,400 --> 04:45:51,480
error or a runtime error so it wouldn't
7796
04:45:51,480 --> 04:45:53,240
result on a compilation error but the
7797
04:45:53,240 --> 04:45:55,320
transaction would revert so so this is
7798
04:45:55,320 --> 04:45:57,360
pretty helpful here but again we always
7799
04:45:57,360 --> 04:45:58,600
want to double check this so this is
7800
04:45:58,600 --> 04:45:59,760
where we'd probably go back to the
7801
04:45:59,760 --> 04:46:03,560
discussions forum and follow up
7802
04:46:04,560 --> 04:46:06,680
there so now that we actually have the
7803
04:46:06,680 --> 04:46:08,440
interface we can start calling these
7804
04:46:08,440 --> 04:46:10,600
functions and calling these addresses
7805
04:46:10,600 --> 04:46:12,200
however having a ton of these interfaces
7806
04:46:12,200 --> 04:46:13,878
is really going to clog up our contracts
7807
04:46:13,878 --> 04:46:15,320
and clog up our files and be really
7808
04:46:15,320 --> 04:46:17,400
gross to work with is there a better way
7809
04:46:17,400 --> 04:46:19,680
for us to do this well when we worked
7810
04:46:19,680 --> 04:46:21,480
with simple storage yes there was we
7811
04:46:21,480 --> 04:46:23,760
just went ahead and used Imports right
7812
04:46:23,760 --> 04:46:25,560
but that's when we had all the code in
7813
04:46:25,560 --> 04:46:27,638
our locally in our directory we don't
7814
04:46:27,638 --> 04:46:29,040
have all the code locally we didn't
7815
04:46:29,040 --> 04:46:30,680
create the aggregator V3 interface we
7816
04:46:30,680 --> 04:46:32,520
didn't create the price feed contracts
7817
04:46:32,520 --> 04:46:34,080
so can we do something like import
7818
04:46:34,080 --> 04:46:36,160
simple storage. but with a contract
7819
04:46:36,160 --> 04:46:38,360
outside of our project well again we
7820
04:46:38,360 --> 04:46:39,920
could copy paste it to its own file and
7821
04:46:39,920 --> 04:46:43,240
import add k T V3 aggregator V3
7822
04:46:43,240 --> 04:46:45,240
interface. so and of course we're going
7823
04:46:45,240 --> 04:46:47,240
to use this named import syntax because
7824
04:46:47,240 --> 04:46:49,480
we're awesome developers we could copy
7825
04:46:49,480 --> 04:46:51,680
paste it like this and do exactly what
7826
04:46:51,680 --> 04:46:53,320
we did before we could create a new file
7827
04:46:53,320 --> 04:46:55,440
called aggregator V3 interface paste the
7828
04:46:55,440 --> 04:46:57,638
code in there or we could actually
7829
04:46:57,638 --> 04:47:00,440
import directly from GitHub if we go
7830
04:47:00,440 --> 04:47:01,958
back to the documentation associated
7831
04:47:01,958 --> 04:47:03,920
with using data feeds we scroll down to
7832
04:47:03,920 --> 04:47:06,760
using data feeds here scroll down we see
7833
04:47:06,760 --> 04:47:08,878
at the top they do this import like this
7834
04:47:08,878 --> 04:47:11,400
import at chainlink contracts as C blah
7835
04:47:11,400 --> 04:47:13,600
blah blah this import actually has the
7836
04:47:13,600 --> 04:47:16,760
same setup as as the path of what's in
7837
04:47:16,760 --> 04:47:19,280
the GitHub repository so instead of us
7838
04:47:19,280 --> 04:47:21,400
copy pasting from GitHub we can actually
7839
04:47:21,400 --> 04:47:24,520
import directly from GitHub or mpm we
7840
04:47:24,520 --> 04:47:26,878
can copy this line back in our remix we
7841
04:47:26,878 --> 04:47:29,240
could paste it in like this remix is
7842
04:47:29,240 --> 04:47:30,638
smart enough to know that this at
7843
04:47:30,638 --> 04:47:33,360
chainlink contracts is referring to the
7844
04:47:33,360 --> 04:47:36,680
what's known as an mpm package chainlink
7845
04:47:36,680 --> 04:47:39,000
contracts chainlink contracts is what's
7846
04:47:39,000 --> 04:47:40,958
known as a package manager and it keeps
7847
04:47:40,958 --> 04:47:42,600
different versions of combinations of
7848
04:47:42,600 --> 04:47:44,878
code for us to download at chainlink
7849
04:47:44,878 --> 04:47:46,878
contracts is created directly from chain
7850
04:47:46,878 --> 04:47:49,280
link repository remix downloads all this
7851
04:47:49,280 --> 04:47:51,320
code from mpm which is Created from the
7852
04:47:51,320 --> 04:47:53,120
GitHub so it essentially downloads it
7853
04:47:53,120 --> 04:47:55,638
from the GitHub so us doing this import
7854
04:47:55,638 --> 04:47:57,520
like this is the same as is just copy
7855
04:47:57,520 --> 04:47:58,958
pasting the entire interface at the top
7856
04:47:58,958 --> 04:48:00,760
of our contract now we have this
7857
04:48:00,760 --> 04:48:02,280
aggregator V3 interface that we want to
7858
04:48:02,280 --> 04:48:03,840
work with we can go ahead and compile
7859
04:48:03,840 --> 04:48:06,600
and bada bing bada
7860
04:48:07,680 --> 04:48:09,958
boom so great so now that we have the
7861
04:48:09,958 --> 04:48:11,558
interface here which will give a
7862
04:48:11,558 --> 04:48:13,520
minimalistic ABI for us to interact with
7863
04:48:13,520 --> 04:48:14,958
the contract how do we actually get the
7864
04:48:14,958 --> 04:48:17,240
pricing information well again if we go
7865
04:48:17,240 --> 04:48:19,520
back to the docs we can see right here
7866
04:48:19,520 --> 04:48:21,520
gives us an example of the code we can
7867
04:48:21,520 --> 04:48:23,320
use to get the latest price but let's
7868
04:48:23,320 --> 04:48:24,760
write it ourselves just so that we know
7869
04:48:24,760 --> 04:48:28,320
what's going on we'll say agregator V3
7870
04:48:28,320 --> 04:48:30,000
interface and we'll actually create a
7871
04:48:30,000 --> 04:48:32,638
new variable called price feed equals
7872
04:48:32,638 --> 04:48:35,718
aggregator V3 interface contract at this
7873
04:48:35,718 --> 04:48:37,718
address which again only works for
7874
04:48:37,718 --> 04:48:40,040
sapoia now we can call this latest round
7875
04:48:40,040 --> 04:48:42,760
data function on the price feed so we'll
7876
04:48:42,760 --> 04:48:46,600
say price feed. late round data and if
7877
04:48:46,600 --> 04:48:48,480
we look at the interface on GitHub we
7878
04:48:48,480 --> 04:48:50,000
can actually see latest round data
7879
04:48:50,000 --> 04:48:51,798
doesn't just return one variable it
7880
04:48:51,798 --> 04:48:53,480
returns a whole bunch of different types
7881
04:48:53,480 --> 04:48:56,080
of variables and to return multiple
7882
04:48:56,080 --> 04:48:58,040
types we do some syntax that looks like
7883
04:48:58,040 --> 04:49:02,400
this and we'll say uint 80 round ID and
7884
04:49:02,400 --> 04:49:04,240
you can even flip back and forth between
7885
04:49:04,240 --> 04:49:05,600
the documentation make sure you have it
7886
04:49:05,600 --> 04:49:08,320
right int price which again we know in
7887
04:49:08,320 --> 04:49:12,120
int defaults to an INT 256 you uint 256
7888
04:49:12,120 --> 04:49:16,000
started app uint 256 Tim stamp and then
7889
04:49:16,000 --> 04:49:20,440
uint 80 answered in round there's a lot
7890
04:49:20,440 --> 04:49:22,200
of code in here since this function
7891
04:49:22,200 --> 04:49:23,958
returns so many variables we have to set
7892
04:49:23,958 --> 04:49:25,718
something up to capture them but we
7893
04:49:25,718 --> 04:49:26,798
don't care about any of these other
7894
04:49:26,798 --> 04:49:28,440
stuff we just care about price so what
7895
04:49:28,440 --> 04:49:30,280
we can do is actually just remove them
7896
04:49:30,280 --> 04:49:32,240
and leave the commas in there so we're
7897
04:49:32,240 --> 04:49:34,400
going to remove started at remove time
7898
04:49:34,400 --> 04:49:36,718
stamp remove answered and round and I
7899
04:49:36,718 --> 04:49:38,400
hit command s to compile we're going to
7900
04:49:38,400 --> 04:49:39,920
get these yellow squiggly lines which
7901
04:49:39,920 --> 04:49:41,400
are warnings but we're going to fix them
7902
04:49:41,400 --> 04:49:43,798
in a minute now we have in price equals
7903
04:49:43,798 --> 04:49:45,718
Price feed. latest round data because we
7904
04:49:45,718 --> 04:49:47,400
only care about getting the price from
7905
04:49:47,400 --> 04:49:49,638
the return the reason price is an into
7906
04:49:49,638 --> 04:49:51,840
56 is because some price feeds could be
7907
04:49:51,840 --> 04:49:54,120
negative now that we have the price this
7908
04:49:54,120 --> 04:49:55,240
price variable is going to be
7909
04:49:55,240 --> 04:49:59,120
representing the price of eth in terms
7910
04:49:59,120 --> 04:50:01,400
of USD and it's going to return a number
7911
04:50:01,400 --> 04:50:03,120
that looks like this because again slity
7912
04:50:03,120 --> 04:50:04,600
doesn't work with decimals so we know
7913
04:50:04,600 --> 04:50:06,320
that this price feed has eight decimals
7914
04:50:06,320 --> 04:50:08,480
but it'll get a return like this boom
7915
04:50:08,480 --> 04:50:10,120
like this it'll return a value that
7916
04:50:10,120 --> 04:50:11,520
looks like this
7917
04:50:11,520 --> 04:50:12,878
if we want to double check how many
7918
04:50:12,878 --> 04:50:14,638
decimals there are in a price feed it
7919
04:50:14,638 --> 04:50:16,160
actually has a decimals function which
7920
04:50:16,160 --> 04:50:18,040
allows you to check that as well now as
7921
04:50:18,040 --> 04:50:20,558
we know message. value is going to have
7922
04:50:20,558 --> 04:50:22,878
18 decimal places how do we know that
7923
04:50:22,878 --> 04:50:24,520
well because we know that one ether is
7924
04:50:24,520 --> 04:50:27,400
equal to this many way and this many way
7925
04:50:27,400 --> 04:50:32,160
has 18 zeros 1 2 3 4 5 6 7 8 9 10 1 2 3
7926
04:50:32,160 --> 04:50:35,120
4 5 6 7 8 so this massive number is
7927
04:50:35,120 --> 04:50:38,840
equal to 1 ethereum right 1. 1 2 3 4 5 6
7928
04:50:38,840 --> 04:50:41,798
7 8 9 10 1 2 3 4 5 6 7 eight so right
7929
04:50:41,798 --> 04:50:43,878
now message. value and price actually
7930
04:50:43,878 --> 04:50:46,600
have different decimal places price has
7931
04:50:46,600 --> 04:50:49,718
eight message. value is going to have 18
7932
04:50:49,718 --> 04:50:52,160
so to get them to match up we have to do
7933
04:50:52,160 --> 04:50:57,558
return price times 1 E10 or to add those
7934
04:50:57,558 --> 04:50:59,798
additional 10 decimal places and yes I
7935
04:50:59,798 --> 04:51:01,040
know we have a red line I'll fix this in
7936
04:51:01,040 --> 04:51:04,680
a minute price as we know is a in 256
7937
04:51:04,680 --> 04:51:07,040
and message. value is going to be a u
7938
04:51:07,040 --> 04:51:09,160
256 so the types are actually different
7939
04:51:09,160 --> 04:51:11,000
so we want to get the price and terms of
7940
04:51:11,000 --> 04:51:14,360
U 256 instead of in 256 to convert them
7941
04:51:14,360 --> 04:51:16,160
we can again do a thing called type
7942
04:51:16,160 --> 04:51:17,718
casting there are a lot of different
7943
04:51:17,718 --> 04:51:19,280
types that can be easely converted
7944
04:51:19,280 --> 04:51:21,520
between each other not all types can be
7945
04:51:21,520 --> 04:51:24,280
typ casted but an INT and a un 256 can
7946
04:51:24,280 --> 04:51:28,000
be so to make our price a u 256 we would
7947
04:51:28,000 --> 04:51:31,680
just do uint 256 and wrap price like
7948
04:51:31,680 --> 04:51:33,798
this or we could just wrap both of them
7949
04:51:33,798 --> 04:51:35,920
like this now of course since we're not
7950
04:51:35,920 --> 04:51:37,958
modifying any state but we are reading
7951
04:51:37,958 --> 04:51:40,040
storage we can make this a view function
7952
04:51:40,040 --> 04:51:43,320
and then we'll say it returns a uint 256
7953
04:51:43,320 --> 04:51:46,040
like so now if we compile we get rid of
7954
04:51:46,040 --> 04:51:48,080
all those errors and warnings now math
7955
04:51:48,080 --> 04:51:49,878
could be a little bit tricky in solidity
7956
04:51:49,878 --> 04:51:51,200
but the more you do it the better you'll
7957
04:51:51,200 --> 04:51:52,798
get and the reason math can be tricky is
7958
04:51:52,798 --> 04:51:54,280
because there aren't any decimal places
7959
04:51:54,280 --> 04:51:55,958
so you need to only work with whole
7960
04:51:55,958 --> 04:51:57,558
numbers the more you work with it the
7961
04:51:57,558 --> 04:52:00,200
better you'll get
7962
04:52:01,240 --> 04:52:03,440
though awesome so now we have a get
7963
04:52:03,440 --> 04:52:05,240
price function which is going to return
7964
04:52:05,240 --> 04:52:08,200
the value of ethereum in terms of USD as
7965
04:52:08,200 --> 04:52:11,400
a u 256 now all we we have to do is
7966
04:52:11,400 --> 04:52:13,718
convert our message. value in terms of
7967
04:52:13,718 --> 04:52:15,798
dollars using this get price function to
7968
04:52:15,798 --> 04:52:16,920
do that we're going to use our get
7969
04:52:16,920 --> 04:52:18,680
conversion rate function this get
7970
04:52:18,680 --> 04:52:19,958
conversion rate function is going to
7971
04:52:19,958 --> 04:52:23,558
take a u 256 eth amount as an input and
7972
04:52:23,558 --> 04:52:25,400
we're to convert this eth amount to its
7973
04:52:25,400 --> 04:52:28,040
value in dollars this will be a public
7974
04:52:28,040 --> 04:52:30,480
view function that will return a uint
7975
04:52:30,480 --> 04:52:32,360
256 so first we're going to get the
7976
04:52:32,360 --> 04:52:36,080
price of ethereum by doing U 256 e price
7977
04:52:36,080 --> 04:52:38,280
equals our get price function that we
7978
04:52:38,280 --> 04:52:40,080
just defined and then we're going to do
7979
04:52:40,080 --> 04:52:46,480
U 256 eth amount in USD equals eth price
7980
04:52:46,480 --> 04:52:49,200
time eth amount and then we actually
7981
04:52:49,200 --> 04:52:52,160
have to divide by 1 E18 the reason we
7982
04:52:52,160 --> 04:52:55,040
divide by 1 E18 is because both of these
7983
04:52:55,040 --> 04:52:57,520
have 18 decimal places and if we
7984
04:52:57,520 --> 04:53:01,240
multiply 1 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7
7985
04:53:01,240 --> 04:53:04,040
8 9 10 if we multiply these by each
7986
04:53:04,040 --> 04:53:05,320
other where both of these are
7987
04:53:05,320 --> 04:53:07,160
representing one we're actually going to
7988
04:53:07,160 --> 04:53:09,440
get a number that's absolutely massive
7989
04:53:09,440 --> 04:53:12,040
with 38 decimal places so we need to
7990
04:53:12,040 --> 04:53:14,920
divide by 188 to reduce it back down to
7991
04:53:14,920 --> 04:53:16,558
what it should actually be an important
7992
04:53:16,558 --> 04:53:18,840
rule with working with math and solidity
7993
04:53:18,840 --> 04:53:21,360
is you always want to multiply before
7994
04:53:21,360 --> 04:53:23,798
you divide the reason for this is since
7995
04:53:23,798 --> 04:53:25,480
again only whole numbers work in
7996
04:53:25,480 --> 04:53:28,480
solidity you were to do 1 iD two you
7997
04:53:28,480 --> 04:53:30,840
would end up getting zero so you always
7998
04:53:30,840 --> 04:53:32,360
want to multiply first when we get to
7999
04:53:32,360 --> 04:53:33,638
the foundary section of this course
8000
04:53:33,638 --> 04:53:35,000
testing all this math is going to be a
8001
04:53:35,000 --> 04:53:36,798
lot easier if you're really struggling
8002
04:53:36,798 --> 04:53:38,200
with some of the math bits right now I
8003
04:53:38,200 --> 04:53:39,680
wouldn't let that slow you down because
8004
04:53:39,680 --> 04:53:41,160
one of the things that AI is really good
8005
04:53:41,160 --> 04:53:42,558
at is doing a lot of these math
8006
04:53:42,558 --> 04:53:44,680
conversions but in any case this eth
8007
04:53:44,680 --> 04:53:46,600
amount in USD is the number that we're
8008
04:53:46,600 --> 04:53:48,600
looking for so we can say return e them
8009
04:53:48,600 --> 04:53:50,718
out in USD and awesome now we have a get
8010
04:53:50,718 --> 04:53:52,360
conversion rate function let's walk
8011
04:53:52,360 --> 04:53:53,480
through this together just so that you
8012
04:53:53,480 --> 04:53:55,240
can understand what's actually going on
8013
04:53:55,240 --> 04:53:57,120
let's say we want to see how much one
8014
04:53:57,120 --> 04:53:59,360
eth is worth well we're going to get the
8015
04:53:59,360 --> 04:54:02,400
eth price which let's say it's $2,000
8016
04:54:02,400 --> 04:54:04,638
but it's going to be $2,000 with one2 3
8017
04:54:04,638 --> 04:54:09,798
4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 18 zeros
8018
04:54:09,798 --> 04:54:12,440
so e might look something like this so
8019
04:54:12,440 --> 04:54:15,080
that means we're going to do this 2,000
8020
04:54:15,080 --> 04:54:18,638
with 18 decimal places times 1 E which
8021
04:54:18,638 --> 04:54:22,718
is going to be 1 1 2 3 4 5 6 7 8 1 2 3 4
8022
04:54:22,718 --> 04:54:25,400
5 6 7 8 8 9 10 we're going to multiply
8023
04:54:25,400 --> 04:54:27,558
those together and then since we're
8024
04:54:27,558 --> 04:54:29,840
going to get an additional 36 zeros then
8025
04:54:29,840 --> 04:54:32,600
we just divide by 1 E18 and that's how
8026
04:54:32,600 --> 04:54:33,958
we would get
8027
04:54:33,958 --> 04:54:37,360
$2,000 equals 1 E it's going to be 2,000
8028
04:54:37,360 --> 04:54:39,520
of course with 18 decimal places one of
8029
04:54:39,520 --> 04:54:40,878
the good reasons for using whole numbers
8030
04:54:40,878 --> 04:54:42,920
in solidity is that it's not possible to
8031
04:54:42,920 --> 04:54:45,120
have decimal places so we don't lose any
8032
04:54:45,120 --> 04:54:46,920
Precision which is really good so
8033
04:54:46,920 --> 04:54:48,558
normally we should test this function
8034
04:54:48,558 --> 04:54:50,240
before continuing but since we're doing
8035
04:54:50,240 --> 04:54:51,718
all this on a test that and I promise
8036
04:54:51,718 --> 04:54:53,360
you that I tested this all beforehand
8037
04:54:53,360 --> 04:54:54,320
we're just going to go ahead and keep
8038
04:54:54,320 --> 04:54:56,440
going so now that we've done all this
8039
04:54:56,440 --> 04:54:58,638
work if we want to make sure that our
8040
04:54:58,638 --> 04:55:01,920
users are sending at least $5 we can do
8041
04:55:01,920 --> 04:55:04,718
get conversion rate of message. sender
8042
04:55:04,718 --> 04:55:06,798
needs to be greater than minimum USD
8043
04:55:06,798 --> 04:55:08,440
because get conversion rate takes an eth
8044
04:55:08,440 --> 04:55:10,600
amount as input uses the price pricing
8045
04:55:10,600 --> 04:55:13,280
information to get the dollar value back
8046
04:55:13,280 --> 04:55:15,200
and we're going to check to see that the
8047
04:55:15,200 --> 04:55:17,160
dollar value of the message. value is
8048
04:55:17,160 --> 04:55:20,080
greater than the minimum USD however
8049
04:55:20,080 --> 04:55:21,840
since get conversion rate returns a
8050
04:55:21,840 --> 04:55:24,040
value with 18 decimal places we need to
8051
04:55:24,040 --> 04:55:28,280
update our minimum USD to say 5 * 10
8052
04:55:28,280 --> 04:55:30,680
raised to the 18th or we could also do 5
8053
04:55:30,680 --> 04:55:35,718
E18 or we do 5 * 1
8054
04:55:37,280 --> 04:55:40,440
E18 I personally like this 5e8 syntax
8055
04:55:40,440 --> 04:55:42,240
but whatever works for you I'm going to
8056
04:55:42,240 --> 04:55:43,520
deploy this to a test net just to
8057
04:55:43,520 --> 04:55:45,280
demonstrate this working but again you
8058
04:55:45,280 --> 04:55:46,958
do not have to so we're going to go
8059
04:55:46,958 --> 04:55:49,040
ahead delete our previous deployments
8060
04:55:49,040 --> 04:55:51,718
injected web 3 deploy metam Mass pops up
8061
04:55:51,718 --> 04:55:53,600
going to go ahead and confirm after a
8062
04:55:53,600 --> 04:55:54,920
long delay we'll get our deployed
8063
04:55:54,920 --> 04:55:57,080
contract here we have all this stuff we
8064
04:55:57,080 --> 04:55:58,520
can call get price and we can see the
8065
04:55:58,520 --> 04:56:00,798
value of ethereum right now is this with
8066
04:56:00,798 --> 04:56:02,638
18 decimal places which is awesome so
8067
04:56:02,638 --> 04:56:04,480
it's around
8068
04:56:04,480 --> 04:56:07,200
$1,896 so if I were to try to fund this
8069
04:56:07,200 --> 04:56:09,718
with maybe 100 way I know for a fact
8070
04:56:09,718 --> 04:56:11,878
that way isn't going to be enough so if
8071
04:56:11,878 --> 04:56:13,680
we call this fun function we're actually
8072
04:56:13,680 --> 04:56:16,440
going to get this gas estimation failed
8073
04:56:16,440 --> 04:56:18,040
gas estimation error failed with the
8074
04:56:18,040 --> 04:56:20,440
following message blah blah blah error
8075
04:56:20,440 --> 04:56:23,040
execution reverted didn't send enough
8076
04:56:23,040 --> 04:56:25,760
eth which is actually exactly the error
8077
04:56:25,760 --> 04:56:28,480
message that we have here it's exactly
8078
04:56:28,480 --> 04:56:29,958
what our error message is here in our
8079
04:56:29,958 --> 04:56:31,878
require didn't send enough eth so if we
8080
04:56:31,878 --> 04:56:33,520
try to fund it we're going to get didn't
8081
04:56:33,520 --> 04:56:36,080
send enough eth and this gas estimation
8082
04:56:36,080 --> 04:56:38,240
failed is a pretty common error that
8083
04:56:38,240 --> 04:56:41,360
you'll see in remix and solidity and evm
8084
04:56:41,360 --> 04:56:43,200
in general it's kind of just the boiler
8085
04:56:43,200 --> 04:56:45,600
plane answer for something went wrong
8086
04:56:45,600 --> 04:56:47,320
luckily we got the actual error message
8087
04:56:47,320 --> 04:56:49,280
here so we could debug here's what's
8088
04:56:49,280 --> 04:56:50,958
actually going on now you see here we
8089
04:56:50,958 --> 04:56:52,840
could still send this transaction like I
8090
04:56:52,840 --> 04:56:55,400
said we would actually spend gas to send
8091
04:56:55,400 --> 04:56:57,480
a failed transaction and this isn't
8092
04:56:57,480 --> 04:56:58,520
something that we want to do so we're
8093
04:56:58,520 --> 04:57:01,080
going to go ahead and cancel however if
8094
04:57:01,080 --> 04:57:05,240
we did send maybe 1 1 2 3 4 5 6 7 8 1 2
8095
04:57:05,240 --> 04:57:08,760
3 4 5 6 7 8 9 so if we go to Google
8096
04:57:08,760 --> 04:57:10,600
actually we can even see like an e to
8097
04:57:10,600 --> 04:57:13,120
dollar conversion rate so if we sent
8098
04:57:13,120 --> 04:57:17,040
0.01 0.01 eth right now is worth $8
8099
04:57:17,040 --> 04:57:18,520
dollar it might be different depending
8100
04:57:18,520 --> 04:57:20,680
on when you actually do it so we send
8101
04:57:20,680 --> 04:57:24,160
0.01 e in our remix and we can do that
8102
04:57:24,160 --> 04:57:27,798
by doing 1 1 2 3 4 5 6 7 8 9 10 1 2 3 4
8103
04:57:27,798 --> 04:57:32,840
5 6 so it's 1 e16 and we hit fund now we
8104
04:57:32,840 --> 04:57:34,440
actually see metam Mass pops up we don't
8105
04:57:34,440 --> 04:57:36,520
get that gas estimation error we can go
8106
04:57:36,520 --> 04:57:38,200
ahead and confirm and we can see that
8107
04:57:38,200 --> 04:57:40,600
our function is working as expected
8108
04:57:40,600 --> 04:57:42,200
which is great it's reverting
8109
04:57:42,200 --> 04:57:44,958
transactions that have less than $5 and
8110
04:57:44,958 --> 04:57:46,440
it's letting transactions go through
8111
04:57:46,440 --> 04:57:48,958
that have at least $5 awesome and if we
8112
04:57:48,958 --> 04:57:50,760
select minimum USD we can obviously see
8113
04:57:50,760 --> 04:57:53,280
that here and we can see we have 0.01
8114
04:57:53,280 --> 04:57:56,558
eth here fantastic and since we don't
8115
04:57:56,558 --> 04:57:57,878
have a withdrawal function here we
8116
04:57:57,878 --> 04:57:59,200
actually can't pull it out which is
8117
04:57:59,200 --> 04:58:01,240
another reason why I say hey maybe don't
8118
04:58:01,240 --> 04:58:02,718
test this right now but great we've
8119
04:58:02,718 --> 04:58:04,000
confirmed our get conversion rate is
8120
04:58:04,000 --> 04:58:07,718
working so let's move on
8121
04:58:09,120 --> 04:58:11,360
fantastic so what's the next thing that
8122
04:58:11,360 --> 04:58:13,480
we should do in this contract well we
8123
04:58:13,480 --> 04:58:15,200
probably want to keep track of the users
8124
04:58:15,200 --> 04:58:17,320
who send us money in this contract so we
8125
04:58:17,320 --> 04:58:18,878
can keep an array of addresses called
8126
04:58:18,878 --> 04:58:20,840
funders and keep updating that depending
8127
04:58:20,840 --> 04:58:23,360
on who actually sends US money so up at
8128
04:58:23,360 --> 04:58:25,638
the top we'll make an address array or
8129
04:58:25,638 --> 04:58:27,958
an address list we'll make it public and
8130
04:58:27,958 --> 04:58:30,360
we'll call it funders and anytime
8131
04:58:30,360 --> 04:58:32,200
somebody sends US money we'll say
8132
04:58:32,200 --> 04:58:36,200
funders do push message. sender like
8133
04:58:36,200 --> 04:58:39,000
message. Val message. sender is another
8134
04:58:39,000 --> 04:58:40,760
Global variable we can use in solidity
8135
04:58:40,760 --> 04:58:42,440
which refers to whoever called this
8136
04:58:42,440 --> 04:58:44,400
function the sender of the transaction
8137
04:58:44,400 --> 04:58:46,718
to this contract so if we're on sapoia
8138
04:58:46,718 --> 04:58:48,240
and we initialize a transaction for a
8139
04:58:48,240 --> 04:58:50,280
metamask the message. sender is going to
8140
04:58:50,280 --> 04:58:52,200
be this account right here and then
8141
04:58:52,200 --> 04:58:54,798
maybe we want to even make a mapping of
8142
04:58:54,798 --> 04:58:56,878
addresses to to make it easier to look
8143
04:58:56,878 --> 04:58:59,480
up how much money each funer has sent so
8144
04:58:59,480 --> 04:59:03,000
we'll make a mapping of an address to a
8145
04:59:03,000 --> 04:59:06,718
u into 256 we'll call it public address
8146
04:59:06,718 --> 04:59:09,718
to amount funded now something that's
8147
04:59:09,718 --> 04:59:11,760
newer in solidity is you can actually
8148
04:59:11,760 --> 04:59:13,840
name the types in your mapping so you
8149
04:59:13,840 --> 04:59:17,680
could say address fun mapped to un 56
8150
04:59:17,680 --> 04:59:19,840
amount funded usually this is what's
8151
04:59:19,840 --> 04:59:21,638
known as a little syntactic sugar it's
8152
04:59:21,638 --> 04:59:24,040
just to make it easier to read what this
8153
04:59:24,040 --> 04:59:27,000
mapping is Right fun to amount funded
8154
04:59:27,000 --> 04:59:28,480
and then our variable name is very
8155
04:59:28,480 --> 04:59:30,760
explicit address to amount funded now if
8156
04:59:30,760 --> 04:59:32,160
somebody funds our contract we'll of
8157
04:59:32,160 --> 04:59:34,120
course do address to amount funded the
8158
04:59:34,120 --> 04:59:37,638
message. senders address plus equals
8159
04:59:37,638 --> 04:59:39,480
whatever they previously have funded
8160
04:59:39,480 --> 04:59:41,680
Plus message. value whatever they're
8161
04:59:41,680 --> 04:59:43,520
additionally adding all right great and
8162
04:59:43,520 --> 04:59:45,080
now we have a way for us to keep track
8163
04:59:45,080 --> 04:59:47,400
of funders sending money to our contract
8164
04:59:47,400 --> 04:59:49,480
and have an easy way with a mapping to
8165
04:59:49,480 --> 04:59:52,878
look up how much they've spent in
8166
04:59:54,000 --> 04:59:56,440
total now I know we've gone over a lot
8167
04:59:56,440 --> 04:59:58,120
of advanced solidity here so let's do a
8168
04:59:58,120 --> 04:59:59,760
quick refresher of what we've learned so
8169
04:59:59,760 --> 05:00:01,958
far whenever we interact with a contract
8170
05:00:01,958 --> 05:00:04,638
we always need the address and the ABI
8171
05:00:04,638 --> 05:00:06,558
compiling an interface allows us to get
8172
05:00:06,558 --> 05:00:09,080
that ABI very easily for us to interact
8173
05:00:09,080 --> 05:00:10,840
with another contract when we combine
8174
05:00:10,840 --> 05:00:12,440
the contract address with the interface
8175
05:00:12,440 --> 05:00:14,440
we can easily call the functions on that
8176
05:00:14,440 --> 05:00:16,360
contract chain link price feeds are an
8177
05:00:16,360 --> 05:00:18,840
easy way to get data especially pricing
8178
05:00:18,840 --> 05:00:20,920
data from The Real World into our smart
8179
05:00:20,920 --> 05:00:22,680
contracts when working with math in
8180
05:00:22,680 --> 05:00:25,120
solidity and the evm in general decimals
8181
05:00:25,120 --> 05:00:26,718
don't work so we need to always make
8182
05:00:26,718 --> 05:00:28,080
sure we're using the correct number of
8183
05:00:28,080 --> 05:00:29,718
units whenever we interact with our
8184
05:00:29,718 --> 05:00:32,440
contracts message. value and message.
8185
05:00:32,440 --> 05:00:34,558
sender are known as globally available
8186
05:00:34,558 --> 05:00:36,638
units in solidity and they refer to the
8187
05:00:36,638 --> 05:00:38,920
send a of a message of the current call
8188
05:00:38,920 --> 05:00:41,040
or the number of way sent with a message
8189
05:00:41,040 --> 05:00:42,920
or transaction there's a whole bunch of
8190
05:00:42,920 --> 05:00:44,320
these and you can view them all in the
8191
05:00:44,320 --> 05:00:46,760
solidity
8192
05:00:48,280 --> 05:00:49,958
documentation all right great so we've
8193
05:00:49,958 --> 05:00:51,240
got a way to actually get this pricing
8194
05:00:51,240 --> 05:00:53,240
information pretty easily however our
8195
05:00:53,240 --> 05:00:54,600
code is getting a little bit cluttered
8196
05:00:54,600 --> 05:00:56,000
with these get price and G conversion
8197
05:00:56,000 --> 05:00:57,680
rate you'd think that these are
8198
05:00:57,680 --> 05:00:59,240
functions that would be reused pretty
8199
05:00:59,240 --> 05:01:00,878
often anyways for anybody looking to
8200
05:01:00,878 --> 05:01:03,080
work with chain link price feeds so is
8201
05:01:03,080 --> 05:01:04,600
there an easier way for us to work with
8202
05:01:04,600 --> 05:01:06,240
this pricing information maybe doing
8203
05:01:06,240 --> 05:01:07,718
some math like this is pretty common and
8204
05:01:07,718 --> 05:01:09,440
we'd want other contracts to be able to
8205
05:01:09,440 --> 05:01:12,040
import this conversion functionality and
8206
05:01:12,040 --> 05:01:13,240
a way that we can do that is actually
8207
05:01:13,240 --> 05:01:15,080
creating something called a library
8208
05:01:15,080 --> 05:01:16,440
there's a site out there called solidity
8209
05:01:16,440 --> 05:01:19,080
by example which has great examples of
8210
05:01:19,080 --> 05:01:21,080
using libraries and what they work with
8211
05:01:21,080 --> 05:01:22,760
libraries are similar to contracts but
8212
05:01:22,760 --> 05:01:24,280
you can't declare any state variables
8213
05:01:24,280 --> 05:01:26,320
and you can't send ether a library is
8214
05:01:26,320 --> 05:01:27,878
embedded into the contract if all
8215
05:01:27,878 --> 05:01:29,958
Library functions are internal otherwise
8216
05:01:29,958 --> 05:01:31,638
the library must be deployed and then
8217
05:01:31,638 --> 05:01:33,600
linked before the contract is deployed
8218
05:01:33,600 --> 05:01:34,798
that's a little bit confusing don't
8219
05:01:34,798 --> 05:01:36,280
worry too much about that right now
8220
05:01:36,280 --> 05:01:37,958
using libraries can actually add
8221
05:01:37,958 --> 05:01:40,000
functionality to different values and
8222
05:01:40,000 --> 05:01:42,280
what do I mean by that well I mean we
8223
05:01:42,280 --> 05:01:44,320
can have our get conversion rate
8224
05:01:44,320 --> 05:01:47,440
function be a function of any value of
8225
05:01:47,440 --> 05:01:49,878
type you 256 means we could take this
8226
05:01:49,878 --> 05:01:51,120
get conversion rate and do something
8227
05:01:51,120 --> 05:01:54,480
like message. value. getet conversion
8228
05:01:54,480 --> 05:01:56,480
rate so we can create our own custom
8229
05:01:56,480 --> 05:01:58,558
function with any type we could work
8230
05:01:58,558 --> 05:02:00,558
with get conversion rate as if message.
8231
05:02:00,558 --> 05:02:02,400
Val was a class or an object or a
8232
05:02:02,400 --> 05:02:04,400
contract that we actually created to do
8233
05:02:04,400 --> 05:02:06,320
this let's go back to our files create a
8234
05:02:06,320 --> 05:02:08,680
new one create a new one called price
8235
05:02:08,680 --> 05:02:10,280
converter
8236
05:02:10,280 --> 05:02:13,320
soul and this is going to be a library a
8237
05:02:13,320 --> 05:02:15,440
price converter Library so how do we
8238
05:02:15,440 --> 05:02:17,320
create a library and what is a library
8239
05:02:17,320 --> 05:02:18,718
well a library is going to be very
8240
05:02:18,718 --> 05:02:20,558
similar to a contract we're going to
8241
05:02:20,558 --> 05:02:22,440
start of course with spdx license
8242
05:02:22,440 --> 05:02:24,760
identifier we're going to do pragma
8243
05:02:24,760 --> 05:02:28,000
solidity and we'll give it a version of
8244
05:02:28,000 --> 05:02:30,760
0.818 the little carrot and instead of
8245
05:02:30,760 --> 05:02:32,400
typing contract we're actually going to
8246
05:02:32,400 --> 05:02:34,558
type library for the name of the library
8247
05:02:34,558 --> 05:02:35,760
and we're going to call this Library
8248
05:02:35,760 --> 05:02:39,120
price converter so libraries can't have
8249
05:02:39,120 --> 05:02:40,840
any state variabl and all the functions
8250
05:02:40,840 --> 05:02:42,638
have to be marked internal so what we're
8251
05:02:42,638 --> 05:02:44,000
going to do is we're going to go back to
8252
05:02:44,000 --> 05:02:46,480
fundme doso zoom out a little bit we're
8253
05:02:46,480 --> 05:02:48,320
going to grab get price get conversion
8254
05:02:48,320 --> 05:02:51,200
rate and get version delete them well I
8255
05:02:51,200 --> 05:02:53,000
hit copy first go back to price
8256
05:02:53,000 --> 05:02:55,120
converter paste them in here and work
8257
05:02:55,120 --> 05:02:57,040
with them in here of course we're going
8258
05:02:57,040 --> 05:02:59,040
to need the aggregator V3 interface so
8259
05:02:59,040 --> 05:03:00,840
we're going to go back to our funme
8260
05:03:00,840 --> 05:03:03,120
we're going to copy this named import
8261
05:03:03,120 --> 05:03:05,558
from aggregator V3 interface paste it in
8262
05:03:05,558 --> 05:03:07,638
at the top here hit command s and we're
8263
05:03:07,638 --> 05:03:09,240
going to go ahead and compile this
8264
05:03:09,240 --> 05:03:11,280
successfully fundme is no longer going
8265
05:03:11,280 --> 05:03:12,558
to compile but we're going to fix that
8266
05:03:12,558 --> 05:03:14,240
in a little bit now the first thing that
8267
05:03:14,240 --> 05:03:15,280
we're going to need to do in here is
8268
05:03:15,280 --> 05:03:16,558
make these all internal so we're going
8269
05:03:16,558 --> 05:03:19,120
to say internal like this we do internal
8270
05:03:19,120 --> 05:03:21,320
get conversion rate and internal get
8271
05:03:21,320 --> 05:03:23,080
version now that we have our price
8272
05:03:23,080 --> 05:03:25,000
converter Library we can actually import
8273
05:03:25,000 --> 05:03:27,600
it back in our fundme and attach it to a
8274
05:03:27,600 --> 05:03:29,840
un 256 and let's actually delete this
8275
05:03:29,840 --> 05:03:32,840
aggregator V3 interface line for now and
8276
05:03:32,840 --> 05:03:36,520
we'll do import price converter
8277
05:03:36,520 --> 05:03:40,480
fromprice converter do soul and now to
8278
05:03:40,480 --> 05:03:42,280
attach the functions in our price
8279
05:03:42,280 --> 05:03:45,360
converter library to All U 256s we'll
8280
05:03:45,360 --> 05:03:50,558
say using price converter or uint
8281
05:03:50,558 --> 05:03:53,000
256 of course if we compile our fundme
8282
05:03:53,000 --> 05:03:54,240
we're going to get an issue because it
8283
05:03:54,240 --> 05:03:55,520
doesn't really know what get conversion
8284
05:03:55,520 --> 05:03:57,240
rate is so for now let's actually just
8285
05:03:57,240 --> 05:03:58,878
comment out this line I'm going to
8286
05:03:58,878 --> 05:04:01,680
remove these comments up here as well so
8287
05:04:01,680 --> 05:04:03,000
what we can do now though is we can do
8288
05:04:03,000 --> 05:04:06,798
message. value. getet conversion rate
8289
05:04:06,798 --> 05:04:09,760
get conversion rate and in your library
8290
05:04:09,760 --> 05:04:11,400
whenever you're working with a library
8291
05:04:11,400 --> 05:04:13,558
the first input variable for a library
8292
05:04:13,558 --> 05:04:15,240
is going to be the type that you're
8293
05:04:15,240 --> 05:04:18,240
using with the library so message. value
8294
05:04:18,240 --> 05:04:21,040
is of type un 256 so this gets passed
8295
05:04:21,040 --> 05:04:23,000
inside of get conversion rate as the
8296
05:04:23,000 --> 05:04:26,440
first variable into U 256 e amount even
8297
05:04:26,440 --> 05:04:28,360
though we don't pass any variables
8298
05:04:28,360 --> 05:04:30,600
inside of these parentheses here for get
8299
05:04:30,600 --> 05:04:32,400
price and get version we don't really
8300
05:04:32,400 --> 05:04:34,718
care to have an input parameter at all
8301
05:04:34,718 --> 05:04:36,878
so it'll pass it in but not do anything
8302
05:04:36,878 --> 05:04:39,200
so now instead of require get conversion
8303
05:04:39,200 --> 05:04:42,160
rate of message value we can actually do
8304
05:04:42,160 --> 05:04:44,120
let's uncomment this line now and let's
8305
05:04:44,120 --> 05:04:47,160
delete this line we can actually do
8306
05:04:47,160 --> 05:04:51,680
message. value. getet conversion rate
8307
05:04:51,680 --> 05:04:54,520
conversion rate and now if we compile
8308
05:04:54,520 --> 05:04:55,878
this this is going to compile
8309
05:04:55,878 --> 05:04:57,798
successfully this works because we're
8310
05:04:57,798 --> 05:05:00,000
attaching the price converter library to
8311
05:05:00,000 --> 05:05:03,958
all un 256s so now all un 256s have
8312
05:05:03,958 --> 05:05:06,000
access to this get conversion rate
8313
05:05:06,000 --> 05:05:09,760
function and since message. Val is a un
8314
05:05:09,760 --> 05:05:12,680
six it can call. get conversion rate and
8315
05:05:12,680 --> 05:05:15,718
it'll pass itself so that message. value
8316
05:05:15,718 --> 05:05:17,718
as the first input parameter to the
8317
05:05:17,718 --> 05:05:19,480
function here if we wanted another
8318
05:05:19,480 --> 05:05:22,480
variable in here like U into 6 something
8319
05:05:22,480 --> 05:05:24,480
else that would be the first parameter
8320
05:05:24,480 --> 05:05:26,320
inside these parentheses so maybe like 1
8321
05:05:26,320 --> 05:05:28,440
2 3 or something right this one 2 3
8322
05:05:28,440 --> 05:05:31,120
would be the something else but message.
8323
05:05:31,120 --> 05:05:33,360
value would still be the initial
8324
05:05:33,360 --> 05:05:35,320
parameter which in this example would be
8325
05:05:35,320 --> 05:05:37,200
eth amount so let's go ahead and undo
8326
05:05:37,200 --> 05:05:39,840
that and undo that but all right great
8327
05:05:39,840 --> 05:05:41,400
we've moved a lot of the math into our
8328
05:05:41,400 --> 05:05:45,360
own Library congratulations nice
8329
05:05:46,680 --> 05:05:48,958
work one of the most common libraries
8330
05:05:48,958 --> 05:05:50,920
that was used for a long time was this
8331
05:05:50,920 --> 05:05:53,558
Library called safemath dossou and in
8332
05:05:53,558 --> 05:05:55,200
your solidity Journeys you'll probably
8333
05:05:55,200 --> 05:05:57,120
see it pop up from time to time now
8334
05:05:57,120 --> 05:05:58,200
we're going to go off on a little bit of
8335
05:05:58,200 --> 05:06:00,040
a tangent here about safe math and the
8336
05:06:00,040 --> 05:06:02,520
library safe math and this is an excerpt
8337
05:06:02,520 --> 05:06:04,320
from my course last year so you might
8338
05:06:04,320 --> 05:06:05,760
see stuff like rink B and some other
8339
05:06:05,760 --> 05:06:07,680
stuff but just focus on the safe math
8340
05:06:07,680 --> 05:06:09,638
stuff just know when we refer to the
8341
05:06:09,638 --> 05:06:10,878
JavaScript virtual machine that's
8342
05:06:10,878 --> 05:06:13,200
talking about the remix virtual
8343
05:06:13,200 --> 05:06:15,798
machine one of the most common libraries
8344
05:06:15,798 --> 05:06:18,200
that was used for the longest time was
8345
05:06:18,200 --> 05:06:21,280
this Library called safemath dossou and
8346
05:06:21,280 --> 05:06:22,638
you'll probably see it a lot of
8347
05:06:22,638 --> 05:06:24,240
different places we're going to go off
8348
05:06:24,240 --> 05:06:26,200
on a quick little tangent here and teach
8349
05:06:26,200 --> 05:06:28,040
you about safe math so let's close
8350
05:06:28,040 --> 05:06:30,240
fundme and close price converter and
8351
05:06:30,240 --> 05:06:34,480
let's create a new file called safe math
8352
05:06:34,480 --> 05:06:37,000
tester. soul and let's start with some
8353
05:06:37,000 --> 05:06:39,280
basic stuff in here safe math was all
8354
05:06:39,280 --> 05:06:41,958
over over the place before version 0.8
8355
05:06:41,958 --> 05:06:44,440
of solidity and now it's almost in no
8356
05:06:44,440 --> 05:06:46,600
contracts what happened why is safe
8357
05:06:46,600 --> 05:06:48,878
maath no longer used as much well let's
8358
05:06:48,878 --> 05:06:51,440
create a sample contract this is a
8359
05:06:51,440 --> 05:06:52,958
section that you don't have to follow
8360
05:06:52,958 --> 05:06:54,400
along if you don't want to code along
8361
05:06:54,400 --> 05:06:56,480
with me but if you want to you
8362
05:06:56,480 --> 05:06:58,240
absolutely still can this is going to be
8363
05:06:58,240 --> 05:07:00,120
a contract we are going to deploy on a
8364
05:07:00,120 --> 05:07:02,240
JavaScript virtual machine uh we can use
8365
05:07:02,240 --> 05:07:04,240
any version of solidity before version
8366
05:07:04,240 --> 05:07:07,360
0.8 of solidity so for example we'll use
8367
05:07:07,360 --> 05:07:11,440
pragma carot 0.6 6.0 and we'll create
8368
05:07:11,440 --> 05:07:16,558
contract safe math tester. Soul now if I
8369
05:07:16,558 --> 05:07:20,320
create a un 8 I set it to
8370
05:07:20,320 --> 05:07:23,718
public big number and I set this to
8371
05:07:23,718 --> 05:07:27,280
255 oops safe math tester let's go ahead
8372
05:07:27,280 --> 05:07:31,600
and compile safe math tester with
8373
05:07:31,600 --> 05:07:36,040
0.67 fragma solidity the maximum size of
8374
05:07:36,040 --> 05:07:39,360
a u 8 is going to be 255 this is going
8375
05:07:39,360 --> 05:07:41,600
to be the biggest number that we can fit
8376
05:07:41,600 --> 05:07:44,320
in an U 8 and if I were to deploy this
8377
05:07:44,320 --> 05:07:46,840
to a JavaScript VM or even a test
8378
05:07:46,840 --> 05:07:49,320
Network save math tester let's go ahead
8379
05:07:49,320 --> 05:07:50,320
and deploy
8380
05:07:50,320 --> 05:07:53,280
it if I hit big number we're going to
8381
05:07:53,280 --> 05:07:54,400
get
8382
05:07:54,400 --> 05:07:57,200
255 well what happens if I create a
8383
05:07:57,200 --> 05:08:01,958
function called add that sets big number
8384
05:08:01,958 --> 05:08:06,000
equal to big number + one let's save
8385
05:08:06,000 --> 05:08:09,558
that delete that old contract and deploy
8386
05:08:09,558 --> 05:08:12,280
right now big number is 255 what happens
8387
05:08:12,280 --> 05:08:16,240
when we add one to big number when 255
8388
05:08:16,240 --> 05:08:19,638
is the max size a uint 8 can be well
8389
05:08:19,638 --> 05:08:22,000
let's hit add now let's check what big
8390
05:08:22,000 --> 05:08:26,120
number is big number gets reset to zero
8391
05:08:26,120 --> 05:08:28,718
so what's going on well prior to version
8392
05:08:28,718 --> 05:08:31,440
0.8 of solidity unside integers and
8393
05:08:31,440 --> 05:08:34,120
integers ran on this concept of being
8394
05:08:34,120 --> 05:08:37,200
unchecked which means that if you passed
8395
05:08:37,200 --> 05:08:39,280
the upper limit of a number it would
8396
05:08:39,280 --> 05:08:41,360
just just wrap around and start back
8397
05:08:41,360 --> 05:08:43,200
from the lowest number it could be so if
8398
05:08:43,200 --> 05:08:45,520
I call add a whole bunch more times and
8399
05:08:45,520 --> 05:08:47,520
hit big number now it's eight if I were
8400
05:08:47,520 --> 05:08:49,878
to hit this add button a ton more times
8401
05:08:49,878 --> 05:08:52,600
and get it back to 255 it would then
8402
05:08:52,600 --> 05:08:55,080
continue to wrap over to zero so one of
8403
05:08:55,080 --> 05:08:57,200
the most popular libraries that was out
8404
05:08:57,200 --> 05:08:59,840
there was this safe math Library which
8405
05:08:59,840 --> 05:09:02,400
would basically check to make sure that
8406
05:09:02,400 --> 05:09:05,080
you weren't wrapping around a un 256 or
8407
05:09:05,080 --> 05:09:07,558
an in 256 basically it was a way to say
8408
05:09:07,558 --> 05:09:09,600
hey you've reached the max this number
8409
05:09:09,600 --> 05:09:11,480
can be and now your transaction is going
8410
05:09:11,480 --> 05:09:14,760
to fail if we switch this to 0.8 of
8411
05:09:14,760 --> 05:09:17,798
solidity delete the old contract go
8412
05:09:17,798 --> 05:09:19,718
switch this to
8413
05:09:19,718 --> 05:09:22,840
0.8 we'll go ahead and compile it and
8414
05:09:22,840 --> 05:09:25,200
now we deploy this to JavaScript
8415
05:09:25,200 --> 05:09:29,280
VM if I hit big number we get 255 but if
8416
05:09:29,280 --> 05:09:32,400
we hit add it actually fails and we
8417
05:09:32,400 --> 05:09:36,040
still get 255 in version 0.8 of solidity
8418
05:09:36,040 --> 05:09:37,680
they added this bit where it
8419
05:09:37,680 --> 05:09:39,400
automatically checks to make sure if
8420
05:09:39,400 --> 05:09:40,600
you're going to do what's called
8421
05:09:40,600 --> 05:09:43,200
overflow or underflow on a variable we
8422
05:09:43,200 --> 05:09:44,878
can actually revert back to the
8423
05:09:44,878 --> 05:09:47,718
unchecked version by using an unchecked
8424
05:09:47,718 --> 05:09:49,958
keyword so if we wrap this big number
8425
05:09:49,958 --> 05:09:52,240
equals big number + one in this
8426
05:09:52,240 --> 05:09:54,798
unchecked bracket let's delete our old
8427
05:09:54,798 --> 05:09:57,520
contract we'll compile we'll
8428
05:09:57,520 --> 05:10:00,920
redeploy we hit big numbers 255 now we
8429
05:10:00,920 --> 05:10:02,920
hit add we hit big number again it
8430
05:10:02,920 --> 05:10:06,040
reverted back to zero so that's a little
8431
05:10:06,040 --> 05:10:08,280
bit more about safe math checked and
8432
05:10:08,280 --> 05:10:12,320
unchecked so version 0.76 and below this
8433
05:10:12,320 --> 05:10:14,520
code that you see in front of you is
8434
05:10:14,520 --> 05:10:17,760
going to be the exact same as this code
8435
05:10:17,760 --> 05:10:20,240
in 0.8 and above with this unchecked
8436
05:10:20,240 --> 05:10:22,520
keyword now you might be thinking in
8437
05:10:22,520 --> 05:10:25,040
newer versions of solidity why would I
8438
05:10:25,040 --> 05:10:27,718
use this unchecked keyword well you'll
8439
05:10:27,718 --> 05:10:29,958
find out later that this unchecked
8440
05:10:29,958 --> 05:10:32,280
keyword makes your code a little bit
8441
05:10:32,280 --> 05:10:34,798
more gas effici so if you're absolutely
8442
05:10:34,798 --> 05:10:36,400
positive that your math is never going
8443
05:10:36,400 --> 05:10:38,400
to reach the top or bottom limits of a
8444
05:10:38,400 --> 05:10:40,440
number then might make sense for you to
8445
05:10:40,440 --> 05:10:42,360
use the unchecked keyword let's head
8446
05:10:42,360 --> 05:10:44,638
back over to our fundme contract where
8447
05:10:44,638 --> 05:10:46,638
we are now using the price converter
8448
05:10:46,638 --> 05:10:49,480
library that we just
8449
05:10:50,680 --> 05:10:52,520
created awesome we have a lot of the
8450
05:10:52,520 --> 05:10:53,878
basics of the math that we need in our
8451
05:10:53,878 --> 05:10:55,718
fundme contract it's all right so this
8452
05:10:55,718 --> 05:10:57,280
is great people can actually send us
8453
05:10:57,280 --> 05:10:58,600
money and we're going to keep track of
8454
05:10:58,600 --> 05:11:00,718
them as well which is fantastic so the
8455
05:11:00,718 --> 05:11:01,878
next thing obviously that we're going to
8456
05:11:01,878 --> 05:11:03,160
want to do is we're going to want to be
8457
05:11:03,160 --> 05:11:06,120
able to withdraw that money out so now
8458
05:11:06,120 --> 05:11:07,718
let's go ahead and Implement our
8459
05:11:07,718 --> 05:11:09,840
withdraw function when we withdraw all
8460
05:11:09,840 --> 05:11:10,958
the money we're probably going to want
8461
05:11:10,958 --> 05:11:13,440
to reset all the mappings back down to
8462
05:11:13,440 --> 05:11:15,360
zero to show that hey we've withdrawn
8463
05:11:15,360 --> 05:11:17,638
all the money and there's nobody left to
8464
05:11:17,638 --> 05:11:18,798
do this we're going to use something
8465
05:11:18,798 --> 05:11:21,798
called a for Loop a for Loop is a way to
8466
05:11:21,798 --> 05:11:23,878
Loop through a list of something or to
8467
05:11:23,878 --> 05:11:25,798
do something in a repeated amount of
8468
05:11:25,798 --> 05:11:27,680
time if you're familiar with other
8469
05:11:27,680 --> 05:11:29,320
programming languages it's the exact
8470
05:11:29,320 --> 05:11:31,360
same concept we wanted to get all the
8471
05:11:31,360 --> 05:11:33,558
elements in this list for example which
8472
05:11:33,558 --> 05:11:36,000
where one is at the zeroth index two is
8473
05:11:36,000 --> 05:11:37,920
at the first index three is at the
8474
05:11:37,920 --> 05:11:39,360
second index and four is at the the
8475
05:11:39,360 --> 05:11:41,200
third index which I know is a little bit
8476
05:11:41,200 --> 05:11:43,160
confusing these are the different these
8477
05:11:43,160 --> 05:11:46,760
are the indexes these are the elements
8478
05:11:46,760 --> 05:11:48,840
we would Loop 0 through three to get all
8479
05:11:48,840 --> 05:11:50,600
the elements out of this array to do
8480
05:11:50,600 --> 05:11:52,120
this loop we're going to use the four
8481
05:11:52,120 --> 05:11:54,638
keyword we're going to say four put some
8482
05:11:54,638 --> 05:11:57,080
parentheses and in a for Loop we can add
8483
05:11:57,080 --> 05:11:58,638
a couple things and by the way this is a
8484
05:11:58,638 --> 05:12:00,680
way to do comments inside of a line and
8485
05:12:00,680 --> 05:12:03,200
solidity you do a back slashstar star
8486
05:12:03,200 --> 05:12:04,680
back slash and now everything in here is
8487
05:12:04,680 --> 05:12:06,958
a common so in a for Loop you first need
8488
05:12:06,958 --> 05:12:08,920
to give it the starting index then you
8489
05:12:08,920 --> 05:12:11,160
give it the ending index and then you
8490
05:12:11,160 --> 05:12:13,638
can give it the step amount for example
8491
05:12:13,638 --> 05:12:15,280
let's say we want to start on the zeroth
8492
05:12:15,280 --> 05:12:17,040
index we want to go all the way up to
8493
05:12:17,040 --> 05:12:19,080
the 10th index and we want to go by up
8494
05:12:19,080 --> 05:12:23,400
each time we would do 0o 1 2 3 4 Etc
8495
05:12:23,400 --> 05:12:25,200
well let's say we want to start with the
8496
05:12:25,200 --> 05:12:27,520
third index we want to go to the 12th
8497
05:12:27,520 --> 05:12:29,600
index and we want to up by two every
8498
05:12:29,600 --> 05:12:32,480
single time well we would do three five
8499
05:12:32,480 --> 05:12:35,760
7 9 Etc so our starting index is going
8500
05:12:35,760 --> 05:12:39,280
to be a un 256 and we'll call it under
8501
05:12:39,280 --> 05:12:41,040
index and we're going to say we're going
8502
05:12:41,040 --> 05:12:43,040
to start with zero and we're going to
8503
05:12:43,040 --> 05:12:46,958
end once the funer index is less than
8504
05:12:46,958 --> 05:12:50,000
the funders length so I know I said up
8505
05:12:50,000 --> 05:12:52,240
here it's the ending index but instead
8506
05:12:52,240 --> 05:12:55,440
it's a Boolean once the funders index is
8507
05:12:55,440 --> 05:12:58,558
greater than fund. length which is how
8508
05:12:58,558 --> 05:13:00,798
you can get the length of an array then
8509
05:13:00,798 --> 05:13:02,798
we're going to end and then finally
8510
05:13:02,798 --> 05:13:04,760
we're going to say every single time we
8511
05:13:04,760 --> 05:13:06,920
do a loop we're going to say funders
8512
05:13:06,920 --> 05:13:10,440
index equals funders index + 1 now
8513
05:13:10,440 --> 05:13:12,878
there's a shortcut you can do to do some
8514
05:13:12,878 --> 05:13:15,400
variable equals itself + 1 and that's
8515
05:13:15,400 --> 05:13:18,520
just Plus+ this plus plus means every
8516
05:13:18,520 --> 05:13:21,120
time we go through the loop just add one
8517
05:13:21,120 --> 05:13:22,958
and we actually don't need that here and
8518
05:13:22,958 --> 05:13:24,878
then we put these curly braces to say
8519
05:13:24,878 --> 05:13:27,400
okay execute everything inside of this
8520
05:13:27,400 --> 05:13:29,520
Loop here for the duration that we
8521
05:13:29,520 --> 05:13:31,638
specified here and this final piece
8522
05:13:31,638 --> 05:13:33,360
means that every time we run through all
8523
05:13:33,360 --> 05:13:35,480
the code inside of these brackets we're
8524
05:13:35,480 --> 05:13:37,958
going to add one to this funders index
8525
05:13:37,958 --> 05:13:40,480
that's how we go from0 to 1 2 3 4 5 6 7
8526
05:13:40,480 --> 05:13:43,160
Etc to access the zero withth element of
8527
05:13:43,160 --> 05:13:44,840
our funders array we're going to say
8528
05:13:44,840 --> 05:13:48,360
funders of fun index and this is going
8529
05:13:48,360 --> 05:13:50,878
to return an address since it's an array
8530
05:13:50,878 --> 05:13:54,480
of addresses so we'll say address fun
8531
05:13:54,480 --> 05:13:57,320
equals funders of funer index and we
8532
05:13:57,320 --> 05:13:59,520
want to use this to reset our mapping
8533
05:13:59,520 --> 05:14:01,798
address to amount funded so we can say
8534
05:14:01,798 --> 05:14:04,798
address to amount funded at the funer
8535
05:14:04,798 --> 05:14:07,400
address is now equal to zero so we're
8536
05:14:07,400 --> 05:14:09,520
going to reset whatever we add added
8537
05:14:09,520 --> 05:14:11,718
when they funded us down to zero because
8538
05:14:11,718 --> 05:14:14,000
we're withdrawing all the money out and
8539
05:14:14,000 --> 05:14:15,240
additionally how there's a nice little
8540
05:14:15,240 --> 05:14:17,958
shorthand like plus plus down here up
8541
05:14:17,958 --> 05:14:19,638
here in the fund another nice little
8542
05:14:19,638 --> 05:14:22,040
shortcut whenever you want to add
8543
05:14:22,040 --> 05:14:24,718
something to whenever you want to add
8544
05:14:24,718 --> 05:14:26,718
something to something that already
8545
05:14:26,718 --> 05:14:29,360
exists instead of doing something equals
8546
05:14:29,360 --> 05:14:31,400
itself plus the new thing you can just
8547
05:14:31,400 --> 05:14:34,360
do plus equals this means that we're
8548
05:14:34,360 --> 05:14:36,200
going to set address to amount funded of
8549
05:14:36,200 --> 05:14:39,040
message. sender equal to itself Plus
8550
05:14:39,040 --> 05:14:41,160
plus message. Val so let's walk through
8551
05:14:41,160 --> 05:14:42,600
this for Loop a little bit we're going
8552
05:14:42,600 --> 05:14:44,760
to start with the zero withth index
8553
05:14:44,760 --> 05:14:47,160
we're going to get the fun at the zero
8554
05:14:47,160 --> 05:14:49,360
with index in our funer array we're
8555
05:14:49,360 --> 05:14:51,080
going to take that address stick it into
8556
05:14:51,080 --> 05:14:53,320
our mapping and reset the amount that
8557
05:14:53,320 --> 05:14:55,558
they've sent us to zero then we're going
8558
05:14:55,558 --> 05:14:57,798
to do funer Plus+ we're going to check
8559
05:14:57,798 --> 05:15:02,000
to see that funer plus funer index Plus+
8560
05:15:02,000 --> 05:15:03,878
is less than funders do length obviously
8561
05:15:03,878 --> 05:15:06,638
fun 0 + 1 is going to be one so we're
8562
05:15:06,638 --> 05:15:08,360
going to check if one is less than the
8563
05:15:08,360 --> 05:15:10,000
total amount of fun fers and then we're
8564
05:15:10,000 --> 05:15:11,878
going to get the address of the fun at
8565
05:15:11,878 --> 05:15:14,240
the first index reset them to zero get
8566
05:15:14,240 --> 05:15:15,958
the address at the second index reset
8567
05:15:15,958 --> 05:15:19,160
them to zero third index etc etc until
8568
05:15:19,160 --> 05:15:22,958
we finally reach the index that is equal
8569
05:15:22,958 --> 05:15:25,160
to or greater than the length so if we
8570
05:15:25,160 --> 05:15:27,920
have 10 funders and we reach funer index
8571
05:15:27,920 --> 05:15:32,200
10 the for Loop will exit and be
8572
05:15:33,480 --> 05:15:35,920
done but we still haven't done two
8573
05:15:35,920 --> 05:15:38,440
things we need to reset the array still
8574
05:15:38,440 --> 05:15:39,798
and then we also need to withdraw the
8575
05:15:39,798 --> 05:15:42,120
funds since we've accumulated all this
8576
05:15:42,120 --> 05:15:44,558
message. Val in the fund function to
8577
05:15:44,558 --> 05:15:46,520
reset the funders array we could do the
8578
05:15:46,520 --> 05:15:47,958
same thing we did with the mapping and
8579
05:15:47,958 --> 05:15:50,680
reset each single address at each index
8580
05:15:50,680 --> 05:15:52,760
or we could just create a brand new
8581
05:15:52,760 --> 05:15:54,120
funders array which is what we're going
8582
05:15:54,120 --> 05:15:56,520
to do so to reset the array we're now
8583
05:15:56,520 --> 05:15:59,958
going to say funders equals new address
8584
05:15:59,958 --> 05:16:02,520
array and to start off at a length of
8585
05:16:02,520 --> 05:16:04,958
zero previously we used the new keyword
8586
05:16:04,958 --> 05:16:07,680
to deploy a different contract now we're
8587
05:16:07,680 --> 05:16:10,240
using the new keyword to reset the
8588
05:16:10,240 --> 05:16:13,200
funders array to a brand new blank
8589
05:16:13,200 --> 05:16:14,480
address array this part is a little
8590
05:16:14,480 --> 05:16:16,280
confusing don't let it hold you back and
8591
05:16:16,280 --> 05:16:17,760
lat later in the course why we make the
8592
05:16:17,760 --> 05:16:19,920
choices here that we do so great we've
8593
05:16:19,920 --> 05:16:22,638
gone ahead and reset the array so now
8594
05:16:22,638 --> 05:16:25,000
how do we actually withdraw the funds
8595
05:16:25,000 --> 05:16:26,400
for this section I'm going to go ahead
8596
05:16:26,400 --> 05:16:28,000
and again refer to a previous course
8597
05:16:28,000 --> 05:16:29,440
that it did because the content is
8598
05:16:29,440 --> 05:16:30,958
exactly the same just remember
8599
05:16:30,958 --> 05:16:35,280
JavaScript VM is remix VM
8600
05:16:41,718 --> 05:16:43,520
so great we've gone ahead and reset the
8601
05:16:43,520 --> 05:16:46,200
array but how do we actually now
8602
05:16:46,200 --> 05:16:49,320
withdraw funds from this contract how do
8603
05:16:49,320 --> 05:16:52,680
we send the funds back to whomever is
8604
05:16:52,680 --> 05:16:55,440
calling this now to actually send ether
8605
05:16:55,440 --> 05:16:58,040
or send native blockchain currency there
8606
05:16:58,040 --> 05:17:00,280
are actually three different ways to do
8607
05:17:00,280 --> 05:17:02,878
this we're going to look at all three
8608
05:17:02,878 --> 05:17:04,718
and say what the differences between the
8609
05:17:04,718 --> 05:17:06,120
three of them are the three different
8610
05:17:06,120 --> 05:17:07,840
ways are going to be
8611
05:17:07,840 --> 05:17:12,320
transfer send and call let's go ahead
8612
05:17:12,320 --> 05:17:14,680
and start with transfer since transfer
8613
05:17:14,680 --> 05:17:17,160
is the simplest and at surface level
8614
05:17:17,160 --> 05:17:19,280
makes the most sense to use so if we
8615
05:17:19,280 --> 05:17:22,000
want to transfer the funds to whomever
8616
05:17:22,000 --> 05:17:24,480
is calling this withdraw function we
8617
05:17:24,480 --> 05:17:27,680
would do we would say message.
8618
05:17:27,680 --> 05:17:29,440
sender.
8619
05:17:29,440 --> 05:17:32,080
transfer and then we'd get the balance
8620
05:17:32,080 --> 05:17:36,000
of our contract here by saying
8621
05:17:36,000 --> 05:17:39,120
address this the this keyword word
8622
05:17:39,120 --> 05:17:42,718
refers to this whole contract. balance
8623
05:17:42,718 --> 05:17:44,080
and we can get the native blockchain
8624
05:17:44,080 --> 05:17:45,760
currency or the ethereum currency
8625
05:17:45,760 --> 05:17:47,878
balance of this address like this and we
8626
05:17:47,878 --> 05:17:49,680
can just do that only thing that we need
8627
05:17:49,680 --> 05:17:52,798
to do is we need to cast we need to typ
8628
05:17:52,798 --> 05:17:55,920
cast message. sender from an address
8629
05:17:55,920 --> 05:17:57,798
type to
8630
05:17:57,798 --> 05:18:02,760
a payable address type so message.
8631
05:18:02,760 --> 05:18:06,120
sender is of type
8632
05:18:06,120 --> 05:18:09,760
address whereas payable
8633
05:18:09,760 --> 05:18:13,120
message. sender is of type payable
8634
05:18:13,120 --> 05:18:15,798
address and in solidity in order to send
8635
05:18:15,798 --> 05:18:17,200
the native blockchain token like
8636
05:18:17,200 --> 05:18:19,878
ethereum you can only work with payable
8637
05:18:19,878 --> 05:18:22,080
addresses to do that so we just wrap it
8638
05:18:22,080 --> 05:18:25,120
in this payable typ Caster so this is
8639
05:18:25,120 --> 05:18:27,240
the first way that we actually send
8640
05:18:27,240 --> 05:18:30,480
ethereum or send tokens from different
8641
05:18:30,480 --> 05:18:32,520
contracts to each other we wrap the
8642
05:18:32,520 --> 05:18:34,360
address that we want to send it in in
8643
05:18:34,360 --> 05:18:37,718
this payable keyword we do transfer and
8644
05:18:37,718 --> 05:18:40,120
then we say EX exactly how much we want
8645
05:18:40,120 --> 05:18:42,480
to transfer but there are some issues
8646
05:18:42,480 --> 05:18:45,400
with transfer here we are on solidity by
8647
05:18:45,400 --> 05:18:48,680
example for sending ether which again is
8648
05:18:48,680 --> 05:18:51,718
a fantastic resource to refer to if you
8649
05:18:51,718 --> 05:18:53,798
get lost the method that we just looked
8650
05:18:53,798 --> 05:18:57,798
at was this transfer method now we saw
8651
05:18:57,798 --> 05:19:01,120
way earlier in the course that if I sent
8652
05:19:01,120 --> 05:19:04,080
ethereum from one address to another it
8653
05:19:04,080 --> 05:19:08,920
cost about 2100 gas or 2,100 gas our
8654
05:19:08,920 --> 05:19:13,080
transfer function is capped at 2300 gas
8655
05:19:13,080 --> 05:19:15,400
and if more gas is used it throws an
8656
05:19:15,400 --> 05:19:18,000
error the next one that we're using is
8657
05:19:18,000 --> 05:19:20,718
going to be send which is also capped at
8658
05:19:20,718 --> 05:19:24,240
2300 gas and if it fails it'll return a
8659
05:19:24,240 --> 05:19:26,840
Boolean so with transfer if this line
8660
05:19:26,840 --> 05:19:28,958
fails it'll error and revert the
8661
05:19:28,958 --> 05:19:32,280
transaction with send it won't error
8662
05:19:32,280 --> 05:19:34,798
it'll return a Boolean of whether or not
8663
05:19:34,798 --> 05:19:38,320
it was successful so using send will do
8664
05:19:38,320 --> 05:19:39,160
pay
8665
05:19:39,160 --> 05:19:40,558
message.
8666
05:19:40,558 --> 05:19:43,040
sender.
8667
05:19:43,040 --> 05:19:45,080
send address
8668
05:19:45,080 --> 05:19:48,920
this balance but we don't want to finish
8669
05:19:48,920 --> 05:19:51,600
our call Here If This Were to fail the
8670
05:19:51,600 --> 05:19:54,120
contract wouldn't revert the transaction
8671
05:19:54,120 --> 05:19:56,200
and we just wouldn't get our money sent
8672
05:19:56,200 --> 05:20:00,040
so we want to do Boolean send
8673
05:20:00,040 --> 05:20:04,080
success equals this whole bit here and
8674
05:20:04,080 --> 05:20:08,120
then we want to require send success and
8675
05:20:08,120 --> 05:20:10,558
if this send fails we'll throw an error
8676
05:20:10,558 --> 05:20:13,240
saying send
8677
05:20:13,240 --> 05:20:17,000
failed this way if this fails we will
8678
05:20:17,000 --> 05:20:19,480
still revert by adding our require
8679
05:20:19,480 --> 05:20:21,680
statement here transfer automatically
8680
05:20:21,680 --> 05:20:25,280
reverts if the transfer fails send will
8681
05:20:25,280 --> 05:20:27,400
only revert the transaction if we add
8682
05:20:27,400 --> 05:20:29,760
this required statement here so great
8683
05:20:29,760 --> 05:20:31,798
what's the third way that we can
8684
05:20:31,798 --> 05:20:33,760
actually send ethereum or native
8685
05:20:33,760 --> 05:20:36,000
currency well it's with this call
8686
05:20:36,000 --> 05:20:38,080
command Now call is going to be one of
8687
05:20:38,080 --> 05:20:40,878
the first lower level commands that we
8688
05:20:40,878 --> 05:20:43,200
actually use in our solidity code
8689
05:20:43,200 --> 05:20:45,638
because this call function is actually
8690
05:20:45,638 --> 05:20:48,360
incredibly powerful and we can use it to
8691
05:20:48,360 --> 05:20:51,840
call virtually any function in all of
8692
05:20:51,840 --> 05:20:54,600
ethereum without even having to have the
8693
05:20:54,600 --> 05:20:57,000
ABI we'll learn the advanced ways to use
8694
05:20:57,000 --> 05:20:59,120
this call much later for now we're just
8695
05:20:59,120 --> 05:21:01,000
going to learn how to use it to send
8696
05:21:01,000 --> 05:21:02,878
ethereum or your native blockchain
8697
05:21:02,878 --> 05:21:05,240
currency call is going to look very
8698
05:21:05,240 --> 05:21:07,760
similar to send we're going to do
8699
05:21:07,760 --> 05:21:09,680
payable
8700
05:21:09,680 --> 05:21:11,160
message.
8701
05:21:11,160 --> 05:21:14,840
sender. call and this is where we'll put
8702
05:21:14,840 --> 05:21:17,040
any function information or any
8703
05:21:17,040 --> 05:21:18,760
information about the function we want
8704
05:21:18,760 --> 05:21:20,718
to call on some other contract we
8705
05:21:20,718 --> 05:21:22,600
actually don't want to call a function
8706
05:21:22,600 --> 05:21:24,680
so we're going to leave this blank we
8707
05:21:24,680 --> 05:21:26,320
can show that we're leaving it blank by
8708
05:21:26,320 --> 05:21:28,320
just putting in these two quotes here we
8709
05:21:28,320 --> 05:21:30,878
instead want to use this like a
8710
05:21:30,878 --> 05:21:32,958
transaction and as we saw in our
8711
05:21:32,958 --> 05:21:35,040
deployment there's always this message.
8712
05:21:35,040 --> 05:21:37,240
value bit so we're going to use this
8713
05:21:37,240 --> 05:21:39,480
call function as if it's a regular
8714
05:21:39,480 --> 05:21:41,600
transaction and we can add stuff like
8715
05:21:41,600 --> 05:21:44,718
message. Val so in here we're going to
8716
05:21:44,718 --> 05:21:47,638
add these squiggly brackets and we're
8717
05:21:47,638 --> 05:21:50,080
going to say
8718
05:21:50,080 --> 05:21:51,958
value
8719
05:21:51,958 --> 05:21:53,600
address
8720
05:21:53,600 --> 05:21:55,240
this
8721
05:21:55,240 --> 05:21:58,320
balance this call function returns
8722
05:21:58,320 --> 05:22:00,200
actually two variables and when a
8723
05:22:00,200 --> 05:22:02,718
function returns two variables we can
8724
05:22:02,718 --> 05:22:04,600
show that by placing them into
8725
05:22:04,600 --> 05:22:06,558
parentheses on the left hand side the
8726
05:22:06,558 --> 05:22:08,840
two variables it returns are going to be
8727
05:22:08,840 --> 05:22:12,240
a Boolean that we're going to call call
8728
05:22:12,240 --> 05:22:16,200
success and also a byes object called
8729
05:22:16,200 --> 05:22:19,400
Data returned since call allows us to
8730
05:22:19,400 --> 05:22:21,600
actually call different functions if
8731
05:22:21,600 --> 05:22:24,240
that function returns some data or
8732
05:22:24,240 --> 05:22:26,638
Returns value we're going to save that
8733
05:22:26,638 --> 05:22:29,798
in the data returned variable it also
8734
05:22:29,798 --> 05:22:32,360
returns call success where if the
8735
05:22:32,360 --> 05:22:34,520
function was successfully called this
8736
05:22:34,520 --> 05:22:38,520
will be true if not this will be false
8737
05:22:38,520 --> 05:22:41,878
and since bytes objects are arrays data
8738
05:22:41,878 --> 05:22:44,958
returns needs to be in memory now for
8739
05:22:44,958 --> 05:22:47,280
our code here we're actually not calling
8740
05:22:47,280 --> 05:22:49,360
a function so we don't really care about
8741
05:22:49,360 --> 05:22:52,000
data returned so similar to what we saw
8742
05:22:52,000 --> 05:22:54,320
with the price contract we can just go
8743
05:22:54,320 --> 05:22:56,480
ahead and delete that and leave the
8744
05:22:56,480 --> 05:22:58,920
comma to tell solidity yeah we know this
8745
05:22:58,920 --> 05:23:00,840
function returns two variables but we
8746
05:23:00,840 --> 05:23:03,600
only care about one and then similar to
8747
05:23:03,600 --> 05:23:05,760
the send piece above we're going to do
8748
05:23:05,760 --> 05:23:10,000
require call success call failed meaning
8749
05:23:10,000 --> 05:23:11,920
that we're requiring call success is
8750
05:23:11,920 --> 05:23:14,120
true otherwise we'll revert with an
8751
05:23:14,120 --> 05:23:16,480
error that says call failed now if
8752
05:23:16,480 --> 05:23:17,920
learning the difference between these
8753
05:23:17,920 --> 05:23:19,760
three is a little complicated for you
8754
05:23:19,760 --> 05:23:22,360
right now don't let that slow you down
8755
05:23:22,360 --> 05:23:24,120
feel free to come back to this after
8756
05:23:24,120 --> 05:23:25,878
you've learn more about how some of
8757
05:23:25,878 --> 05:23:27,718
these lower level functions work and a
8758
05:23:27,718 --> 05:23:29,520
little bit more about how Gas Works
8759
05:23:29,520 --> 05:23:32,120
solidity by example does a fantastic job
8760
05:23:32,120 --> 05:23:34,240
though of saying what the differences
8761
05:23:34,240 --> 05:23:36,160
between all three are transfer has a
8762
05:23:36,160 --> 05:23:38,958
maximum of 2300 gas and throws an error
8763
05:23:38,958 --> 05:23:42,160
if it fails send has a maximum of 2300
8764
05:23:42,160 --> 05:23:45,320
gas returns a Boolean if it fails call
8765
05:23:45,320 --> 05:23:48,000
forwards all gas so doesn't have a
8766
05:23:48,000 --> 05:23:51,440
capped gas and similar to send returns a
8767
05:23:51,440 --> 05:23:54,520
Boolean if it is successful or if it
8768
05:23:54,520 --> 05:23:58,080
fails as of recording right now using
8769
05:23:58,080 --> 05:24:01,240
call is the recommended way to actually
8770
05:24:01,240 --> 05:24:04,120
send and receive ethereum or your
8771
05:24:04,120 --> 05:24:06,360
blockchain native token for now if this
8772
05:24:06,360 --> 05:24:08,040
part's a little bit confusing for you
8773
05:24:08,040 --> 05:24:10,280
for now now just look at this and see Ah
8774
05:24:10,280 --> 05:24:13,240
that's how we send and transfer ethereum
8775
05:24:13,240 --> 05:24:15,638
or native blockchain currency tokens and
8776
05:24:15,638 --> 05:24:18,280
I'm going to delete this part for the
8777
05:24:18,280 --> 05:24:20,120
video but but I'll keep those comments
8778
05:24:20,120 --> 05:24:22,240
in the code repository associated with
8779
05:24:22,240 --> 05:24:24,440
this
8780
05:24:25,600 --> 05:24:28,000
course all right great and actually the
8781
05:24:28,000 --> 05:24:29,920
exact same code from that video we're
8782
05:24:29,920 --> 05:24:31,400
going to use for this as well so we're
8783
05:24:31,400 --> 05:24:33,920
going to use this call call success to
8784
05:24:33,920 --> 05:24:36,558
work with sending a balance however
8785
05:24:36,558 --> 05:24:38,638
there's a bit of an issue here right now
8786
05:24:38,638 --> 05:24:41,040
anybody can call this withdraw function
8787
05:24:41,040 --> 05:24:42,680
and take all the money out of this
8788
05:24:42,680 --> 05:24:45,080
contract we don't want that we want
8789
05:24:45,080 --> 05:24:46,920
anyone to be able to fund the contract
8790
05:24:46,920 --> 05:24:48,718
but we don't want anyone to be able to
8791
05:24:48,718 --> 05:24:50,480
withdraw money from the contract we only
8792
05:24:50,480 --> 05:24:52,040
want the owner of the contract to be
8793
05:24:52,040 --> 05:24:54,200
able to withdraw so how do we set this
8794
05:24:54,200 --> 05:24:55,638
contract up so that the withdrawal
8795
05:24:55,638 --> 05:24:57,878
function can only be called by the owner
8796
05:24:57,878 --> 05:24:59,878
of this contract well we want to set
8797
05:24:59,878 --> 05:25:01,558
this contract up so that whenever we
8798
05:25:01,558 --> 05:25:03,200
deploy it whenever we create this
8799
05:25:03,200 --> 05:25:05,798
contract an owner gets assigned to this
8800
05:25:05,798 --> 05:25:07,480
contract we assign some address to being
8801
05:25:07,480 --> 05:25:09,200
the owner and then then we add some
8802
05:25:09,200 --> 05:25:11,040
parameters so that withdraw can only be
8803
05:25:11,040 --> 05:25:13,040
called by that address so what we could
8804
05:25:13,040 --> 05:25:15,200
do is we could set up some function
8805
05:25:15,200 --> 05:25:17,320
called call me WR away and when we
8806
05:25:17,320 --> 05:25:18,920
deploy this contract we would just
8807
05:25:18,920 --> 05:25:20,638
immediately call this call me RightWay
8808
05:25:20,638 --> 05:25:23,000
function which will set us up as the
8809
05:25:23,000 --> 05:25:24,878
owner however that would take two
8810
05:25:24,878 --> 05:25:26,400
transactions and remember we're
8811
05:25:26,400 --> 05:25:27,920
Engineers we want to work incredibly
8812
05:25:27,920 --> 05:25:30,440
hard to be incredibly lazy so instead
8813
05:25:30,440 --> 05:25:31,920
solidity has something called a
8814
05:25:31,920 --> 05:25:33,878
Constructor and if you're familiar with
8815
05:25:33,878 --> 05:25:35,400
other programming languages a
8816
05:25:35,400 --> 05:25:37,920
Constructor is the exact same as really
8817
05:25:37,920 --> 05:25:39,958
every other programming language and the
8818
05:25:39,958 --> 05:25:42,200
Constructor is a keyword and a special
8819
05:25:42,200 --> 05:25:44,638
function in solidity so we can create a
8820
05:25:44,638 --> 05:25:46,280
Constructor function without the
8821
05:25:46,280 --> 05:25:48,280
function keyword we just call it
8822
05:25:48,280 --> 05:25:50,718
structor and we also don't even need the
8823
05:25:50,718 --> 05:25:52,878
public keyword you'll see remix even
8824
05:25:52,878 --> 05:25:55,280
highlights it pink this is going to be
8825
05:25:55,280 --> 05:25:56,520
that function it's going to be a
8826
05:25:56,520 --> 05:25:58,320
function that is immediately called
8827
05:25:58,320 --> 05:26:00,320
whenever you deploy your contract this
8828
05:26:00,320 --> 05:26:01,958
function will be called in the exact
8829
05:26:01,958 --> 05:26:05,280
same transaction that is used to deploy
8830
05:26:05,280 --> 05:26:07,280
your contract for example if I were to
8831
05:26:07,280 --> 05:26:09,520
take this minimum USD added in our
8832
05:26:09,520 --> 05:26:12,760
Constructor and say minimum USD equals 2
8833
05:26:12,760 --> 05:26:14,798
this minimum USD would immediately get
8834
05:26:14,798 --> 05:26:17,160
updated to two right after this contract
8835
05:26:17,160 --> 05:26:18,558
is deployed in that exact same
8836
05:26:18,558 --> 05:26:20,240
transaction since we want this
8837
05:26:20,240 --> 05:26:22,160
withdrawal function to only to be able
8838
05:26:22,160 --> 05:26:23,920
to be called by the owner of this
8839
05:26:23,920 --> 05:26:26,520
contract in our Constructor we can set
8840
05:26:26,520 --> 05:26:28,878
up an address right away to be the owner
8841
05:26:28,878 --> 05:26:31,000
of this contract so let's create a
8842
05:26:31,000 --> 05:26:33,920
global variable called address public
8843
05:26:33,920 --> 05:26:36,280
owner and then right in our Constructor
8844
05:26:36,280 --> 05:26:40,200
we'll say owner equals message. sender
8845
05:26:40,200 --> 05:26:42,160
message. sender of course being the
8846
05:26:42,160 --> 05:26:44,000
sender of the caller which in this
8847
05:26:44,000 --> 05:26:46,280
example is going to be the deployer of
8848
05:26:46,280 --> 05:26:47,958
the contract don't worry we're going to
8849
05:26:47,958 --> 05:26:49,878
demo all of this very soon to show you
8850
05:26:49,878 --> 05:26:51,360
everything that's going on if you want
8851
05:26:51,360 --> 05:26:53,480
to test all this right now absolutely go
8852
05:26:53,480 --> 05:26:55,080
for it just remember it's going to take
8853
05:26:55,080 --> 05:26:56,760
you a little bit longer on a test net
8854
05:26:56,760 --> 05:26:58,080
and I'm going to show you how it all
8855
05:26:58,080 --> 05:27:00,240
works anyways now that we have our owner
8856
05:27:00,240 --> 05:27:01,840
set up we can actually modify our
8857
05:27:01,840 --> 05:27:03,920
withdraw function so that only the owner
8858
05:27:03,920 --> 05:27:06,120
can call this function easily enough
8859
05:27:06,120 --> 05:27:07,760
we're already familiar with the require
8860
05:27:07,760 --> 05:27:10,320
keyword we could add a require the
8861
05:27:10,320 --> 05:27:12,600
message. sender of whoever calls this
8862
05:27:12,600 --> 05:27:15,360
withdrawal function must be equal to and
8863
05:27:15,360 --> 05:27:16,958
this is how you do equals in solidity
8864
05:27:16,958 --> 05:27:18,958
with this double equal sign a single
8865
05:27:18,958 --> 05:27:21,360
equal is set a double equals means
8866
05:27:21,360 --> 05:27:24,600
equals so message. sender must equal the
8867
05:27:24,600 --> 05:27:26,680
owner and if it's not the owner we could
8868
05:27:26,680 --> 05:27:29,760
revert with something like must be owner
8869
05:27:29,760 --> 05:27:31,280
awesome so now we have a quick way to
8870
05:27:31,280 --> 05:27:33,440
require that whoever calls the
8871
05:27:33,440 --> 05:27:35,760
withdrawal function is indeed the owner
8872
05:27:35,760 --> 05:27:38,760
awesome
8873
05:27:40,160 --> 05:27:42,000
but let's say we have a lot of admin
8874
05:27:42,000 --> 05:27:44,480
functions or only owner functions or
8875
05:27:44,480 --> 05:27:46,200
functions that should only be called by
8876
05:27:46,200 --> 05:27:48,360
the owner would we have to put this line
8877
05:27:48,360 --> 05:27:51,440
on every single function remember we
8878
05:27:51,440 --> 05:27:53,120
want to work incredibly hard to be
8879
05:27:53,120 --> 05:27:55,200
incredibly lazy we don't want to have to
8880
05:27:55,200 --> 05:27:56,958
copy paste this line to every one of
8881
05:27:56,958 --> 05:27:58,558
these functions and this is where
8882
05:27:58,558 --> 05:28:00,400
something called modifiers come into
8883
05:28:00,400 --> 05:28:02,320
play so we're going to go ahead and
8884
05:28:02,320 --> 05:28:04,480
actually delete this line and at the
8885
05:28:04,480 --> 05:28:06,440
bottom we're going to create our first
8886
05:28:06,440 --> 05:28:09,000
modifier a modifier is going to allow us
8887
05:28:09,000 --> 05:28:11,120
to create a keyword that we can put
8888
05:28:11,120 --> 05:28:13,680
right in the function declaration to add
8889
05:28:13,680 --> 05:28:15,480
some functionality very quickly and
8890
05:28:15,480 --> 05:28:17,878
easily to any function to create a
8891
05:28:17,878 --> 05:28:21,200
modifier you use the modifier keyword
8892
05:28:21,200 --> 05:28:23,000
and then you set it up very similarly to
8893
05:28:23,000 --> 05:28:24,798
a function so our modifier is going to
8894
05:28:24,798 --> 05:28:27,558
be called only owner we don't give it a
8895
05:28:27,558 --> 05:28:30,000
visibility like functions and in here we
8896
05:28:30,000 --> 05:28:32,280
can put our code so again we'll say
8897
05:28:32,280 --> 05:28:36,600
require the message. sender is equal to
8898
05:28:36,600 --> 05:28:40,320
not set to is equal to the owner and if
8899
05:28:40,320 --> 05:28:41,680
it's not the owner we're going to say
8900
05:28:41,680 --> 05:28:45,440
sender is not owner like this and then
8901
05:28:45,440 --> 05:28:47,200
underneath we're going to put this
8902
05:28:47,200 --> 05:28:50,160
little underscore with a semicolon what
8903
05:28:50,160 --> 05:28:52,160
we can do is we can take this only owner
8904
05:28:52,160 --> 05:28:54,638
keyword and stick it in the function
8905
05:28:54,638 --> 05:28:57,040
Declaration of our withdraw and what's
8906
05:28:57,040 --> 05:28:59,558
going to happen now is it's going to
8907
05:28:59,558 --> 05:29:02,520
execute what's in this modifier first
8908
05:29:02,520 --> 05:29:05,200
it's going to execute this require and
8909
05:29:05,200 --> 05:29:07,200
then this little underscore says and
8910
05:29:07,200 --> 05:29:09,040
then add whatever ever else you want to
8911
05:29:09,040 --> 05:29:10,760
do in the function so we're going to
8912
05:29:10,760 --> 05:29:13,520
execute this require then whatever else
8913
05:29:13,520 --> 05:29:15,480
is in the function and for our withdraw
8914
05:29:15,480 --> 05:29:16,718
a function it's going to be everything
8915
05:29:16,718 --> 05:29:20,040
else in here in our modifier if we had
8916
05:29:20,040 --> 05:29:22,718
the underscore above the require this
8917
05:29:22,718 --> 05:29:24,878
means that we would execute the code
8918
05:29:24,878 --> 05:29:27,000
inside the function first and then the
8919
05:29:27,000 --> 05:29:29,718
require so the order of your underscore
8920
05:29:29,718 --> 05:29:32,200
matters so now with this modifier
8921
05:29:32,200 --> 05:29:33,798
keyword in the withdraw function
8922
05:29:33,798 --> 05:29:35,958
whenever you call the withdraw function
8923
05:29:35,958 --> 05:29:38,240
we first go up there's a modifier I got
8924
05:29:38,240 --> 05:29:41,160
a drop down here we'll execute this oh
8925
05:29:41,160 --> 05:29:42,920
here's an underscore time to go back to
8926
05:29:42,920 --> 05:29:44,680
the function let's do what else is in
8927
05:29:44,680 --> 05:29:46,958
the rest of the code and then it'll come
8928
05:29:46,958 --> 05:29:48,718
back down to the only owner modifier and
8929
05:29:48,718 --> 05:29:50,798
say oh is there anything else to do oh
8930
05:29:50,798 --> 05:29:54,160
there's nothing else so I guess we're
8931
05:29:55,280 --> 05:29:57,718
good so let's see this all go through
8932
05:29:57,718 --> 05:29:59,600
end to end and remember you don't
8933
05:29:59,600 --> 05:30:01,680
actually have to deploy this to a test
8934
05:30:01,680 --> 05:30:03,480
net if you don't want to but if you want
8935
05:30:03,480 --> 05:30:05,160
to follow along feel free to do so of
8936
05:30:05,160 --> 05:30:07,360
course as well get started let's of
8937
05:30:07,360 --> 05:30:09,760
course compile file fundme Doo looks
8938
05:30:09,760 --> 05:30:12,638
good let's delete any contracts deployed
8939
05:30:12,638 --> 05:30:14,400
previously let's make sure we're on
8940
05:30:14,400 --> 05:30:16,840
injected provider menam mask and let's
8941
05:30:16,840 --> 05:30:19,000
make sure that we are on a test net we
8942
05:30:19,000 --> 05:30:21,360
are indeed let's make sure we have a
8943
05:30:21,360 --> 05:30:23,638
little bit of test net eth in our wallet
8944
05:30:23,638 --> 05:30:25,878
and we sure do and let's go down to the
8945
05:30:25,878 --> 05:30:27,520
contract and make sure we're on the
8946
05:30:27,520 --> 05:30:29,840
right contract if you try to deploy some
8947
05:30:29,840 --> 05:30:31,798
like an interface you'll get an alert
8948
05:30:31,798 --> 05:30:33,360
like this this contract might be
8949
05:30:33,360 --> 05:30:35,520
abstract blah blah blah so we're not
8950
05:30:35,520 --> 05:30:36,920
going to do the interface we're going to
8951
05:30:36,920 --> 05:30:39,520
do the fundme contract of course we'll
8952
05:30:39,520 --> 05:30:42,520
hit deploy metamask will pop up we'll go
8953
05:30:42,520 --> 05:30:45,200
ahead and hit confirm on the metamask
8954
05:30:45,200 --> 05:30:46,558
and then we're going to have to wait a
8955
05:30:46,558 --> 05:30:48,600
little bit for the contract to actually
8956
05:30:48,600 --> 05:30:50,200
finish deploying if we pull up the
8957
05:30:50,200 --> 05:30:51,760
terminal we can see the contract go
8958
05:30:51,760 --> 05:30:54,400
through and we can also see it in remix
8959
05:30:54,400 --> 05:30:56,920
here now we've got a number of buttons
8960
05:30:56,920 --> 05:31:00,000
in here we've got our red fund button of
8961
05:31:00,000 --> 05:31:02,240
course which is because we have our fund
8962
05:31:02,240 --> 05:31:04,320
function which is payable and this
8963
05:31:04,320 --> 05:31:07,600
allows us to send eth with this function
8964
05:31:07,600 --> 05:31:09,400
we have our withdrawal function which is
8965
05:31:09,400 --> 05:31:11,520
just orange because it is not payable
8966
05:31:11,520 --> 05:31:14,400
although it is going to be withdrawing
8967
05:31:14,400 --> 05:31:16,360
money out of the contract and then we
8968
05:31:16,360 --> 05:31:19,000
have our typical blue View and pure
8969
05:31:19,000 --> 05:31:20,798
functions the owner of course is going
8970
05:31:20,798 --> 05:31:23,760
to be our metamask since we are the ones
8971
05:31:23,760 --> 05:31:26,200
who deployed this contract minimum USD
8972
05:31:26,200 --> 05:31:28,878
is going to be five and these are of
8973
05:31:28,878 --> 05:31:31,400
course going to be empty we can call our
8974
05:31:31,400 --> 05:31:34,440
fund function only if we send some value
8975
05:31:34,440 --> 05:31:36,638
with it if we try to call fund without
8976
05:31:36,638 --> 05:31:38,680
any value we're going to get this gas
8977
05:31:38,680 --> 05:31:40,878
estimation error failed and we'll even
8978
05:31:40,878 --> 05:31:43,878
see didn't send enough eth in the ER log
8979
05:31:43,878 --> 05:31:45,680
so let's go ahead and cancel this again
8980
05:31:45,680 --> 05:31:47,040
we could send this but that would be a
8981
05:31:47,040 --> 05:31:50,200
huge waste of gas so we'll cancel it and
8982
05:31:50,200 --> 05:31:51,680
let's get a value that's going to be
8983
05:31:51,680 --> 05:31:55,558
enough so I believe 0.01 eth should be
8984
05:31:55,558 --> 05:31:58,040
enough let's say 0.01 eth it looks like
8985
05:31:58,040 --> 05:32:01,440
that's about $18 so back in remix let's
8986
05:32:01,440 --> 05:32:04,920
do 0.01 e in terms of wayy which is this
8987
05:32:04,920 --> 05:32:09,080
value here paste that in
8988
05:32:09,080 --> 05:32:10,878
and we'll scroll down now if we call
8989
05:32:10,878 --> 05:32:14,040
fund it does indeed go through and we
8990
05:32:14,040 --> 05:32:16,000
can go ahead and hit confirm on this as
8991
05:32:16,000 --> 05:32:18,638
well and we see that transaction pop up
8992
05:32:18,638 --> 05:32:20,760
on ether scan and we might have to wait
8993
05:32:20,760 --> 05:32:22,240
a little bit for this transaction to
8994
05:32:22,240 --> 05:32:24,558
finish finish going through finish
8995
05:32:24,558 --> 05:32:26,760
indexing Etc so let's give it a couple
8996
05:32:26,760 --> 05:32:29,040
minutes oh looks like it's gone through
8997
05:32:29,040 --> 05:32:31,480
fantastic we can even see in the fundme
8998
05:32:31,480 --> 05:32:34,600
contract the balance has gone up to 0.01
8999
05:32:34,600 --> 05:32:36,878
and we can see if we look at funders at
9000
05:32:36,878 --> 05:32:40,000
index zero we can see our address and if
9001
05:32:40,000 --> 05:32:42,680
we copy our address and paste it into
9002
05:32:42,680 --> 05:32:44,480
the mapping address to amount funded we
9003
05:32:44,480 --> 05:32:46,718
do indeed see an amount in here with
9004
05:32:46,718 --> 05:32:48,360
this transaction fund being called of
9005
05:32:48,360 --> 05:32:51,080
course on The testnet Ether scan we can
9006
05:32:51,080 --> 05:32:52,558
see all the data and information
9007
05:32:52,558 --> 05:32:54,120
associated with this and we can even
9008
05:32:54,120 --> 05:32:55,760
scroll down and see the input data we
9009
05:32:55,760 --> 05:32:58,040
can see that this was calling the fund
9010
05:32:58,040 --> 05:32:59,798
function we'll learn more about the
9011
05:32:59,798 --> 05:33:02,400
input data later so now we could do is
9012
05:33:02,400 --> 05:33:04,040
we could do the reverse we could go
9013
05:33:04,040 --> 05:33:06,680
ahead and withdraw and that should reset
9014
05:33:06,680 --> 05:33:09,120
the mapping and the array back down to
9015
05:33:09,120 --> 05:33:11,878
zero for our modifier to work we have to
9016
05:33:11,878 --> 05:33:14,160
use withdraw on this account if we
9017
05:33:14,160 --> 05:33:16,558
switch to an account that isn't the
9018
05:33:16,558 --> 05:33:18,280
owner of this contract and we go ahead
9019
05:33:18,280 --> 05:33:20,958
and reconnect and we scroll down we make
9020
05:33:20,958 --> 05:33:22,878
sure value is zero and we scroll down
9021
05:33:22,878 --> 05:33:25,360
and try to hit withdraw we'll see we get
9022
05:33:25,360 --> 05:33:27,520
gas estimation failed and we'll even say
9023
05:33:27,520 --> 05:33:29,798
sender is not the owner so we'll go
9024
05:33:29,798 --> 05:33:32,280
ahead and cancel that we'll switch back
9025
05:33:32,280 --> 05:33:34,160
to account one we'll make sure we're
9026
05:33:34,160 --> 05:33:36,400
working with account one now we'll call
9027
05:33:36,400 --> 05:33:38,798
withdraw we'll see ass does indeed pop
9028
05:33:38,798 --> 05:33:41,680
up and we can go ahead and confirm and
9029
05:33:41,680 --> 05:33:43,680
in just a minute we'll see the balance
9030
05:33:43,680 --> 05:33:46,280
reset and if we call our funders and
9031
05:33:46,280 --> 05:33:48,798
mapping they should also have been reset
9032
05:33:48,798 --> 05:33:50,878
so let's wait a little bit now if I try
9033
05:33:50,878 --> 05:33:52,558
to call address to amount funded with
9034
05:33:52,558 --> 05:33:55,160
that same address we now get zero and
9035
05:33:55,160 --> 05:33:57,440
now if I look at funders at index zero
9036
05:33:57,440 --> 05:34:01,120
it actually airs and this isn't
9037
05:34:02,400 --> 05:34:04,680
correct following our more advanced Lo
9038
05:34:04,680 --> 05:34:06,000
Concepts if you don't understand them
9039
05:34:06,000 --> 05:34:07,718
the first time don't let them stop you
9040
05:34:07,718 --> 05:34:09,718
they're not required to know to continue
9041
05:34:09,718 --> 05:34:11,440
the following is an excerpt from a
9042
05:34:11,440 --> 05:34:13,320
slightly older edition of this course
9043
05:34:13,320 --> 05:34:14,600
you'll see that I don't use named
9044
05:34:14,600 --> 05:34:17,120
Imports like a noob and a few other
9045
05:34:17,120 --> 05:34:18,280
pieces of the code look slightly
9046
05:34:18,280 --> 05:34:19,878
different but this next section we're
9047
05:34:19,878 --> 05:34:21,320
going to go over a lot of really
9048
05:34:21,320 --> 05:34:23,080
Advanced solidity pieces here that are
9049
05:34:23,080 --> 05:34:24,878
going to really Advanced solidity
9050
05:34:24,878 --> 05:34:26,320
fundamentals these are going to be
9051
05:34:26,320 --> 05:34:28,320
fantastic for saving gas making your
9052
05:34:28,320 --> 05:34:30,160
code look a lot cleaner and just better
9053
05:34:30,160 --> 05:34:32,120
coding practices overall for those of
9054
05:34:32,120 --> 05:34:33,718
you who are looking to go super far with
9055
05:34:33,718 --> 05:34:35,200
this definitely be sure to pay attention
9056
05:34:35,200 --> 05:34:36,920
to this section because this will make
9057
05:34:36,920 --> 05:34:38,480
you look like a bad as when you code
9058
05:34:38,480 --> 05:34:40,120
later on just remember when we say
9059
05:34:40,120 --> 05:34:42,558
JavaScript VM we just mean remix VM
9060
05:34:42,558 --> 05:34:44,000
additionally whenever we deploy to the
9061
05:34:44,000 --> 05:34:45,718
rink B test net just know that you
9062
05:34:45,718 --> 05:34:47,718
should be deploying to theoa test net or
9063
05:34:47,718 --> 05:34:49,638
whatever the most upto-date test net is
9064
05:34:49,638 --> 05:34:51,558
or just don't deploy to the test net and
9065
05:34:51,558 --> 05:34:53,840
just follow
9066
05:34:53,840 --> 05:34:55,798
along we're going to modify this
9067
05:34:55,798 --> 05:34:57,558
contract to make it a little bit more
9068
05:34:57,558 --> 05:34:59,120
professional it's not going to be end to
9069
05:34:59,120 --> 05:35:00,798
end amazing but it's going to be a
9070
05:35:00,798 --> 05:35:02,120
little bit better and you'll see why in
9071
05:35:02,120 --> 05:35:03,558
a minute so the first thing that we're
9072
05:35:03,558 --> 05:35:04,958
going to do is we're looking we're going
9073
05:35:04,958 --> 05:35:07,000
to look at some of these variables here
9074
05:35:07,000 --> 05:35:10,480
in particular owner and minimum USD
9075
05:35:10,480 --> 05:35:13,440
owner gets set one time in our contract
9076
05:35:13,440 --> 05:35:15,798
here and then it never changes again
9077
05:35:15,798 --> 05:35:19,920
minimum USD gets set one time even
9078
05:35:19,920 --> 05:35:22,320
outside of the Constructor if we have
9079
05:35:22,320 --> 05:35:25,240
variables that only get set one time we
9080
05:35:25,240 --> 05:35:28,000
can actually use some tools and solidity
9081
05:35:28,000 --> 05:35:30,240
to make them more gas efficient for now
9082
05:35:30,240 --> 05:35:32,240
let's compile our fundme contract and
9083
05:35:32,240 --> 05:35:34,160
then deploy it to a jscript virtual
9084
05:35:34,160 --> 05:35:36,000
machine remember we can go ahead and
9085
05:35:36,000 --> 05:35:38,760
deploy it right now however ever funding
9086
05:35:38,760 --> 05:35:40,400
and withdrawing and doing any of the
9087
05:35:40,400 --> 05:35:42,600
money stuff isn't going to work because
9088
05:35:42,600 --> 05:35:45,040
again we don't have a chain Lake Network
9089
05:35:45,040 --> 05:35:47,480
on our JavaScript VM so those aren't
9090
05:35:47,480 --> 05:35:48,878
going to work so well but for what we're
9091
05:35:48,878 --> 05:35:50,440
going to do right now we don't really
9092
05:35:50,440 --> 05:35:52,240
care so much here's what we do care
9093
05:35:52,240 --> 05:35:55,240
about we do care about how much gas this
9094
05:35:55,240 --> 05:35:57,718
costs to actually send we do care about
9095
05:35:57,718 --> 05:36:00,200
how much gas this costs to create right
9096
05:36:00,200 --> 05:36:04,878
now creating this contract costs about
9097
05:36:04,878 --> 05:36:07,638
$859,000 gas and we're going to add a
9098
05:36:07,638 --> 05:36:09,798
couple of Tricks right now to bring this
9099
05:36:09,798 --> 05:36:11,360
number down we're going to add some
9100
05:36:11,360 --> 05:36:12,920
stuff back in in a bit which will bring
9101
05:36:12,920 --> 05:36:15,120
it back up but for now we're going to
9102
05:36:15,120 --> 05:36:16,360
learn some tricks to bring this number
9103
05:36:16,360 --> 05:36:17,840
down the two tricks that we're going to
9104
05:36:17,840 --> 05:36:20,840
learn are the constant keyword and the
9105
05:36:20,840 --> 05:36:23,000
immutable keyword in their solidity
9106
05:36:23,000 --> 05:36:25,558
there are two keywords that make it so
9107
05:36:25,558 --> 05:36:27,840
that your variables can't be changed and
9108
05:36:27,840 --> 05:36:29,240
those keywords are constant and
9109
05:36:29,240 --> 05:36:31,480
immutable you can learn more about them
9110
05:36:31,480 --> 05:36:33,320
in the solidity documentation if you
9111
05:36:33,320 --> 05:36:35,600
assign a variable once outside of a
9112
05:36:35,600 --> 05:36:38,000
function and then never change it so if
9113
05:36:38,000 --> 05:36:40,558
if it's assigned at compile time you can
9114
05:36:40,558 --> 05:36:43,840
go ahead and add this constant keyword
9115
05:36:43,840 --> 05:36:45,798
we'll learn later about storage but when
9116
05:36:45,798 --> 05:36:47,920
you add a constant keyword this minimum
9117
05:36:47,920 --> 05:36:50,798
USD no longer takes up a storage spot
9118
05:36:50,798 --> 05:36:53,840
and is much easier to read to so now we
9119
05:36:53,840 --> 05:36:56,000
recompile this and we deploy this new
9120
05:36:56,000 --> 05:36:58,600
contract let's see if we saved any
9121
05:36:58,600 --> 05:37:02,160
gas we look in the transaction logs now
9122
05:37:02,160 --> 05:37:04,840
we can grab the transaction cost of how
9123
05:37:04,840 --> 05:37:06,878
much this cost to deploy and let's
9124
05:37:06,878 --> 05:37:09,200
compare it to how how much it was before
9125
05:37:09,200 --> 05:37:11,878
wow we saved almost 19,000 gas that's
9126
05:37:11,878 --> 05:37:13,920
almost as much gas as it cost to send
9127
05:37:13,920 --> 05:37:16,040
ethereum typically constant variables
9128
05:37:16,040 --> 05:37:18,440
have a different naming convention
9129
05:37:18,440 --> 05:37:19,798
typically you'll want to do them all
9130
05:37:19,798 --> 05:37:24,840
caps like Min eum underscore USD so all
9131
05:37:24,840 --> 05:37:27,040
caps with underscores so now let's just
9132
05:37:27,040 --> 05:37:29,440
find minimum USD and replace that with
9133
05:37:29,440 --> 05:37:32,000
all caps as well with this interaction
9134
05:37:32,000 --> 05:37:34,120
we know that this variable is a constant
9135
05:37:34,120 --> 05:37:35,920
variable and it's much cheaper to read
9136
05:37:35,920 --> 05:37:39,400
from now if we go ahead compile this and
9137
05:37:39,400 --> 05:37:42,360
redeploy in our fund Rec contract even
9138
05:37:42,360 --> 05:37:44,840
though this is a view function remember
9139
05:37:44,840 --> 05:37:47,878
view functions do have gas costs when
9140
05:37:47,878 --> 05:37:50,160
when called by a contract as a constant
9141
05:37:50,160 --> 05:37:52,680
variable we can see the execution cost
9142
05:37:52,680 --> 05:37:54,280
of this variable
9143
05:37:54,280 --> 05:37:57,600
21,45 gas so let's put a little note
9144
05:37:57,600 --> 05:38:00,558
right underneath it if we remove the
9145
05:38:00,558 --> 05:38:03,160
constant variable we delete this
9146
05:38:03,160 --> 05:38:07,200
contract we redeploy collect fundme and
9147
05:38:07,200 --> 05:38:10,000
we hit minimum USD again we can now see
9148
05:38:10,000 --> 05:38:11,958
how much gas this was cost if it wasn't
9149
05:38:11,958 --> 05:38:14,400
a constant variable we can see the gas
9150
05:38:14,400 --> 05:38:16,680
cost did indeed go up now on chains that
9151
05:38:16,680 --> 05:38:18,638
are much cheaper this gas difference
9152
05:38:18,638 --> 05:38:19,878
probably won't make that much of a
9153
05:38:19,878 --> 05:38:21,718
difference but on more expensive chains
9154
05:38:21,718 --> 05:38:23,320
like ethereum this is going to make a
9155
05:38:23,320 --> 05:38:26,360
big difference for example on ethereum
9156
05:38:26,360 --> 05:38:29,080
we can actually see current gas prices
9157
05:38:29,080 --> 05:38:31,000
on ethereum here we can see the current
9158
05:38:31,000 --> 05:38:34,958
gas price of ethereum is about 141 gay
9159
05:38:34,958 --> 05:38:37,558
so we'll go to our converter way to way
9160
05:38:37,558 --> 05:38:40,440
we'll copy the way price times this
9161
05:38:40,440 --> 05:38:43,000
we'll get the gas price of calling our
9162
05:38:43,000 --> 05:38:45,878
minimum USD which is this number here
9163
05:38:45,878 --> 05:38:48,680
which if we put back in our ethereum
9164
05:38:48,680 --> 05:38:51,760
unit converter we can see cost this much
9165
05:38:51,760 --> 05:38:54,638
gas and if we times that by the
9166
05:38:54,638 --> 05:38:56,840
approximate current price of ethereum
9167
05:38:56,840 --> 05:38:57,958
which is around
9168
05:38:57,958 --> 05:39:01,600
$3,000 calling minimum USD as a constant
9169
05:39:01,600 --> 05:39:04,680
is going to cost $9 calling this that at
9170
05:39:04,680 --> 05:39:07,638
a non-constant is going to cost almost
9171
05:39:07,638 --> 05:39:10,240
an entire dollar more you you can see
9172
05:39:10,240 --> 05:39:11,920
how all these little gas optimization
9173
05:39:11,920 --> 05:39:13,478
tricks are going to make your life a lot
9174
05:39:13,478 --> 05:39:15,160
better so let's keep this constant
9175
05:39:15,160 --> 05:39:17,520
keyword in here we'll learn more about
9176
05:39:17,520 --> 05:39:19,718
constant and storage in later sections
9177
05:39:19,718 --> 05:39:21,478
of this course now as you're just
9178
05:39:21,478 --> 05:39:23,120
getting started with this course and
9179
05:39:23,120 --> 05:39:26,478
with solidity do not struggle and do not
9180
05:39:26,478 --> 05:39:29,320
worry about making your contracts as gas
9181
05:39:29,320 --> 05:39:31,958
efficient as possible in the beginning
9182
05:39:31,958 --> 05:39:34,040
and especially right now just write your
9183
05:39:34,040 --> 05:39:36,440
contracts as best as you can once you
9184
05:39:36,440 --> 05:39:38,920
get really good at gas and once you get
9185
05:39:38,920 --> 05:39:41,320
much later on in the course and much
9186
05:39:41,320 --> 05:39:43,520
more advanced with solidity then you can
9187
05:39:43,520 --> 05:39:45,360
start going back and working on gas
9188
05:39:45,360 --> 05:39:47,798
optimizations but do not let gas
9189
05:39:47,798 --> 05:39:50,040
optimizations hold you back or if you
9190
05:39:50,040 --> 05:39:52,760
start stressing over it just let it go
9191
05:39:52,760 --> 05:39:54,798
don't worry about it and just write your
9192
05:39:54,798 --> 05:39:57,600
code as best you can so long story short
9193
05:39:57,600 --> 05:39:59,520
do not stress about gas optimizations
9194
05:39:59,520 --> 05:40:01,440
right now now another variable we only
9195
05:40:01,440 --> 05:40:03,478
set one time is going to be our owner
9196
05:40:03,478 --> 05:40:06,920
variable owner equals message. sender we
9197
05:40:06,920 --> 05:40:08,320
set this this one time in the
9198
05:40:08,320 --> 05:40:10,760
Constructor variables that we set one
9199
05:40:10,760 --> 05:40:13,040
time but outside of the same line that
9200
05:40:13,040 --> 05:40:14,958
they're declared and we set them for
9201
05:40:14,958 --> 05:40:17,240
example in the Constructor we can Mark
9202
05:40:17,240 --> 05:40:19,478
as a mutable typically a good convention
9203
05:40:19,478 --> 05:40:21,200
for marking immutable variables is going
9204
05:40:21,200 --> 05:40:24,240
to be doing I underscore so that we know
9205
05:40:24,240 --> 05:40:26,360
that these are immutable variables they
9206
05:40:26,360 --> 05:40:28,400
have very similar gas savings to the
9207
05:40:28,400 --> 05:40:30,558
constant keyword owner of course is a
9208
05:40:30,558 --> 05:40:32,600
variable that we can't set on the line
9209
05:40:32,600 --> 05:40:35,280
here because inside the global scope
9210
05:40:35,280 --> 05:40:37,558
there's no function going on how over
9211
05:40:37,558 --> 05:40:39,840
inside functions because inside the
9212
05:40:39,840 --> 05:40:41,400
global scope there's going to be no
9213
05:40:41,400 --> 05:40:43,400
message. sender there's only going to be
9214
05:40:43,400 --> 05:40:45,680
a message. sender when we're inside of a
9215
05:40:45,680 --> 05:40:48,160
function so inside here we might say I
9216
05:40:48,160 --> 05:40:50,680
owner equals mesh. sender and then of
9217
05:40:50,680 --> 05:40:52,958
course we'll scroll down and we'll
9218
05:40:52,958 --> 05:40:55,718
change this require only owner now
9219
05:40:55,718 --> 05:40:58,798
equals I owner now if we compile that
9220
05:40:58,798 --> 05:41:03,240
and deploy it we can see how much gas we
9221
05:41:03,240 --> 05:41:05,520
can see how much gas calling I owner is
9222
05:41:05,520 --> 05:41:08,440
going to be by with the IM muteness we
9223
05:41:08,440 --> 05:41:09,638
get
9224
05:41:09,638 --> 05:41:12,120
2158 which we'll go ahead and copy for
9225
05:41:12,120 --> 05:41:16,798
now and we'll put right here we'll say
9226
05:41:16,798 --> 05:41:19,280
immutable now if we remove the immutable
9227
05:41:19,280 --> 05:41:22,120
keyword let's close this
9228
05:41:22,120 --> 05:41:24,160
redeploy now if we scroll down to I
9229
05:41:24,160 --> 05:41:26,558
owner scroll up the logs we go down to
9230
05:41:26,558 --> 05:41:28,958
the call scroll down we see the
9231
05:41:28,958 --> 05:41:32,040
execution cost was much more so we'll do
9232
05:41:32,040 --> 05:41:36,718
double backslash paste that in here gas
9233
05:41:36,718 --> 05:41:39,680
we not on immutable so you want to keep
9234
05:41:39,680 --> 05:41:41,280
some of these tricks in mind when it
9235
05:41:41,280 --> 05:41:43,958
comes to storing variables the reason
9236
05:41:43,958 --> 05:41:45,920
that these two save gas is because
9237
05:41:45,920 --> 05:41:48,320
instead of storing these variables
9238
05:41:48,320 --> 05:41:50,160
inside of a storage slot we actually
9239
05:41:50,160 --> 05:41:52,120
store them directly into the bite code
9240
05:41:52,120 --> 05:41:53,878
of the contract and like I said don't
9241
05:41:53,878 --> 05:41:55,878
worry too much about that for now later
9242
05:41:55,878 --> 05:41:58,000
on in the course we'll teach you more
9243
05:41:58,000 --> 05:41:59,680
about storage and a lot of this
9244
05:41:59,680 --> 05:42:01,280
low-level stuff that comes with these
9245
05:42:01,280 --> 05:42:03,240
contracts but for now just know that
9246
05:42:03,240 --> 05:42:06,080
these exist and they're nice gas Savers
9247
05:42:06,080 --> 05:42:09,520
if you're only setting your VAR Ables
9248
05:42:09,558 --> 05:42:12,000
once all right great so we've just made
9249
05:42:12,000 --> 05:42:13,680
our contract a little bit more gas
9250
05:42:13,680 --> 05:42:15,760
efficient little gas efficiency
9251
05:42:15,760 --> 05:42:17,400
improvements are going to be Concepts I
9252
05:42:17,400 --> 05:42:19,280
sprinkle throughout this course and when
9253
05:42:19,280 --> 05:42:20,760
we get to the more advanced section I'm
9254
05:42:20,760 --> 05:42:23,080
going to break down exactly what's going
9255
05:42:23,080 --> 05:42:25,160
on and why all these gas efficiencies
9256
05:42:25,160 --> 05:42:26,600
exist and what's going on behind the
9257
05:42:26,600 --> 05:42:28,718
scenes for these gas efficiencies to
9258
05:42:28,718 --> 05:42:30,798
occur it's a little bit in the weeds
9259
05:42:30,798 --> 05:42:32,360
which is why I'm going to gloss over it
9260
05:42:32,360 --> 05:42:34,280
right now so if it's confusing don't
9261
05:42:34,280 --> 05:42:35,840
worry I wouldn't let these gas
9262
05:42:35,840 --> 05:42:37,360
efficiencies be the thing that's slow
9263
05:42:37,360 --> 05:42:39,320
you down awesome so we have these two
9264
05:42:39,320 --> 05:42:41,878
gas optimizations how else can we make
9265
05:42:41,878 --> 05:42:43,558
this contract a little bit more gas
9266
05:42:43,558 --> 05:42:45,440
efficient well one of the ways we can
9267
05:42:45,440 --> 05:42:47,400
make this more gas efficient is by
9268
05:42:47,400 --> 05:42:50,000
updating our requires right now with our
9269
05:42:50,000 --> 05:42:51,878
requir statement we actually have to
9270
05:42:51,878 --> 05:42:55,160
store this sender is not an owner as a
9271
05:42:55,160 --> 05:42:57,080
string array every single one of these
9272
05:42:57,080 --> 05:42:59,320
characters in this error log needs to
9273
05:42:59,320 --> 05:43:01,718
get stored individually this the string
9274
05:43:01,718 --> 05:43:03,638
may not seem very big but it's a lot
9275
05:43:03,638 --> 05:43:05,120
bigger than the alternative with what we
9276
05:43:05,120 --> 05:43:08,638
can do as of 0.8.4 solidity you can now
9277
05:43:08,638 --> 05:43:11,840
actually do custom errors for our
9278
05:43:11,840 --> 05:43:14,520
reverts we declare them at the top and
9279
05:43:14,520 --> 05:43:17,558
then use ifs instead of require and then
9280
05:43:17,558 --> 05:43:20,240
just add our revert statements this ends
9281
05:43:20,240 --> 05:43:22,000
up saving a lot of gas since we just
9282
05:43:22,000 --> 05:43:24,558
call the error code as opposed to
9283
05:43:24,558 --> 05:43:26,680
calling the entire string associated
9284
05:43:26,680 --> 05:43:29,240
with the error so for example with our
9285
05:43:29,240 --> 05:43:31,558
require down here and with actually with
9286
05:43:31,558 --> 05:43:34,280
all of our requires what we could do is
9287
05:43:34,280 --> 05:43:36,120
instead of having this require we could
9288
05:43:36,120 --> 05:43:39,840
create custom error so at the top what
9289
05:43:39,840 --> 05:43:42,638
we could do is we could say
9290
05:43:42,638 --> 05:43:45,920
error not
9291
05:43:45,920 --> 05:43:48,240
owner and you'll notice that this is
9292
05:43:48,240 --> 05:43:50,718
actually outside of the contract here
9293
05:43:50,718 --> 05:43:52,360
now what we can do is we can take this
9294
05:43:52,360 --> 05:43:54,680
eror not owner scroll down into our only
9295
05:43:54,680 --> 05:43:56,958
owner instead of doing a require we'll
9296
05:43:56,958 --> 05:44:00,638
do an if statement we'll say if message.
9297
05:44:00,638 --> 05:44:04,000
sender is not I
9298
05:44:04,000 --> 05:44:06,680
owner then we're going to go ahead and
9299
05:44:06,680 --> 05:44:09,040
reverse
9300
05:44:09,798 --> 05:44:13,160
with a not owner error this ends up
9301
05:44:13,160 --> 05:44:15,160
saving us a lot of gas since we don't
9302
05:44:15,160 --> 05:44:17,878
have to store and emit this long string
9303
05:44:17,878 --> 05:44:19,840
here now in a lot of code today you'll
9304
05:44:19,840 --> 05:44:21,878
still see require a lot of places
9305
05:44:21,878 --> 05:44:23,680
because these these custom errors are
9306
05:44:23,680 --> 05:44:25,760
pretty new in solidity so you'll want to
9307
05:44:25,760 --> 05:44:27,320
get used to writing it both ways I
9308
05:44:27,320 --> 05:44:29,240
wouldn't be surprised if in the future
9309
05:44:29,240 --> 05:44:31,360
the Syntax for some of these errors
9310
05:44:31,360 --> 05:44:33,000
looks like this so that it's more
9311
05:44:33,000 --> 05:44:35,000
readable but for now if you want to do a
9312
05:44:35,000 --> 05:44:36,840
more gas efficient way than requires you
9313
05:44:36,840 --> 05:44:38,760
can can use something like this we could
9314
05:44:38,760 --> 05:44:40,520
update all of our requires here for
9315
05:44:40,520 --> 05:44:42,320
these custom errors but for now I'm
9316
05:44:42,320 --> 05:44:43,638
going to leave both in just to show you
9317
05:44:43,638 --> 05:44:45,718
the differences this revert keyword does
9318
05:44:45,718 --> 05:44:48,280
the exact same thing that required does
9319
05:44:48,280 --> 05:44:50,120
without the conditional beforehand so
9320
05:44:50,120 --> 05:44:52,120
you can actually go ahead and and revert
9321
05:44:52,120 --> 05:44:54,280
any transaction or any function call in
9322
05:44:54,280 --> 05:44:57,080
the middle of the function
9323
05:44:57,280 --> 05:45:00,160
call now let's look at one more way to
9324
05:45:00,160 --> 05:45:02,000
improve this contract sometimes people
9325
05:45:02,000 --> 05:45:03,440
will try to interact with a contract
9326
05:45:03,440 --> 05:45:04,840
that takes ethereum or the native
9327
05:45:04,840 --> 05:45:07,000
blockchain token without actually going
9328
05:45:07,000 --> 05:45:08,600
going through the required function
9329
05:45:08,600 --> 05:45:10,718
calls that that are needed for example
9330
05:45:10,718 --> 05:45:13,280
on a JavaScript evm here I could
9331
05:45:13,280 --> 05:45:15,958
actually try to send this contract money
9332
05:45:15,958 --> 05:45:18,360
without calling the fund function
9333
05:45:18,360 --> 05:45:20,400
however if I were to do that what would
9334
05:45:20,400 --> 05:45:21,958
happen would our fund function get
9335
05:45:21,958 --> 05:45:24,240
triggered no it wouldn't get triggered
9336
05:45:24,240 --> 05:45:26,280
we wouldn't keep track of that fun we
9337
05:45:26,280 --> 05:45:28,440
wouldn't have that person's information
9338
05:45:28,440 --> 05:45:30,680
updated in this contract so if later on
9339
05:45:30,680 --> 05:45:32,520
we want to give rewards or something we
9340
05:45:32,520 --> 05:45:35,040
wouldn't know about those funders and
9341
05:45:35,040 --> 05:45:36,320
this wouldn't be great cuz people would
9342
05:45:36,320 --> 05:45:38,400
send our contract money without us ever
9343
05:45:38,400 --> 05:45:40,000
knowing and we wouldn't be able to give
9344
05:45:40,000 --> 05:45:42,920
them any credit or anything additionally
9345
05:45:42,920 --> 05:45:45,240
maybe they called the wrong function by
9346
05:45:45,240 --> 05:45:46,680
accident and they they weren't using
9347
05:45:46,680 --> 05:45:48,638
metamask and they weren't using a tool
9348
05:45:48,638 --> 05:45:50,120
to tell them hey this transaction is
9349
05:45:50,120 --> 05:45:52,040
likely going to fail so what can we do
9350
05:45:52,040 --> 05:45:55,798
in this case what happens if someone
9351
05:45:55,798 --> 05:45:57,638
sends this
9352
05:45:57,638 --> 05:46:01,798
contract eth without calling the fund
9353
05:46:01,798 --> 05:46:04,000
function right now if we were to send
9354
05:46:04,000 --> 05:46:06,320
this fundme contract eth it would just
9355
05:46:06,320 --> 05:46:07,718
go to the contract contract right and
9356
05:46:07,718 --> 05:46:09,320
this contract just wouldn't keep track
9357
05:46:09,320 --> 05:46:11,000
of those people but there's actually a
9358
05:46:11,000 --> 05:46:12,958
way for when people send money to this
9359
05:46:12,958 --> 05:46:15,040
contract or people call a function that
9360
05:46:15,040 --> 05:46:17,080
doesn't exist for us to still trigger
9361
05:46:17,080 --> 05:46:19,520
some code and now there are two special
9362
05:46:19,520 --> 05:46:23,280
functions in solidity one is called
9363
05:46:23,280 --> 05:46:26,200
receive and one is called the
9364
05:46:26,200 --> 05:46:28,440
fallback now in solidity there are
9365
05:46:28,440 --> 05:46:30,478
actually a number of special functions
9366
05:46:30,478 --> 05:46:32,080
and two of these special functions are
9367
05:46:32,080 --> 05:46:34,638
the receive special function and the
9368
05:46:34,638 --> 05:46:37,040
fallback special function a contract can
9369
05:46:37,040 --> 05:46:38,760
have at most one receive function
9370
05:46:38,760 --> 05:46:40,798
declared using the receive external
9371
05:46:40,798 --> 05:46:43,878
payable without the function keyword
9372
05:46:43,878 --> 05:46:45,280
this function cannot have arguments
9373
05:46:45,280 --> 05:46:46,680
cannot return anything and must have
9374
05:46:46,680 --> 05:46:49,200
external visibility and a payable State
9375
05:46:49,200 --> 05:46:51,478
mutability what does that actually mean
9376
05:46:51,478 --> 05:46:53,718
and or look like well let's create a
9377
05:46:53,718 --> 05:46:55,478
separate contract to go ahead and play
9378
05:46:55,478 --> 05:46:57,000
with this so in here we're going to
9379
05:46:57,000 --> 05:47:00,040
create a new file called fallback
9380
05:47:00,040 --> 05:47:02,680
example. soul and in here we're going to
9381
05:47:02,680 --> 05:47:05,080
add our basic pieces SPX license
9382
05:47:05,080 --> 05:47:08,600
identifier MIT pragma
9383
05:47:08,600 --> 05:47:11,520
solidity
9384
05:47:11,520 --> 05:47:15,798
0.8.7 and we'll do contract fallback
9385
05:47:15,798 --> 05:47:18,558
example like so feel free to pause the
9386
05:47:18,558 --> 05:47:20,600
video to catch up to this point once we
9387
05:47:20,600 --> 05:47:22,558
create our fallback contract let's
9388
05:47:22,558 --> 05:47:24,638
create a variable to go ahead and try to
9389
05:47:24,638 --> 05:47:28,160
test this function we'll create a un 256
9390
05:47:28,160 --> 05:47:31,080
public result variable and let's create
9391
05:47:31,080 --> 05:47:33,558
this receive function so we'll say
9392
05:47:33,558 --> 05:47:35,558
receive it's going to be an external
9393
05:47:35,558 --> 05:47:38,120
payable
9394
05:47:38,120 --> 05:47:40,718
function we don't add the function
9395
05:47:40,718 --> 05:47:43,840
keyword for receive since solidity knows
9396
05:47:43,840 --> 05:47:46,280
that receive is a special function
9397
05:47:46,280 --> 05:47:48,958
whenever we send ethereum or make a
9398
05:47:48,958 --> 05:47:52,080
transaction to this contract now as long
9399
05:47:52,080 --> 05:47:54,240
as there's no data associated with the
9400
05:47:54,240 --> 05:47:56,478
transaction this receive function will
9401
05:47:56,478 --> 05:47:58,840
get triggered what we can do in here now
9402
05:47:58,840 --> 05:48:03,080
is we can say result equals 1 so let's
9403
05:48:03,080 --> 05:48:04,878
go ahead and test this out on the
9404
05:48:04,878 --> 05:48:07,080
JavaScript virtual machine we compile
9405
05:48:07,080 --> 05:48:08,478
this so we're going to go ahead and
9406
05:48:08,478 --> 05:48:10,878
compile this we'll go deploy it on the
9407
05:48:10,878 --> 05:48:12,478
JavaScript virtual machine we're going
9408
05:48:12,478 --> 05:48:15,680
to deploy our fallback example and we're
9409
05:48:15,680 --> 05:48:17,718
going to see what result is initialized
9410
05:48:17,718 --> 05:48:19,840
to since we haven't set anything for
9411
05:48:19,840 --> 05:48:22,600
result result of course is initialized
9412
05:48:22,600 --> 05:48:25,878
to zero but what if we were to send this
9413
05:48:25,878 --> 05:48:28,558
contract some ethereum well receive
9414
05:48:28,558 --> 05:48:30,440
would go ahead and be triggered here we
9415
05:48:30,440 --> 05:48:32,040
can actually send this contract some
9416
05:48:32,040 --> 05:48:33,840
ethereum directly by working with this
9417
05:48:33,840 --> 05:48:35,718
low-level interactions bit here don't
9418
05:48:35,718 --> 05:48:38,120
worry about what call data means for now
9419
05:48:38,120 --> 05:48:40,440
just know that this area down here is a
9420
05:48:40,440 --> 05:48:42,558
way we can send and work with different
9421
05:48:42,558 --> 05:48:44,760
functions and we can add parameters to
9422
05:48:44,760 --> 05:48:47,120
this transaction by going up here and
9423
05:48:47,120 --> 05:48:49,200
adjusting the variables up here if we
9424
05:48:49,200 --> 05:48:52,000
keep call data blank it'll be the same
9425
05:48:52,000 --> 05:48:53,680
as if we were in metamask and just
9426
05:48:53,680 --> 05:48:55,558
hitting send and then choosing this
9427
05:48:55,558 --> 05:48:57,600
contract address again we can't actually
9428
05:48:57,600 --> 05:48:59,600
use metamask since this is a virtual
9429
05:48:59,600 --> 05:49:01,840
machine and not one of the networks that
9430
05:49:01,840 --> 05:49:03,600
we're working with so if I do for
9431
05:49:03,600 --> 05:49:07,160
example I change this value to one way
9432
05:49:07,160 --> 05:49:09,798
and I keep everything blank and I go
9433
05:49:09,798 --> 05:49:11,600
ahead and hit this transaction button
9434
05:49:11,600 --> 05:49:13,558
which again is going to be the same as
9435
05:49:13,558 --> 05:49:15,478
hitting this send button but only
9436
05:49:15,478 --> 05:49:17,718
sending one way what do you think will
9437
05:49:17,718 --> 05:49:20,920
happen well let's try it we can see in
9438
05:49:20,920 --> 05:49:23,520
the log area that we did indeed send a
9439
05:49:23,520 --> 05:49:26,400
transaction and if you look at the
9440
05:49:26,400 --> 05:49:28,000
description here you can even see it
9441
05:49:28,000 --> 05:49:32,160
says from so and so to fallback example.
9442
05:49:32,160 --> 05:49:34,558
receive it looks like it called our
9443
05:49:34,558 --> 05:49:36,718
receive function which should have
9444
05:49:36,718 --> 05:49:39,280
updated our result to one so if we hit
9445
05:49:39,280 --> 05:49:42,360
result now we can indeed see that result
9446
05:49:42,360 --> 05:49:44,958
has been updated to the value of one
9447
05:49:44,958 --> 05:49:46,798
well let's go ahead and delete this
9448
05:49:46,798 --> 05:49:49,200
let's deploy this contract again and
9449
05:49:49,200 --> 05:49:52,080
this time let's have value be zero does
9450
05:49:52,080 --> 05:49:54,400
receive get trigger this time so let's
9451
05:49:54,400 --> 05:49:57,080
pull this down let's hit transact let's
9452
05:49:57,080 --> 05:49:59,240
leave the call data blank we'll leave
9453
05:49:59,240 --> 05:50:02,200
value at zero so this will be the same
9454
05:50:02,200 --> 05:50:05,920
as if we had sent zero ethereum to this
9455
05:50:05,920 --> 05:50:07,840
contract let's hit
9456
05:50:07,840 --> 05:50:10,558
transact looks like that went through do
9457
05:50:10,558 --> 05:50:12,798
you think result is going to be one or
9458
05:50:12,798 --> 05:50:15,320
zero you thought one you were correct a
9459
05:50:15,320 --> 05:50:17,240
receive function gets triggered anytime
9460
05:50:17,240 --> 05:50:19,280
we send a transaction to this contract
9461
05:50:19,280 --> 05:50:22,478
now and we don't specify a function and
9462
05:50:22,478 --> 05:50:24,798
we keep the call data blank when working
9463
05:50:24,798 --> 05:50:26,958
with any other contract like fundme for
9464
05:50:26,958 --> 05:50:28,878
example when we call one of these
9465
05:50:28,878 --> 05:50:31,080
functions we're actually just Po in this
9466
05:50:31,080 --> 05:50:33,040
call data bit with certain data that
9467
05:50:33,040 --> 05:50:35,600
points to one of these functions up here
9468
05:50:35,600 --> 05:50:38,040
if we send a transaction and we add data
9469
05:50:38,040 --> 05:50:40,120
to it we could actually call one of
9470
05:50:40,120 --> 05:50:41,840
these functions now let's try this again
9471
05:50:41,840 --> 05:50:43,520
let's delete the contract again we'll
9472
05:50:43,520 --> 05:50:45,878
redeploy open this up result is
9473
05:50:45,878 --> 05:50:48,558
currently zero receive like I said only
9474
05:50:48,558 --> 05:50:51,200
is triggered if our call data to it is
9475
05:50:51,200 --> 05:50:53,878
blank now this time if I add some call
9476
05:50:53,878 --> 05:50:56,080
data to this transaction you think
9477
05:50:56,080 --> 05:50:57,840
receive will be triggered this time if
9478
05:50:57,840 --> 05:50:59,798
we hit transact and remix we actually
9479
05:50:59,798 --> 05:51:02,160
get a popup saying fallback function is
9480
05:51:02,160 --> 05:51:04,440
not defined this is because whenever
9481
05:51:04,440 --> 05:51:07,718
data is sent with a transaction solidity
9482
05:51:07,718 --> 05:51:10,360
says oh well since you're sending data
9483
05:51:10,360 --> 05:51:12,200
you're not looking for receive you're
9484
05:51:12,200 --> 05:51:14,120
looking for some function so let me look
9485
05:51:14,120 --> 05:51:16,798
for that function for you hm I don't see
9486
05:51:16,798 --> 05:51:19,878
any function that matches the 0x0 0 so
9487
05:51:19,878 --> 05:51:21,798
I'm going to look for your fallback
9488
05:51:21,798 --> 05:51:23,920
Function Remix is smart enough to know
9489
05:51:23,920 --> 05:51:26,320
that we don't have a fallback function
9490
05:51:26,320 --> 05:51:28,120
the second special function in solidity
9491
05:51:28,120 --> 05:51:30,360
is called the fallback function this is
9492
05:51:30,360 --> 05:51:33,040
very similar to the receive function
9493
05:51:33,040 --> 05:51:34,798
except for the fact that it can work
9494
05:51:34,798 --> 05:51:36,798
even when data is sent along with
9495
05:51:36,798 --> 05:51:38,478
transaction so our fallback will look
9496
05:51:38,478 --> 05:51:40,840
something like this
9497
05:51:40,840 --> 05:51:43,360
fallback
9498
05:51:43,360 --> 05:51:46,040
external
9499
05:51:46,040 --> 05:51:50,160
payable result equals 2 fallback is
9500
05:51:50,160 --> 05:51:51,478
another one of these functions where
9501
05:51:51,478 --> 05:51:52,920
we're not going to put the function
9502
05:51:52,920 --> 05:51:55,120
selector because solidity is expecting
9503
05:51:55,120 --> 05:51:57,080
this actually you're already familiar
9504
05:51:57,080 --> 05:51:59,760
with one other special function if we go
9505
05:51:59,760 --> 05:52:02,840
back to our funme our Constructor for
9506
05:52:02,840 --> 05:52:05,080
example is another type of special
9507
05:52:05,080 --> 05:52:07,160
function there's no function key keyword
9508
05:52:07,160 --> 05:52:09,440
solidity knows that this Constructor is
9509
05:52:09,440 --> 05:52:11,320
immediately called when we deploy this
9510
05:52:11,320 --> 05:52:13,400
contract so now we have our fallback
9511
05:52:13,400 --> 05:52:16,160
function let's go ahead and compile this
9512
05:52:16,160 --> 05:52:17,638
let's delete our old
9513
05:52:17,638 --> 05:52:19,920
contract let's go ahead and deploy this
9514
05:52:19,920 --> 05:52:23,440
new contract let's click here we hit
9515
05:52:23,440 --> 05:52:27,080
result we do indeed see it's set to zero
9516
05:52:27,080 --> 05:52:31,240
now if I add this 0x00 0 and I send this
9517
05:52:31,240 --> 05:52:33,840
and I hit transact this is equivalent to
9518
05:52:33,840 --> 05:52:35,840
calling our contract here without a
9519
05:52:35,840 --> 05:52:38,080
valid function so our contract goes hm I
9520
05:52:38,080 --> 05:52:39,280
don't recognize what you're trying to
9521
05:52:39,280 --> 05:52:41,120
tell me here I'm going to refer you to
9522
05:52:41,120 --> 05:52:44,320
our fallback now if we hit result we see
9523
05:52:44,320 --> 05:52:46,638
that it's been updated to two if we take
9524
05:52:46,638 --> 05:52:49,638
this away solidity will go hm it looks
9525
05:52:49,638 --> 05:52:51,080
like you're trying to send some ethereum
9526
05:52:51,080 --> 05:52:53,000
or call this contract without specifying
9527
05:52:53,000 --> 05:52:54,680
what you want to do well I have a
9528
05:52:54,680 --> 05:52:56,440
receive function so I'm just going to go
9529
05:52:56,440 --> 05:52:58,200
ahead and forward you to that so if we
9530
05:52:58,200 --> 05:53:01,040
call transact we hit result we see it
9531
05:53:01,040 --> 05:53:03,840
updates back to one add some data hit
9532
05:53:03,840 --> 05:53:06,878
transact we see it updates to two no
9533
05:53:06,878 --> 05:53:09,478
data updates to one solidity by
9534
05:53:09,478 --> 05:53:12,320
example.org has a wonderful little chart
9535
05:53:12,320 --> 05:53:14,558
that we can use to figure out whether
9536
05:53:14,558 --> 05:53:16,400
not receive is going to get triggered or
9537
05:53:16,400 --> 05:53:18,240
fallback is going to get triggered if it
9538
05:53:18,240 --> 05:53:20,360
is empty and there's a receive function
9539
05:53:20,360 --> 05:53:23,200
it'll call the receive function if it is
9540
05:53:23,200 --> 05:53:25,360
data and there's no receive function
9541
05:53:25,360 --> 05:53:27,680
it'll just go to the fallback function
9542
05:53:27,680 --> 05:53:29,360
and if there's no fallback function it
9543
05:53:29,360 --> 05:53:31,718
might just it might error out so this is
9544
05:53:31,718 --> 05:53:33,280
a lot of really fantastic information
9545
05:53:33,280 --> 05:53:36,600
here how can we apply this to our fundme
9546
05:53:36,600 --> 05:53:39,160
contract here well what we can do now in
9547
05:53:39,160 --> 05:53:41,878
our fundme is we can add these fallback
9548
05:53:41,878 --> 05:53:44,080
and receive functions just in case
9549
05:53:44,080 --> 05:53:45,798
somebody actually sends this contract
9550
05:53:45,798 --> 05:53:47,360
money instead of calling the fund
9551
05:53:47,360 --> 05:53:49,718
function correctly so what we can do is
9552
05:53:49,718 --> 05:53:51,840
let's add a receive function so if
9553
05:53:51,840 --> 05:53:53,798
somebody accidentally sends it money we
9554
05:53:53,798 --> 05:53:55,558
can still process the transaction we'll
9555
05:53:55,558 --> 05:53:59,958
say receive is going to be external
9556
05:53:59,958 --> 05:54:02,400
payable and we'll just have the receive
9557
05:54:02,400 --> 05:54:05,478
function call fund and we'll do the same
9558
05:54:05,478 --> 05:54:07,400
thing with our fall
9559
05:54:07,400 --> 05:54:12,440
function we'll have fallback external
9560
05:54:12,798 --> 05:54:14,920
payable we'll just have it automatically
9561
05:54:14,920 --> 05:54:18,400
call fund now if somebody accidentally
9562
05:54:18,400 --> 05:54:20,120
sends this money without calling our
9563
05:54:20,120 --> 05:54:23,120
fund function it'll still automatically
9564
05:54:23,120 --> 05:54:25,520
route them over to the fund function
9565
05:54:25,520 --> 05:54:27,520
this means too that if somebody doesn't
9566
05:54:27,520 --> 05:54:30,120
send us enough funding it'll that
9567
05:54:30,120 --> 05:54:32,240
transaction will still get reverted so
9568
05:54:32,240 --> 05:54:34,000
let's go ahead now and let's switch to
9569
05:54:34,000 --> 05:54:36,558
rink B to test this on a real test net
9570
05:54:36,558 --> 05:54:39,120
I'm on rink be and my metamask let's
9571
05:54:39,120 --> 05:54:42,240
switch over to injected web 3 and we'll
9572
05:54:42,240 --> 05:54:44,600
scroll down we'll choose our fundme
9573
05:54:44,600 --> 05:54:47,280
contract and we'll go ahead and deploy
9574
05:54:47,280 --> 05:54:50,160
this menam mask pops up I'm going to go
9575
05:54:50,160 --> 05:54:52,080
ahead and confirm the transaction and we
9576
05:54:52,080 --> 05:54:54,320
see our fundme contract here right now
9577
05:54:54,320 --> 05:54:56,040
we can see the own we can see I'm the
9578
05:54:56,040 --> 05:54:58,920
owner we can see minimum USD and we can
9579
05:54:58,920 --> 05:55:01,200
see of course that it's a blank contract
9580
05:55:01,200 --> 05:55:03,160
and there's nothing funded in here if we
9581
05:55:03,160 --> 05:55:05,200
copy the address and then go to Rinky
9582
05:55:05,200 --> 05:55:07,520
ether scan
9583
05:55:07,520 --> 05:55:10,718
paste the address in we can see that
9584
05:55:10,718 --> 05:55:12,600
there's no ether in here and the only
9585
05:55:12,600 --> 05:55:14,320
transaction associated with this has
9586
05:55:14,320 --> 05:55:16,040
been the contract creation we saw what
9587
05:55:16,040 --> 05:55:17,478
happened before when we hit the fund
9588
05:55:17,478 --> 05:55:21,080
function our contract was updated with a
9589
05:55:21,080 --> 05:55:23,280
new balance and that funer was added to
9590
05:55:23,280 --> 05:55:25,680
our array let's see what happens now if
9591
05:55:25,680 --> 05:55:28,160
we just directly send this contract
9592
05:55:28,160 --> 05:55:30,958
money without calling the fund function
9593
05:55:30,958 --> 05:55:34,120
here if we did this right our receive
9594
05:55:34,120 --> 05:55:36,958
function should pick it up and kick the
9595
05:55:36,958 --> 05:55:40,160
transaction over to fund so let's copy
9596
05:55:40,160 --> 05:55:42,400
this address we'll go to our
9597
05:55:42,400 --> 05:55:45,520
metamask we'll hit send paste the
9598
05:55:45,520 --> 05:55:49,120
address in here we'll do 0.02 eth again
9599
05:55:49,120 --> 05:55:51,400
because this should be more than the
9600
05:55:51,400 --> 05:55:55,000
minimum amount in USD we'll hit next
9601
05:55:55,000 --> 05:55:57,718
I'll go ahead and confirm this and after
9602
05:55:57,718 --> 05:56:00,840
a slight delay if we did this right well
9603
05:56:00,840 --> 05:56:03,120
we should see this transaction having
9604
05:56:03,120 --> 05:56:05,200
called the fund function here now that
9605
05:56:05,200 --> 05:56:07,320
our transaction has gone through and
9606
05:56:07,320 --> 05:56:08,760
after a brief delay and waiting for
9607
05:56:08,760 --> 05:56:11,478
ether scan to update we do indeed see
9608
05:56:11,478 --> 05:56:13,400
that our balance has updated to
9609
05:56:13,400 --> 05:56:16,200
0.02 which of course this makes sense
9610
05:56:16,200 --> 05:56:19,040
and we see in the transactions list here
9611
05:56:19,040 --> 05:56:20,400
we see that this actually went through
9612
05:56:20,400 --> 05:56:22,600
as a as a transfer instead of what's
9613
05:56:22,600 --> 05:56:24,680
calling the fund function let's go ahead
9614
05:56:24,680 --> 05:56:27,878
and remix and see if our funders was
9615
05:56:27,878 --> 05:56:30,840
updated it looks like it was at the
9616
05:56:30,840 --> 05:56:33,000
zeroth position of funders we have our
9617
05:56:33,000 --> 05:56:35,280
address and if we take our address and
9618
05:56:35,280 --> 05:56:37,680
pop it into address to amount funded we
9619
05:56:37,680 --> 05:56:40,360
can see exactly how much we had funded
9620
05:56:40,360 --> 05:56:41,718
this means that since we added this
9621
05:56:41,718 --> 05:56:43,520
receive function in here we
9622
05:56:43,520 --> 05:56:45,920
automatically had to call our fund
9623
05:56:45,920 --> 05:56:48,000
function up here so awesome work we were
9624
05:56:48,000 --> 05:56:50,680
able to add a receive function to help
9625
05:56:50,680 --> 05:56:53,000
people who accidentally call the wrong
9626
05:56:53,000 --> 05:56:55,120
function or accidentally send this
9627
05:56:55,120 --> 05:56:57,160
contract money instead of correctly
9628
05:56:57,160 --> 05:56:59,478
calling the fund function now if they
9629
05:56:59,478 --> 05:57:01,520
had directly called the fund function it
9630
05:57:01,520 --> 05:57:02,958
would have cost them a little bit less
9631
05:57:02,958 --> 05:57:04,760
gas but at least this time they're going
9632
05:57:04,760 --> 05:57:06,360
to get credit and added to to our
9633
05:57:06,360 --> 05:57:08,120
funders array for having sent our
9634
05:57:08,120 --> 05:57:10,878
funding contract
9635
05:57:11,040 --> 05:57:13,680
money we've even learned some Advanced
9636
05:57:13,680 --> 05:57:15,558
sections of solidity and this is going
9637
05:57:15,558 --> 05:57:17,080
to be the last time that we start our
9638
05:57:17,080 --> 05:57:19,200
projects in remix we're going to be
9639
05:57:19,200 --> 05:57:22,080
moving over to a code editor now where
9640
05:57:22,080 --> 05:57:23,638
we can get even more advanced with our
9641
05:57:23,638 --> 05:57:26,360
solidity and our setups for the most
9642
05:57:26,360 --> 05:57:28,280
part you've gone over the vast majority
9643
05:57:28,280 --> 05:57:30,360
of solidity Basics there are a number of
9644
05:57:30,360 --> 05:57:32,160
things that we still haven't learned yet
9645
05:57:32,160 --> 05:57:34,000
and the reason we haven't gone into them
9646
05:57:34,000 --> 05:57:35,760
is because they get more advanced and
9647
05:57:35,760 --> 05:57:37,400
understanding the real use doesn't
9648
05:57:37,400 --> 05:57:38,760
really make too much sense until a
9649
05:57:38,760 --> 05:57:40,280
little bit later some of the things that
9650
05:57:40,280 --> 05:57:42,920
we're going to go over are enims events
9651
05:57:42,920 --> 05:57:45,558
try catch function selectors ABI
9652
05:57:45,558 --> 05:57:47,798
encoding hashing and then U slash and
9653
05:57:47,798 --> 05:57:49,878
then u/ assembly however if you've
9654
05:57:49,878 --> 05:57:51,920
gotten this far you probably can read
9655
05:57:51,920 --> 05:57:54,080
most solidity code and understand what's
9656
05:57:54,080 --> 05:57:56,798
going on which is absolutely fantastic
9657
05:57:56,798 --> 05:57:58,478
so you should give yourself a huge round
9658
05:57:58,478 --> 05:58:00,440
of applause for getting this far in
9659
05:58:00,440 --> 05:58:02,400
doing this let's do a quick summary of
9660
05:58:02,400 --> 05:58:04,400
this more advanced section and make sure
9661
05:58:04,400 --> 05:58:06,360
we understand what we learned in Sol
9662
05:58:06,360 --> 05:58:08,080
there are a couple special functions
9663
05:58:08,080 --> 05:58:11,440
some of them are receive fallback and
9664
05:58:11,440 --> 05:58:13,638
Constructor these functions don't need
9665
05:58:13,638 --> 05:58:16,360
to have the function keyword and instead
9666
05:58:16,360 --> 05:58:19,080
can just be called like so receive and
9667
05:58:19,080 --> 05:58:21,360
fallback are two very special functions
9668
05:58:21,360 --> 05:58:24,040
if data is sent with a transaction and
9669
05:58:24,040 --> 05:58:26,160
no function was specified the
9670
05:58:26,160 --> 05:58:27,878
transaction will default to the fallback
9671
05:58:27,878 --> 05:58:29,718
function if that fallback function
9672
05:58:29,718 --> 05:58:32,320
exists if data is empty and there's a
9673
05:58:32,320 --> 05:58:34,840
receive function it'll call the receive
9674
05:58:34,840 --> 05:58:37,120
function there are a couple of keywords
9675
05:58:37,120 --> 05:58:39,440
that can help us save gas in the long
9676
05:58:39,440 --> 05:58:40,920
run some of those keywords are going to
9677
05:58:40,920 --> 05:58:43,320
be constant and immutable constant and
9678
05:58:43,320 --> 05:58:45,080
immutable are for variables that can
9679
05:58:45,080 --> 05:58:47,718
only be declared and updated once once
9680
05:58:47,718 --> 05:58:51,958
we say minimum USD is 50 * 1 E18 this
9681
05:58:51,958 --> 05:58:54,760
minimum USD can never be changed again
9682
05:58:54,760 --> 05:58:57,120
and this helps us save gas IM mutable
9683
05:58:57,120 --> 05:58:59,798
can also save gas similar to constant
9684
05:58:59,798 --> 05:59:01,400
however immutable variables can be
9685
05:59:01,400 --> 05:59:03,840
declared one time in the Constructor
9686
05:59:03,840 --> 05:59:06,718
once an immutable variable is declared
9687
05:59:06,718 --> 05:59:09,000
it can't be changed later on in fact if
9688
05:59:09,000 --> 05:59:11,240
we even tried to update an immutable
9689
05:59:11,240 --> 05:59:13,798
variable or a constant variable and we
9690
05:59:13,798 --> 05:59:15,878
compiled a compiler would give us an
9691
05:59:15,878 --> 05:59:18,600
error saying can't write to immutable
9692
05:59:18,600 --> 05:59:21,718
here or if we tried to change a constant
9693
05:59:21,718 --> 05:59:24,520
variable our compiler would say hey you
9694
05:59:24,520 --> 05:59:26,200
can't assign to a constant variable
9695
05:59:26,200 --> 05:59:28,558
sorry in remix if we want to send ether
9696
05:59:28,558 --> 05:59:30,120
to a contract that's on the JavaScript
9697
05:59:30,120 --> 05:59:32,280
virtual machine we can deploy that
9698
05:59:32,280 --> 05:59:34,520
contract and then in the contract we can
9699
05:59:34,520 --> 05:59:36,638
just hit the transact button without any
9700
05:59:36,638 --> 05:59:39,000
call data and update the value that we
9701
05:59:39,000 --> 05:59:40,840
send with the transaction if call data
9702
05:59:40,840 --> 05:59:43,360
is blank it'll trigger a receive
9703
05:59:43,360 --> 05:59:45,840
function if it exists but if there's
9704
05:59:45,840 --> 05:59:47,840
data that doesn't specify any of the
9705
05:59:47,840 --> 05:59:49,600
other functions it'll trigger the
9706
05:59:49,600 --> 05:59:53,080
fallback function
9707
06:00:18,040 --> 06:00:20,080
all right my code's done time to ship it
9708
06:00:20,080 --> 06:00:23,040
free box to you dog water zero earn zpr
9709
06:00:23,040 --> 06:00:24,558
in the age of AI debugging and getting
9710
06:00:24,558 --> 06:00:25,840
into software engineering has never been
9711
06:00:25,840 --> 06:00:27,600
easier here the exact six steps you need
9712
06:00:27,600 --> 06:00:29,080
to take to unblock yourself from any
9713
06:00:29,080 --> 06:00:30,520
software engineering area you'll ever
9714
06:00:30,520 --> 06:00:32,320
get number one Tinker try to pinpoint
9715
06:00:32,320 --> 06:00:33,958
your air you can usually use an AI buddy
9716
06:00:33,958 --> 06:00:35,360
to help you out here pinpointing your
9717
06:00:35,360 --> 06:00:36,840
air will potentially solve your problem
9718
06:00:36,840 --> 06:00:38,558
before even going to an AI and allow you
9719
06:00:38,558 --> 06:00:40,200
to craft a better question to an AI once
9720
06:00:40,200 --> 06:00:41,718
You' pinpointed the issue you can move
9721
06:00:41,718 --> 06:00:43,760
to step two which is ask your AI you can
9722
06:00:43,760 --> 06:00:46,520
use chat gbt find Bing's AI or if you
9723
06:00:46,520 --> 06:00:47,760
want to get wrong answers Google's
9724
06:00:47,760 --> 06:00:49,478
barred there's six principles to prompt
9725
06:00:49,478 --> 06:00:50,680
engineering so that you can get the best
9726
06:00:50,680 --> 06:00:52,798
out of your AI write clear and Specific
9727
06:00:52,798 --> 06:00:54,878
Instructions give as much context as
9728
06:00:54,878 --> 06:00:56,798
possible use delimiters to clearly
9729
06:00:56,798 --> 06:00:58,920
indicate distinct parts of the input and
9730
06:00:58,920 --> 06:01:00,478
especially look out for something called
9731
06:01:00,478 --> 06:01:02,360
hallucinations hallucinations are when
9732
06:01:02,360 --> 06:01:03,840
your AI gives you an output that it
9733
06:01:03,840 --> 06:01:05,080
thinks is right but it's completely
9734
06:01:05,080 --> 06:01:06,558
wrong for example if I write about
9735
06:01:06,558 --> 06:01:08,000
writing solidity and variant tests in
9736
06:01:08,000 --> 06:01:10,000
Foundry disgraces Us by saying we have
9737
06:01:10,000 --> 06:01:11,878
to mpm install it from open Zeppelin
9738
06:01:11,878 --> 06:01:13,120
these can be tough to spot but once you
9739
06:01:13,120 --> 06:01:14,600
try it out you'll see it doesn't work
9740
06:01:14,600 --> 06:01:16,040
and finally you want to understand the
9741
06:01:16,040 --> 06:01:17,478
limitations of the AI you're working
9742
06:01:17,478 --> 06:01:19,600
with and iterate constantly large
9743
06:01:19,600 --> 06:01:21,080
learning language models are trained on
9744
06:01:21,080 --> 06:01:22,958
human conversations so you can interact
9745
06:01:22,958 --> 06:01:23,920
with them as if you're having a
9746
06:01:23,920 --> 06:01:25,440
conversation but it's important to know
9747
06:01:25,440 --> 06:01:27,878
the limitations of these AIS as most AIS
9748
06:01:27,878 --> 06:01:29,718
have a limit on how many tokens or words
9749
06:01:29,718 --> 06:01:31,760
they can keep in context at one time AI
9750
06:01:31,760 --> 06:01:33,080
is trained off human language so if
9751
06:01:33,080 --> 06:01:34,240
you're good at asking other humans
9752
06:01:34,240 --> 06:01:35,280
questions you'll probably be good at
9753
06:01:35,280 --> 06:01:37,080
asking robots questions too asking
9754
06:01:37,080 --> 06:01:38,958
questions is a skill so keep practicing
9755
06:01:38,958 --> 06:01:40,280
I've got a link in the description to
9756
06:01:40,280 --> 06:01:42,520
learn. deeplearning.ai which is a free
9757
06:01:42,520 --> 06:01:44,040
course to help software Engineers be
9758
06:01:44,040 --> 06:01:46,320
better prompt Engineers now when the AIS
9759
06:01:46,320 --> 06:01:47,680
can't help you you'll have to go back to
9760
06:01:47,680 --> 06:01:49,478
the old standbys actually doing work
9761
06:01:49,478 --> 06:01:51,040
yourself and one of the first pieces of
9762
06:01:51,040 --> 06:01:52,760
work is reading the documentation you
9763
06:01:52,760 --> 06:01:54,000
probably should have done this already
9764
06:01:54,000 --> 06:01:56,040
however we can still use chat gbt cuz a
9765
06:01:56,040 --> 06:01:57,798
strategy that I constantly use is I'll
9766
06:01:57,798 --> 06:02:00,000
copy paste sections of the documentation
9767
06:02:00,000 --> 06:02:03,000
at chpts context and say some like the
9768
06:02:03,000 --> 06:02:04,760
above are the docs for Tool X based on
9769
06:02:04,760 --> 06:02:06,798
those docs how do I do why so Google
9770
06:02:06,798 --> 06:02:08,280
might be crying because chat PT is
9771
06:02:08,280 --> 06:02:09,878
eating its lunch but Google still has
9772
06:02:09,878 --> 06:02:12,120
what AI doesn't have the entire internet
9773
06:02:12,120 --> 06:02:14,160
previously anytime I ran into an issue I
9774
06:02:14,160 --> 06:02:15,400
prayed someone else to run into it
9775
06:02:15,400 --> 06:02:16,638
before I made a post on it so I could
9776
06:02:16,638 --> 06:02:18,400
Google search that exact issue there's a
9777
06:02:18,400 --> 06:02:19,878
new tool called fine that combines web
9778
06:02:19,878 --> 06:02:22,120
search with AI as it does a web search
9779
06:02:22,120 --> 06:02:23,718
and it crawls through all the data of
9780
06:02:23,718 --> 06:02:25,478
the sites reads them all and then gives
9781
06:02:25,478 --> 06:02:27,760
you an answer based off of what it reads
9782
06:02:27,760 --> 06:02:29,400
five asking a forum sometimes the
9783
06:02:29,400 --> 06:02:30,760
information just isn't out there and we
9784
06:02:30,760 --> 06:02:33,280
need to ask human beings we always want
9785
06:02:33,280 --> 06:02:35,120
to ask our question on a webbed index
9786
06:02:35,120 --> 06:02:37,760
Forum like stack exchange stack Overflow
9787
06:02:37,760 --> 06:02:39,798
pirana or Reddit this way webcrawlers
9788
06:02:39,798 --> 06:02:41,958
and more likely AIS can scrape the data
9789
06:02:41,958 --> 06:02:44,200
from these sites and learn from us that
9790
06:02:44,200 --> 06:02:45,558
way the next time we have this question
9791
06:02:45,558 --> 06:02:47,400
we can get our answers quickly asking on
9792
06:02:47,400 --> 06:02:48,840
Discord and Twitter are because your
9793
06:02:48,840 --> 06:02:49,920
knowledge will get lost to the
9794
06:02:49,920 --> 06:02:52,000
unsearchable hellhole of conversations
9795
06:02:52,000 --> 06:02:53,760
that Discord is and web crawlers don't
9796
06:02:53,760 --> 06:02:56,120
index them the super secret alpha is to
9797
06:02:56,120 --> 06:02:57,840
ask a question on stack exchange and
9798
06:02:57,840 --> 06:02:59,520
then post your stack exchange link to
9799
06:02:59,520 --> 06:03:01,680
Discord you should 100% always ask your
9800
06:03:01,680 --> 06:03:03,638
questions and format them with markdown
9801
06:03:03,638 --> 06:03:04,600
and if you're not sure how to do
9802
06:03:04,600 --> 06:03:06,920
markdown you can ask chat to to help you
9803
06:03:06,920 --> 06:03:08,638
format your questions and markdown ask
9804
06:03:08,638 --> 06:03:10,280
on the support GitHub or forum is the
9805
06:03:10,280 --> 06:03:11,638
tool you're working on open source
9806
06:03:11,638 --> 06:03:13,240
awesome ask a well formatted question on
9807
06:03:13,240 --> 06:03:15,280
their git page not open source never use
9808
06:03:15,280 --> 06:03:16,760
that tool again this is how we improve
9809
06:03:16,760 --> 06:03:18,440
our tools by creating issues engaging
9810
06:03:18,440 --> 06:03:19,718
with each other and even taking on
9811
06:03:19,718 --> 06:03:21,000
issues and contributing to the open
9812
06:03:21,000 --> 06:03:22,958
source code and then finally iterate do
9813
06:03:22,958 --> 06:03:24,760
all these same steps over again and as
9814
06:03:24,760 --> 06:03:26,878
always keep hopping through the code and
9815
06:03:26,878 --> 06:03:29,000
until next time stay riveting my fellow
9816
06:03:29,000 --> 06:03:31,630
blockchain ear
9817
06:03:31,630 --> 06:03:37,599
[Music]
9818
06:03:38,878 --> 06:03:40,600
all right fantastic so now we know a
9819
06:03:40,600 --> 06:03:42,638
little bit more about the different
9820
06:03:42,638 --> 06:03:44,760
tools and techniques we can use when we
9821
06:03:44,760 --> 06:03:47,040
do in fact get stuck we can use
9822
06:03:47,040 --> 06:03:50,080
something like chat TBT forums to ask
9823
06:03:50,080 --> 06:03:51,400
questions we obviously want to Google
9824
06:03:51,400 --> 06:03:54,280
search and especially for this course
9825
06:03:54,280 --> 06:03:56,000
you definitely want to make sure you use
9826
06:03:56,000 --> 06:03:57,638
the discussions Channel but I wanted to
9827
06:03:57,638 --> 06:04:00,040
give you some very specific tips about
9828
06:04:00,040 --> 06:04:02,798
working with this course number one
9829
06:04:02,798 --> 06:04:05,280
limit your self triaging to 15 or 20
9830
06:04:05,280 --> 06:04:07,558
minutes for example if we're trying to
9831
06:04:07,558 --> 06:04:09,840
compile our price converter doou and
9832
06:04:09,840 --> 06:04:11,680
maybe we forgot to add the address in
9833
06:04:11,680 --> 06:04:13,360
here right and we're going ahead and
9834
06:04:13,360 --> 06:04:15,000
compile and we're getting this error
9835
06:04:15,000 --> 06:04:17,638
this is exactly one argument expected
9836
06:04:17,638 --> 06:04:19,920
for explicit type conversion now this
9837
06:04:19,920 --> 06:04:21,280
should be pretty obvious what the error
9838
06:04:21,280 --> 06:04:23,478
is hey it's expecting one argument and
9839
06:04:23,478 --> 06:04:25,478
we obviously just removed that argument
9840
06:04:25,478 --> 06:04:27,120
but maybe you're having a really hard
9841
06:04:27,120 --> 06:04:28,680
time and you're trying all this
9842
06:04:28,680 --> 06:04:29,878
different stuff and you can't seem to
9843
06:04:29,878 --> 06:04:32,878
figure it out limit yourself to 15 or 20
9844
06:04:32,878 --> 06:04:35,718
minutes we do not want to be messing
9845
06:04:35,718 --> 06:04:38,320
around for so long that we can't figure
9846
06:04:38,320 --> 06:04:39,638
something out right something like this
9847
06:04:39,638 --> 06:04:42,920
would be very easy for us to compile
9848
06:04:42,920 --> 06:04:45,760
copy this error go to chat gbt and say
9849
06:04:45,760 --> 06:04:49,840
something like hey I'm getting an error
9850
06:04:49,840 --> 06:04:54,320
compiling my solidity here is the error
9851
06:04:54,320 --> 06:04:56,200
do three back ticks paste it in here
9852
06:04:56,200 --> 06:04:58,920
like that three back ticks is markdown
9853
06:04:58,920 --> 06:05:00,280
and like we said in the video we want to
9854
06:05:00,280 --> 06:05:03,558
use delimiters to clearly identify what
9855
06:05:03,558 --> 06:05:06,120
is Code versus what is not oops and I
9856
06:05:06,120 --> 06:05:08,120
hit and I hit enter whoops the daisy
9857
06:05:08,120 --> 06:05:09,240
we're actually going toit stop
9858
06:05:09,240 --> 06:05:11,840
generating and we're going to copy paste
9859
06:05:11,840 --> 06:05:13,680
the question again now we're going to
9860
06:05:13,680 --> 06:05:18,718
say here is my solidity it's wrong then
9861
06:05:18,718 --> 06:05:20,360
we'll copy the solidity
9862
06:05:20,360 --> 06:05:23,320
line once again three back ticks we'll
9863
06:05:23,320 --> 06:05:25,558
say solidity here we'll paste it in
9864
06:05:25,558 --> 06:05:27,718
three back ticks to end it hit enter and
9865
06:05:27,718 --> 06:05:29,680
it'll probably give us the answer here
9866
06:05:29,680 --> 06:05:30,798
and sure enough the error message
9867
06:05:30,798 --> 06:05:32,120
suggests that you need to provide an
9868
06:05:32,120 --> 06:05:33,840
address when using explicit type
9869
06:05:33,840 --> 06:05:36,080
conversion so we go ah okay whoops we
9870
06:05:36,080 --> 06:05:38,000
need to actually add an address in here
9871
06:05:38,000 --> 06:05:39,920
it gives us an example and we can go
9872
06:05:39,920 --> 06:05:41,440
back to our code and you know paste that
9873
06:05:41,440 --> 06:05:43,600
address in here and be good to go so
9874
06:05:43,600 --> 06:05:46,600
limit self triage to 15 20 minutes
9875
06:05:46,600 --> 06:05:48,400
that's going to be the first tip number
9876
06:05:48,400 --> 06:05:53,958
two don't be afraid to ask AI but don't
9877
06:05:53,958 --> 06:05:56,840
skip learning the purpose of this course
9878
06:05:56,840 --> 06:05:59,000
is for you to be able to learn
9879
06:05:59,000 --> 06:06:01,360
everything here AI is going to get
9880
06:06:01,360 --> 06:06:03,520
things wrong and it's only the people
9881
06:06:03,520 --> 06:06:05,760
who actually have learned what's going
9882
06:06:05,760 --> 06:06:07,160
on under the hood who are going to be
9883
06:06:07,160 --> 06:06:09,200
able to call out when AI gets something
9884
06:06:09,200 --> 06:06:11,520
wrong when AI gets something wrong it
9885
06:06:11,520 --> 06:06:13,558
does something called hallucinate and we
9886
06:06:13,558 --> 06:06:15,000
talked a little bit about that in that
9887
06:06:15,000 --> 06:06:17,320
AI video we just watched so
9888
06:06:17,320 --> 06:06:19,320
hallucinations are when the AI makes
9889
06:06:19,320 --> 06:06:21,200
something up that it thinks is right but
9890
06:06:21,200 --> 06:06:22,558
it's completely wrong and that's
9891
06:06:22,558 --> 06:06:24,440
something we absolutely need to watch
9892
06:06:24,440 --> 06:06:25,798
out for when we're coding and when we're
9893
06:06:25,798 --> 06:06:28,080
learning a perfect example of this is
9894
06:06:28,080 --> 06:06:30,000
with Foundry which is a tool we're about
9895
06:06:30,000 --> 06:06:32,000
to learn very soon in order for us to
9896
06:06:32,000 --> 06:06:34,600
install Foundry we actually need to run
9897
06:06:34,600 --> 06:06:37,080
this Command right getf founder. sh it's
9898
06:06:37,080 --> 06:06:39,840
the first thing that it tells us to do
9899
06:06:39,840 --> 06:06:42,798
at the time of recording chat gbt has
9900
06:06:42,798 --> 06:06:46,000
not been trained on The Foundry tool so
9901
06:06:46,000 --> 06:06:48,798
if I ask it a question like I'd like to
9902
06:06:48,798 --> 06:06:51,600
initialize a Foundry project with
9903
06:06:51,600 --> 06:06:56,798
solidity can you show me how to do that
9904
06:06:56,798 --> 06:06:58,760
and we'll let enter so the first
9905
06:06:58,760 --> 06:07:00,798
sentence out the gate is wrong it's not
9906
06:07:00,798 --> 06:07:03,120
aware of Foundry so it tried to guess
9907
06:07:03,120 --> 06:07:04,958
what Foundry was and it got it wrong it
9908
06:07:04,958 --> 06:07:06,718
is not a CR space framework for building
9909
06:07:06,718 --> 06:07:09,200
blockchains at all and it is directly
9910
06:07:09,200 --> 06:07:11,200
related to solidity so it's really
9911
06:07:11,200 --> 06:07:13,558
important that we use AI to augment our
9912
06:07:13,558 --> 06:07:16,200
learning but we don't skip over the
9913
06:07:16,200 --> 06:07:18,400
learning with AI it's really good to
9914
06:07:18,400 --> 06:07:20,798
bounce questions good ideas off of but
9915
06:07:20,798 --> 06:07:22,878
in order for us to be even able to
9916
06:07:22,878 --> 06:07:25,600
recognize when Foundry is hallucinating
9917
06:07:25,600 --> 06:07:27,400
and making stuff up we need to have that
9918
06:07:27,400 --> 06:07:29,478
knowledge ourself step three of course
9919
06:07:29,478 --> 06:07:32,520
use the forms web3 education. deev will
9920
06:07:32,520 --> 06:07:34,680
have a place for you to ask questions
9921
06:07:34,680 --> 06:07:36,120
but in the meantime definitely be sure
9922
06:07:36,120 --> 06:07:37,718
to use The Foundry full course
9923
06:07:37,718 --> 06:07:40,718
discussions use this to your advantage
9924
06:07:40,718 --> 06:07:42,760
and use this to help other people out
9925
06:07:42,760 --> 06:07:44,600
who have questions this is a community
9926
06:07:44,600 --> 06:07:45,600
project we're all going to be helping
9927
06:07:45,600 --> 06:07:47,440
each other out learning number three
9928
06:07:47,440 --> 06:07:50,558
Google the exact error if AI doesn't
9929
06:07:50,558 --> 06:07:53,120
know the forms aren't know Google the
9930
06:07:53,120 --> 06:07:54,958
exact error maybe somebody else has come
9931
06:07:54,958 --> 06:07:57,400
across this error previously asked the
9932
06:07:57,400 --> 06:07:59,638
question online and you can just Google
9933
06:07:59,638 --> 06:08:01,840
it and then of course post your question
9934
06:08:01,840 --> 06:08:03,920
in stack exchange or piranha and like we
9935
06:08:03,920 --> 06:08:06,160
said in that AI video you want to use
9936
06:08:06,160 --> 06:08:07,840
markdown and format your questions as
9937
06:08:07,840 --> 06:08:09,958
best as possible so if you're unfamiliar
9938
06:08:09,958 --> 06:08:11,160
with how to use markdown if you're
9939
06:08:11,160 --> 06:08:13,000
unfamiliar with how to format your
9940
06:08:13,000 --> 06:08:15,440
questions again please be sure to ask
9941
06:08:15,440 --> 06:08:18,440
chat GPT or some other AI how to best
9942
06:08:18,440 --> 06:08:20,080
format your question you can even simply
9943
06:08:20,080 --> 06:08:22,280
say ask chat GPT could you give me an
9944
06:08:22,280 --> 06:08:23,558
example of a well formatted stack
9945
06:08:23,558 --> 06:08:26,638
Overflow question with Cod or code and
9946
06:08:26,638 --> 06:08:28,718
it'll actually give us a really good
9947
06:08:28,718 --> 06:08:30,680
formatted question so it gives us the
9948
06:08:30,680 --> 06:08:33,520
question it formats the code for us it's
9949
06:08:33,520 --> 06:08:35,080
using this with the three back ticks
9950
06:08:35,080 --> 06:08:36,760
that I showed you in order to get this
9951
06:08:36,760 --> 06:08:38,040
code block here it's using three
9952
06:08:38,040 --> 06:08:41,400
backticks and it's being very verbose in
9953
06:08:41,400 --> 06:08:43,600
giving all the details of the question
9954
06:08:43,600 --> 06:08:46,160
so be sure to ask questions like chbt
9955
06:08:46,160 --> 06:08:48,798
awesome again let's say we're in here
9956
06:08:48,798 --> 06:08:51,320
compile get this error exactly when
9957
06:08:51,320 --> 06:08:52,840
argument expected for explicit type
9958
06:08:52,840 --> 06:08:55,680
conversion if we copy this error go to
9959
06:08:55,680 --> 06:08:58,600
Google we paste just the error in we'll
9960
06:08:58,600 --> 06:09:01,280
remove this our specific code looks like
9961
06:09:01,280 --> 06:09:03,000
the first thing we get in Google is
9962
06:09:03,000 --> 06:09:05,000
actually contract inheritance and we can
9963
06:09:05,000 --> 06:09:06,520
see that this is actually exactly the
9964
06:09:06,520 --> 06:09:08,360
error that we're getting it looks like
9965
06:09:08,360 --> 06:09:09,878
this does actually explain the answer
9966
06:09:09,878 --> 06:09:11,600
but it's a little bit confusing to
9967
06:09:11,600 --> 06:09:13,638
understand here so maybe you would copy
9968
06:09:13,638 --> 06:09:15,440
paste this into chat gpts context right
9969
06:09:15,440 --> 06:09:17,798
there's a lot of creative ways you can
9970
06:09:17,798 --> 06:09:19,958
approach debugging some of your issues
9971
06:09:19,958 --> 06:09:21,160
obviously when you're out in the wild
9972
06:09:21,160 --> 06:09:22,200
and you're actually building things
9973
06:09:22,200 --> 06:09:24,520
yourself obviously the education site
9974
06:09:24,520 --> 06:09:26,280
and the discussions channel of the giup
9975
06:09:26,280 --> 06:09:28,360
repo the people in these aren't going to
9976
06:09:28,360 --> 06:09:30,478
have context for the new creative thing
9977
06:09:30,478 --> 06:09:32,120
that you're working on so I want you to
9978
06:09:32,120 --> 06:09:33,958
get used to doing that methodology that
9979
06:09:33,958 --> 06:09:35,760
we're teaching here right asking your AI
9980
06:09:35,760 --> 06:09:37,958
buddy if your AI buddy doesn't know
9981
06:09:37,958 --> 06:09:40,080
Googling asking questions on stack
9982
06:09:40,080 --> 06:09:42,478
exchange ethereum asking questions on
9983
06:09:42,478 --> 06:09:44,440
piranha piran is arguably better because
9984
06:09:44,440 --> 06:09:46,360
you're asking your questions in a
9985
06:09:46,360 --> 06:09:48,240
decentralized location as opposed to a
9986
06:09:48,240 --> 06:09:50,718
centralized server but I definitely want
9987
06:09:50,718 --> 06:09:53,600
you to practice asking questions and go
9988
06:09:53,600 --> 06:09:56,240
to piran go to stack exchange make
9989
06:09:56,240 --> 06:09:58,478
accounts for these so that when you do
9990
06:09:58,478 --> 06:10:00,840
run into an issue because you will
9991
06:10:00,840 --> 06:10:02,440
you'll know where to post them high
9992
06:10:02,440 --> 06:10:03,840
encourage you to pause and post a
9993
06:10:03,840 --> 06:10:05,360
question on one of these forms right now
9994
06:10:05,360 --> 06:10:07,320
now just so that you get used to it just
9995
06:10:07,320 --> 06:10:09,440
so that you get out of your shell and
9996
06:10:09,440 --> 06:10:10,958
you're going to suck at asking questions
9997
06:10:10,958 --> 06:10:12,638
in the beginning and that's okay you
9998
06:10:12,638 --> 06:10:14,440
will get better at asking questions as
9999
06:10:14,440 --> 06:10:16,558
you continue with this course asking
10000
06:10:16,558 --> 06:10:20,160
good questions is a skill in itself and
10001
06:10:20,160 --> 06:10:23,040
if you learn how to ask very good
10002
06:10:23,040 --> 06:10:25,360
questions that's the secret sauce to
10003
06:10:25,360 --> 06:10:28,040
being amazing at AI prompting as well
10004
06:10:28,040 --> 06:10:29,878
now the final step in all of this is
10005
06:10:29,878 --> 06:10:32,280
actually going to be posting an issue on
10006
06:10:32,280 --> 06:10:35,638
GitHub SLG a surprisingly incred
10007
06:10:35,638 --> 06:10:37,958
important part of being a software
10008
06:10:37,958 --> 06:10:40,558
engineer and being a developer in web 3
10009
06:10:40,558 --> 06:10:42,600
is interacting with the community the
10010
06:10:42,600 --> 06:10:43,840
vast majority of these tools that we're
10011
06:10:43,840 --> 06:10:45,718
working with are going to be something
10012
06:10:45,718 --> 06:10:48,040
called open source meaning that the code
10013
06:10:48,040 --> 06:10:49,600
associated with them is actually
10014
06:10:49,600 --> 06:10:51,920
available for anybody to view this tool
10015
06:10:51,920 --> 06:10:53,080
Foundry that we're going to be working
10016
06:10:53,080 --> 06:10:56,000
with is one such example and if you see
10017
06:10:56,000 --> 06:10:57,958
it has this issues tab where there's
10018
06:10:57,958 --> 06:11:01,160
just a ton of issues people are posting
10019
06:11:01,160 --> 06:11:03,920
while using this tool this is how code
10020
06:11:03,920 --> 06:11:06,280
is able to be improved and move forward
10021
06:11:06,280 --> 06:11:07,958
all this code is public for people to
10022
06:11:07,958 --> 06:11:10,040
use and work with and if there's a
10023
06:11:10,040 --> 06:11:11,680
question that isn't answered you can
10024
06:11:11,680 --> 06:11:13,798
post here and tell the developers of
10025
06:11:13,798 --> 06:11:15,760
this tool hey I'm running into an issue
10026
06:11:15,760 --> 06:11:17,080
maybe we should make a project
10027
06:11:17,080 --> 06:11:18,798
Improvement I would say be very
10028
06:11:18,798 --> 06:11:20,240
respectful with the way that you make
10029
06:11:20,240 --> 06:11:22,040
issues you definitely want to do some
10030
06:11:22,040 --> 06:11:23,920
searching on issues to make sure that
10031
06:11:23,920 --> 06:11:25,798
nobody else has asked the question that
10032
06:11:25,798 --> 06:11:27,760
you're working with and be to sure to
10033
06:11:27,760 --> 06:11:29,680
use these other resources first like
10034
06:11:29,680 --> 06:11:31,760
panha like stack exchange but in the
10035
06:11:31,760 --> 06:11:33,080
future once you leave this court it's
10036
06:11:33,080 --> 06:11:34,680
going to be incredibly important for you
10037
06:11:34,680 --> 06:11:36,200
to participate in the ecosystem by
10038
06:11:36,200 --> 06:11:38,520
making issues by making poll requests
10039
06:11:38,520 --> 06:11:40,040
and actually improving some of the tools
10040
06:11:40,040 --> 06:11:40,958
that we're going to be working with
10041
06:11:40,958 --> 06:11:43,760
yourself even ethereum has a GitHub and
10042
06:11:43,760 --> 06:11:45,680
if there's any improvements that you
10043
06:11:45,680 --> 06:11:47,798
want to make you can add an EIP to
10044
06:11:47,798 --> 06:11:49,718
actually improve ethereum we'll talk
10045
06:11:49,718 --> 06:11:51,760
about EIP some more later you can
10046
06:11:51,760 --> 06:11:53,160
improve some of the clients that
10047
06:11:53,160 --> 06:11:55,040
ethereum runs so interacting with each
10048
06:11:55,040 --> 06:11:57,120
other is incredibly important and in
10049
06:11:57,120 --> 06:11:59,558
fact if you don't have a GitHub we are
10050
06:11:59,558 --> 06:12:02,000
going to get you set up with GitHub
10051
06:12:02,000 --> 06:12:04,638
right now because GitHub is the platform
10052
06:12:04,638 --> 06:12:07,440
that most developers use to share code
10053
06:12:07,440 --> 06:12:09,360
and write code and interact with code in
10054
06:12:09,360 --> 06:12:11,120
between each other so if you don't have
10055
06:12:11,120 --> 06:12:13,280
a GitHub let's sign up right now and
10056
06:12:13,280 --> 06:12:15,280
we're going to use the GitHub to create
10057
06:12:15,280 --> 06:12:17,600
our own portfolios of all the different
10058
06:12:17,600 --> 06:12:19,638
cool coding projects that we've created
10059
06:12:19,638 --> 06:12:21,878
this way when you go to apply for a job
10060
06:12:21,878 --> 06:12:23,360
you can say hey go look at my GitHub
10061
06:12:23,360 --> 06:12:25,320
I've got all these really cool projects
10062
06:12:25,320 --> 06:12:26,798
so we're going to make you a GitHub
10063
06:12:26,798 --> 06:12:28,240
right now if you don't have an email
10064
06:12:28,240 --> 06:12:29,558
you're going to need an email I made a
10065
06:12:29,558 --> 06:12:31,638
burner account just for this video and
10066
06:12:31,638 --> 06:12:32,760
I'm also going to walk you through
10067
06:12:32,760 --> 06:12:34,558
formatting a question and I know I'm
10068
06:12:34,558 --> 06:12:36,718
belaboring the point here but I really
10069
06:12:36,718 --> 06:12:38,760
really want to stress the importance of
10070
06:12:38,760 --> 06:12:41,280
formatting these questions really well
10071
06:12:41,280 --> 06:12:42,680
so we're actually going to show a clip
10072
06:12:42,680 --> 06:12:44,440
from my past video so we're going to be
10073
06:12:44,440 --> 06:12:46,320
using the full blockchain cility course
10074
06:12:46,320 --> 06:12:48,680
JS but again for this video just be sure
10075
06:12:48,680 --> 06:12:50,320
to use the GitHub repo associated with
10076
06:12:50,320 --> 06:12:52,478
this course and not that other old
10077
06:12:52,478 --> 06:12:57,320
GitHub repo all right let's watch this
10078
06:13:02,558 --> 06:13:04,638
video in fact if you haven't already
10079
06:13:04,638 --> 06:13:06,478
let's sign up for for GitHub right now
10080
06:13:06,478 --> 06:13:08,360
and let me walk you through formatting
10081
06:13:08,360 --> 06:13:09,760
one of these questions because the
10082
06:13:09,760 --> 06:13:11,680
better you format your questions the
10083
06:13:11,680 --> 06:13:13,080
better chance you have of actually
10084
06:13:13,080 --> 06:13:14,680
getting the answer and remember when
10085
06:13:14,680 --> 06:13:16,240
asking questions on these forums when
10086
06:13:16,240 --> 06:13:18,760
asking questions in these discussion
10087
06:13:18,760 --> 06:13:20,478
communities people answer these
10088
06:13:20,478 --> 06:13:21,760
questions out of the goodness of their
10089
06:13:21,760 --> 06:13:23,240
heart right so if you don't get a
10090
06:13:23,240 --> 06:13:25,280
response there's a chance that maybe
10091
06:13:25,280 --> 06:13:27,478
nobody knows maybe it's your question
10092
06:13:27,478 --> 06:13:30,120
isn't formatted very well and Etc so
10093
06:13:30,120 --> 06:13:31,680
we're going to learn how to ask really
10094
06:13:31,680 --> 06:13:33,240
good questions here and if you're new to
10095
06:13:33,240 --> 06:13:35,718
blockchain do not skip this section okay
10096
06:13:35,718 --> 06:13:36,840
this is going to be that piece that's
10097
06:13:36,840 --> 06:13:38,200
going to give you the superpower to
10098
06:13:38,200 --> 06:13:40,478
unblock yourself from any coding issue
10099
06:13:40,478 --> 06:13:42,878
you run into so don't skip this part be
10100
06:13:42,878 --> 06:13:44,638
sure to follow along okay so if you
10101
06:13:44,638 --> 06:13:46,200
don't have a GitHub already you do need
10102
06:13:46,200 --> 06:13:48,240
an email to get started so I'm going to
10103
06:13:48,240 --> 06:13:50,360
go ahead and sign in I made a burner
10104
06:13:50,360 --> 06:13:52,120
account just for this video so what
10105
06:13:52,120 --> 06:13:52,958
we're going to do we're going to go
10106
06:13:52,958 --> 06:13:57,240
ahead and sign up GitHub enter your
10107
06:14:02,958 --> 06:14:05,360
email and we hit create account they're
10108
06:14:05,360 --> 06:14:06,798
going to send us an email so we're going
10109
06:14:06,798 --> 06:14:08,440
to come back to our email going to get
10110
06:14:08,440 --> 06:14:11,520
our launch code here paste it
10111
06:14:11,520 --> 06:14:15,360
in answer a little bit of
10112
06:14:15,680 --> 06:14:17,920
information we're going to choose the
10113
06:14:17,920 --> 06:14:18,798
free
10114
06:14:18,798 --> 06:14:21,280
version and fantastic we've now created
10115
06:14:21,280 --> 06:14:23,878
a GitHub
10116
06:14:25,200 --> 06:14:27,478
profile awesome so now we've created a
10117
06:14:27,478 --> 06:14:29,760
GitHub so I'm actually using a GitHub
10118
06:14:29,760 --> 06:14:31,718
that I used in my last course so that's
10119
06:14:31,718 --> 06:14:33,200
why I have all these repositories over
10120
06:14:33,200 --> 06:14:34,718
here now in order to create a new
10121
06:14:34,718 --> 06:14:36,240
discussion disc Over The Foundry full
10122
06:14:36,240 --> 06:14:38,200
course f23 let's go over to the
10123
06:14:38,200 --> 06:14:40,520
discussions tab we'll hit new discussion
10124
06:14:40,520 --> 06:14:42,440
and we'll hit General and I'll say
10125
06:14:42,440 --> 06:14:45,080
something like test discussion be like
10126
06:14:45,080 --> 06:14:48,680
feel free to say hello here start
10127
06:14:48,680 --> 06:14:51,160
discussion now I'm going to show you a
10128
06:14:51,160 --> 06:14:53,400
question that's formatted poorly and I
10129
06:14:53,400 --> 06:14:55,040
want you to never ever ever ask a
10130
06:14:55,040 --> 06:14:56,760
question like this and if you see
10131
06:14:56,760 --> 06:14:58,280
somebody ask a question like this please
10132
06:14:58,280 --> 06:14:59,600
help them format their question
10133
06:14:59,600 --> 06:15:03,680
correctly hey why my code not be good
10134
06:15:03,680 --> 06:15:06,160
and then let's just have it be issue
10135
06:15:06,160 --> 06:15:08,440
like this right what's wrong wrong with
10136
06:15:08,440 --> 06:15:11,920
this okay well why my code not be good
10137
06:15:11,920 --> 06:15:14,120
obviously isn't clear what's going on
10138
06:15:14,120 --> 06:15:16,718
the code isn't formatted well and even
10139
06:15:16,718 --> 06:15:18,400
an AI would have a hard time answering
10140
06:15:18,400 --> 06:15:20,320
this so let's fix this to be a little
10141
06:15:20,320 --> 06:15:22,680
bit better as we know we want to copy
10142
06:15:22,680 --> 06:15:24,680
the exact error we're getting so we'll
10143
06:15:24,680 --> 06:15:27,040
say We'll copy the error we'll go back
10144
06:15:27,040 --> 06:15:30,558
we'll say I am receiving this error
10145
06:15:30,558 --> 06:15:32,520
we'll do the three little back ticks
10146
06:15:32,520 --> 06:15:35,520
paste our error right in here like that
10147
06:15:35,520 --> 06:15:37,120
actually let's be even more exposit I'm
10148
06:15:37,120 --> 06:15:40,000
receiving this error while compiling
10149
06:15:40,000 --> 06:15:42,440
here's my code re betic we'll put
10150
06:15:42,440 --> 06:15:45,600
solidity here copy the whole line that
10151
06:15:45,600 --> 06:15:49,000
is erroring paste it in here and someone
10152
06:15:49,000 --> 06:15:52,520
help me figure out what the issue is
10153
06:15:52,520 --> 06:15:54,200
right and you see how this is much much
10154
06:15:54,200 --> 06:15:56,920
better right we have these two blocks
10155
06:15:56,920 --> 06:15:58,320
that pop up because we did the back
10156
06:15:58,320 --> 06:16:01,440
ticks and the secret is that this is
10157
06:16:01,440 --> 06:16:03,000
going to get you a much better answer
10158
06:16:03,000 --> 06:16:06,798
from an AI as well right if we edit this
10159
06:16:06,798 --> 06:16:09,120
we can copy the whole thing in markdown
10160
06:16:09,120 --> 06:16:12,240
go over to chat jbt paste it in zoom out
10161
06:16:12,240 --> 06:16:14,160
a little bit and we're going to get it
10162
06:16:14,160 --> 06:16:15,680
actually an answer hey you're receiving
10163
06:16:15,680 --> 06:16:16,878
this air because you're trying to create
10164
06:16:16,878 --> 06:16:18,878
an instance of aggregator V in phas
10165
06:16:18,878 --> 06:16:20,878
without providing the necessary argument
10166
06:16:20,878 --> 06:16:22,920
blah blah blah oh and it actually gives
10167
06:16:22,920 --> 06:16:24,638
an updated version of that but it helps
10168
06:16:24,638 --> 06:16:27,000
us out here so ask format your questions
10169
06:16:27,000 --> 06:16:29,320
correctly you will get better answers
10170
06:16:29,320 --> 06:16:31,558
from both AIS and humans and I know I'm
10171
06:16:31,558 --> 06:16:32,878
spending a long time on this but I
10172
06:16:32,878 --> 06:16:34,160
really really need you to understand
10173
06:16:34,160 --> 06:16:36,520
that the secret to prompt engineering is
10174
06:16:36,520 --> 06:16:39,000
actually just being able to ask better
10175
06:16:39,000 --> 06:16:41,680
formatted questions with human beings
10176
06:16:41,680 --> 06:16:43,520
and it's better for interacting with
10177
06:16:43,520 --> 06:16:45,520
human beings as well now the other thing
10178
06:16:45,520 --> 06:16:47,760
that I did really well here was I only
10179
06:16:47,760 --> 06:16:49,958
posted the relevant code to the error
10180
06:16:49,958 --> 06:16:51,718
that I was getting what we see a lot of
10181
06:16:51,718 --> 06:16:53,440
people do is they just copy paste their
10182
06:16:53,440 --> 06:16:55,920
entire code base into here this is not
10183
06:16:55,920 --> 06:16:57,280
very helpful as it's going to make
10184
06:16:57,280 --> 06:16:59,000
somebody who wants to help you their job
10185
06:16:59,000 --> 06:17:01,798
a lot harder if they have to read your
10186
06:17:01,798 --> 06:17:04,958
entire code base right we reply here
10187
06:17:04,958 --> 06:17:06,400
this is so much more reading for them to
10188
06:17:06,400 --> 06:17:08,000
do it's going to take them a lot longer
10189
06:17:08,000 --> 06:17:10,200
and they might not actually read it and
10190
06:17:10,200 --> 06:17:11,478
we didn't actually highlight this with
10191
06:17:11,478 --> 06:17:13,520
the back ticks and it goes the same
10192
06:17:13,520 --> 06:17:15,840
thing with AI if you give your AI too
10193
06:17:15,840 --> 06:17:19,160
much text it can't read all of the text
10194
06:17:19,160 --> 06:17:21,400
because again some of these AIS have
10195
06:17:21,400 --> 06:17:23,280
limitations in how much text they can
10196
06:17:23,280 --> 06:17:24,680
read so it's the exact same thing with
10197
06:17:24,680 --> 06:17:26,760
working with human beings so feel free
10198
06:17:26,760 --> 06:17:29,040
to take some time to either in chat BT
10199
06:17:29,040 --> 06:17:31,440
or whatever AI you're using or in this
10200
06:17:31,440 --> 06:17:34,240
test discussion forum to post some well
10201
06:17:34,240 --> 06:17:35,718
formatted question questions and
10202
06:17:35,718 --> 06:17:38,440
remember you can use AI to help you get
10203
06:17:38,440 --> 06:17:40,638
those formatted questions in markdown be
10204
06:17:40,638 --> 06:17:42,840
sure to ask chat WT to give you the
10205
06:17:42,840 --> 06:17:45,360
output in markdown so if you haven't
10206
06:17:45,360 --> 06:17:47,360
worked with markdown before that's okay
10207
06:17:47,360 --> 06:17:49,600
you'll learn as you go along but one of
10208
06:17:49,600 --> 06:17:51,878
the biggest differences especially when
10209
06:17:51,878 --> 06:17:53,040
working with markdown that's going to
10210
06:17:53,040 --> 06:17:55,160
make your code so much more readable and
10211
06:17:55,160 --> 06:17:57,440
I 100% need you to always do this
10212
06:17:57,440 --> 06:17:59,440
whenever you ask questions is you see
10213
06:17:59,440 --> 06:18:01,798
how this got like some syntax
10214
06:18:01,798 --> 06:18:04,160
highlighting in this above question well
10215
06:18:04,160 --> 06:18:06,040
if we go click edit again we can
10216
06:18:06,040 --> 06:18:08,200
actually see why up here we did those
10217
06:18:08,200 --> 06:18:09,878
three back ticks and then we typed the
10218
06:18:09,878 --> 06:18:11,760
word solidity when you do these three
10219
06:18:11,760 --> 06:18:14,360
back ticks in your questions if you type
10220
06:18:14,360 --> 06:18:16,600
the word or you type the language next
10221
06:18:16,600 --> 06:18:18,400
to the first three back ticks it'll
10222
06:18:18,400 --> 06:18:20,558
actually add some formatting to make it
10223
06:18:20,558 --> 06:18:22,360
more readable so if we scroll down to
10224
06:18:22,360 --> 06:18:24,400
this poorly formatted question you can
10225
06:18:24,400 --> 06:18:26,360
see that this is just all white and like
10226
06:18:26,360 --> 06:18:28,920
impossible to read it would be at least
10227
06:18:28,920 --> 06:18:31,478
slightly better if we hit edit and next
10228
06:18:31,478 --> 06:18:33,280
to these three back ticks we wrote
10229
06:18:33,280 --> 06:18:35,958
solidity if this like Java code or
10230
06:18:35,958 --> 06:18:38,400
python code we could write python or
10231
06:18:38,400 --> 06:18:40,080
Java or whatever but since this is
10232
06:18:40,080 --> 06:18:42,080
solidity we'll write
10233
06:18:42,080 --> 06:18:44,240
solidity I'll hit
10234
06:18:44,240 --> 06:18:46,878
update and you can see that it is
10235
06:18:46,878 --> 06:18:49,360
substantially nicer and it is much more
10236
06:18:49,360 --> 06:18:51,280
readable now so even though this is
10237
06:18:51,280 --> 06:18:52,840
still a bad question obviously because
10238
06:18:52,840 --> 06:18:55,440
we just copy pasted all of our code it's
10239
06:18:55,440 --> 06:18:57,280
at least much more readable so anytime
10240
06:18:57,280 --> 06:18:59,440
you do a code block like this of any of
10241
06:18:59,440 --> 06:19:03,478
your code absolutely 100% be sure to do
10242
06:19:03,478 --> 06:19:05,120
the three back ticks and then the
10243
06:19:05,120 --> 06:19:07,760
language of the block of code so just
10244
06:19:07,760 --> 06:19:09,878
remember this there are no bad questions
10245
06:19:09,878 --> 06:19:12,680
but there are poorly formatted questions
10246
06:19:12,680 --> 06:19:15,160
make your questions well formatted for
10247
06:19:15,160 --> 06:19:17,680
both human beings and for AI and then
10248
06:19:17,680 --> 06:19:19,440
most importantly be sure to join these
10249
06:19:19,440 --> 06:19:21,280
forums and like I've said 100 times
10250
06:19:21,280 --> 06:19:23,520
interact with these people interact and
10251
06:19:23,520 --> 06:19:25,400
help and give back the more people that
10252
06:19:25,400 --> 06:19:27,320
use and are good at the tool that you're
10253
06:19:27,320 --> 06:19:28,840
working with the more likely that
10254
06:19:28,840 --> 06:19:29,958
they're going to help you sometime in
10255
06:19:29,958 --> 06:19:32,200
the future and this is how I've met so
10256
06:19:32,200 --> 06:19:33,840
many people in the industry is just
10257
06:19:33,840 --> 06:19:35,400
giving back in interacting with other
10258
06:19:35,400 --> 06:19:38,200
people so whenever you ask a question
10259
06:19:38,200 --> 06:19:39,440
especially in the beginning cuz in the
10260
06:19:39,440 --> 06:19:40,320
beginning you're going to have more
10261
06:19:40,320 --> 06:19:42,200
questions than not be sure to at least
10262
06:19:42,200 --> 06:19:44,400
try to go back and answer a question
10263
06:19:44,400 --> 06:19:46,520
think of it as question and answer debt
10264
06:19:46,520 --> 06:19:48,760
every time you answer a question make a
10265
06:19:48,760 --> 06:19:50,798
little mental note and say ah in the
10266
06:19:50,798 --> 06:19:52,920
future I need to at least try to answer
10267
06:19:52,920 --> 06:19:54,840
one of somebody else's questions this is
10268
06:19:54,840 --> 06:19:59,120
how we grow and move so much
10269
06:20:01,760 --> 06:20:03,878
faster now this next piece that I'm
10270
06:20:03,878 --> 06:20:05,760
going to show you is outside of this
10271
06:20:05,760 --> 06:20:07,558
course but it's a resource that I wanted
10272
06:20:07,558 --> 06:20:09,520
to show you in case after this course is
10273
06:20:09,520 --> 06:20:11,840
done you want more resources to learn
10274
06:20:11,840 --> 06:20:14,080
about ethereum and learn about the EVN
10275
06:20:14,080 --> 06:20:15,600
it's with my good friend Austin who's
10276
06:20:15,600 --> 06:20:17,520
going to show you speedrun ethereum and
10277
06:20:17,520 --> 06:20:18,520
definitely something you might want to
10278
06:20:18,520 --> 06:20:20,320
check out after taking this course
10279
06:20:20,320 --> 06:20:22,160
what's up I'm Austin Griffith happy bow
10280
06:20:22,160 --> 06:20:23,840
tie Friday I want to show you the best
10281
06:20:23,840 --> 06:20:26,840
way to get started building on ethereum
10282
06:20:26,840 --> 06:20:30,300
is speedrun ethereum.org
10283
06:20:30,300 --> 06:20:33,390
[Music]
10284
06:20:34,958 --> 06:20:36,840
you'll build a decentralized staking app
10285
06:20:36,840 --> 06:20:38,520
you'll learn that the superpower of
10286
06:20:38,520 --> 06:20:40,280
ethereum is allowing you the Builder to
10287
06:20:40,280 --> 06:20:42,600
create a simple set of rules where an
10288
06:20:42,600 --> 06:20:44,360
adversarial group of people can
10289
06:20:44,360 --> 06:20:46,680
coordinate financially you'll build a
10290
06:20:46,680 --> 06:20:48,760
token vendor you'll build a dice game
10291
06:20:48,760 --> 06:20:50,280
and you'll learn about Randomness on
10292
06:20:50,280 --> 06:20:52,718
chain and where it works and where it
10293
06:20:52,718 --> 06:20:55,040
doesn't and what you can do about that
10294
06:20:55,040 --> 06:20:56,920
you learn about a DEX and what a hyper
10295
06:20:56,920 --> 06:20:59,400
structure is and how people can use
10296
06:20:59,400 --> 06:21:01,240
liquidity to swap you'll learn about
10297
06:21:01,240 --> 06:21:03,520
State Channel and scalability and sign
10298
06:21:03,520 --> 06:21:05,920
messages and multisig wallets and
10299
06:21:05,920 --> 06:21:09,638
account abstraction and SVG nfts lots of
10300
06:21:09,638 --> 06:21:12,160
fun stuff along the way like I said not
10301
06:21:12,160 --> 06:21:14,400
just the how but the why go to speedrun
10302
06:21:14,400 --> 06:21:17,080
ethereum.org and get started today uh
10303
06:21:17,080 --> 06:21:19,040
it'll have you do a quick video uh and
10304
06:21:19,040 --> 06:21:20,638
then it says to use scaffold eth to
10305
06:21:20,638 --> 06:21:22,040
start tinkering I want to show you how
10306
06:21:22,040 --> 06:21:23,558
to do that first of all all this stuff
10307
06:21:23,558 --> 06:21:26,520
is open source uh it's all ungated and
10308
06:21:26,520 --> 06:21:28,798
open source just get in and get get in
10309
06:21:28,798 --> 06:21:31,240
get learning okay but this scaffold e
10310
06:21:31,240 --> 06:21:33,520
thing uh scaffold e is a great way to
10311
06:21:33,520 --> 06:21:36,600
Tinker with solidity and kind of get
10312
06:21:36,600 --> 06:21:39,240
your your your bearings right so let me
10313
06:21:39,240 --> 06:21:41,718
show scaffold 2 just for a second if we
10314
06:21:41,718 --> 06:21:44,320
zoom in uh I've already kind of uh gone
10315
06:21:44,320 --> 06:21:46,000
through the whole readme and installed
10316
06:21:46,000 --> 06:21:47,478
everything I want to show this right
10317
06:21:47,478 --> 06:21:50,840
here here's a smart contract and I have
10318
06:21:50,840 --> 06:21:53,718
my front end that's uh Auto adapting to
10319
06:21:53,718 --> 06:21:56,958
the smart contract and so uh when in
10320
06:21:56,958 --> 06:21:58,920
speedrun ethereum it tells you to Tinker
10321
06:21:58,920 --> 06:22:01,400
with each one of these Concepts let's
10322
06:22:01,400 --> 06:22:03,240
just go look at mappings or strs or
10323
06:22:03,240 --> 06:22:04,718
modifiers let's just go look at get a
10324
06:22:04,718 --> 06:22:07,200
mapping and let's grab a mapping right
10325
06:22:07,200 --> 06:22:08,878
and let's copy and paste it right into
10326
06:22:08,878 --> 06:22:11,240
our smart contract so something called
10327
06:22:11,240 --> 06:22:13,080
my map I don't even know what it is
10328
06:22:13,080 --> 06:22:15,520
right and then we yarn deploy and we'll
10329
06:22:15,520 --> 06:22:18,478
see that my map show up over here and
10330
06:22:18,478 --> 06:22:20,478
this is kind of the feedback loop I want
10331
06:22:20,478 --> 06:22:23,558
you to get into where you can grab some
10332
06:22:23,558 --> 06:22:26,798
stuff from solidity by example paste it
10333
06:22:26,798 --> 06:22:29,120
into your smart contract deploy it
10334
06:22:29,120 --> 06:22:31,160
locally and then Tinker with it there's
10335
06:22:31,160 --> 06:22:33,638
my my map let's see what vitalic bance
10336
06:22:33,638 --> 06:22:35,440
is in my map
10337
06:22:35,440 --> 06:22:39,478
it's zero oh okay so check out speedrun
10338
06:22:39,478 --> 06:22:42,520
ethereum check out scaffold e get
10339
06:22:42,520 --> 06:22:44,798
started building cool things on ethereum
10340
06:22:44,798 --> 06:22:47,280
today happy bowai Friday hearts hearts
10341
06:22:47,280 --> 06:22:51,200
hearts see you
10342
06:23:09,760 --> 06:23:11,520
now the reason I especially wanted to
10343
06:23:11,520 --> 06:23:13,680
show you all of these debugging things
10344
06:23:13,680 --> 06:23:15,638
right now is because we are about to
10345
06:23:15,638 --> 06:23:18,638
move off of remix remix has been this
10346
06:23:18,638 --> 06:23:20,840
phenomenal IDE or this phenomenal
10347
06:23:20,840 --> 06:23:22,760
integrated development environment that
10348
06:23:22,760 --> 06:23:24,680
allows us to quickly try things and
10349
06:23:24,680 --> 06:23:26,400
quickly deploy things but we're actually
10350
06:23:26,400 --> 06:23:28,600
going to move off of remix to a more
10351
06:23:28,600 --> 06:23:30,360
professional setup and we're going to be
10352
06:23:30,360 --> 06:23:32,878
using a modern set of tools that most of
10353
06:23:32,878 --> 06:23:34,638
the rest of the development community
10354
06:23:34,638 --> 06:23:36,280
also works with and I'm going to tell
10355
06:23:36,280 --> 06:23:39,280
you this right now often installing
10356
06:23:39,280 --> 06:23:41,440
these new tools and often just getting
10357
06:23:41,440 --> 06:23:43,520
your local development environment set
10358
06:23:43,520 --> 06:23:45,878
up not using remix or not using what's
10359
06:23:45,878 --> 06:23:49,200
called a cloud IDE can often be the
10360
06:23:49,200 --> 06:23:52,240
actually most difficult step in this
10361
06:23:52,240 --> 06:23:54,200
whole process so I want you to be
10362
06:23:54,200 --> 06:23:57,240
absolutely Vigilant in using all of the
10363
06:23:57,240 --> 06:23:59,360
resources that I just showed you using
10364
06:23:59,360 --> 06:24:02,798
the chat using chat GPT using piranha
10365
06:24:02,798 --> 06:24:05,160
using stack Exchange eth using web3
10366
06:24:05,160 --> 06:24:07,638
education. once we get this up and live
10367
06:24:07,638 --> 06:24:11,080
be sure to use these tools and don't let
10368
06:24:11,080 --> 06:24:12,760
installing these slow you down because
10369
06:24:12,760 --> 06:24:15,798
in my mind installing these can be the
10370
06:24:15,798 --> 06:24:18,040
hardest part of this whole course and
10371
06:24:18,040 --> 06:24:19,920
it's okay things might not work the
10372
06:24:19,920 --> 06:24:22,280
first time and that's okay just be sure
10373
06:24:22,280 --> 06:24:24,680
to ask questions and be very specific
10374
06:24:24,680 --> 06:24:26,878
with the errors that you're seeing and
10375
06:24:26,878 --> 06:24:28,080
installing these things that's what
10376
06:24:28,080 --> 06:24:30,120
we're going to learn how to do right now
10377
06:24:30,120 --> 06:24:31,920
so remix is a phenomenal tool but now
10378
06:24:31,920 --> 06:24:33,240
we're going to move over to this more
10379
06:24:33,240 --> 06:24:35,478
professional setup called called Foundry
10380
06:24:35,478 --> 06:24:37,638
Foundry is one of the most popular smart
10381
06:24:37,638 --> 06:24:39,600
contract development Frameworks similar
10382
06:24:39,600 --> 06:24:41,080
to hardhead or brownie if you're
10383
06:24:41,080 --> 06:24:43,000
familiar with those and it's known
10384
06:24:43,000 --> 06:24:45,558
specifically for its speed Foundry is
10385
06:24:45,558 --> 06:24:47,680
easily the fastest to work with smart
10386
06:24:47,680 --> 06:24:49,440
contract development framework one of
10387
06:24:49,440 --> 06:24:52,160
the unique aspects about Foundry is that
10388
06:24:52,160 --> 06:24:54,000
whereas hard hat is Javascript based
10389
06:24:54,000 --> 06:24:56,280
brownie is python based Foundry is
10390
06:24:56,280 --> 06:24:58,680
completely solidity based so we don't
10391
06:24:58,680 --> 06:25:00,360
have to learn any other programming
10392
06:25:00,360 --> 06:25:02,120
languages other than solidity to work
10393
06:25:02,120 --> 06:25:04,080
with Foundry and similar to everything
10394
06:25:04,080 --> 06:25:05,680
that we we've been doing so far all of
10395
06:25:05,680 --> 06:25:07,240
the code for all of our Foundry products
10396
06:25:07,240 --> 06:25:08,920
are going to be in the GitHub repo
10397
06:25:08,920 --> 06:25:10,920
associated with this course however the
10398
06:25:10,920 --> 06:25:13,160
documentation for Foundry I think is
10399
06:25:13,160 --> 06:25:15,878
also phenomenal so be sure to use this
10400
06:25:15,878 --> 06:25:18,400
as you code along and something very
10401
06:25:18,400 --> 06:25:20,280
interesting that I really love to do
10402
06:25:20,280 --> 06:25:22,840
most of these pages are pretty small so
10403
06:25:22,840 --> 06:25:25,200
even if your AI isn't trained off of
10404
06:25:25,200 --> 06:25:27,680
Foundry which as a recording it's not
10405
06:25:27,680 --> 06:25:28,878
what we can do is something called
10406
06:25:28,878 --> 06:25:31,400
context injection when we have issues so
10407
06:25:31,400 --> 06:25:34,360
we can copy the entire page of Doc
10408
06:25:34,360 --> 06:25:38,120
mentation we can say I'd like to start
10409
06:25:38,120 --> 06:25:42,400
I'd like to install Foundry here are the
10410
06:25:42,400 --> 06:25:45,760
documentations for installation how can
10411
06:25:45,760 --> 06:25:48,120
I do it do the three back ticks paste
10412
06:25:48,120 --> 06:25:50,440
the whole thing in there and by giving
10413
06:25:50,440 --> 06:25:53,000
our AIS the documentation for working
10414
06:25:53,000 --> 06:25:55,478
with Foundry it's actually going to give
10415
06:25:55,478 --> 06:25:58,840
us outputs to install Foundry so this is
10416
06:25:58,840 --> 06:26:00,320
a methodology you'll see me use from
10417
06:26:00,320 --> 06:26:03,080
time to time this context injection you
10418
06:26:03,080 --> 06:26:04,878
can find more
10419
06:26:04,878 --> 06:26:06,600
in the GitHub repo once again associated
10420
06:26:06,600 --> 06:26:08,600
with this course on installation and
10421
06:26:08,600 --> 06:26:10,920
setup Mac OS and this should be Linux
10422
06:26:10,920 --> 06:26:12,280
and then we have some Windows setup
10423
06:26:12,280 --> 06:26:14,040
stuff down here we're going to go over
10424
06:26:14,040 --> 06:26:15,558
how to set up all the important things
10425
06:26:15,558 --> 06:26:17,478
for this course so be sure to use this
10426
06:26:17,478 --> 06:26:19,280
as a reference now a great question you
10427
06:26:19,280 --> 06:26:20,798
might be asking is well what's even the
10428
06:26:20,798 --> 06:26:22,798
purpose of Foundry why do we need to use
10429
06:26:22,798 --> 06:26:25,240
this other tool remix is working great
10430
06:26:25,240 --> 06:26:27,400
well in remix you notice that we did a
10431
06:26:27,400 --> 06:26:29,200
lot of stuff manually like I came in
10432
06:26:29,200 --> 06:26:31,680
here I had to go to compile maybe I
10433
06:26:31,680 --> 06:26:33,160
wanted to test something out I would go
10434
06:26:33,160 --> 06:26:35,760
deploy it uh I got a put a price feed in
10435
06:26:35,760 --> 06:26:39,200
here a price feed in here deploy okay
10436
06:26:39,200 --> 06:26:41,360
does the get version work Uh something's
10437
06:26:41,360 --> 06:26:43,558
wrong with my get version okay my o i
10438
06:26:43,558 --> 06:26:46,400
owner works okay minimum USD works oh
10439
06:26:46,400 --> 06:26:48,320
crap I got to go make some little change
10440
06:26:48,320 --> 06:26:50,638
here you know maybe I want get version
10441
06:26:50,638 --> 06:26:54,360
to actually return you know 7 + 2 or 7 +
10442
06:26:54,360 --> 06:26:57,040
1 now I got to go you know delete this I
10443
06:26:57,040 --> 06:26:59,360
got to go redeploy I got to go click
10444
06:26:59,360 --> 06:27:01,798
this I got to go down I got to click and
10445
06:27:01,798 --> 06:27:03,280
then if I have a hundred things that I
10446
06:27:03,280 --> 06:27:05,520
change testing all of this is going to
10447
06:27:05,520 --> 06:27:08,680
take a really long time and anytime you
10448
06:27:08,680 --> 06:27:10,878
do something anytime us as human beings
10449
06:27:10,878 --> 06:27:12,478
changes our code in some way there's a
10450
06:27:12,478 --> 06:27:14,240
chance that we break something and
10451
06:27:14,240 --> 06:27:15,320
remember these smart contracts are
10452
06:27:15,320 --> 06:27:16,798
immutable so if we break something if we
10453
06:27:16,798 --> 06:27:18,478
mess something up that's really bad
10454
06:27:18,478 --> 06:27:19,920
because that mess up will be permanent
10455
06:27:19,920 --> 06:27:22,040
on the blockchain so we want a framework
10456
06:27:22,040 --> 06:27:24,200
that helps us deploy our smart contracts
10457
06:27:24,200 --> 06:27:26,440
test our smart contracts and interact
10458
06:27:26,440 --> 06:27:28,638
with them in a much more programmatic
10459
06:27:28,638 --> 06:27:30,440
way rather than we having to manually
10460
06:27:30,440 --> 06:27:32,680
click around right if I changed 10
10461
06:27:32,680 --> 06:27:34,600
functions and I wanted to test the work
10462
06:27:34,600 --> 06:27:36,280
I would have to go click 10 buttons
10463
06:27:36,280 --> 06:27:38,478
that's ridiculous in Foundry we can do
10464
06:27:38,478 --> 06:27:41,320
all of that in one command or one button
10465
06:27:41,320 --> 06:27:42,840
so that's why we're going to be using
10466
06:27:42,840 --> 06:27:44,680
Foundry here and I'm so excited for you
10467
06:27:44,680 --> 06:27:46,200
to be using this Foundry tool because
10468
06:27:46,200 --> 06:27:48,120
like I said it's the fastest smart
10469
06:27:48,120 --> 06:27:50,040
contract development framework out there
10470
06:27:50,040 --> 06:27:53,080
right now but additionally it's also the
10471
06:27:53,080 --> 06:27:55,200
framework of choice for smart contract
10472
06:27:55,200 --> 06:27:57,680
security engineers and Auditors and I
10473
06:27:57,680 --> 06:27:59,360
expect more and more projects in the
10474
06:27:59,360 --> 06:28:01,400
future to be built in Foundry so
10475
06:28:01,400 --> 06:28:02,920
incredibly excited for you here now for
10476
06:28:02,920 --> 06:28:04,120
the rest of the course I'm going to be
10477
06:28:04,120 --> 06:28:06,520
we're using a code editor called Visual
10478
06:28:06,520 --> 06:28:08,878
Studio code this is one of the most
10479
06:28:08,878 --> 06:28:10,878
powerful code editors on the planet and
10480
06:28:10,878 --> 06:28:12,360
if you've already got it set up feel
10481
06:28:12,360 --> 06:28:14,040
free to go ahead and skip this part
10482
06:28:14,040 --> 06:28:15,878
you'll often hear people refer to this
10483
06:28:15,878 --> 06:28:18,680
as VSS code or Visual Studio code or
10484
06:28:18,680 --> 06:28:20,558
just Visual Studio however it's
10485
06:28:20,558 --> 06:28:23,520
important to not that Visual Studio code
10486
06:28:23,520 --> 06:28:26,280
this is different than Visual Studio
10487
06:28:26,280 --> 06:28:28,760
which you might see look like this so
10488
06:28:28,760 --> 06:28:31,440
visual studio code is what you want not
10489
06:28:31,440 --> 06:28:33,798
Visual Studio Visual Studio is a
10490
06:28:33,798 --> 06:28:35,718
different application make sure you're
10491
06:28:35,718 --> 06:28:38,400
on Visual Studio code now if you choose
10492
06:28:38,400 --> 06:28:40,520
so and you're a total Hardo you can
10493
06:28:40,520 --> 06:28:42,920
absolutely work just with your terminal
10494
06:28:42,920 --> 06:28:45,280
or just with Powershell or just with
10495
06:28:45,280 --> 06:28:47,080
whatever coding environment that you
10496
06:28:47,080 --> 06:28:50,478
want like atom or Sublime however for us
10497
06:28:50,478 --> 06:28:51,958
we're going to be working with Visual
10498
06:28:51,958 --> 06:28:54,000
Studio code and I'm going to be going
10499
06:28:54,000 --> 06:28:56,040
through setting up visual studio code
10500
06:28:56,040 --> 06:28:58,080
the way that I like to set it up you can
10501
06:28:58,080 --> 06:29:00,160
absolutely set it up whatever way that
10502
06:29:00,160 --> 06:29:01,798
you feel comfortable now we're going to
10503
06:29:01,798 --> 06:29:03,478
go through three different installation
10504
06:29:03,478 --> 06:29:05,360
processes and pick the one that's most
10505
06:29:05,360 --> 06:29:07,478
appropriate for you the first one is
10506
06:29:07,478 --> 06:29:10,520
going to be for mac and Linux users the
10507
06:29:10,520 --> 06:29:12,160
second one is going to be for Windows
10508
06:29:12,160 --> 06:29:14,320
users and then our third one is going to
10509
06:29:14,320 --> 06:29:17,080
be a last ditch effort if for whatever
10510
06:29:17,080 --> 06:29:19,440
reason you can't get Windows or Linux or
10511
06:29:19,440 --> 06:29:21,440
the Mac instructions to work we're going
10512
06:29:21,440 --> 06:29:24,120
to use a git pod installation now I
10513
06:29:24,120 --> 06:29:26,400
highly highly recommend that you try to
10514
06:29:26,400 --> 06:29:28,200
get everything working locally without
10515
06:29:28,200 --> 06:29:31,240
using git pod however if for whatever
10516
06:29:31,240 --> 06:29:33,558
reason you can't get those installation
10517
06:29:33,558 --> 06:29:35,638
pieces to work we will have git pod
10518
06:29:35,638 --> 06:29:38,320
instructions for all of the repos that
10519
06:29:38,320 --> 06:29:40,000
we work with here but to get started
10520
06:29:40,000 --> 06:29:42,000
we'll start with the mac and Linux
10521
06:29:42,000 --> 06:29:44,638
installation
10522
06:29:53,478 --> 06:29:55,120
instructions the first thing you're
10523
06:29:55,120 --> 06:29:57,440
going to want to do is download the Mac
10524
06:29:57,440 --> 06:29:59,478
or if you're working with Linux download
10525
06:29:59,478 --> 06:30:02,200
the Linux installation of Visual Studio
10526
06:30:02,200 --> 06:30:04,280
code once you have it installed it'll
10527
06:30:04,280 --> 06:30:06,718
look a little something like this and if
10528
06:30:06,718 --> 06:30:09,080
it's a fresh installation it'll even
10529
06:30:09,080 --> 06:30:11,320
give you some tips and tools to actually
10530
06:30:11,320 --> 06:30:12,680
get started if you've never worked with
10531
06:30:12,680 --> 06:30:14,760
Visual Studio code before I highly
10532
06:30:14,760 --> 06:30:16,878
recommend going through any get started
10533
06:30:16,878 --> 06:30:19,558
or getting instructions tips that come
10534
06:30:19,558 --> 06:30:21,600
with opening Visual Studio code
10535
06:30:21,600 --> 06:30:23,200
additionally we have a visual studio
10536
06:30:23,200 --> 06:30:26,160
code crash course in the GitHub repo
10537
06:30:26,160 --> 06:30:28,080
associated with this course now one of
10538
06:30:28,080 --> 06:30:30,080
the awesome things about Visual Studio
10539
06:30:30,080 --> 06:30:31,680
code is it has this thing called
10540
06:30:31,680 --> 06:30:34,200
terminals which are commandline promps
10541
06:30:34,200 --> 06:30:36,558
that allow us to run scripts basically
10542
06:30:36,558 --> 06:30:37,760
it's where we're going to be running all
10543
06:30:37,760 --> 06:30:39,638
of our code the way we can open up the
10544
06:30:39,638 --> 06:30:41,080
terminal is we can go ahead and hit
10545
06:30:41,080 --> 06:30:43,520
terminal and select new terminal and
10546
06:30:43,520 --> 06:30:45,760
you'll get something like this now you
10547
06:30:45,760 --> 06:30:48,558
might have bash or zch or some other
10548
06:30:48,558 --> 06:30:50,320
type of shell the type that you have
10549
06:30:50,320 --> 06:30:52,120
doesn't really matter because on Mac and
10550
06:30:52,120 --> 06:30:55,120
Linux it's going to be Linux based and
10551
06:30:55,120 --> 06:30:56,638
like I said sometimes installing this
10552
06:30:56,638 --> 06:30:58,360
can be the hardest part of this entire
10553
06:30:58,360 --> 06:31:00,718
course so so don't get discouraged and
10554
06:31:00,718 --> 06:31:02,478
please use stack overflow stack exchange
10555
06:31:02,478 --> 06:31:04,280
ethereum and the GitHub repo to to move
10556
06:31:04,280 --> 06:31:06,080
past any issues you run into now if
10557
06:31:06,080 --> 06:31:08,360
you're on Mac or Linux you can actually
10558
06:31:08,360 --> 06:31:11,360
hit control back tick to actually toggle
10559
06:31:11,360 --> 06:31:13,120
your terminal mode this will pull the
10560
06:31:13,120 --> 06:31:15,200
terminal up and down for you getting
10561
06:31:15,200 --> 06:31:16,958
familiar with keyboard shortcuts will
10562
06:31:16,958 --> 06:31:18,718
actually make your life a lot easier cuz
10563
06:31:18,718 --> 06:31:20,520
you'll be able to move around Visual
10564
06:31:20,520 --> 06:31:22,638
Studio code much more effectively we
10565
06:31:22,638 --> 06:31:24,558
have a link to a list of keyboard
10566
06:31:24,558 --> 06:31:26,760
shortcuts additionally in the GitHub
10567
06:31:26,760 --> 06:31:28,718
repository associated with this section
10568
06:31:28,718 --> 06:31:30,360
as we move along I'll give tip on
10569
06:31:30,360 --> 06:31:32,000
different keyboard shortcuts that you
10570
06:31:32,000 --> 06:31:34,320
can optionally use otherwise you just go
10571
06:31:34,320 --> 06:31:36,000
ahead and click as well you can click
10572
06:31:36,000 --> 06:31:38,040
the trash can to delete the terminal go
10573
06:31:38,040 --> 06:31:40,280
back up terminal new terminal to pop it
10574
06:31:40,280 --> 06:31:41,478
back up now the next thing that we're
10575
06:31:41,478 --> 06:31:42,920
going to need a little bit later we're
10576
06:31:42,920 --> 06:31:44,280
not going to need it for this section
10577
06:31:44,280 --> 06:31:46,200
but it's good to install it now is going
10578
06:31:46,200 --> 06:31:48,000
to be git we will have links to the
10579
06:31:48,000 --> 06:31:50,080
installation instructions in the GitHub
10580
06:31:50,080 --> 06:31:52,320
repository installing git on Linux
10581
06:31:52,320 --> 06:31:53,478
you're going to use one of these two
10582
06:31:53,478 --> 06:31:56,000
commands and on Mac OS if you just type
10583
06:31:56,000 --> 06:31:57,958
git on the command line it should go
10584
06:31:57,958 --> 06:31:59,760
ahead and prompt you to install it so if
10585
06:31:59,760 --> 06:32:01,040
we're back in our command line and we
10586
06:32:01,040 --> 06:32:02,798
just type get it should prompt you to go
10587
06:32:02,798 --> 06:32:05,360
ahead and install it and if you do g--
10588
06:32:05,360 --> 06:32:07,398
version you should get something that
10589
06:32:07,398 --> 06:32:09,320
looks like this you can also use a Mac
10590
06:32:09,320 --> 06:32:11,280
OS git installer by clicking this link
10591
06:32:11,280 --> 06:32:12,360
here and running through the
10592
06:32:12,360 --> 06:32:14,160
installation process all right now that
10593
06:32:14,160 --> 06:32:16,040
you have git and visual studio code
10594
06:32:16,040 --> 06:32:18,600
installed we can continue on to the next
10595
06:32:18,600 --> 06:32:20,878
section awesome if you're not planning
10596
06:32:20,878 --> 06:32:23,840
on using Windows or git pod feel free to
10597
06:32:23,840 --> 06:32:26,760
skip the next two
10598
06:32:28,000 --> 06:32:30,398
sections and for this Windows setup
10599
06:32:30,398 --> 06:32:31,680
we're going to be learning about a tool
10600
06:32:31,680 --> 06:32:34,440
called WSL and to introduce that to us
10601
06:32:34,440 --> 06:32:36,840
we have my friend basili who has done
10602
06:32:36,840 --> 06:32:38,638
amazing work helping me on some of my
10603
06:32:38,638 --> 06:32:40,200
past courses and he's going to be
10604
06:32:40,200 --> 06:32:42,520
helping us here today so take it away
10605
06:32:42,520 --> 06:32:44,398
this tutorial is going to be useful for
10606
06:32:44,398 --> 06:32:47,120
any Windows version from Windows 10 and
10607
06:32:47,120 --> 06:32:50,000
above let's get started by installing or
10608
06:32:50,000 --> 06:32:52,360
code editor in this case Visual Studio
10609
06:32:52,360 --> 06:32:54,398
code so let's type BS code on the
10610
06:32:54,398 --> 06:32:55,958
browser and hit
10611
06:32:55,958 --> 06:32:59,520
enter s or version for Windows select
10612
06:32:59,520 --> 06:33:01,638
the destination and click save and the
10613
06:33:01,638 --> 06:33:03,280
installation process is going to be the
10614
06:33:03,280 --> 06:33:05,520
same as any other program so let's
10615
06:33:05,520 --> 06:33:07,240
select an accept the agreement click
10616
06:33:07,240 --> 06:33:10,600
next add code to the pat create a
10617
06:33:10,600 --> 06:33:13,840
desktop icon next and
10618
06:33:13,840 --> 06:33:17,478
install this shouldn't take a lot and
10619
06:33:17,478 --> 06:33:19,600
this is how the editor is going to look
10620
06:33:19,600 --> 06:33:22,160
like the first time we install it we can
10621
06:33:22,160 --> 06:33:25,718
customize the theme create shortcuts and
10622
06:33:25,718 --> 06:33:27,240
sync with another
10623
06:33:27,240 --> 06:33:30,160
devices and if you want to go deep into
10624
06:33:30,160 --> 06:33:32,558
Visual Studio code well I suggest you to
10625
06:33:32,558 --> 06:33:35,240
pause the video for a moment and go
10626
06:33:35,240 --> 06:33:38,600
through all these steps one by one now
10627
06:33:38,600 --> 06:33:41,320
we could 100% go forward and install the
10628
06:33:41,320 --> 06:33:43,160
rest of our Tools in a Windows
10629
06:33:43,160 --> 06:33:45,878
environment but basili is actually going
10630
06:33:45,878 --> 06:33:47,440
to explain to us that the windows
10631
06:33:47,440 --> 06:33:49,558
environment isn't really actually the
10632
06:33:49,558 --> 06:33:51,840
best way and the best place to do our
10633
06:33:51,840 --> 06:33:53,840
installations Microsoft has definitely
10634
06:33:53,840 --> 06:33:55,638
increased their support for developers
10635
06:33:55,638 --> 06:33:57,478
in the recent years but when it comes to
10636
06:33:57,478 --> 06:33:59,120
Smart contct development there is a
10637
06:33:59,120 --> 06:34:02,320
better option to consider using WSL the
10638
06:34:02,320 --> 06:34:04,600
windows subsystem for Linux trust me is
10639
06:34:04,600 --> 06:34:06,760
a game changer you see a smart contract
10640
06:34:06,760 --> 06:34:08,840
development often involves working with
10641
06:34:08,840 --> 06:34:11,040
tools and utilities that are commonly
10642
06:34:11,040 --> 06:34:13,320
found on Unix based environments while
10643
06:34:13,320 --> 06:34:14,958
Windows has come a long way in
10644
06:34:14,958 --> 06:34:17,600
accommodating developers there can still
10645
06:34:17,600 --> 06:34:19,440
be some challenges when it comes to
10646
06:34:19,440 --> 06:34:21,920
ruining certain command line tools and
10647
06:34:21,920 --> 06:34:23,600
setting up the right development
10648
06:34:23,600 --> 06:34:26,478
environment not mentioning that if you
10649
06:34:26,478 --> 06:34:29,638
want your code to run on any machine
10650
06:34:29,638 --> 06:34:34,200
using a units based system Mac and Linux
10651
06:34:34,200 --> 06:34:36,638
is better for your developer needs here
10652
06:34:36,638 --> 06:34:39,718
is where WSL shines by installing a
10653
06:34:39,718 --> 06:34:42,558
Linux distribution through WSL you can
10654
06:34:42,558 --> 06:34:44,638
access to a full-fledged Unix light
10655
06:34:44,638 --> 06:34:46,760
console right on your Windows machine
10656
06:34:46,760 --> 06:34:48,958
and don't worry you don't need to be a
10657
06:34:48,958 --> 06:34:52,080
hacker or wear a hoodie to make it
10658
06:34:52,080 --> 06:34:55,280
happen is actually quite simple so let's
10659
06:34:55,280 --> 06:34:57,958
do it for that let's open the windows
10660
06:34:57,958 --> 06:34:59,718
terminal this is a pre-installed
10661
06:34:59,718 --> 06:35:02,320
application on Windows
10662
06:35:02,320 --> 06:35:05,000
11 and so something you can easily
10663
06:35:05,000 --> 06:35:07,600
install through the Microsoft store on
10664
06:35:07,600 --> 06:35:10,638
Windows 10 just type terminal and here
10665
06:35:10,638 --> 06:35:12,600
you are going to have the windows
10666
06:35:12,600 --> 06:35:17,320
one so let's install WSL by typing WL
10667
06:35:17,320 --> 06:35:20,440
minus minus install hit enter is going
10668
06:35:20,440 --> 06:35:24,120
to trigger us a admin operation and
10669
06:35:24,120 --> 06:35:26,398
installation is going to start and here
10670
06:35:26,398 --> 06:35:28,040
we just have to wait until the process
10671
06:35:28,040 --> 06:35:30,958
finishes once the process is done this
10672
06:35:30,958 --> 06:35:33,080
will require you to reboot your
10673
06:35:33,080 --> 06:35:35,280
operating system system so I'll see you
10674
06:35:35,280 --> 06:35:38,080
on a second once rebooted this is going
10675
06:35:38,080 --> 06:35:41,440
to automatically open this terminal and
10676
06:35:41,440 --> 06:35:44,520
the installation process is going to
10677
06:35:44,520 --> 06:35:47,360
proceed now you have to input a new Unix
10678
06:35:47,360 --> 06:35:49,798
username for me is going to be chare and
10679
06:35:49,798 --> 06:35:51,398
then you have to set up your password
10680
06:35:51,398 --> 06:35:54,120
don't worry the password is always
10681
06:35:54,120 --> 06:35:57,040
hidden on Linux operating systems and as
10682
06:35:57,040 --> 06:35:59,040
this as that we already have a operating
10683
06:35:59,040 --> 06:36:02,440
Linux terminal inside our Windows
10684
06:36:02,440 --> 06:36:05,680
machine so we can now close this now if
10685
06:36:05,680 --> 06:36:07,440
we open a new instance on the Windows
10686
06:36:07,440 --> 06:36:10,240
terminal we click here on this drop-
10687
06:36:10,240 --> 06:36:13,398
down arrow we can have now this obuntu
10688
06:36:13,398 --> 06:36:15,798
shell on which we are going to inst all
10689
06:36:15,798 --> 06:36:17,398
the development requirements we are
10690
06:36:17,398 --> 06:36:19,638
going to use during the course so the
10691
06:36:19,638 --> 06:36:21,958
next step is to make Visual Studio code
10692
06:36:21,958 --> 06:36:25,680
compatible with WSL so let's do
10693
06:36:25,680 --> 06:36:28,760
that let's go to the extension stab
10694
06:36:28,760 --> 06:36:32,638
let's search for remote development and
10695
06:36:32,638 --> 06:36:35,760
install all these extensions this is
10696
06:36:35,760 --> 06:36:37,840
going to automatically install the
10697
06:36:37,840 --> 06:36:39,958
compatibility to connect or Visual
10698
06:36:39,958 --> 06:36:43,240
Studio code with WSL and as you can see
10699
06:36:43,240 --> 06:36:46,440
over here I have a new econ called open
10700
06:36:46,440 --> 06:36:49,320
a remote window if I click here I can
10701
06:36:49,320 --> 06:36:52,558
directly connect to WSL however there is
10702
06:36:52,558 --> 06:36:55,600
an easy way to do this let's close Vis
10703
06:36:55,600 --> 06:36:58,958
Studio code and on the Linux terminal
10704
06:36:58,958 --> 06:37:00,920
let's just create a new folder for
10705
06:37:00,920 --> 06:37:04,398
example Mader solidity course let's move
10706
06:37:04,398 --> 06:37:07,958
to that folder and now let's open Visual
10707
06:37:07,958 --> 06:37:10,320
Studio code inside this folder just type
10708
06:37:10,320 --> 06:37:13,200
code dot hit enter this is going to
10709
06:37:13,200 --> 06:37:16,760
install the latest server for w cell on
10710
06:37:16,760 --> 06:37:19,240
Visual Studio code and once this is done
10711
06:37:19,240 --> 06:37:22,638
we are going to have a new instance of
10712
06:37:22,638 --> 06:37:26,120
Visual Studio code but using WSL let's
10713
06:37:26,120 --> 06:37:28,520
just trust the outdors and as you can
10714
06:37:28,520 --> 06:37:32,080
see here I'm getting this WSL Ubuntu
10715
06:37:32,080 --> 06:37:34,320
Banner over here and and is because I
10716
06:37:34,320 --> 06:37:36,520
already connected this with the Linux
10717
06:37:36,520 --> 06:37:39,840
instance so you have two options from
10718
06:37:39,840 --> 06:37:42,718
now on you can start using just the
10719
06:37:42,718 --> 06:37:45,200
windows terminal to execute all the
10720
06:37:45,200 --> 06:37:47,240
things we are going to need or you can
10721
06:37:47,240 --> 06:37:49,958
use the integrated terminal which comes
10722
06:37:49,958 --> 06:37:52,558
with Visual Studio code just go to
10723
06:37:52,558 --> 06:37:55,718
terminal new terminal and now we are
10724
06:37:55,718 --> 06:37:58,280
going to have a terminal using the exact
10725
06:37:58,280 --> 06:38:01,718
same W cell instance so we can start
10726
06:38:01,718 --> 06:38:03,920
using PSE sudo commands for example to
10727
06:38:03,920 --> 06:38:07,558
the AP update and this is going to work
10728
06:38:07,558 --> 06:38:09,760
properly now just take something in
10729
06:38:09,760 --> 06:38:11,280
consideration maybe you are going to
10730
06:38:11,280 --> 06:38:14,120
develop all your projects on a folder
10731
06:38:14,120 --> 06:38:16,798
called development inside your documents
10732
06:38:16,798 --> 06:38:20,280
on Windows and you can do so however if
10733
06:38:20,280 --> 06:38:23,478
you take a look to the Linux terminal
10734
06:38:23,478 --> 06:38:25,958
with ls command as you can see here you
10735
06:38:25,958 --> 06:38:28,200
are going to have just access to the
10736
06:38:28,200 --> 06:38:31,478
local files and folders inside of the
10737
06:38:31,478 --> 06:38:34,440
WSL instance and I highly recommend you
10738
06:38:34,440 --> 06:38:36,798
to do that because of course you can do
10739
06:38:36,798 --> 06:38:39,398
something like typing the address of
10740
06:38:39,398 --> 06:38:43,200
your local development folders and use
10741
06:38:43,200 --> 06:38:45,478
the projects from here but the
10742
06:38:45,478 --> 06:38:48,558
communication from the WL console and
10743
06:38:48,558 --> 06:38:51,760
the local Windows files are actually
10744
06:38:51,760 --> 06:38:55,200
quite slow so I prefer just to keep
10745
06:38:55,200 --> 06:38:58,878
Simple and use all the folders inside W
10746
06:38:58,878 --> 06:39:01,478
cell remember that you have to just
10747
06:39:01,478 --> 06:39:04,040
manage simple commands such as LS to
10748
06:39:04,040 --> 06:39:07,638
know all the folders on the current
10749
06:39:07,638 --> 06:39:10,000
directory and CD to navigate through
10750
06:39:10,000 --> 06:39:12,200
them now if you go back to your vs code
10751
06:39:12,200 --> 06:39:13,920
and you hit terminal new terminal and
10752
06:39:13,920 --> 06:39:15,478
open up a terminal we're going to want
10753
06:39:15,478 --> 06:39:17,360
to then install git we're not going to
10754
06:39:17,360 --> 06:39:19,718
use git for this lesson however we will
10755
06:39:19,718 --> 06:39:21,840
definitely be using it in the future see
10756
06:39:21,840 --> 06:39:24,920
if git is installed type g-- version
10757
06:39:24,920 --> 06:39:26,478
sometimes Linux will automatically come
10758
06:39:26,478 --> 06:39:27,920
with get installed and you'll see
10759
06:39:27,920 --> 06:39:30,120
something output like this however if
10760
06:39:30,120 --> 06:39:32,360
you are the ones who decided to keep
10761
06:39:32,360 --> 06:39:34,040
using po sh
10762
06:39:34,040 --> 06:39:37,760
and just Windows instead of WSL don't
10763
06:39:37,760 --> 06:39:40,798
forget to go to the official git page
10764
06:39:40,798 --> 06:39:44,000
and install it for Windows the process
10765
06:39:44,000 --> 06:39:46,638
is as same as we did before pretty
10766
06:39:46,638 --> 06:39:49,478
standard just the common sequence of
10767
06:39:49,478 --> 06:39:51,558
clicking next and of course please to
10768
06:39:51,558 --> 06:39:54,200
read the license agreement and now if
10769
06:39:54,200 --> 06:39:55,638
you've made it this far you should be
10770
06:39:55,638 --> 06:39:57,280
able to follow along with the mac and
10771
06:39:57,280 --> 06:39:59,280
Linux constructions as if you're running
10772
06:39:59,280 --> 06:40:00,958
on a Mac and a Linux even though you're
10773
06:40:00,958 --> 06:40:03,520
running on a Windows just be sure that
10774
06:40:03,520 --> 06:40:05,200
whenever you're in your vs code you take
10775
06:40:05,200 --> 06:40:06,718
a look at the bottom left and make sure
10776
06:40:06,718 --> 06:40:09,878
you're on WSL yuntu like I said before
10777
06:40:09,878 --> 06:40:11,718
if you want to run in Powershell or in a
10778
06:40:11,718 --> 06:40:13,120
Windows environment you're more than
10779
06:40:13,120 --> 06:40:15,200
free to do so but like I said if you've
10780
06:40:15,200 --> 06:40:17,558
made it this far huge congratulations
10781
06:40:17,558 --> 06:40:19,958
awesome
10782
06:40:28,320 --> 06:40:31,160
work and then finally our last setup is
10783
06:40:31,160 --> 06:40:33,558
going to be using a tool called gitpod
10784
06:40:33,558 --> 06:40:35,200
starting from lesson five the lesson
10785
06:40:35,200 --> 06:40:36,920
that we're on right now ether's JS
10786
06:40:36,920 --> 06:40:39,160
simple storage all of our code repos are
10787
06:40:39,160 --> 06:40:42,200
going to come with a button in the repo
10788
06:40:42,200 --> 06:40:44,558
scroll down they'll come with this open
10789
06:40:44,558 --> 06:40:47,760
in git pod button now git pod is a cloud
10790
06:40:47,760 --> 06:40:50,080
development environment where you can
10791
06:40:50,080 --> 06:40:53,478
actually run your code on a remote
10792
06:40:53,478 --> 06:40:55,958
server it's kind of similar to remix IDE
10793
06:40:55,958 --> 06:40:58,280
but it allows you to run Visual Studio
10794
06:40:58,280 --> 06:41:01,520
code in the browser or connected to
10795
06:41:01,520 --> 06:41:03,478
another server this is good because then
10796
06:41:03,478 --> 06:41:05,520
you don't have to do any installation on
10797
06:41:05,520 --> 06:41:07,878
anything since all the tools that you
10798
06:41:07,878 --> 06:41:09,360
want to use are just going to be running
10799
06:41:09,360 --> 06:41:11,958
on this remote server this has its
10800
06:41:11,958 --> 06:41:14,320
downsides though obviously since you'll
10801
06:41:14,320 --> 06:41:16,920
only be able to code if git pod is up
10802
06:41:16,920 --> 06:41:19,120
and working for you additionally when it
10803
06:41:19,120 --> 06:41:21,280
comes to private Keys you absolutely do
10804
06:41:21,280 --> 06:41:24,080
not want to run any code with a private
10805
06:41:24,080 --> 06:41:26,558
key that has real money in it on gitpod
10806
06:41:26,558 --> 06:41:28,798
why well once again since you're running
10807
06:41:28,798 --> 06:41:31,840
your scripts on a remote server those
10808
06:41:31,840 --> 06:41:34,878
servers have access to your private keys
10809
06:41:34,878 --> 06:41:37,440
but since you've pinky promised that for
10810
06:41:37,440 --> 06:41:39,360
this course you're not going to be using
10811
06:41:39,360 --> 06:41:41,320
a metamask or a private key with actual
10812
06:41:41,320 --> 06:41:43,638
money in it it should be fine the other
10813
06:41:43,638 --> 06:41:45,840
downside is that these often cost money
10814
06:41:45,840 --> 06:41:48,558
to use and git pod isn't free but it's
10815
06:41:48,558 --> 06:41:51,360
an option if you absolutely cannot get
10816
06:41:51,360 --> 06:41:53,200
any of the installation working so if
10817
06:41:53,200 --> 06:41:54,718
you go ahead and you hit this opening
10818
06:41:54,718 --> 06:41:56,878
git pod button you'll get a welcome to
10819
06:41:56,878 --> 06:41:58,680
git pod showing up uh we're going to go
10820
06:41:58,680 --> 06:42:00,878
ahead and continue with GitHub since
10821
06:42:00,878 --> 06:42:02,680
you've signed up for GitHub here you
10822
06:42:02,680 --> 06:42:05,718
want to go head and authorize git
10823
06:42:05,718 --> 06:42:08,200
pod and it'll go ahead and start
10824
06:42:08,200 --> 06:42:10,638
creating this workspace for you and
10825
06:42:10,638 --> 06:42:13,000
you'll notice it looks exactly like
10826
06:42:13,000 --> 06:42:15,600
Visual Studio code since I opened the
10827
06:42:15,600 --> 06:42:18,798
repo up in gitpod it came with all the
10828
06:42:18,798 --> 06:42:21,600
code and you can even open this
10829
06:42:21,600 --> 06:42:24,958
workspace up in vs code desktop so this
10830
06:42:24,958 --> 06:42:27,240
is might be a little bit confusing but
10831
06:42:27,240 --> 06:42:29,760
basically you can run off of git pod
10832
06:42:29,760 --> 06:42:32,558
using your local Visual Studio code and
10833
06:42:32,558 --> 06:42:34,520
if you see G pod here that's how you
10834
06:42:34,520 --> 06:42:36,638
know that you're running off of git pod
10835
06:42:36,638 --> 06:42:38,638
if you see this popup do you want to
10836
06:42:38,638 --> 06:42:41,320
open this workspace in vs code desktop
10837
06:42:41,320 --> 06:42:43,398
you can hit open and it'll ask you if
10838
06:42:43,398 --> 06:42:45,680
you want to open up visual studio code
10839
06:42:45,680 --> 06:42:47,718
which I'm going to go ahead and hit yes
10840
06:42:47,718 --> 06:42:49,000
and you'll get something that looks like
10841
06:42:49,000 --> 06:42:51,638
this on your Visual Studio code it'll
10842
06:42:51,638 --> 06:42:53,120
tell you that it wants to install the
10843
06:42:53,120 --> 06:42:56,240
git pod extension and then open that git
10844
06:42:56,240 --> 06:42:58,718
pod URL so you can go ahead and install
10845
06:42:58,718 --> 06:43:01,478
it reload window and
10846
06:43:01,478 --> 06:43:03,520
open and it's going to go ahead and
10847
06:43:03,520 --> 06:43:05,798
start connecting to our the git pod
10848
06:43:05,798 --> 06:43:08,080
workspace and this is going to be the
10849
06:43:08,080 --> 06:43:11,320
same as running git pod in the browser
10850
06:43:11,320 --> 06:43:13,680
here or you can also do it manually by
10851
06:43:13,680 --> 06:43:16,760
hitting the git pod in the bottom left
10852
06:43:16,760 --> 06:43:20,638
and then type in open in vs
10853
06:43:20,638 --> 06:43:22,760
code and then you should be able to run
10854
06:43:22,760 --> 06:43:24,680
it in your Visual Studio code for now
10855
06:43:24,680 --> 06:43:26,080
I'm going to recommend that if you're
10856
06:43:26,080 --> 06:43:28,478
using git pod just stay in the browser
10857
06:43:28,478 --> 06:43:30,920
just so that you know okay I am running
10858
06:43:30,920 --> 06:43:33,478
this on a remote server and just as a
10859
06:43:33,478 --> 06:43:35,478
reminder for you that you're not
10860
06:43:35,478 --> 06:43:37,680
actually locally developing and
10861
06:43:37,680 --> 06:43:39,160
hopefully this will be a trigger to not
10862
06:43:39,160 --> 06:43:41,718
actually put any special private keys or
10863
06:43:41,718 --> 06:43:43,360
anything like that but you can make
10864
06:43:43,360 --> 06:43:45,320
workspaces you can make new folders and
10865
06:43:45,320 --> 06:43:47,320
you should be able to run all the
10866
06:43:47,320 --> 06:43:49,200
commands on here as if you were running
10867
06:43:49,200 --> 06:43:51,638
locally with Visual Studio code to open
10868
06:43:51,638 --> 06:43:53,680
up the terminal you hit this little bar
10869
06:43:53,680 --> 06:43:57,000
in the top left go to terminal new
10870
06:43:57,000 --> 06:44:01,160
terminal or use control Tilda exact same
10871
06:44:01,160 --> 06:44:03,840
as Mac OS and Linux keyboard shortcuts
10872
06:44:03,840 --> 06:44:05,840
to create a new folder we can change
10873
06:44:05,840 --> 06:44:08,878
directory CD do dot
10874
06:44:08,878 --> 06:44:12,638
mkdir new folder mkd makes make
10875
06:44:12,638 --> 06:44:14,878
directory called new folder and then
10876
06:44:14,878 --> 06:44:17,280
we're going to change our directory into
10877
06:44:17,280 --> 06:44:19,638
new folder and hit enter and now we're
10878
06:44:19,638 --> 06:44:22,240
in that new folder for each section you
10879
06:44:22,240 --> 06:44:24,000
can either open up the entire source
10880
06:44:24,000 --> 06:44:26,920
code right into gitpod or you can create
10881
06:44:26,920 --> 06:44:29,718
a new folder for each section yourself
10882
06:44:29,718 --> 06:44:31,558
and start from blank and then you would
10883
06:44:31,558 --> 06:44:34,160
just type code period
10884
06:44:34,160 --> 06:44:37,958
and you'd be in a brand new
10885
06:44:39,558 --> 06:44:41,878
folder and if you're using Windows this
10886
06:44:41,878 --> 06:44:45,798
should say WSL or yuntu or something
10887
06:44:45,798 --> 06:44:47,558
like that and if you have all that that
10888
06:44:47,558 --> 06:44:50,478
means we're ready to go now a quick note
10889
06:44:50,478 --> 06:44:52,040
something that you'll see me do a lot
10890
06:44:52,040 --> 06:44:54,718
and you can do this as well often times
10891
06:44:54,718 --> 06:44:56,600
when my terminal gets really really big
10892
06:44:56,600 --> 06:44:58,360
or there's a ton of commands in here
10893
06:44:58,360 --> 06:45:00,280
gets a little bit overwhelming for me so
10894
06:45:00,280 --> 06:45:02,080
one thing that you can do is you can
10895
06:45:02,080 --> 06:45:05,200
type clear and hit enter to clear it or
10896
06:45:05,200 --> 06:45:08,398
what you can do is you can hit command K
10897
06:45:08,398 --> 06:45:11,360
if you're on a Mac or control K if
10898
06:45:11,360 --> 06:45:13,558
you're on a Linux or a Windows and it's
10899
06:45:13,558 --> 06:45:15,080
one of my favorite keyboard shortcuts
10900
06:45:15,080 --> 06:45:17,600
that I use all the time Additionally the
10901
06:45:17,600 --> 06:45:20,240
trash can and the X here are very
10902
06:45:20,240 --> 06:45:23,120
different if I go do a couple of enters
10903
06:45:23,120 --> 06:45:25,478
here and we're down here if I hit the X
10904
06:45:25,478 --> 06:45:27,840
here and then pull my terminal back up
10905
06:45:27,840 --> 06:45:30,160
by doing the toggle or by doing terminal
10906
06:45:30,160 --> 06:45:32,680
new terminal you'll see all those lines
10907
06:45:32,680 --> 06:45:34,718
are still here but if I hit the trash
10908
06:45:34,718 --> 06:45:37,638
can and then pull the terminal back up
10909
06:45:37,638 --> 06:45:39,680
you you'll see it actually refreshes M
10910
06:45:39,680 --> 06:45:41,878
has a special command that prints stuff
10911
06:45:41,878 --> 06:45:44,440
out trashing your terminal is basically
10912
06:45:44,440 --> 06:45:46,360
deleting whatever is running in it and
10913
06:45:46,360 --> 06:45:49,558
the x is just hiding it and it's hitting
10914
06:45:49,558 --> 06:45:51,958
control Tilda or toggling our terminal
10915
06:45:51,958 --> 06:45:53,440
or whatever command it is on your
10916
06:45:53,440 --> 06:45:55,638
environment that's equivalent to hitting
10917
06:45:55,638 --> 06:45:58,360
the hide not the trash so if we want to
10918
06:45:58,360 --> 06:46:00,200
remove and start a terminal over we hit
10919
06:46:00,200 --> 06:46:02,600
the trash can and then we pull it back
10920
06:46:02,600 --> 06:46:04,920
up
10921
06:46:06,680 --> 06:46:08,320
so after we have that set up the next
10922
06:46:08,320 --> 06:46:09,398
thing that we're going to want to
10923
06:46:09,398 --> 06:46:12,280
install is actually Foundry itself in
10924
06:46:12,280 --> 06:46:13,840
The Foundry book you can find this in
10925
06:46:13,840 --> 06:46:16,440
the installation tab or you can go to
10926
06:46:16,440 --> 06:46:19,440
get found. sh and it'll have this
10927
06:46:19,440 --> 06:46:20,680
command that you can actually just go
10928
06:46:20,680 --> 06:46:22,638
ahead and copy Windows users we're going
10929
06:46:22,638 --> 06:46:24,120
to teach you how to do it the Linux or
10930
06:46:24,120 --> 06:46:26,320
Mac OS way so just stay tuned so we're
10931
06:46:26,320 --> 06:46:27,718
going to go ahead and copy this and run
10932
06:46:27,718 --> 06:46:30,240
this command again we can go terminal
10933
06:46:30,240 --> 06:46:31,638
new terminal and there are also some
10934
06:46:31,638 --> 06:46:33,440
shortcuts to do this I'm just going to
10935
06:46:33,440 --> 06:46:35,160
go ahead and paste this in here and hit
10936
06:46:35,160 --> 06:46:37,798
enter you will need internet access for
10937
06:46:37,798 --> 06:46:39,000
this to work because it's actually
10938
06:46:39,000 --> 06:46:42,280
downloading Foundry from this website
10939
06:46:42,280 --> 06:46:44,320
let me just move this up zoom in a
10940
06:46:44,320 --> 06:46:45,878
little bit here and you'll see me do
10941
06:46:45,878 --> 06:46:47,920
this a lot in the terminal I'll type
10942
06:46:47,920 --> 06:46:50,878
clear a lot to remove anything that's
10943
06:46:50,878 --> 06:46:53,200
been coded or output in our terminal
10944
06:46:53,200 --> 06:46:56,600
here or you'll also see me do command K
10945
06:46:56,600 --> 06:46:59,000
like that which clears the screen when
10946
06:46:59,000 --> 06:47:00,440
I'm typing in the terminal you'll see me
10947
06:47:00,440 --> 06:47:02,320
hit control w a lot which actually
10948
06:47:02,320 --> 06:47:03,440
removes
10949
06:47:03,440 --> 06:47:04,878
the most recent block of code you've
10950
06:47:04,878 --> 06:47:07,320
written you'll also see me do control U
10951
06:47:07,320 --> 06:47:09,360
which deletes the entire line so I'm
10952
06:47:09,360 --> 06:47:12,240
going to use command C for copy and
10953
06:47:12,240 --> 06:47:15,398
command V for paste a lot for those of
10954
06:47:15,398 --> 06:47:18,120
you on Windows and Linux it might be
10955
06:47:18,120 --> 06:47:20,798
control C and control V and if you're
10956
06:47:20,798 --> 06:47:22,398
unfamiliar you can Google the keyboard
10957
06:47:22,398 --> 06:47:25,240
shortcuts for for copying and pasting
10958
06:47:25,240 --> 06:47:26,878
for Windows or Linux if you're on a
10959
06:47:26,878 --> 06:47:28,280
Windows these keyboard shortcuts might
10960
06:47:28,280 --> 06:47:29,878
be a little bit different we've got a
10961
06:47:29,878 --> 06:47:32,000
list of keyboard shortcuts in the git
10962
06:47:32,000 --> 06:47:33,680
repo associated with with this course
10963
06:47:33,680 --> 06:47:35,120
but if you just run that curl command
10964
06:47:35,120 --> 06:47:36,798
you'll see an output at the bottom down
10965
06:47:36,798 --> 06:47:38,200
here that says something like detected
10966
06:47:38,200 --> 06:47:40,280
your preferred shell is whatever your
10967
06:47:40,280 --> 06:47:42,478
shell is here and added Foundry up to
10968
06:47:42,478 --> 06:47:44,878
path run Source or simply start a new
10969
06:47:44,878 --> 06:47:47,080
terminal session to use Foundry up and
10970
06:47:47,080 --> 06:47:48,160
once you run that we can go ahead and
10971
06:47:48,160 --> 06:47:50,360
run Foundry up and this will actually
10972
06:47:50,360 --> 06:47:52,520
install an update Foundry to the latest
10973
06:47:52,520 --> 06:47:54,878
version now whenever we want to install
10974
06:47:54,878 --> 06:47:56,600
an update Foundry we can just run
10975
06:47:56,600 --> 06:47:58,958
Foundry up like this it'll automatically
10976
06:47:58,958 --> 06:48:00,958
install everything and Foundry comes
10977
06:48:00,958 --> 06:48:05,680
with four components Forge cast Anvil
10978
06:48:05,680 --> 06:48:07,760
and chisel we'll know we've installed
10979
06:48:07,760 --> 06:48:10,798
these right if we run Forge D- version
10980
06:48:10,798 --> 06:48:11,840
and we'll see an output that looks
10981
06:48:11,840 --> 06:48:13,478
something like this now something
10982
06:48:13,478 --> 06:48:15,718
important to note if you hit this trash
10983
06:48:15,718 --> 06:48:18,638
can in the top right this actually kills
10984
06:48:18,638 --> 06:48:21,718
the terminal it's different from the X
10985
06:48:21,718 --> 06:48:23,920
which is just close the panel we close
10986
06:48:23,920 --> 06:48:26,280
the panel and then we reopen our
10987
06:48:26,280 --> 06:48:28,920
terminal by hitting terminal new
10988
06:48:28,920 --> 06:48:31,200
terminal like this this actually creates
10989
06:48:31,200 --> 06:48:33,280
a new terminal which we can kill
10990
06:48:33,280 --> 06:48:35,840
like this but our old terminal is still
10991
06:48:35,840 --> 06:48:37,878
up in order to actually delete this
10992
06:48:37,878 --> 06:48:39,878
terminal we have to hit the trash can
10993
06:48:39,878 --> 06:48:41,638
now you want to try this out now delete
10994
06:48:41,638 --> 06:48:44,000
your terminal like we just did open up a
10995
06:48:44,000 --> 06:48:46,878
new terminal and run Foundry up if this
10996
06:48:46,878 --> 06:48:49,160
doesn't run we might have an issue with
10997
06:48:49,160 --> 06:48:51,200
your path and you might need to add
10998
06:48:51,200 --> 06:48:53,638
Foundry to your path if this is an issue
10999
06:48:53,638 --> 06:48:55,638
that you have please make a discussion
11000
06:48:55,638 --> 06:48:57,200
on the GitHub repo assed with this
11001
06:48:57,200 --> 06:49:01,320
course or check please first check this
11002
06:49:01,320 --> 06:49:03,958
lesson six of the GitHub repo associated
11003
06:49:03,958 --> 06:49:06,080
with this course and we'll add some
11004
06:49:06,080 --> 06:49:07,760
debugging tips to make sure that that
11005
06:49:07,760 --> 06:49:10,040
does indeed happen or if there is no
11006
06:49:10,040 --> 06:49:12,200
debugging tips here make a discussion on
11007
06:49:12,200 --> 06:49:15,360
the course but first be sure to check to
11008
06:49:15,360 --> 06:49:18,000
see if that discussion already exists
11009
06:49:18,000 --> 06:49:20,000
and you should be able to do Forge D-
11010
06:49:20,000 --> 06:49:22,760
version however what can happen is if
11011
06:49:22,760 --> 06:49:25,878
you trash can the terminal and open up a
11012
06:49:25,878 --> 06:49:29,398
new terminal if you run Forge D- version
11013
06:49:29,398 --> 06:49:33,360
now it might say Forge command not found
11014
06:49:33,360 --> 06:49:35,280
this means that you have to rerun this
11015
06:49:35,280 --> 06:49:37,958
command this Source command that Foundry
11016
06:49:37,958 --> 06:49:39,920
told us to do if you're working with
11017
06:49:39,920 --> 06:49:43,120
bash most of the time this bash RC file
11018
06:49:43,120 --> 06:49:45,320
automatically gets loaded but sometimes
11019
06:49:45,320 --> 06:49:46,840
it actually won't depending on what your
11020
06:49:46,840 --> 06:49:49,558
setup is if this happens for you another
11021
06:49:49,558 --> 06:49:52,680
thing that you can do is you can type CD
11022
06:49:52,680 --> 06:49:55,040
and go to your home directory and type
11023
06:49:55,040 --> 06:49:58,760
this line Echo source and then whatever
11024
06:49:58,760 --> 06:50:02,200
Foundry up told you to do double carrot.
11025
06:50:02,200 --> 06:50:05,160
Bash profile and hit enter for example
11026
06:50:05,160 --> 06:50:07,120
when we just ran Foundry up right here
11027
06:50:07,120 --> 06:50:09,000
it gave us this command here this Source
11028
06:50:09,000 --> 06:50:11,638
users patrick. bashrc that's what we
11029
06:50:11,638 --> 06:50:14,080
would want to Echo however this will
11030
06:50:14,080 --> 06:50:16,440
change depending on your terminal setup
11031
06:50:16,440 --> 06:50:19,760
so look to the GitHub repository for the
11032
06:50:19,760 --> 06:50:21,280
command that you should be using for
11033
06:50:21,280 --> 06:50:23,320
your setup please make a discussions
11034
06:50:23,320 --> 06:50:25,520
thread if one does not already exist
11035
06:50:25,520 --> 06:50:27,440
what this will do is it'll add this
11036
06:50:27,440 --> 06:50:30,160
command to the end of your bash profile
11037
06:50:30,160 --> 06:50:32,638
make sure you do double like this
11038
06:50:32,638 --> 06:50:34,280
otherwise you could override whatever is
11039
06:50:34,280 --> 06:50:35,680
currently in your bash profile now I'm
11040
06:50:35,680 --> 06:50:37,958
going to give you a command that if you
11041
06:50:37,958 --> 06:50:39,840
screw up you could accidentally override
11042
06:50:39,840 --> 06:50:41,920
some stuff if you've never used bash
11043
06:50:41,920 --> 06:50:43,440
profile before you kind of don't have to
11044
06:50:43,440 --> 06:50:45,360
worry about it though the other command
11045
06:50:45,360 --> 06:50:47,558
you can run is something like this if
11046
06:50:47,558 --> 06:50:49,240
you do get an issue we can just ask an
11047
06:50:49,240 --> 06:50:51,320
AI something like how do I get my do
11048
06:50:51,320 --> 06:50:53,878
bash RC to load by default and there's a
11049
06:50:53,878 --> 06:50:55,160
couple of different ways for this
11050
06:50:55,160 --> 06:50:58,160
depending on what system using and what
11051
06:50:58,160 --> 06:51:00,200
you're working with all I'm going to say
11052
06:51:00,200 --> 06:51:02,718
though is if this happens to you if you
11053
06:51:02,718 --> 06:51:05,240
run Forge D- version and instead of
11054
06:51:05,240 --> 06:51:06,638
getting an output you get something like
11055
06:51:06,638 --> 06:51:10,638
command not found ask an AI or come into
11056
06:51:10,638 --> 06:51:13,160
the discussions of the channel and as
11057
06:51:13,160 --> 06:51:15,478
people run into this we'll build and
11058
06:51:15,478 --> 06:51:17,478
start a discussion and if enough people
11059
06:51:17,478 --> 06:51:19,240
have issues we'll create a new file here
11060
06:51:19,240 --> 06:51:22,478
to help people debug that issue so what
11061
06:51:22,478 --> 06:51:24,878
it looks like chat gbt does give a
11062
06:51:24,878 --> 06:51:27,718
pretty good output of what we can do we
11063
06:51:27,718 --> 06:51:30,240
can edit our bash RC our bash profile
11064
06:51:30,240 --> 06:51:33,120
our profile Etc and work with it like
11065
06:51:33,120 --> 06:51:34,958
that so if you run into that issue
11066
06:51:34,958 --> 06:51:36,280
there's plenty of things we can do to
11067
06:51:36,280 --> 06:51:38,320
fix it don't worry but if you're a
11068
06:51:38,320 --> 06:51:40,040
little nervous feel free to use the
11069
06:51:40,040 --> 06:51:42,760
discussions channel of the course got it
11070
06:51:42,760 --> 06:51:44,680
okay great if you see an output like
11071
06:51:44,680 --> 06:51:46,360
this you've done it right if you see an
11072
06:51:46,360 --> 06:51:47,958
output like we don't know what you're
11073
06:51:47,958 --> 06:51:49,760
doing you've done it wrong all right
11074
06:51:49,760 --> 06:51:52,320
great and again installing these can be
11075
06:51:52,320 --> 06:51:53,920
some of the hardest parts of this course
11076
06:51:53,920 --> 06:51:55,638
so don't get discouraged if this doesn't
11077
06:51:55,638 --> 06:51:57,718
work right away if it worked right away
11078
06:51:57,718 --> 06:52:01,878
for you that's actually amazing
11079
06:52:03,200 --> 06:52:06,040
now also the control back tick shortcut
11080
06:52:06,040 --> 06:52:08,080
toggles the terminal visibility between
11081
06:52:08,080 --> 06:52:12,040
up and down I also have command J as a
11082
06:52:12,040 --> 06:52:15,398
toggle for panel visibility as well this
11083
06:52:15,398 --> 06:52:16,920
is a key binding that you'll see me use
11084
06:52:16,920 --> 06:52:18,920
pretty often because we often will flip
11085
06:52:18,920 --> 06:52:20,760
back and forth between the terminal and
11086
06:52:20,760 --> 06:52:23,080
our code which is going to be up here in
11087
06:52:23,080 --> 06:52:25,360
fact if we click this explore button on
11088
06:52:25,360 --> 06:52:28,360
the left we can select this area select
11089
06:52:28,360 --> 06:52:30,840
new file do something like
11090
06:52:30,840 --> 06:52:34,240
hello.txt or better yet hello. Soul
11091
06:52:34,240 --> 06:52:35,878
we're going to add some code in here
11092
06:52:35,878 --> 06:52:37,520
what's important to know is if you see
11093
06:52:37,520 --> 06:52:39,878
this white dot in the top section here
11094
06:52:39,878 --> 06:52:42,680
this means that this file isn't saved
11095
06:52:42,680 --> 06:52:45,360
command s or controls depending on if
11096
06:52:45,360 --> 06:52:47,878
you're on a Windows or Mac or Linux will
11097
06:52:47,878 --> 06:52:50,040
save it and make that white dot go away
11098
06:52:50,040 --> 06:52:53,878
unsaved saved unsaved saved it's
11099
06:52:53,878 --> 06:52:55,958
important to recognize if a file is
11100
06:52:55,958 --> 06:52:58,120
saved or not because if it's not saved
11101
06:52:58,120 --> 06:52:59,878
it might not do what you think it should
11102
06:52:59,878 --> 06:53:02,798
do so I kind of by default will always
11103
06:53:02,798 --> 06:53:04,958
automatically save by hitting command s
11104
06:53:04,958 --> 06:53:06,520
and it's a good practice to get into
11105
06:53:06,520 --> 06:53:09,320
just always autosave everything you do
11106
06:53:09,320 --> 06:53:10,638
we can also delete this file we just
11107
06:53:10,638 --> 06:53:12,320
created by right clicking it and
11108
06:53:12,320 --> 06:53:14,920
selecting delete move to trash final
11109
06:53:14,920 --> 06:53:16,478
thing that we want to install and we'll
11110
06:53:16,478 --> 06:53:18,958
install a lot of these as we go along is
11111
06:53:18,958 --> 06:53:22,120
actually an AI extension something in vs
11112
06:53:22,120 --> 06:53:25,240
code to help us actually have ai inside
11113
06:53:25,240 --> 06:53:27,680
of our Visual Studio code if you select
11114
06:53:27,680 --> 06:53:30,600
this little box looking thing that says
11115
06:53:30,600 --> 06:53:32,840
extensions you get a search box box
11116
06:53:32,840 --> 06:53:34,520
which allows you to search for
11117
06:53:34,520 --> 06:53:37,000
extensions the AI that I work with the
11118
06:53:37,000 --> 06:53:40,600
most is GitHub co-pilot but you can use
11119
06:53:40,600 --> 06:53:42,600
whatever AI you want or you could just
11120
06:53:42,600 --> 06:53:45,320
not even use an AI get a co-pilot does
11121
06:53:45,320 --> 06:53:48,638
cost money to use so feel free to also
11122
06:53:48,638 --> 06:53:51,080
not use it there's some other free vs
11123
06:53:51,080 --> 06:53:53,478
code extensions that use AI so feel free
11124
06:53:53,478 --> 06:53:54,840
to browse around and choose which one
11125
06:53:54,840 --> 06:53:56,760
you like for me I'm going to go ahead
11126
06:53:56,760 --> 06:53:58,958
and install GitHub co-pilot you'll get a
11127
06:53:58,958 --> 06:54:00,878
little guy in the bottom right for your
11128
06:54:00,878 --> 06:54:02,558
vs code that will let you know that
11129
06:54:02,558 --> 06:54:03,878
you've done it correctly you'll need to
11130
06:54:03,878 --> 06:54:06,160
sign into GitHub which is something that
11131
06:54:06,160 --> 06:54:08,280
we've recently made in order for it to
11132
06:54:08,280 --> 06:54:10,478
work now you'll see me using GitHub
11133
06:54:10,478 --> 06:54:12,398
co-pilot pretty often when I write my
11134
06:54:12,398 --> 06:54:15,040
code because I have this little doad on
11135
06:54:15,040 --> 06:54:16,878
down here I can start writing some code
11136
06:54:16,878 --> 06:54:18,760
and GI up co-pilot will start giving me
11137
06:54:18,760 --> 06:54:21,320
suggestions as to what I should write
11138
06:54:21,320 --> 06:54:23,718
for example if I were to add
11139
06:54:23,718 --> 06:54:28,280
spdx by since identifier get up copilot
11140
06:54:28,280 --> 06:54:30,240
actually automatically starts to gray
11141
06:54:30,240 --> 06:54:33,360
out and give me a suggestion if I tab I
11142
06:54:33,360 --> 06:54:35,680
can autocomplete my code with GitHub
11143
06:54:35,680 --> 06:54:38,240
copilot suggestion alternatively what I
11144
06:54:38,240 --> 06:54:40,320
could do then for example I could keep
11145
06:54:40,320 --> 06:54:43,200
coding and I can see it's already giving
11146
06:54:43,200 --> 06:54:47,000
me a suggestion here and if I hit upkey
11147
06:54:47,000 --> 06:54:49,958
enter I'll actually open up this bit on
11148
06:54:49,958 --> 06:54:51,200
the
11149
06:54:51,200 --> 06:54:53,478
side where get up co-pilot will give me
11150
06:54:53,478 --> 06:54:55,360
a ton of different solutions on what it
11151
06:54:55,360 --> 06:54:57,040
thinks I'm trying to write and I can
11152
06:54:57,040 --> 06:54:59,600
just pick one of these Solutions
11153
06:54:59,600 --> 06:55:01,360
obviously some of these aren't doing
11154
06:55:01,360 --> 06:55:02,638
anything we'll learn about about the
11155
06:55:02,638 --> 06:55:04,718
command pallet soon and we can also use
11156
06:55:04,718 --> 06:55:06,638
any of the GitHub co-pilot commands that
11157
06:55:06,638 --> 06:55:08,600
come with the command pallet an
11158
06:55:08,600 --> 06:55:10,760
alternate to vs code is a tool called
11159
06:55:10,760 --> 06:55:13,478
VSS codium so VSS code is a tool that's
11160
06:55:13,478 --> 06:55:15,478
owned by Microsoft and it sends up
11161
06:55:15,478 --> 06:55:17,878
Telemetry data up to Microsoft so
11162
06:55:17,878 --> 06:55:20,280
basically it can send data about ways to
11163
06:55:20,280 --> 06:55:22,718
make your experience better with vs code
11164
06:55:22,718 --> 06:55:24,240
for people who have a more security
11165
06:55:24,240 --> 06:55:26,798
mindset this is an open- sourced version
11166
06:55:26,798 --> 06:55:28,840
of vs code that I highly recommend you
11167
06:55:28,840 --> 06:55:30,958
check it out another extension that you
11168
06:55:30,958 --> 06:55:32,958
might want to add is GitHub co-pilot
11169
06:55:32,958 --> 06:55:35,760
Labs get up co-pilot Labs has AI
11170
06:55:35,760 --> 06:55:37,760
features that are experimental so it
11171
06:55:37,760 --> 06:55:39,320
might be worth installing as well all
11172
06:55:39,320 --> 06:55:41,080
right fantastic at this point you should
11173
06:55:41,080 --> 06:55:44,000
be 100% set up with Visual Studio code
11174
06:55:44,000 --> 06:55:46,320
and git if you're using git pod that's
11175
06:55:46,320 --> 06:55:47,798
great as well and if you're using
11176
06:55:47,798 --> 06:55:50,680
Windows you should be 100% using WSL
11177
06:55:50,680 --> 06:55:51,958
because the rest of the commands are
11178
06:55:51,958 --> 06:55:54,638
only going to work if you're using WSL
11179
06:55:54,638 --> 06:55:55,878
and we're only going to be working with
11180
06:55:55,878 --> 06:55:58,558
Linux bash or zsh commands moving
11181
06:55:58,558 --> 06:56:00,638
forward if you want to be a Hardo like I
11182
06:56:00,638 --> 06:56:01,878
was saying do everything in Powershell
11183
06:56:01,878 --> 06:56:03,920
that's great too moving forward what I
11184
06:56:03,920 --> 06:56:05,718
want you guys all to do is open up your
11185
06:56:05,718 --> 06:56:07,920
terminal the different ways I showed you
11186
06:56:07,920 --> 06:56:10,760
and create a folder by typing in mkd
11187
06:56:10,760 --> 06:56:15,280
foundary hyphen f23 and then you do CD
11188
06:56:15,280 --> 06:56:17,718
foundary f23 you'll notice something
11189
06:56:17,718 --> 06:56:19,478
else I do a lot is I'll type the first
11190
06:56:19,478 --> 06:56:21,280
couple letters of the folder I want to
11191
06:56:21,280 --> 06:56:24,200
go into and then I'll hit tab which will
11192
06:56:24,200 --> 06:56:27,080
autocomplete a lot of stuff for you in
11193
06:56:27,080 --> 06:56:28,638
the terminal sometimes it doesn't work
11194
06:56:28,638 --> 06:56:29,798
you'll get better at figuring out what
11195
06:56:29,798 --> 06:56:31,558
Auto completes and what doesn't I hit
11196
06:56:31,558 --> 06:56:34,840
enter this means I'm now inside of my
11197
06:56:34,840 --> 06:56:35,878
Foundry
11198
06:56:35,878 --> 06:56:38,878
f23 folder and I can run commands inside
11199
06:56:38,878 --> 06:56:40,798
of this folder moving forward I want you
11200
06:56:40,798 --> 06:56:43,320
to put all of your repositories inside
11201
06:56:43,320 --> 06:56:45,398
this folder this way moving forward in
11202
06:56:45,398 --> 06:56:46,718
the future when you start actually
11203
06:56:46,718 --> 06:56:48,440
working on projects in real life you can
11204
06:56:48,440 --> 06:56:50,760
refer back to this folder and refer back
11205
06:56:50,760 --> 06:56:52,958
to code that you wrote and refer back to
11206
06:56:52,958 --> 06:56:55,160
your notes to make sure that you
11207
06:56:55,160 --> 06:56:56,878
understand stuff moving forward we've
11208
06:56:56,878 --> 06:57:00,920
got git D- version Forge D- verion we
11209
06:57:00,920 --> 06:57:04,798
have cast d D version which cast came
11210
06:57:04,798 --> 06:57:08,240
with Forge and Foundry we have Anvil --
11211
06:57:08,240 --> 06:57:11,240
version and we also have chisle D-
11212
06:57:11,240 --> 06:57:13,360
version I'm going to type clear or hit
11213
06:57:13,360 --> 06:57:17,600
command K to clear everything in the
11214
06:57:18,920 --> 06:57:21,000
terminal and all right now that we have
11215
06:57:21,000 --> 06:57:22,520
everything set up let's go ahead and
11216
06:57:22,520 --> 06:57:25,000
start creating our simple storage
11217
06:57:25,000 --> 06:57:27,320
project in a professional environment
11218
06:57:27,320 --> 06:57:29,080
this is going to be the exact same
11219
06:57:29,080 --> 06:57:31,680
environment that the big protocols use
11220
06:57:31,680 --> 06:57:33,680
these are the environments that Unis
11221
06:57:33,680 --> 06:57:37,120
swap a curve Etc these billion dooll
11222
06:57:37,120 --> 06:57:39,160
groups use you are learning the exact
11223
06:57:39,160 --> 06:57:41,680
same tools as them additionally for
11224
06:57:41,680 --> 06:57:43,040
those of you who are interested in
11225
06:57:43,040 --> 06:57:45,398
security and auditing Foundry is the
11226
06:57:45,398 --> 06:57:48,160
most popular tool amongst Auditors so
11227
06:57:48,160 --> 06:57:49,280
for those of you who want to become
11228
06:57:49,280 --> 06:57:50,680
security researchers you're going to
11229
06:57:50,680 --> 06:57:53,160
learn the exact same tools that the best
11230
06:57:53,160 --> 06:57:57,840
of the best use you ready I sure am so
11231
06:57:57,840 --> 06:58:00,320
let's go ahead and create a new folder
11232
06:58:00,320 --> 06:58:02,600
inside of this folder here to do this
11233
06:58:02,600 --> 06:58:04,080
we're going to type
11234
06:58:04,080 --> 06:58:09,680
mkdir foundary simple storage f23 and
11235
06:58:09,680 --> 06:58:12,080
then we're going to CD into Foundry
11236
06:58:12,080 --> 06:58:14,878
simple storage f23 and you'll notice I
11237
06:58:14,878 --> 06:58:17,360
hit tab there to autocomplete again now
11238
06:58:17,360 --> 06:58:19,000
everyone's terminals are going to look a
11239
06:58:19,000 --> 06:58:21,680
little bit differently mine tells me the
11240
06:58:21,680 --> 06:58:24,320
exact path of the folder that I'm in but
11241
06:58:24,320 --> 06:58:27,000
I have a Alias called video shell which
11242
06:58:27,000 --> 06:58:28,600
just shows me the current folder that
11243
06:58:28,600 --> 06:58:30,798
I'm in and I'm going to use that for the
11244
06:58:30,798 --> 06:58:33,120
rest of the video so if you see my
11245
06:58:33,120 --> 06:58:35,240
terminal look like this it means I'm at
11246
06:58:35,240 --> 06:58:37,478
this location now if you're inside of
11247
06:58:37,478 --> 06:58:39,718
this folder you can actually type in
11248
06:58:39,718 --> 06:58:42,080
code and then hit a period and then you
11249
06:58:42,080 --> 06:58:45,000
should get a new Visual Studio code
11250
06:58:45,000 --> 06:58:47,840
which is now defaulted to that folder if
11251
06:58:47,840 --> 06:58:50,600
you don't you can also hit file open
11252
06:58:50,600 --> 06:58:52,638
folder and select the folder that you
11253
06:58:52,638 --> 06:58:55,200
want to open which will also open up a
11254
06:58:55,200 --> 06:58:57,558
new Visual Studio code inside of that
11255
06:58:57,558 --> 06:59:00,120
folder if you open up your terminal now
11256
06:59:00,120 --> 06:59:02,440
you'll see that we are indeed in in the
11257
06:59:02,440 --> 06:59:04,920
folder for this project and now on the
11258
06:59:04,920 --> 06:59:07,080
left hand side over here this Explorer
11259
06:59:07,080 --> 06:59:09,638
piece we create a file you'll see it pop
11260
06:59:09,638 --> 06:59:12,440
up in the left hand side of our Explorer
11261
06:59:12,440 --> 06:59:16,160
touch is a command to create or touch a
11262
06:59:16,160 --> 06:59:19,080
file and we go ahead and click it and
11263
06:59:19,080 --> 06:59:21,878
type stuff in this file now all these CD
11264
06:59:21,878 --> 06:59:25,040
and mkd and all these commands are known
11265
06:59:25,040 --> 06:59:28,160
as bash or zsh or like Linux terminal
11266
06:59:28,160 --> 06:59:29,600
commands and we're going to be using
11267
06:59:29,600 --> 06:59:31,600
them a lot throughout this course if you
11268
06:59:31,600 --> 06:59:33,478
want it's a great lesson on working with
11269
06:59:33,478 --> 06:59:35,360
bash and CCH and Linux commands on the
11270
06:59:35,360 --> 06:59:37,440
free Cod Camp YouTube but at the same
11271
06:59:37,440 --> 06:59:40,440
time most of the time chat gbt and most
11272
06:59:40,440 --> 06:59:43,440
AIS are actually very well-versed in
11273
06:59:43,440 --> 06:59:45,760
bash and Linux commands so anytime you
11274
06:59:45,760 --> 06:59:47,280
have a problem doing something you can
11275
06:59:47,280 --> 06:59:49,160
often just ask one of these AIS and it
11276
06:59:49,160 --> 06:59:50,798
can help you out as of recording this
11277
06:59:50,798 --> 06:59:53,000
one just came out a couple weeks ago so
11278
06:59:53,000 --> 06:59:54,638
it's incredibly up to date so if you
11279
06:59:54,638 --> 06:59:56,160
want to get the basics down it's only
11280
06:59:56,160 --> 06:59:57,958
about 45 minutes long I definitely
11281
06:59:57,958 --> 06:59:59,520
recommend watching this so you can at
11282
06:59:59,520 --> 07:00:01,280
least be familiar with some of the power
11283
07:00:01,280 --> 07:00:03,558
that Bash has you can absolutely
11284
07:00:03,558 --> 07:00:06,040
continue on with the course as is and
11285
07:00:06,040 --> 07:00:08,360
just use AI to augment you but for those
11286
07:00:08,360 --> 07:00:09,638
of you who want to get more knowledge
11287
07:00:09,638 --> 07:00:11,240
definitely check that out and again the
11288
07:00:11,240 --> 07:00:14,080
reason I have this- f23 is to let
11289
07:00:14,080 --> 07:00:15,520
everyone know that this is associated
11290
07:00:15,520 --> 07:00:17,000
with The Foundry
11291
07:00:17,000 --> 07:00:19,878
2023 course but awesome we can actually
11292
07:00:19,878 --> 07:00:21,680
begin getting set up with our own local
11293
07:00:21,680 --> 07:00:23,798
environments similar to that remix VM
11294
07:00:23,798 --> 07:00:25,240
that we saw when we were working with
11295
07:00:25,240 --> 07:00:27,558
remix we can work with our own local
11296
07:00:27,558 --> 07:00:30,000
blockchain and do a bunch of stuff
11297
07:00:30,000 --> 07:00:32,240
locally as you can tell by the name of
11298
07:00:32,240 --> 07:00:33,840
this project and from what I was saying
11299
07:00:33,840 --> 07:00:35,760
earlier this is going to be our simple
11300
07:00:35,760 --> 07:00:38,360
storage project but coded with Foundry
11301
07:00:38,360 --> 07:00:40,240
which again is a smart contract
11302
07:00:40,240 --> 07:00:41,558
development framework that's going to
11303
07:00:41,558 --> 07:00:43,398
make our deployments and interactions
11304
07:00:43,398 --> 07:00:45,478
with our code much more professional to
11305
07:00:45,478 --> 07:00:47,200
get started with Foundry what we can do
11306
07:00:47,200 --> 07:00:48,840
is we can open up our Explorer to see
11307
07:00:48,840 --> 07:00:50,760
what's in here let's go ahead and delete
11308
07:00:50,760 --> 07:00:53,840
high. txt move to trash I'm going to do
11309
07:00:53,840 --> 07:00:56,000
my video shell command here which won't
11310
07:00:56,000 --> 07:00:57,478
work for you but it works for me what
11311
07:00:57,478 --> 07:00:58,478
we're going to do is we're going to run
11312
07:00:58,478 --> 07:01:01,360
a command to create a new Foundry basic
11313
07:01:01,360 --> 07:01:03,638
project for for us and if you go through
11314
07:01:03,638 --> 07:01:05,360
The Foundry documentation this is going
11315
07:01:05,360 --> 07:01:07,600
to be basically this creating a new
11316
07:01:07,600 --> 07:01:09,760
project section of the documentation and
11317
07:01:09,760 --> 07:01:10,878
if you want to follow along with the
11318
07:01:10,878 --> 07:01:12,958
documentation you can do that as well
11319
07:01:12,958 --> 07:01:14,200
but to do this we're just going to run
11320
07:01:14,200 --> 07:01:17,958
Forge in knit like this and we'll see it
11321
07:01:17,958 --> 07:01:20,398
created a ton of folders over on the
11322
07:01:20,398 --> 07:01:22,240
left hand side for us and if you run
11323
07:01:22,240 --> 07:01:23,520
into an error because you accidentally
11324
07:01:23,520 --> 07:01:25,000
have some files in here for example if I
11325
07:01:25,000 --> 07:01:26,478
run Forge init right now it's going to
11326
07:01:26,478 --> 07:01:28,878
say oh it's not an empty directory what
11327
07:01:28,878 --> 07:01:32,200
we can do is type Forge init D- Force
11328
07:01:32,200 --> 07:01:34,160
period to say let's do it in this
11329
07:01:34,160 --> 07:01:36,160
directory hit enter and it's actually
11330
07:01:36,160 --> 07:01:37,320
going to give us an error because it's
11331
07:01:37,320 --> 07:01:38,600
going to go hey it already has
11332
07:01:38,600 --> 07:01:40,200
everything that I was going to do so it
11333
07:01:40,200 --> 07:01:42,360
just it's just not going to do anything
11334
07:01:42,360 --> 07:01:44,280
but if you have files in here already
11335
07:01:44,280 --> 07:01:46,958
you just add this-- Force piece now if
11336
07:01:46,958 --> 07:01:49,360
you get a different error about git
11337
07:01:49,360 --> 07:01:51,160
Basel is actually going to help us
11338
07:01:51,160 --> 07:01:53,360
triage that so take it away and we are
11339
07:01:53,360 --> 07:01:54,958
getting this error and this is pretty
11340
07:01:54,958 --> 07:01:57,080
common don't worry reason is because
11341
07:01:57,080 --> 07:01:59,478
even though git comes pre-install it on
11342
07:01:59,478 --> 07:02:02,760
our WSL install we still have to
11343
07:02:02,760 --> 07:02:06,240
configure our username and our email so
11344
07:02:06,240 --> 07:02:08,638
we can just use this commands change
11345
07:02:08,638 --> 07:02:11,840
this one my actual email and now let's
11346
07:02:11,840 --> 07:02:15,280
also configure the username after we
11347
07:02:15,280 --> 07:02:17,600
have these configurations we can run
11348
07:02:17,600 --> 07:02:21,240
that command again P init hello fundry
11349
07:02:21,240 --> 07:02:23,920
and if we check this out we have our
11350
07:02:23,920 --> 07:02:26,920
first fundry project ready to be used
11351
07:02:26,920 --> 07:02:28,878
with all the things we are going to need
11352
07:02:28,878 --> 07:02:30,680
and let's walk through what we have over
11353
07:02:30,680 --> 07:02:32,520
on the left hand side here so we have
11354
07:02:32,520 --> 07:02:35,240
this GitHub slork flows file which we're
11355
07:02:35,240 --> 07:02:36,718
going to ignore for now but we'll
11356
07:02:36,718 --> 07:02:39,000
explain this later we have lib which
11357
07:02:39,000 --> 07:02:40,440
we're also going to ignore for now but
11358
07:02:40,440 --> 07:02:43,040
we'll explain later we have script with
11359
07:02:43,040 --> 07:02:45,600
a file in here which for now we're going
11360
07:02:45,600 --> 07:02:47,320
to go ahead and
11361
07:02:47,320 --> 07:02:50,320
delete we have SRC which is where we're
11362
07:02:50,320 --> 07:02:51,920
going to put all of our smart contracts
11363
07:02:51,920 --> 07:02:53,920
that we want to deploy right now it
11364
07:02:53,920 --> 07:02:56,680
comes packed with this counter. Soul
11365
07:02:56,680 --> 07:02:59,280
which we're also going to delete move to
11366
07:02:59,280 --> 07:03:01,958
trash and then we also have test which
11367
07:03:01,958 --> 07:03:03,798
we haven't learned about yet but we will
11368
07:03:03,798 --> 07:03:05,240
and for now once again you guessed it
11369
07:03:05,240 --> 07:03:06,320
we're going to go ahead and right click
11370
07:03:06,320 --> 07:03:08,440
and delete source is going to be the
11371
07:03:08,440 --> 07:03:09,600
main section that we're going to be
11372
07:03:09,600 --> 07:03:12,680
working with SRC stands for source and
11373
07:03:12,680 --> 07:03:14,240
you'll see in a lot of projects this is
11374
07:03:14,240 --> 07:03:16,000
where they put all of their main
11375
07:03:16,000 --> 07:03:18,080
contracts test is where we're going to
11376
07:03:18,080 --> 07:03:20,920
put code to test what's in SRC and
11377
07:03:20,920 --> 07:03:22,398
script is where we're going to put code
11378
07:03:22,398 --> 07:03:24,200
to interact with our contracts that are
11379
07:03:24,200 --> 07:03:27,080
in SRC get ignore is going to be files
11380
07:03:27,080 --> 07:03:29,360
that we're not going to push up to
11381
07:03:29,360 --> 07:03:31,840
GitHub if we push our code to GitHub
11382
07:03:31,840 --> 07:03:33,478
which is going to be really important
11383
07:03:33,478 --> 07:03:35,878
get modules we get ignore for Now teach
11384
07:03:35,878 --> 07:03:39,160
about that later and founder. toml is a
11385
07:03:39,160 --> 07:03:41,920
file that is going to give us
11386
07:03:41,920 --> 07:03:43,878
configuration parameters about working
11387
07:03:43,878 --> 07:03:45,920
with Foundry and as we go along in this
11388
07:03:45,920 --> 07:03:47,478
course we're going to update this folder
11389
07:03:47,478 --> 07:03:49,240
because we're going to update how we're
11390
07:03:49,240 --> 07:03:50,878
going to work with Foundry now for us to
11391
07:03:50,878 --> 07:03:52,360
get started here we're going to add our
11392
07:03:52,360 --> 07:03:54,760
simple storage code into the SRC or
11393
07:03:54,760 --> 07:03:56,958
Source folder if you close your remix we
11394
07:03:56,958 --> 07:03:59,160
can just come on back to the repo
11395
07:03:59,160 --> 07:04:01,160
associated with this course we'll scroll
11396
07:04:01,160 --> 07:04:04,320
down to to the remix simple storage
11397
07:04:04,320 --> 07:04:06,798
select the code base and we'll go here
11398
07:04:06,798 --> 07:04:09,798
and just copy all the code in here come
11399
07:04:09,798 --> 07:04:12,200
back over to vs code in an SRC we'll
11400
07:04:12,200 --> 07:04:15,600
right click new folder simple
11401
07:04:15,600 --> 07:04:19,878
storage. paste it in here and hit
11402
07:04:21,000 --> 07:04:23,000
save now one of the first things that
11403
07:04:23,000 --> 07:04:25,520
you'll notice is this is formatted
11404
07:04:25,520 --> 07:04:28,798
horribly it's just all white text this
11405
07:04:28,798 --> 07:04:30,558
cute little eth logo comes up which is
11406
07:04:30,558 --> 07:04:32,240
really nice but we want to way to
11407
07:04:32,240 --> 07:04:34,600
actually format this code correctly so
11408
07:04:34,600 --> 07:04:35,958
there are a lot of different vs code
11409
07:04:35,958 --> 07:04:37,680
extensions that actually will format our
11410
07:04:37,680 --> 07:04:40,160
solidity code for us one of them is the
11411
07:04:40,160 --> 07:04:42,638
solidity if we if we simply type
11412
07:04:42,638 --> 07:04:44,520
solidity in the extensions bar we'll get
11413
07:04:44,520 --> 07:04:46,958
a whole bunch of options that we can use
11414
07:04:46,958 --> 07:04:49,760
I'm a big fan of the hard hat solidity
11415
07:04:49,760 --> 07:04:51,478
extension even though hard hat is
11416
07:04:51,478 --> 07:04:54,200
another framework it also can format our
11417
07:04:54,200 --> 07:04:56,958
code in Foundry another one that a lot
11418
07:04:56,958 --> 07:04:59,478
of people like is the solidity visual
11419
07:04:59,478 --> 07:05:01,000
developer so that's another option if
11420
07:05:01,000 --> 07:05:02,320
you want to use that one
11421
07:05:02,320 --> 07:05:04,320
and this one by Juan Blanco is probably
11422
07:05:04,320 --> 07:05:06,200
the most used on the planet but we're
11423
07:05:06,200 --> 07:05:08,280
going to go ahead and hit install to
11424
07:05:08,280 --> 07:05:10,958
install this nomic Foundation solidity
11425
07:05:10,958 --> 07:05:13,478
vs code extension and if we go back to
11426
07:05:13,478 --> 07:05:15,240
our simple storage. soou you'll see it
11427
07:05:15,240 --> 07:05:17,160
is now formatted with syntax
11428
07:05:17,160 --> 07:05:19,600
highlighting similar to what we saw in
11429
07:05:19,600 --> 07:05:21,760
remix if it doesn't automatically
11430
07:05:21,760 --> 07:05:24,440
highlight for you here what we can do is
11431
07:05:24,440 --> 07:05:28,320
hit command shift p or control shift p
11432
07:05:28,320 --> 07:05:30,680
which opens up our Command bar here and
11433
07:05:30,680 --> 07:05:33,000
we can type in settings and we want to
11434
07:05:33,000 --> 07:05:35,718
open our user settings in Json you can
11435
07:05:35,718 --> 07:05:37,920
also hit code and then settings as well
11436
07:05:37,920 --> 07:05:40,878
in here and a lot of you might have
11437
07:05:40,878 --> 07:05:43,878
nothing in here so what you can do is
11438
07:05:43,878 --> 07:05:46,280
you create these little brackets to say
11439
07:05:46,280 --> 07:05:47,718
hey whatever is in here is going to be
11440
07:05:47,718 --> 07:05:50,240
our new settings and we want to type
11441
07:05:50,240 --> 07:05:52,600
these little quotes little brackets and
11442
07:05:52,600 --> 07:05:56,040
say solidity like this little set little
11443
07:05:56,040 --> 07:05:59,040
colon here some more brackets and since
11444
07:05:59,040 --> 07:06:01,638
I'm using GI up co-pilot it's even
11445
07:06:01,638 --> 07:06:03,600
starting to give me suggestions which
11446
07:06:03,600 --> 07:06:05,798
I'll explain much later but we could do
11447
07:06:05,798 --> 07:06:09,080
editor dot but you could paste in this
11448
07:06:09,080 --> 07:06:11,000
editor. default formatter NCH
11449
07:06:11,000 --> 07:06:13,760
foundation. hardhead solidity I'll have
11450
07:06:13,760 --> 07:06:15,798
this code in the repo associated with
11451
07:06:15,798 --> 07:06:17,320
this course so you can just copy paste
11452
07:06:17,320 --> 07:06:19,000
this if you want to I've got a whole
11453
07:06:19,000 --> 07:06:20,080
bunch of other stuff in here so I'm
11454
07:06:20,080 --> 07:06:21,718
going to go ahead and delete this though
11455
07:06:21,718 --> 07:06:23,798
but that way your solidity code will
11456
07:06:23,798 --> 07:06:25,840
default format using that hardhead
11457
07:06:25,840 --> 07:06:28,478
extension that we just installed great
11458
07:06:28,478 --> 07:06:31,638
additionally this
11459
07:06:31,638 --> 07:06:33,840
also isn't formatted very well so we'll
11460
07:06:33,840 --> 07:06:36,680
go to extensions we'll type in toml and
11461
07:06:36,680 --> 07:06:38,798
we'll install this better toml here
11462
07:06:38,798 --> 07:06:42,000
close this now if we go to Foundry doomo
11463
07:06:42,000 --> 07:06:44,760
we'll see this is now highlighted very
11464
07:06:44,760 --> 07:06:47,160
nicely too great now just remember
11465
07:06:47,160 --> 07:06:48,718
whenever you see this little dot here
11466
07:06:48,718 --> 07:06:50,638
this means that it's not saved so hit
11467
07:06:50,638 --> 07:06:54,240
command s or file save and do that a lot
11468
07:06:54,240 --> 07:06:55,760
the other thing that's really good about
11469
07:06:55,760 --> 07:06:58,760
us adding that default formatter is in
11470
07:06:58,760 --> 07:07:00,478
our code here you know maybe this isn't
11471
07:07:00,478 --> 07:07:02,520
formatted very nicely right maybe we
11472
07:07:02,520 --> 07:07:04,520
we've got this over here and and this
11473
07:07:04,520 --> 07:07:07,080
over here and it's kind of not looking
11474
07:07:07,080 --> 07:07:10,080
very nice here if I go ahead and save
11475
07:07:10,080 --> 07:07:12,840
without formatting it'll save it here
11476
07:07:12,840 --> 07:07:15,240
but what we can do is if we add that
11477
07:07:15,240 --> 07:07:18,200
auto formatter now if we do command
11478
07:07:18,200 --> 07:07:20,840
shift p again that brings this up this
11479
07:07:20,840 --> 07:07:23,440
command pallet up you can also get it by
11480
07:07:23,440 --> 07:07:26,320
hitting view command pallet and we type
11481
07:07:26,320 --> 07:07:29,638
format document it'll format our code
11482
07:07:29,638 --> 07:07:31,638
automatically depending on what
11483
07:07:31,638 --> 07:07:33,840
formatter we're defaulting to since we
11484
07:07:33,840 --> 07:07:35,840
opened our Json and we defaulted to the
11485
07:07:35,840 --> 07:07:37,718
solidity hard hat it'll automatically
11486
07:07:37,718 --> 07:07:40,360
format with that if your code isn't
11487
07:07:40,360 --> 07:07:42,440
autof formatting that's okay don't worry
11488
07:07:42,440 --> 07:07:45,080
about this too much be sure to use AI a
11489
07:07:45,080 --> 07:07:46,760
web search and the forums to get your
11490
07:07:46,760 --> 07:07:48,558
formatting good the other thing that I
11491
07:07:48,558 --> 07:07:51,000
like to do is we'll go over to settings
11492
07:07:51,000 --> 07:07:52,798
again we're not going to go to the Json
11493
07:07:52,798 --> 07:07:55,000
we're going to open the user settings
11494
07:07:55,000 --> 07:07:57,240
and we're going to type in format on
11495
07:07:57,240 --> 07:08:01,000
Save and we'll check this box on this
11496
07:08:01,000 --> 07:08:03,000
way every time we save it'll
11497
07:08:03,000 --> 07:08:05,160
automatically format so if I have this
11498
07:08:05,160 --> 07:08:06,718
and I hit save it'll automatically
11499
07:08:06,718 --> 07:08:09,000
format my solidity code for me if I
11500
07:08:09,000 --> 07:08:11,120
don't want it to format again we open
11501
07:08:11,120 --> 07:08:13,000
the command pallet with command shift p
11502
07:08:13,000 --> 07:08:16,160
or view command pallet and we can say
11503
07:08:16,160 --> 07:08:18,120
save without formatting and it'll save
11504
07:08:18,120 --> 07:08:20,160
it see the white dot is gone and it will
11505
07:08:20,160 --> 07:08:23,120
not be formatted but I'm going to save
11506
07:08:23,120 --> 07:08:24,520
and reformat it because I like it
11507
07:08:24,520 --> 07:08:26,600
formatted and just to note we pretty
11508
07:08:26,600 --> 07:08:28,200
much never want to open these default
11509
07:08:28,200 --> 07:08:33,000
settings Jason so avoid that one
11510
07:08:34,160 --> 07:08:36,320
all right great and just with this
11511
07:08:36,320 --> 07:08:38,280
little pieces of code and Foundry
11512
07:08:38,280 --> 07:08:41,080
installed we can go ahead and compile
11513
07:08:41,080 --> 07:08:43,600
our simple storage. Soul right in our
11514
07:08:43,600 --> 07:08:45,680
terminal so what we can do is we pull up
11515
07:08:45,680 --> 07:08:49,320
our terminal and we can type in Forge
11516
07:08:49,320 --> 07:08:52,760
build or Forge compile and this will
11517
07:08:52,760 --> 07:08:56,000
compile our code like so once we compile
11518
07:08:56,000 --> 07:08:58,280
we see a couple new folders show up one
11519
07:08:58,280 --> 07:09:01,680
of them is out and this file in out has
11520
07:09:01,680 --> 07:09:03,240
all the different information that the
11521
07:09:03,240 --> 07:09:05,878
remix compiler would have for example it
11522
07:09:05,878 --> 07:09:09,200
has the ABI we go back to remix we go to
11523
07:09:09,200 --> 07:09:11,200
the compiler tab we go to one of our
11524
07:09:11,200 --> 07:09:13,478
contracts we scroll down we can see we
11525
07:09:13,478 --> 07:09:16,320
have the ABI section or it's also in the
11526
07:09:16,320 --> 07:09:18,718
compilation details in vs code we can
11527
07:09:18,718 --> 07:09:20,600
even click this little drop down thing
11528
07:09:20,600 --> 07:09:23,600
next to it and it'll minimize the ABI
11529
07:09:23,600 --> 07:09:25,440
and we can see the rest of this stuff
11530
07:09:25,440 --> 07:09:28,280
like B code method identifiers and all
11531
07:09:28,280 --> 07:09:30,120
this other stuff which we'll learn about
11532
07:09:30,120 --> 07:09:33,520
later we also get this cache folder this
11533
07:09:33,520 --> 07:09:35,200
is a folder that you could basically
11534
07:09:35,200 --> 07:09:37,798
ignore now anytime in our terminal we
11535
07:09:37,798 --> 07:09:40,200
hit up we can actually cycle through
11536
07:09:40,200 --> 07:09:42,240
commands that we've recently run so if I
11537
07:09:42,240 --> 07:09:43,878
run some crazy long command like this
11538
07:09:43,878 --> 07:09:45,798
Echo here which is a bash command don't
11539
07:09:45,798 --> 07:09:47,360
worry about it and I want to run it
11540
07:09:47,360 --> 07:09:50,398
again I can just hit
11541
07:09:51,360 --> 07:09:54,120
up all right great so one of the things
11542
07:09:54,120 --> 07:09:57,080
that we did in remix quite a lot was we
11543
07:09:57,080 --> 07:09:59,558
deployed our code to a remix VM or a
11544
07:09:59,558 --> 07:10:01,680
JavaScript virtual environment we want
11545
07:10:01,680 --> 07:10:04,080
to be able to do the exact same thing in
11546
07:10:04,080 --> 07:10:06,320
Foundry in order to test and interact
11547
07:10:06,320 --> 07:10:08,320
with our contracts Foundry actually
11548
07:10:08,320 --> 07:10:10,878
comes built in with a virtual
11549
07:10:10,878 --> 07:10:12,798
environment in the shell and if you run
11550
07:10:12,798 --> 07:10:15,680
Anvil you'll get an output that looks
11551
07:10:15,680 --> 07:10:17,798
and we pull this to the top you'll get
11552
07:10:17,798 --> 07:10:20,280
an output that looks something like this
11553
07:10:20,280 --> 07:10:23,160
Anvil and we get some fake available
11554
07:10:23,160 --> 07:10:26,120
accounts with some fake private Keys
11555
07:10:26,120 --> 07:10:28,878
you'll also get a wallet pneumonic the
11556
07:10:28,878 --> 07:10:31,320
derivation path which you can ignore
11557
07:10:31,320 --> 07:10:33,680
some details about the blockchain and
11558
07:10:33,680 --> 07:10:36,718
then this endpoint or RPC URL which
11559
07:10:36,718 --> 07:10:38,680
we're going to learn about soon for now
11560
07:10:38,680 --> 07:10:41,280
if you want to close this hit contrl C
11561
07:10:41,280 --> 07:10:43,558
or just delete your terminal to end
11562
07:10:43,558 --> 07:10:46,520
running the Anvil blockchain now moving
11563
07:10:46,520 --> 07:10:48,638
forward we're going to work with Anvil
11564
07:10:48,638 --> 07:10:49,600
but I do want to give you an
11565
07:10:49,600 --> 07:10:51,878
intermediary step that's going to be
11566
07:10:51,878 --> 07:10:54,600
with the ganach eth chain and we'll have
11567
07:10:54,600 --> 07:10:56,680
a link to this in the GitHub repo
11568
07:10:56,680 --> 07:10:59,360
associated with this lesson ginach is a
11569
07:10:59,360 --> 07:11:03,240
oneclick blockchain and gives us a user
11570
07:11:03,240 --> 07:11:06,040
interface or an app for us to look at
11571
07:11:06,040 --> 07:11:09,120
our transactions in an easier way so if
11572
07:11:09,120 --> 07:11:10,680
you go ahead and download it for your
11573
07:11:10,680 --> 07:11:13,320
system we can get started there now a
11574
07:11:13,320 --> 07:11:15,760
note for Windows users if you're using
11575
07:11:15,760 --> 07:11:19,280
WSL the setup here is a little funky we
11576
07:11:19,280 --> 07:11:20,878
ran into some issues with it in our
11577
07:11:20,878 --> 07:11:23,000
previous course and we'll have some
11578
07:11:23,000 --> 07:11:24,440
troubleshooting tips for those of you
11579
07:11:24,440 --> 07:11:26,638
who are using Windows and WSL if you
11580
07:11:26,638 --> 07:11:28,798
want to work with ganach everything that
11581
07:11:28,798 --> 07:11:30,160
we're going to be doing moving forward
11582
07:11:30,160 --> 07:11:33,040
though does work work with Anvil ganach
11583
07:11:33,040 --> 07:11:35,398
just allows us to see transactions a
11584
07:11:35,398 --> 07:11:37,160
little bit better than viewing all this
11585
07:11:37,160 --> 07:11:38,958
stuff in the terminal so if you're
11586
07:11:38,958 --> 07:11:41,160
having a hard time with ganache don't
11587
07:11:41,160 --> 07:11:42,680
worry we can do everything that we're
11588
07:11:42,680 --> 07:11:44,558
doing with Anvil which should work for
11589
07:11:44,558 --> 07:11:46,360
you no problem once you have ganach
11590
07:11:46,360 --> 07:11:48,600
installed when you open it up it'll look
11591
07:11:48,600 --> 07:11:50,638
something like this and if we hit quick
11592
07:11:50,638 --> 07:11:53,120
start for ethereum we'll actually create
11593
07:11:53,120 --> 07:11:57,160
a brand new locally running blockchain
11594
07:11:57,160 --> 07:11:59,718
with a nice little UI to view things
11595
07:11:59,718 --> 07:12:01,798
same as Anvil and same as REM we get
11596
07:12:01,798 --> 07:12:04,000
some addresses we get each of them has
11597
07:12:04,000 --> 07:12:05,878
balances they come with some dummy
11598
07:12:05,878 --> 07:12:08,398
private keys and dummy addresses and the
11599
07:12:08,398 --> 07:12:10,718
likes what's nice about this is that we
11600
07:12:10,718 --> 07:12:12,920
can see the blocks we can see different
11601
07:12:12,920 --> 07:12:14,638
transactions and if we're working with
11602
07:12:14,638 --> 07:12:16,200
truffle we can see contracts we're not
11603
07:12:16,200 --> 07:12:17,920
going to work with truffle though but
11604
07:12:17,920 --> 07:12:19,520
these are going to be very helpful for
11605
07:12:19,520 --> 07:12:21,718
us to view stuff additionally we're not
11606
07:12:21,718 --> 07:12:23,718
going to use ganache again in the future
11607
07:12:23,718 --> 07:12:25,760
so if you have trouble setting up with
11608
07:12:25,760 --> 07:12:28,398
it don't worry just use Anvil I'm going
11609
07:12:28,398 --> 07:12:30,638
to use it to show you what's going on
11610
07:12:30,638 --> 07:12:31,718
remember though
11611
07:12:31,718 --> 07:12:33,360
don't use these private keys on a public
11612
07:12:33,360 --> 07:12:35,040
blockchain it's for development purposes
11613
07:12:35,040 --> 07:12:36,478
only because everyone knows these
11614
07:12:36,478 --> 07:12:38,040
private Keys cuz they're dummy private
11615
07:12:38,040 --> 07:12:40,398
Keys now in order for us to learn how to
11616
07:12:40,398 --> 07:12:42,760
actually deploy to this blockchain or
11617
07:12:42,760 --> 07:12:44,600
how to deploy to Anvil if we're working
11618
07:12:44,600 --> 07:12:47,280
with Anvil we need to understand how
11619
07:12:47,280 --> 07:12:49,478
even remix was able to deploy to a
11620
07:12:49,478 --> 07:12:51,520
public blockchain when in remix when we
11621
07:12:51,520 --> 07:12:53,520
switch to injected provider of metamask
11622
07:12:53,520 --> 07:12:55,638
we know that metamask popped up it asked
11623
07:12:55,638 --> 07:12:57,760
us to add our password and we went ahead
11624
07:12:57,760 --> 07:12:59,360
and got connected and if we looked in
11625
07:12:59,360 --> 07:13:01,520
metamask we saw our account is indeed
11626
07:13:01,520 --> 07:13:04,520
connected to saoo when we hit deploy our
11627
07:13:04,520 --> 07:13:07,120
Rass popped up again and it was able to
11628
07:13:07,120 --> 07:13:10,398
deploy our contract to a real test
11629
07:13:10,398 --> 07:13:12,958
Network well how did it know where to
11630
07:13:12,958 --> 07:13:14,600
send our transaction how did it know
11631
07:13:14,600 --> 07:13:17,360
where to send our contract well let's go
11632
07:13:17,360 --> 07:13:20,000
ahead and open up our metamask here if
11633
07:13:20,000 --> 07:13:21,638
we click the three little dots and hit
11634
07:13:21,638 --> 07:13:23,920
expand view we hit the little button now
11635
07:13:23,920 --> 07:13:26,320
and we go to settings and we go to
11636
07:13:26,320 --> 07:13:29,160
networks you'll actually see in here
11637
07:13:29,160 --> 07:13:31,760
that each one of these Networks ethereum
11638
07:13:31,760 --> 07:13:34,120
mainnet Gil sapoia Linea or whatever you
11639
07:13:34,120 --> 07:13:36,120
have comes with a whole bunch of
11640
07:13:36,120 --> 07:13:38,000
information let's go to eth mainnet and
11641
07:13:38,000 --> 07:13:39,638
check that out for a second it has a
11642
07:13:39,638 --> 07:13:43,840
name an RPC URL a chain ID currency
11643
07:13:43,840 --> 07:13:46,680
symbol and block Explorer this RPC URL
11644
07:13:46,680 --> 07:13:49,200
is the actual https endpoint that we
11645
07:13:49,200 --> 07:13:51,760
actually send API calls to when we're
11646
07:13:51,760 --> 07:13:54,320
sending transactions so whenever you
11647
07:13:54,320 --> 07:13:57,240
interact with metamask and you send a
11648
07:13:57,240 --> 07:13:59,320
transaction or you deploy a contract
11649
07:13:59,320 --> 07:14:01,240
you're actually making an API call to
11650
07:14:01,240 --> 07:14:03,558
whatever is in here you'll see this is
11651
07:14:03,558 --> 07:14:06,080
an infura endpoint and infura is known
11652
07:14:06,080 --> 07:14:08,920
as a node as a service project that
11653
07:14:08,920 --> 07:14:11,600
allows you to send transactions to a
11654
07:14:11,600 --> 07:14:13,120
blockchain node without having to run
11655
07:14:13,120 --> 07:14:15,440
one yourself if you wanted to send
11656
07:14:15,440 --> 07:14:17,398
transactions to your own blockchain node
11657
07:14:17,398 --> 07:14:19,398
you would just Swap this out with your
11658
07:14:19,398 --> 07:14:21,958
own blockchain node address we can't
11659
07:14:21,958 --> 07:14:23,840
actually change the ones that come built
11660
07:14:23,840 --> 07:14:26,360
into mamass but we can add new networks
11661
07:14:26,360 --> 07:14:28,160
which is what we're going to do now in
11662
07:14:28,160 --> 07:14:29,478
here if we scroll to the bottom we can
11663
07:14:29,478 --> 07:14:32,200
hit add Network manually and we can add
11664
07:14:32,200 --> 07:14:34,958
information about our own custom Network
11665
07:14:34,958 --> 07:14:36,958
so for us we're going to make this new
11666
07:14:36,958 --> 07:14:40,360
network called local host or local chain
11667
07:14:40,360 --> 07:14:42,798
or whatever you want to call it for RPC
11668
07:14:42,798 --> 07:14:45,280
URL if you're working with ganach it's
11669
07:14:45,280 --> 07:14:48,040
going to be this RPC server right here
11670
07:14:48,040 --> 07:14:50,320
if you're working with Anvil at the
11671
07:14:50,320 --> 07:14:53,000
bottom we have this listening here so
11672
07:14:53,000 --> 07:14:55,240
what we would do is we would copy this
11673
07:14:55,240 --> 07:14:57,920
or we would copy this from ganache and
11674
07:14:57,920 --> 07:15:00,280
paste it in here just note that you
11675
07:15:00,280 --> 07:15:04,798
always need the HTTP or https col slash
11676
07:15:04,798 --> 07:15:06,478
most of our local applications aren't
11677
07:15:06,478 --> 07:15:08,520
going to be https they're just going to
11678
07:15:08,520 --> 07:15:11,280
be HTTP so if you're working with ganach
11679
07:15:11,280 --> 07:15:12,718
let's go ahead and copy the ganach
11680
07:15:12,718 --> 07:15:15,558
endpoint paste it in here like so every
11681
07:15:15,558 --> 07:15:17,320
single blockchain gets their own chain
11682
07:15:17,320 --> 07:15:19,680
ID it's an easy way for us to know which
11683
07:15:19,680 --> 07:15:21,638
blockchain that we're interacting with
11684
07:15:21,638 --> 07:15:24,878
gach has 1337 and Anvil doesn't say it
11685
07:15:24,878 --> 07:15:29,000
but it's 31 337 so Anvil is
11686
07:15:29,000 --> 07:15:31,760
31337 since I'm using the endpoint here
11687
07:15:31,760 --> 07:15:34,040
I'm going to typee in 1337 if you're
11688
07:15:34,040 --> 07:15:36,520
using Anvil it would be
11689
07:15:36,520 --> 07:15:38,840
31337 but what's kind of nice is
11690
07:15:38,840 --> 07:15:40,478
metamask can actually identify what
11691
07:15:40,478 --> 07:15:42,440
you're using and identify the chain ID
11692
07:15:42,440 --> 07:15:44,520
and basically tell you what chain ID to
11693
07:15:44,520 --> 07:15:46,280
use just a note it looks like the newer
11694
07:15:46,280 --> 07:15:48,080
versions of ganos are using a different
11695
07:15:48,080 --> 07:15:50,958
RPC server and a different network ID
11696
07:15:50,958 --> 07:15:52,798
and make sure you're on this hard for
11697
07:15:52,798 --> 07:15:55,320
the merge here as well although in
11698
07:15:55,320 --> 07:15:56,920
practice I've found that even when you
11699
07:15:56,920 --> 07:15:57,878
have
11700
07:15:57,878 --> 07:16:01,878
5777 it still is expecting 137 7 so be
11701
07:16:01,878 --> 07:16:03,878
sure to use the correct chain ID when
11702
07:16:03,878 --> 07:16:05,558
you're working with this currency symbol
11703
07:16:05,558 --> 07:16:07,798
we're going to do eth and since this is
11704
07:16:07,798 --> 07:16:10,120
a local blockchain we don't actually
11705
07:16:10,120 --> 07:16:13,240
have a block Explorer ether scan has no
11706
07:16:13,240 --> 07:16:14,798
way to connect to our own local
11707
07:16:14,798 --> 07:16:16,878
blockchain so we don't get a block
11708
07:16:16,878 --> 07:16:18,840
explore for this one but if I go ahead
11709
07:16:18,840 --> 07:16:22,000
and hit save now it says Network added
11710
07:16:22,000 --> 07:16:23,398
successfully and I can go ahead and
11711
07:16:23,398 --> 07:16:26,320
switch to my local host chain boom and
11712
07:16:26,320 --> 07:16:28,958
now we can see it in my list of networks
11713
07:16:28,958 --> 07:16:32,280
of Local Host I've got no asset no nfts
11714
07:16:32,280 --> 07:16:34,798
and no activity now if your local Anvil
11715
07:16:34,798 --> 07:16:37,240
or ganache chain isn't running after
11716
07:16:37,240 --> 07:16:38,958
you've put it in your metamask if you
11717
07:16:38,958 --> 07:16:42,040
actually try to swap to your Anvil or to
11718
07:16:42,040 --> 07:16:43,798
your local host or to your ganache
11719
07:16:43,798 --> 07:16:45,280
you'll just get this spinning wheel of
11720
07:16:45,280 --> 07:16:46,760
death here right and eventually you'll
11721
07:16:46,760 --> 07:16:48,760
get this little a that'll show up and
11722
07:16:48,760 --> 07:16:50,080
you'll have to switch to a different
11723
07:16:50,080 --> 07:16:51,638
network so if you ever want to switch to
11724
07:16:51,638 --> 07:16:53,398
one of these that isn't running it won't
11725
07:16:53,398 --> 07:16:55,280
work you'll have to either run it or you
11726
07:16:55,280 --> 07:16:58,398
can hit X here and then in your metamask
11727
07:16:58,398 --> 07:17:00,120
you could just delete one of these right
11728
07:17:00,120 --> 07:17:01,798
here while while we're not running our
11729
07:17:01,798 --> 07:17:03,600
ganache or our Anvil we're just not
11730
07:17:03,600 --> 07:17:05,600
going to have one of these selected
11731
07:17:05,600 --> 07:17:08,080
great and so this is where on both Anvil
11732
07:17:08,080 --> 07:17:09,718
and ganache they have these available
11733
07:17:09,718 --> 07:17:11,840
accounts in these private keys since I'm
11734
07:17:11,840 --> 07:17:13,840
using ganache what I can do is I can
11735
07:17:13,840 --> 07:17:16,600
select this show Keys copy this private
11736
07:17:16,600 --> 07:17:19,760
key and import it into my metamask so I
11737
07:17:19,760 --> 07:17:21,718
can go up hit this little button I can
11738
07:17:21,718 --> 07:17:24,280
hit import account paste my private key
11739
07:17:24,280 --> 07:17:27,120
in here and hit import now you'll see in
11740
07:17:27,120 --> 07:17:28,398
my menas I have a couple different
11741
07:17:28,398 --> 07:17:30,840
accounts account three the one I just
11742
07:17:30,840 --> 07:17:33,680
imported has 100 eth why does it have
11743
07:17:33,680 --> 07:17:36,280
100 eth well because I'm using one of
11744
07:17:36,280 --> 07:17:38,600
these dumm accounts from ganach and
11745
07:17:38,600 --> 07:17:41,360
again if you're using Anvil they have
11746
07:17:41,360 --> 07:17:44,600
they start with a th000
11747
07:17:45,958 --> 07:17:50,280
eth this process that we just did to add
11748
07:17:50,280 --> 07:17:52,760
our new ganache local chain is also how
11749
07:17:52,760 --> 07:17:55,160
we're going to add any evm compatible
11750
07:17:55,160 --> 07:17:57,040
chain on the planet we'll just hit add
11751
07:17:57,040 --> 07:17:59,600
Network and metamask actually comes
11752
07:17:59,600 --> 07:18:01,398
built in with a lot of these and for
11753
07:18:01,398 --> 07:18:02,718
example if we wanted to work with
11754
07:18:02,718 --> 07:18:05,680
arbitrum 1 we could just hit add and it
11755
07:18:05,680 --> 07:18:08,320
would add all this information in for us
11756
07:18:08,320 --> 07:18:11,120
approve Network added successfully but
11757
07:18:11,120 --> 07:18:12,878
if metamask doesn't have those built in
11758
07:18:12,878 --> 07:18:15,080
that's the process now if we go back to
11759
07:18:15,080 --> 07:18:17,840
settings network Local Host this
11760
07:18:17,840 --> 07:18:19,638
endpoint is the most important thing you
11761
07:18:19,638 --> 07:18:21,478
need to send a transaction to a
11762
07:18:21,478 --> 07:18:24,040
blockchain you need a connection to a
11763
07:18:24,040 --> 07:18:26,398
node in order to send transactions to if
11764
07:18:26,398 --> 07:18:28,000
you wanted to send transactions to your
11765
07:18:28,000 --> 07:18:30,798
own node you would run something like G
11766
07:18:30,798 --> 07:18:32,600
which is an execution client and then
11767
07:18:32,600 --> 07:18:34,600
something maybe like teu a prism which
11768
07:18:34,600 --> 07:18:36,240
is a consensus client and send
11769
07:18:36,240 --> 07:18:38,040
transactions there I'm not going to go
11770
07:18:38,040 --> 07:18:39,878
over this right now but I highly
11771
07:18:39,878 --> 07:18:41,240
recommend that those of you who are
11772
07:18:41,240 --> 07:18:43,558
curious maybe you take some time and you
11773
07:18:43,558 --> 07:18:46,120
try to run your own ethereum node I run
11774
07:18:46,120 --> 07:18:47,920
many ethereum nodes and it's a lot of
11775
07:18:47,920 --> 07:18:49,638
fun that's kind of a weird thing to say
11776
07:18:49,638 --> 07:18:52,000
it's fun to run nodes whatever it is fun
11777
07:18:52,000 --> 07:18:53,478
to run nodes each one of these
11778
07:18:53,478 --> 07:18:55,320
blockchains has different methods you
11779
07:18:55,320 --> 07:18:57,240
could send to them to do things if
11780
07:18:57,240 --> 07:18:59,360
you're familiar with apis and HTTP
11781
07:18:59,360 --> 07:19:01,000
endpoints and you go to this ether eum
11782
07:19:01,000 --> 07:19:02,320
jsonrpc
11783
07:19:02,320 --> 07:19:04,638
specification site you can actually see
11784
07:19:04,638 --> 07:19:07,080
all the different methods that ethereum
11785
07:19:07,080 --> 07:19:09,320
blockchain nodes can make and most evm
11786
07:19:09,320 --> 07:19:11,200
blockchain nodes can make and when we
11787
07:19:11,200 --> 07:19:13,520
actually sign and send transactions it's
11788
07:19:13,520 --> 07:19:15,398
these calls that we're actually making
11789
07:19:15,398 --> 07:19:18,120
like e sign sign transaction send
11790
07:19:18,120 --> 07:19:20,600
transaction send raw transaction Etc
11791
07:19:20,600 --> 07:19:21,600
we're actually not going to be going
11792
07:19:21,600 --> 07:19:23,120
over interacting with these because
11793
07:19:23,120 --> 07:19:25,200
Forge actually handles a lot of sending
11794
07:19:25,200 --> 07:19:27,200
these transactions itself if you want to
11795
07:19:27,200 --> 07:19:29,478
learn how to send a raw transaction
11796
07:19:29,478 --> 07:19:31,680
making raw API calls to your own
11797
07:19:31,680 --> 07:19:33,680
ethereum node or an ethereum node as a
11798
07:19:33,680 --> 07:19:36,440
service like infura or Alchemy you would
11799
07:19:36,440 --> 07:19:37,718
do that in a different programming
11800
07:19:37,718 --> 07:19:41,638
language like bash python or
11801
07:19:43,040 --> 07:19:45,080
JavaScript all right awesome now that we
11802
07:19:45,080 --> 07:19:47,360
have our endpoint and our private key we
11803
07:19:47,360 --> 07:19:48,680
pretty much have everything that we need
11804
07:19:48,680 --> 07:19:50,920
to deploy to our own local blockchain be
11805
07:19:50,920 --> 07:19:53,080
it ganach or Anvil same as working with
11806
07:19:53,080 --> 07:19:54,798
a real blockchain we need an actual
11807
07:19:54,798 --> 07:19:57,760
balance to spend gas to deploy our
11808
07:19:57,760 --> 07:20:00,398
contract now there's actually two ways
11809
07:20:00,398 --> 07:20:02,718
that we're going to learn to deploy
11810
07:20:02,718 --> 07:20:04,840
contracts and the first way is actually
11811
07:20:04,840 --> 07:20:07,440
with just working with the command line
11812
07:20:07,440 --> 07:20:09,160
if we're in our command line if we're in
11813
07:20:09,160 --> 07:20:12,718
our terminal here and we do Forge d-el
11814
07:20:12,718 --> 07:20:14,160
we can actually see all the different
11815
07:20:14,160 --> 07:20:16,520
commands that Forge comes built in with
11816
07:20:16,520 --> 07:20:17,680
the one we're going to be working with
11817
07:20:17,680 --> 07:20:19,920
right now is this create command and if
11818
07:20:19,920 --> 07:20:21,920
you read it it says it deploys a smart
11819
07:20:21,920 --> 07:20:24,080
contract which is perfect that's exactly
11820
07:20:24,080 --> 07:20:26,120
what we want to do and if we're in our
11821
07:20:26,120 --> 07:20:27,600
Command here let's hit clear and we do
11822
07:20:27,600 --> 07:20:31,440
Forge create d-el we can you see a ton
11823
07:20:31,440 --> 07:20:33,798
of different options for deploying our
11824
07:20:33,798 --> 07:20:36,360
contract click show Keys copy the
11825
07:20:36,360 --> 07:20:38,798
private key again if you're using Anvil
11826
07:20:38,798 --> 07:20:40,440
use the private keys there if we do
11827
07:20:40,440 --> 07:20:43,558
Forge create simple storage which is the
11828
07:20:43,558 --> 07:20:45,840
name of our contract it'll compile and
11829
07:20:45,840 --> 07:20:48,320
then it'll throw an error actually or it
11830
07:20:48,320 --> 07:20:50,080
might actually work but because I'm
11831
07:20:50,080 --> 07:20:52,760
working with this RPC server but this
11832
07:20:52,760 --> 07:20:55,520
RPC server is different from the one
11833
07:20:55,520 --> 07:20:58,080
that Forge actually defaults to so
11834
07:20:58,080 --> 07:21:01,398
instead what I can do is Forge create
11835
07:21:01,398 --> 07:21:03,200
simple
11836
07:21:03,200 --> 07:21:08,558
storage-- RPC URL copy this paste it in
11837
07:21:08,558 --> 07:21:10,478
here it might be upset with the
11838
07:21:10,478 --> 07:21:11,718
uppercase so let's just make that
11839
07:21:11,718 --> 07:21:13,638
lowercase and I'll hit enter and this
11840
07:21:13,638 --> 07:21:15,920
won't work either well of course we
11841
07:21:15,920 --> 07:21:18,600
forgot to add a private key so if I hit
11842
07:21:18,600 --> 07:21:21,160
up I can hit--
11843
07:21:21,160 --> 07:21:24,080
interactive as well and now it'll prompt
11844
07:21:24,080 --> 07:21:26,920
me for a private key now and a really
11845
07:21:26,920 --> 07:21:29,120
important note that I want to tell you
11846
07:21:29,120 --> 07:21:31,600
never use a real private key in your vs
11847
07:21:31,600 --> 07:21:34,760
code if you're using an application that
11848
07:21:34,760 --> 07:21:36,958
potentially will send your information a
11849
07:21:36,958 --> 07:21:38,320
much better option is to use your own
11850
07:21:38,320 --> 07:21:40,360
terminal as opposed to something like vs
11851
07:21:40,360 --> 07:21:43,520
code which might send data or get pod
11852
07:21:43,520 --> 07:21:45,280
since we are just developing and we're
11853
07:21:45,280 --> 07:21:47,240
just practicing it's fine to paste our
11854
07:21:47,240 --> 07:21:49,440
private Keys here because this is a
11855
07:21:49,440 --> 07:21:51,040
private key that's not going to have any
11856
07:21:51,040 --> 07:21:53,840
real money right it's a fake private key
11857
07:21:53,840 --> 07:21:56,000
so for now we can go ahead we can go
11858
07:21:56,000 --> 07:21:58,120
back to our ganache or back to our envil
11859
07:21:58,120 --> 07:22:01,280
hit show Keys copy this private key key
11860
07:22:01,280 --> 07:22:04,040
paste it in here it won't show up if you
11861
07:22:04,040 --> 07:22:06,558
hit paste but I'll hit enter and we'll
11862
07:22:06,558 --> 07:22:09,398
go ahead and see information about our
11863
07:22:09,398 --> 07:22:11,200
transaction now if you're working with
11864
07:22:11,200 --> 07:22:13,718
ganach we can now hit done here we go to
11865
07:22:13,718 --> 07:22:16,718
blocks we see we created a new block we
11866
07:22:16,718 --> 07:22:18,798
go to transactions we can see that we
11867
07:22:18,798 --> 07:22:21,120
sent a transaction and we created a
11868
07:22:21,120 --> 07:22:23,840
contract and then you can see logs about
11869
07:22:23,840 --> 07:22:26,878
working with this as well fantastic if
11870
07:22:26,878 --> 07:22:28,440
you're working with Anvil and you send a
11871
07:22:28,440 --> 07:22:29,798
transaction you're not going to see any
11872
07:22:29,798 --> 07:22:31,478
of those details for those of you who
11873
07:22:31,478 --> 07:22:34,160
want to continue to see these blocks and
11874
07:22:34,160 --> 07:22:35,478
these transactions and want to keep
11875
07:22:35,478 --> 07:22:38,000
working with ganach feel free to do so
11876
07:22:38,000 --> 07:22:39,398
moving forward we're going to work with
11877
07:22:39,398 --> 07:22:40,958
Anvil so I'm actually going to close
11878
07:22:40,958 --> 07:22:43,200
ganache now I'm going to hit clear in
11879
07:22:43,200 --> 07:22:45,760
the terminal and I'm going to run Anvil
11880
07:22:45,760 --> 07:22:47,798
here and what I'm going to do is I'm
11881
07:22:47,798 --> 07:22:50,000
going to create a new terminal by
11882
07:22:50,000 --> 07:22:51,840
hitting the plus button here and we're
11883
07:22:51,840 --> 07:22:53,360
going to run that command again but
11884
07:22:53,360 --> 07:22:55,200
we're going to run it with a private key
11885
07:22:55,200 --> 07:22:57,638
from Anvil so if we go to here we do
11886
07:22:57,638 --> 07:23:00,760
Forge create this time we don't have to
11887
07:23:00,760 --> 07:23:04,120
put an RPC because Forge defaults to the
11888
07:23:04,120 --> 07:23:08,120
Anvil one but I can say simple storage
11889
07:23:08,120 --> 07:23:10,680
inter active it'll do enter the private
11890
07:23:10,680 --> 07:23:12,878
key I will paste it and we'll go ahead
11891
07:23:12,878 --> 07:23:15,000
and deploy go to Anvil we don't get any
11892
07:23:15,000 --> 07:23:17,360
logs like this but we can see we went
11893
07:23:17,360 --> 07:23:19,200
ahead and actually deployed it to our
11894
07:23:19,200 --> 07:23:21,478
Anvil blockchain awesome work another
11895
07:23:21,478 --> 07:23:23,080
way we can do this Forge create is by
11896
07:23:23,080 --> 07:23:27,000
running Forge create simple storage if
11897
07:23:27,000 --> 07:23:29,280
we wanted to be incredibly explicit we
11898
07:23:29,280 --> 07:23:34,280
would do D- RPC C- URL copy this
11899
07:23:34,280 --> 07:23:39,520
HTTP col paste it in there-- private key
11900
07:23:39,520 --> 07:23:42,558
and back in Anvil copy the private key
11901
07:23:42,558 --> 07:23:44,280
paste it in like this and we will get
11902
07:23:44,280 --> 07:23:46,638
the same
11903
07:23:47,958 --> 07:23:50,120
thing now here's what I'm going to tell
11904
07:23:50,120 --> 07:23:52,120
you and this is incredibly important
11905
07:23:52,120 --> 07:23:54,638
pasting in your private key like this is
11906
07:23:54,638 --> 07:23:57,760
no bueno very bad we pretty much never
11907
07:23:57,760 --> 07:23:59,920
want to have our private key in plain
11908
07:23:59,920 --> 07:24:01,080
text
11909
07:24:01,080 --> 07:24:03,558
especially our production or our private
11910
07:24:03,558 --> 07:24:05,240
keys with actual money putting this
11911
07:24:05,240 --> 07:24:07,080
private key in PL Tex is not a big deal
11912
07:24:07,080 --> 07:24:09,040
because this is a fake dummy one it's
11913
07:24:09,040 --> 07:24:11,160
also bad to have our private keys in our
11914
07:24:11,160 --> 07:24:14,920
shell or bash history if I hit up once
11915
07:24:14,920 --> 07:24:17,760
on my terminal I can see the private key
11916
07:24:17,760 --> 07:24:20,120
in here which is why the interactive is
11917
07:24:20,120 --> 07:24:21,878
a little bit better because it at least
11918
07:24:21,878 --> 07:24:24,958
offis skates the private key to remove
11919
07:24:24,958 --> 07:24:26,760
your private key from your history in
11920
07:24:26,760 --> 07:24:30,160
bash you can do history- c now if I hit
11921
07:24:30,160 --> 07:24:32,920
up I can't see any commands and if I do
11922
07:24:32,920 --> 07:24:35,120
history I can see my entire history
11923
07:24:35,120 --> 07:24:37,160
which is just the history keyword now if
11924
07:24:37,160 --> 07:24:39,798
I type clear I'll do history now I see
11925
07:24:39,798 --> 07:24:42,318
history clear history great and we don't
11926
07:24:42,318 --> 07:24:44,040
have the private key in our Command
11927
07:24:44,040 --> 07:24:46,638
history anymore we will learn more about
11928
07:24:46,638 --> 07:24:49,398
proper private Key Safety in the future
11929
07:24:49,398 --> 07:24:52,080
but I want you to do something for me
11930
07:24:52,080 --> 07:24:54,360
right now in a new file I want you to
11931
07:24:54,360 --> 07:24:58,360
rightclick and I want you to write
11932
07:24:58,360 --> 07:25:01,000
promise. MD we're going to hide the
11933
07:25:01,000 --> 07:25:04,080
terminal and in here we're going to say
11934
07:25:04,080 --> 07:25:09,638
I promise to never use my private key
11935
07:25:09,638 --> 07:25:13,638
associated with real money in plain text
11936
07:25:13,638 --> 07:25:16,360
in fact take this and tweet this I
11937
07:25:16,360 --> 07:25:18,240
promise to never use my private key
11938
07:25:18,240 --> 07:25:20,520
associated with real money in plain text
11939
07:25:20,520 --> 07:25:22,840
and I can't spell and that's fine and
11940
07:25:22,840 --> 07:25:24,840
then if you want to add me or you want
11941
07:25:24,840 --> 07:25:28,200
to add cyron audits or whatever go ahead
11942
07:25:28,200 --> 07:25:30,718
and send that we are going to have more
11943
07:25:30,718 --> 07:25:32,200
of these promises that you're going to
11944
07:25:32,200 --> 07:25:35,080
do but this is the first one that I need
11945
07:25:35,080 --> 07:25:37,520
you to understand right now it's cool
11946
07:25:37,520 --> 07:25:39,160
because these are dummy keys but in the
11947
07:25:39,160 --> 07:25:42,080
future it will definitely not be cool
11948
07:25:42,080 --> 07:25:44,000
and I'm stressing this because I've seen
11949
07:25:44,000 --> 07:25:46,240
a lot of multi-million dollar companies
11950
07:25:46,240 --> 07:25:48,160
not follow this and get their private
11951
07:25:48,160 --> 07:25:51,240
Keys hacked great now of course though
11952
07:25:51,240 --> 07:25:53,318
the basic way to deploy to any
11953
07:25:53,318 --> 07:25:55,958
blockchain would be Forge create the
11954
07:25:55,958 --> 07:25:59,200
name of your contract add the RPC URL
11955
07:25:59,200 --> 07:26:00,840
and then add your private key we're
11956
07:26:00,840 --> 07:26:03,920
going to learn how to get RP crls for
11957
07:26:03,920 --> 07:26:06,680
free using Alchemy for any blockchain
11958
07:26:06,680 --> 07:26:09,160
that we want and like I said more safe
11959
07:26:09,160 --> 07:26:11,280
private key methodologies in the future
11960
07:26:11,280 --> 07:26:12,638
but now you've just learned how to
11961
07:26:12,638 --> 07:26:14,718
deploy your contracts to any chain from
11962
07:26:14,718 --> 07:26:17,840
the command line this is
11963
07:26:18,840 --> 07:26:20,958
great all right great so now we've
11964
07:26:20,958 --> 07:26:23,360
learned how to actually deploy a
11965
07:26:23,360 --> 07:26:25,638
contract to any blockchain that we want
11966
07:26:25,638 --> 07:26:27,478
using the command line now I'm going to
11967
07:26:27,478 --> 07:26:28,840
teach you the second way we're going to
11968
07:26:28,840 --> 07:26:30,600
deploy our contracts and and this is the
11969
07:26:30,600 --> 07:26:31,680
way we're actually going to do it for
11970
07:26:31,680 --> 07:26:33,558
the rest of the course when we're
11971
07:26:33,558 --> 07:26:35,240
deploying our code we want to make sure
11972
07:26:35,240 --> 07:26:37,840
we have a continuous reproducible way to
11973
07:26:37,840 --> 07:26:39,840
deploy our smart contracts and when we
11974
07:26:39,840 --> 07:26:41,958
test our code in the future we want the
11975
07:26:41,958 --> 07:26:45,120
tests to test the deployment processes
11976
07:26:45,120 --> 07:26:47,680
as well as the code so instead of just
11977
07:26:47,680 --> 07:26:49,120
doing the command line we're actually
11978
07:26:49,120 --> 07:26:52,240
going to write a script for us to deploy
11979
07:26:52,240 --> 07:26:54,840
our code and because Foundry has
11980
07:26:54,840 --> 07:26:57,200
everything written in solidity this
11981
07:26:57,200 --> 07:26:58,520
script that we're going to write to
11982
07:26:58,520 --> 07:27:00,718
deploy our code is also going to be
11983
07:27:00,718 --> 07:27:03,878
written in solidity and this is where
11984
07:27:03,878 --> 07:27:06,040
solidity as a contract language versus
11985
07:27:06,040 --> 07:27:07,878
solidity as a scripting language is a
11986
07:27:07,878 --> 07:27:09,718
little bit different Foundry has a whole
11987
07:27:09,718 --> 07:27:12,120
bunch of built-in stuff to give our
11988
07:27:12,120 --> 07:27:14,440
solidity even more functionality outside
11989
07:27:14,440 --> 07:27:16,840
of just smart contracts and you'll learn
11990
07:27:16,840 --> 07:27:19,040
about how later in the course but for
11991
07:27:19,040 --> 07:27:21,160
now we're going to learn how to create a
11992
07:27:21,160 --> 07:27:23,718
script to deploy our simple storage
11993
07:27:23,718 --> 07:27:25,718
contract and the way we create a script
11994
07:27:25,718 --> 07:27:28,040
to do it is first we come to our script
11995
07:27:28,040 --> 07:27:30,520
folder we'll rightclick new file we'll
11996
07:27:30,520 --> 07:27:34,398
create deploy simple storage.
11997
07:27:34,398 --> 07:27:37,920
s.o this S.L is just a Foundry
11998
07:27:37,920 --> 07:27:40,600
convention most of the time scripts have
11999
07:27:40,600 --> 07:27:44,160
a s doou instead of just being doou and
12000
07:27:44,160 --> 07:27:46,080
in here we're actually going to write a
12001
07:27:46,080 --> 07:27:49,718
contract in solidity to deploy our smart
12002
07:27:49,718 --> 07:27:51,878
contract which sounds a little bit weird
12003
07:27:51,878 --> 07:27:53,798
but don't worry too much about that this
12004
07:27:53,798 --> 07:27:55,760
deploy script is going to be written in
12005
07:27:55,760 --> 07:27:57,440
solidity but it it shouldn't be
12006
07:27:57,440 --> 07:27:59,080
considered a contract that we actually
12007
07:27:59,080 --> 07:28:01,638
ever want to deploy it's just for
12008
07:28:01,638 --> 07:28:03,840
deploying our code but it is written in
12009
07:28:03,840 --> 07:28:05,240
solidity so since it's written in
12010
07:28:05,240 --> 07:28:06,638
solidity we'll do the same thing as
12011
07:28:06,638 --> 07:28:10,440
usual spdx license identifier MIT and if
12012
07:28:10,440 --> 07:28:12,558
you're using GitHub co-pilot it might
12013
07:28:12,558 --> 07:28:15,280
even Auto suggest like this and I'm just
12014
07:28:15,280 --> 07:28:17,600
going to go ahead and hit tab I'll do
12015
07:28:17,600 --> 07:28:20,840
pragma solidity
12016
07:28:20,840 --> 07:28:23,558
0.818 and then I'll create contract
12017
07:28:23,558 --> 07:28:27,120
deploy simple storage like so and I'll
12018
07:28:27,120 --> 07:28:29,160
hit save if you go to The Foundry docs
12019
07:28:29,160 --> 07:28:31,638
we can actually scroll down to this
12020
07:28:31,638 --> 07:28:33,318
solidity scripting section in the
12021
07:28:33,318 --> 07:28:35,798
tutorials and you can learn how to
12022
07:28:35,798 --> 07:28:37,240
actually write scripts and work with
12023
07:28:37,240 --> 07:28:39,080
scripts the first thing that we need to
12024
07:28:39,080 --> 07:28:41,280
do in order to tell that Foundry that
12025
07:28:41,280 --> 07:28:43,318
this is a script is we need to actually
12026
07:28:43,318 --> 07:28:45,478
import some additional code now one of
12027
07:28:45,478 --> 07:28:47,000
the things that we saw in here was this
12028
07:28:47,000 --> 07:28:49,280
lib folder and this lib folder actually
12029
07:28:49,280 --> 07:28:51,280
starts with another folder called Forge
12030
07:28:51,280 --> 07:28:54,558
STD this Forge STD stands for Forge
12031
07:28:54,558 --> 07:28:57,718
standard library in here there's a ton
12032
07:28:57,718 --> 07:29:01,000
of helpful tools and Scripts for working
12033
07:29:01,000 --> 07:29:03,558
with Foundry and to tell Foundry that
12034
07:29:03,558 --> 07:29:05,600
this contract deploy simple storage is
12035
07:29:05,600 --> 07:29:07,398
actually a script we need to import from
12036
07:29:07,398 --> 07:29:10,280
Forge STD so we're going to do import
12037
07:29:10,280 --> 07:29:12,200
Forge
12038
07:29:12,200 --> 07:29:16,200
dstd script. soul and we'll have our
12039
07:29:16,200 --> 07:29:18,638
contract deploy simple storage inherit
12040
07:29:18,638 --> 07:29:20,760
all the functionality of this script by
12041
07:29:20,760 --> 07:29:23,398
saying is script and I know we learned
12042
07:29:23,398 --> 07:29:25,080
about inheritance before so you should
12043
07:29:25,080 --> 07:29:28,080
know what that means is script and then
12044
07:29:28,080 --> 07:29:29,840
additionally our deploy simple storage
12045
07:29:29,840 --> 07:29:31,680
is is going to need to know about our
12046
07:29:31,680 --> 07:29:33,878
simple storage contract so we'll go
12047
07:29:33,878 --> 07:29:36,160
ahead and import that import we'll go
12048
07:29:36,160 --> 07:29:38,000
down a directory since we're in the
12049
07:29:38,000 --> 07:29:39,718
script folder and we need to go to the
12050
07:29:39,718 --> 07:29:42,280
SRC folder these two dots is how you go
12051
07:29:42,280 --> 07:29:46,160
down a directory we'll do slash SRC vs
12052
07:29:46,160 --> 07:29:48,600
code even might help prompt you here
12053
07:29:48,600 --> 07:29:51,280
Dash and it again Auto prompted for me
12054
07:29:51,280 --> 07:29:53,638
and I hit Tab and now we've imported
12055
07:29:53,638 --> 07:29:55,920
simple storage now since we know that
12056
07:29:55,920 --> 07:29:58,600
this is the noob way to do Imports we're
12057
07:29:58,600 --> 07:30:01,240
going to do the cool way by using named
12058
07:30:01,240 --> 07:30:04,160
Imports instead of nameless Imports okay
12059
07:30:04,160 --> 07:30:07,120
great now inside every deploy or script
12060
07:30:07,120 --> 07:30:09,558
contract we need our main function which
12061
07:30:09,558 --> 07:30:11,440
is going to be called run and this is
12062
07:30:11,440 --> 07:30:14,200
going to be the command that gets called
12063
07:30:14,200 --> 07:30:16,398
when we go to deploy our contract so
12064
07:30:16,398 --> 07:30:18,958
we'll create a function called run we'll
12065
07:30:18,958 --> 07:30:21,160
make it external and we can have a
12066
07:30:21,160 --> 07:30:24,200
return a simple storage contract and in
12067
07:30:24,200 --> 07:30:27,000
here we're going to use a new keyword
12068
07:30:27,000 --> 07:30:28,798
that we haven't used before we're going
12069
07:30:28,798 --> 07:30:33,160
to say VM start broadcast VM is a
12070
07:30:33,160 --> 07:30:35,760
special keyword in the Forge standard
12071
07:30:35,760 --> 07:30:38,160
Library the VM keyword is a special
12072
07:30:38,160 --> 07:30:40,398
keyword that we can only use in Foundry
12073
07:30:40,398 --> 07:30:41,958
it's related to something called cheat
12074
07:30:41,958 --> 07:30:44,240
codes we're not going to go over that
12075
07:30:44,240 --> 07:30:46,558
too deep right now you can see a whole
12076
07:30:46,558 --> 07:30:49,840
list of Foundry cheat codes in the
12077
07:30:49,840 --> 07:30:52,478
documentation and Forge standard Library
12078
07:30:52,478 --> 07:30:54,398
references which have even more cheat
12079
07:30:54,398 --> 07:30:56,878
codes as well this VM stuff is only
12080
07:30:56,878 --> 07:30:59,160
going to work in Foundry if you actually
12081
07:30:59,160 --> 07:31:01,200
were to try to deploy this in remix or
12082
07:31:01,200 --> 07:31:03,718
some other framework it wouldn't work
12083
07:31:03,718 --> 07:31:06,160
these VM cheat codes only work in
12084
07:31:06,160 --> 07:31:08,318
Foundry it's not valid in regular
12085
07:31:08,318 --> 07:31:11,040
solidity but if we're inheriting Forge
12086
07:31:11,040 --> 07:31:14,000
STD code this VM keyword exists if
12087
07:31:14,000 --> 07:31:16,240
you're using the hard hat solidity
12088
07:31:16,240 --> 07:31:18,200
extension we can actually control or
12089
07:31:18,200 --> 07:31:21,000
command click into VM and we can
12090
07:31:21,000 --> 07:31:24,000
actually see where it's defined but if
12091
07:31:24,000 --> 07:31:26,040
that's confusing ignore that for now
12092
07:31:26,040 --> 07:31:29,040
this vm. start broadcast says hey
12093
07:31:29,040 --> 07:31:31,160
everything after after this line inside
12094
07:31:31,160 --> 07:31:33,318
of this function you should actually
12095
07:31:33,318 --> 07:31:36,440
send to the RPC and then when we're done
12096
07:31:36,440 --> 07:31:39,798
broadcasting we're going to do vm. stop
12097
07:31:39,798 --> 07:31:42,878
broadcast so everything inside of these
12098
07:31:42,878 --> 07:31:45,638
is what we actually want to send and
12099
07:31:45,638 --> 07:31:47,718
deploy the reason we have this is
12100
07:31:47,718 --> 07:31:50,398
because maybe we have some stuff like we
12101
07:31:50,398 --> 07:31:52,478
want to set some boilerplate code before
12102
07:31:52,478 --> 07:31:54,318
we actually send transactions and we
12103
07:31:54,318 --> 07:31:56,080
don't want to spend any gas to like set
12104
07:31:56,080 --> 07:31:59,280
starting value to one right so any
12105
07:31:59,280 --> 07:32:01,318
transaction that we want to actually
12106
07:32:01,318 --> 07:32:04,200
send we need to put in between these vm.
12107
07:32:04,200 --> 07:32:07,120
start broadcast and vm. stop broadcast
12108
07:32:07,120 --> 07:32:09,040
and for us to deploy our simple storage
12109
07:32:09,040 --> 07:32:12,840
contract we just do simple storage
12110
07:32:12,840 --> 07:32:15,478
lowercase simple storage right these are
12111
07:32:15,478 --> 07:32:17,600
different simple storage the variable
12112
07:32:17,600 --> 07:32:21,600
simple storage the contract equals new
12113
07:32:21,600 --> 07:32:24,280
simple storage like this and remember
12114
07:32:24,280 --> 07:32:26,280
what does this new keyword do well the
12115
07:32:26,280 --> 07:32:28,840
new keyword creates a new contract in
12116
07:32:28,840 --> 07:32:31,360
solidity it's also going to create a new
12117
07:32:31,360 --> 07:32:34,318
contract in between our VM dostar
12118
07:32:34,318 --> 07:32:37,200
broadcast this being in between these VM
12119
07:32:37,200 --> 07:32:38,920
dostar broadcast is going to send a
12120
07:32:38,920 --> 07:32:41,120
transaction to create a new simple
12121
07:32:41,120 --> 07:32:43,318
storage contract if this is a little bit
12122
07:32:43,318 --> 07:32:45,558
confusing for you right now that's okay
12123
07:32:45,558 --> 07:32:47,440
it's going to make more sense as we go
12124
07:32:47,440 --> 07:32:50,160
on later in the course but for now just
12125
07:32:50,160 --> 07:32:52,558
do this and follow along with me and
12126
07:32:52,558 --> 07:32:56,120
then of course we can say turn simple
12127
07:32:56,120 --> 07:32:59,080
storage okay great now if we pull our
12128
07:32:59,080 --> 07:33:00,280
terminal back up
12129
07:33:00,280 --> 07:33:01,920
we can see we have Anvil running right
12130
07:33:01,920 --> 07:33:04,040
now we can actually kill it with contrl
12131
07:33:04,040 --> 07:33:07,000
C we'll clear to the top and what we can
12132
07:33:07,000 --> 07:33:12,200
do now is run Forge script script deploy
12133
07:33:12,200 --> 07:33:15,878
simple storage. s.o hit enter and look
12134
07:33:15,878 --> 07:33:17,600
oops looks like I got some different
12135
07:33:17,600 --> 07:33:21,160
solidity versions let's change this to a
12136
07:33:21,160 --> 07:33:24,120
carrot in here let's change this to a
12137
07:33:24,120 --> 07:33:27,440
carrot in here this being an 18 so that
12138
07:33:27,440 --> 07:33:29,840
they're both on the same version let's
12139
07:33:29,840 --> 07:33:32,398
type clear close these or minimize these
12140
07:33:32,398 --> 07:33:35,360
out we'll hit up twice and we'll run
12141
07:33:35,360 --> 07:33:37,398
this again and now what you'll see is
12142
07:33:37,398 --> 07:33:40,878
it's compiling it compiles both the
12143
07:33:40,878 --> 07:33:44,160
script to deploy and our simple storage
12144
07:33:44,160 --> 07:33:47,280
contract using 0.8.9 because we did the
12145
07:33:47,280 --> 07:33:49,398
car compiler successful script
12146
07:33:49,398 --> 07:33:51,478
successful tells us the gas and then we
12147
07:33:51,478 --> 07:33:53,080
went ahead we returned our simple
12148
07:33:53,080 --> 07:33:55,200
storage contract which was deployed here
12149
07:33:55,200 --> 07:33:56,718
now you might be asking wait wait wait
12150
07:33:56,718 --> 07:33:58,520
wait Patrick we we don't have Anvil
12151
07:33:58,520 --> 07:34:00,080
running we don't have a local blockchain
12152
07:34:00,080 --> 07:34:02,318
running where did this deploy to well in
12153
07:34:02,318 --> 07:34:05,718
Foundry if you don't specify an RPC URL
12154
07:34:05,718 --> 07:34:07,958
it'll just automatically deploy your
12155
07:34:07,958 --> 07:34:11,040
contract or run your script on a
12156
07:34:11,040 --> 07:34:13,958
temporary Anvil chain so once I ran
12157
07:34:13,958 --> 07:34:16,920
Forge script it saw there was no RPC URL
12158
07:34:16,920 --> 07:34:19,798
so it spun up a temporary Anvil
12159
07:34:19,798 --> 07:34:22,478
blockchain deployed our simple storage
12160
07:34:22,478 --> 07:34:24,840
and then tore it back down at the end
12161
07:34:24,840 --> 07:34:26,280
you can see at the bottom if you wish to
12162
07:34:26,280 --> 07:34:28,958
simulate on Trin transaction pass an RPC
12163
07:34:28,958 --> 07:34:32,718
URL so if we do clear we run Anvil and
12164
07:34:32,718 --> 07:34:35,760
then create a new terminal we could run
12165
07:34:35,760 --> 07:34:39,760
Forge script script deploy simple
12166
07:34:39,760 --> 07:34:42,200
storage at s.o and I'm hitting tab to
12167
07:34:42,200 --> 07:34:46,520
autocomplete that-- RPC URL go back to
12168
07:34:46,520 --> 07:34:51,240
Anvil copy this go back to bash
12169
07:34:51,240 --> 07:34:55,000
HTTP slash we actually almost deployed
12170
07:34:55,000 --> 07:34:57,240
this to the blockchain we actually did a
12171
07:34:57,240 --> 07:35:00,280
simulation of deploying to our chain
12172
07:35:00,280 --> 07:35:02,000
here it gives us one more piece of
12173
07:35:02,000 --> 07:35:03,600
information to broadcast these
12174
07:35:03,600 --> 07:35:07,440
transactions add-- broadcast and wallet
12175
07:35:07,440 --> 07:35:09,840
configurations to the previous command
12176
07:35:09,840 --> 07:35:13,280
and now we get a new folder which gives
12177
07:35:13,280 --> 07:35:15,200
us information about our previous
12178
07:35:15,200 --> 07:35:17,760
deployments in case we forget for
12179
07:35:17,760 --> 07:35:19,398
example if we deploy a contract we can
12180
07:35:19,398 --> 07:35:20,958
flip back here and see where we actually
12181
07:35:20,958 --> 07:35:23,000
deployed code so let's pull up our
12182
07:35:23,000 --> 07:35:25,558
terminal once more and actually deploy
12183
07:35:25,558 --> 07:35:27,760
this to the blockchain so we'll hit
12184
07:35:27,760 --> 07:35:32,120
clear I'll hit up we have our RPC URL so
12185
07:35:32,120 --> 07:35:36,840
now let's do D- broadcast and we'll do
12186
07:35:36,840 --> 07:35:40,478
D- private key and we'll grab a private
12187
07:35:40,478 --> 07:35:43,440
key from Anvil and paste that in here
12188
07:35:43,440 --> 07:35:45,878
and hit enter boom and we see at the
12189
07:35:45,878 --> 07:35:48,798
bottom onchain execution complete and
12190
07:35:48,798 --> 07:35:50,718
successful we see we get some
12191
07:35:50,718 --> 07:35:53,040
transactions here we waited for receipts
12192
07:35:53,040 --> 07:35:55,558
Etc so fantastic so we learned how to
12193
07:35:55,558 --> 07:35:58,798
actually deploy our smart contracts
12194
07:35:58,798 --> 07:36:00,798
through these script in command now
12195
07:36:00,798 --> 07:36:03,240
awesome
12196
07:36:04,318 --> 07:36:06,680
job now let's learn a little bit more
12197
07:36:06,680 --> 07:36:09,360
about what actually just happened right
12198
07:36:09,360 --> 07:36:11,120
because right now sending transactions
12199
07:36:11,120 --> 07:36:13,280
is still kind of this magic thing right
12200
07:36:13,280 --> 07:36:15,040
so let's hide our terminal and let's go
12201
07:36:15,040 --> 07:36:17,600
up to our Explorer let's pull this out a
12202
07:36:17,600 --> 07:36:20,440
little bit and let's go into here now
12203
07:36:20,440 --> 07:36:21,760
what's important to note is that there's
12204
07:36:21,760 --> 07:36:23,318
actually a couple different folders in
12205
07:36:23,318 --> 07:36:25,878
here dry run is the folder whenever we
12206
07:36:25,878 --> 07:36:27,718
don't have a blockchain running
12207
07:36:27,718 --> 07:36:30,080
otherwise this gets separated by
12208
07:36:30,080 --> 07:36:31,520
chain ID and we'll talk about this a
12209
07:36:31,520 --> 07:36:33,040
little bit later but if we go into one
12210
07:36:33,040 --> 07:36:35,000
of these either dry run or or even just
12211
07:36:35,000 --> 07:36:37,200
run latest we'll see details about the
12212
07:36:37,200 --> 07:36:39,840
transaction we'll see a hash transaction
12213
07:36:39,840 --> 07:36:41,718
type contract name address blah blah
12214
07:36:41,718 --> 07:36:44,200
blah this right here this transaction
12215
07:36:44,200 --> 07:36:47,200
section is actually what is getting sent
12216
07:36:47,200 --> 07:36:49,958
on the Chain when we do Forge script or
12217
07:36:49,958 --> 07:36:52,920
Forge create this is the transaction
12218
07:36:52,920 --> 07:36:55,318
that we send to that RPC URL right this
12219
07:36:55,318 --> 07:36:57,360
is the API data if you're familiar with
12220
07:36:57,360 --> 07:36:59,120
https post this is the data that we
12221
07:36:59,120 --> 07:37:01,080
actually sent send we send the type
12222
07:37:01,080 --> 07:37:03,280
which for now just everything is type
12223
07:37:03,280 --> 07:37:05,160
two because we're in the merge don't
12224
07:37:05,160 --> 07:37:06,958
worry about type one for now we have a
12225
07:37:06,958 --> 07:37:09,478
from which is of course the from address
12226
07:37:09,478 --> 07:37:13,000
that we want to have we have a gas here
12227
07:37:13,000 --> 07:37:15,638
and this is the hex value of gas now if
12228
07:37:15,638 --> 07:37:17,160
we pull our terminal back up we'll clear
12229
07:37:17,160 --> 07:37:18,878
this out I'm about to show you an
12230
07:37:18,878 --> 07:37:20,280
amazing trick that's going to make your
12231
07:37:20,280 --> 07:37:22,520
life a lot easier Down the Line cast
12232
07:37:22,520 --> 07:37:24,520
actually can convert between hex and
12233
07:37:24,520 --> 07:37:26,638
numbers really easily and cast comes
12234
07:37:26,638 --> 07:37:30,040
built in with Foundry we do cast D- to
12235
07:37:30,040 --> 07:37:34,398
base paste our hex in here and write DEC
12236
07:37:34,398 --> 07:37:38,160
for decimal it'll convert this hex value
12237
07:37:38,160 --> 07:37:43,000
to its decimal value 0x 714 C2 whatever
12238
07:37:43,000 --> 07:37:45,680
is just this number and I use this cast
12239
07:37:45,680 --> 07:37:48,120
to base all the time you can put some
12240
07:37:48,120 --> 07:37:49,600
value in here and then what you want to
12241
07:37:49,600 --> 07:37:51,638
convert it to and it's a very easy way
12242
07:37:51,638 --> 07:37:53,760
to see what some value is there's some
12243
07:37:53,760 --> 07:37:56,558
other stuff in cast as well if you do
12244
07:37:56,558 --> 07:38:00,878
cast d-el there's some other ways to
12245
07:38:00,878 --> 07:38:03,080
convert different units to each other
12246
07:38:03,080 --> 07:38:05,878
like from way spites 32 and some other
12247
07:38:05,878 --> 07:38:07,958
stuff but two base is going to be one
12248
07:38:07,958 --> 07:38:09,718
that we're going to use a lot so we have
12249
07:38:09,718 --> 07:38:11,920
the gas we have the value with the
12250
07:38:11,920 --> 07:38:15,240
transaction yes since deploying a
12251
07:38:15,240 --> 07:38:17,440
contract is just a transaction we can
12252
07:38:17,440 --> 07:38:19,398
add a value to it if we want in our
12253
07:38:19,398 --> 07:38:21,398
deploy script right in here we would
12254
07:38:21,398 --> 07:38:22,958
just do some brackets we would say like
12255
07:38:22,958 --> 07:38:26,120
value and like one ether if we wanted to
12256
07:38:26,120 --> 07:38:29,040
deploy this with one ether we can't send
12257
07:38:29,040 --> 07:38:31,160
a value here because in solidity you
12258
07:38:31,160 --> 07:38:32,760
can't set the option value if the
12259
07:38:32,760 --> 07:38:34,318
Constructor is not payable we'd have to
12260
07:38:34,318 --> 07:38:35,878
make the Constructor payable but we
12261
07:38:35,878 --> 07:38:37,798
could send value just like any other
12262
07:38:37,798 --> 07:38:40,638
transaction there's this huge data piece
12263
07:38:40,638 --> 07:38:42,240
here this is actually the contract
12264
07:38:42,240 --> 07:38:44,398
deployment code and the contract code in
12265
07:38:44,398 --> 07:38:46,398
here we have the nuns which is going to
12266
07:38:46,398 --> 07:38:49,240
be that number that's only used once and
12267
07:38:49,240 --> 07:38:50,798
then don't worry about access list for
12268
07:38:50,798 --> 07:38:52,878
now but this is all the transaction
12269
07:38:52,878 --> 07:38:54,520
information and then of course we have
12270
07:38:54,520 --> 07:38:56,878
our RPC now what's not stored in here is
12271
07:38:56,878 --> 07:38:58,360
is a couple other pieces of the
12272
07:38:58,360 --> 07:39:00,360
transaction and additionally there are
12273
07:39:00,360 --> 07:39:03,318
these v r and s values that count for
12274
07:39:03,318 --> 07:39:05,360
the transaction signature it's not
12275
07:39:05,360 --> 07:39:06,478
getting saved here because it's
12276
07:39:06,478 --> 07:39:08,120
technically part of this from anyways
12277
07:39:08,120 --> 07:39:10,840
they're public values and these RS andv
12278
07:39:10,840 --> 07:39:13,040
allow our private key to sign the
12279
07:39:13,040 --> 07:39:15,638
transaction so what's really happening
12280
07:39:15,638 --> 07:39:17,760
when we send this the reason we need our
12281
07:39:17,760 --> 07:39:19,478
private key is we need the private key
12282
07:39:19,478 --> 07:39:22,040
to actually sign the transaction that we
12283
07:39:22,040 --> 07:39:23,878
built and that's happening a little bit
12284
07:39:23,878 --> 07:39:25,760
under the hood so whenever we send a
12285
07:39:25,760 --> 07:39:27,958
transaction there is a signature
12286
07:39:27,958 --> 07:39:30,760
happening we are signing a transaction
12287
07:39:30,760 --> 07:39:32,280
and then we are sending it and that's
12288
07:39:32,280 --> 07:39:33,920
important for later in the course they
12289
07:39:33,920 --> 07:39:35,878
don't save it here but signing the
12290
07:39:35,878 --> 07:39:38,760
transaction does happen when you sign a
12291
07:39:38,760 --> 07:39:40,398
transaction it's very similar to doing
12292
07:39:40,398 --> 07:39:42,360
that hex thing we showed you way way at
12293
07:39:42,360 --> 07:39:43,398
the beginning of the course with the
12294
07:39:43,398 --> 07:39:45,680
blockchain only the private key can sign
12295
07:39:45,680 --> 07:39:48,000
the transaction this is how when we send
12296
07:39:48,000 --> 07:39:50,798
our data to a node it knows that it's
12297
07:39:50,798 --> 07:39:52,718
able to execute it because it's signed
12298
07:39:52,718 --> 07:39:54,360
by our private key I'm not going to go
12299
07:39:54,360 --> 07:39:56,520
too deep into that right now this nuts
12300
07:39:56,520 --> 07:39:58,760
piece is a little bit important every
12301
07:39:58,760 --> 07:39:59,920
single wallet
12302
07:39:59,920 --> 07:40:02,318
has a counter of transactions which is
12303
07:40:02,318 --> 07:40:04,040
basically the nuns whenever you send a
12304
07:40:04,040 --> 07:40:06,398
transaction you give it a nuns or this
12305
07:40:06,398 --> 07:40:08,240
value this number only used once to
12306
07:40:08,240 --> 07:40:10,878
basically count your transactions this
12307
07:40:10,878 --> 07:40:12,520
is really good because if you want to
12308
07:40:12,520 --> 07:40:15,040
replay transactions you would just send
12309
07:40:15,040 --> 07:40:16,798
the same transaction data with the same
12310
07:40:16,798 --> 07:40:18,878
nuns for example if we have a
12311
07:40:18,878 --> 07:40:20,478
transaction that didn't go through
12312
07:40:20,478 --> 07:40:22,680
you'll see that this is in this run
12313
07:40:22,680 --> 07:40:25,680
latest with the dry if we run this again
12314
07:40:25,680 --> 07:40:27,638
if we hit up you'll see that if we run
12315
07:40:27,638 --> 07:40:29,760
our transaction again with our Anvil
12316
07:40:29,760 --> 07:40:31,558
deployed here we'll actually deploy
12317
07:40:31,558 --> 07:40:33,840
another transaction if we go back to our
12318
07:40:33,840 --> 07:40:35,398
broadcast folder we see there's actually
12319
07:40:35,398 --> 07:40:37,718
two runs and a new run latest if we go
12320
07:40:37,718 --> 07:40:40,360
to our run latest now you'll see that
12321
07:40:40,360 --> 07:40:43,760
the most the latest run now has 0x1 so
12322
07:40:43,760 --> 07:40:45,478
this increments every single time we
12323
07:40:45,478 --> 07:40:47,680
send a transaction your nuns increments
12324
07:40:47,680 --> 07:40:50,160
every time you send a transaction and
12325
07:40:50,160 --> 07:40:52,000
again contract deployments are
12326
07:40:52,000 --> 07:40:54,120
transactions now we went over a lot of
12327
07:40:54,120 --> 07:40:55,440
stuff in here but the most important
12328
07:40:55,440 --> 07:40:57,120
takeaway I want you to have from this is
12329
07:40:57,120 --> 07:40:58,318
anytime you change State on the
12330
07:40:58,318 --> 07:41:01,160
blockchain it does it in a transaction
12331
07:41:01,160 --> 07:41:02,878
and the differentiator is going to be
12332
07:41:02,878 --> 07:41:05,200
what's ever in this data field this data
12333
07:41:05,200 --> 07:41:07,200
field contains the op codes to tell the
12334
07:41:07,200 --> 07:41:09,520
blockchain hey I'd like to create a new
12335
07:41:09,520 --> 07:41:11,520
contract we're not really going to go
12336
07:41:11,520 --> 07:41:13,878
too deep into what these op codes are or
12337
07:41:13,878 --> 07:41:16,200
this evm bite code we'll briefly talk
12338
07:41:16,200 --> 07:41:18,040
about op codes later in this course but
12339
07:41:18,040 --> 07:41:20,318
if you want to really learn about op
12340
07:41:20,318 --> 07:41:21,760
codes and assembly we have another
12341
07:41:21,760 --> 07:41:23,200
course on security coming out that we'll
12342
07:41:23,200 --> 07:41:25,040
go over that but this is the most
12343
07:41:25,040 --> 07:41:27,360
important thing to take away when we're
12344
07:41:27,360 --> 07:41:28,920
in remix and we're sending transactions
12345
07:41:28,920 --> 07:41:31,360
with these buttons we're doing the exact
12346
07:41:31,360 --> 07:41:32,920
same thing we're populating the data
12347
07:41:32,920 --> 07:41:35,160
field of a transaction but instead of
12348
07:41:35,160 --> 07:41:37,040
the data being associated with creating
12349
07:41:37,040 --> 07:41:39,280
a contract the data is associated with
12350
07:41:39,280 --> 07:41:41,878
sending a
12351
07:41:50,080 --> 07:41:52,520
transaction right great now that we've
12352
07:41:52,520 --> 07:41:53,798
actually deployed our contracts though
12353
07:41:53,798 --> 07:41:55,080
we should learn how to interact with
12354
07:41:55,080 --> 07:41:56,680
them in the same way that remix allows
12355
07:41:56,680 --> 07:41:57,840
us to interact with them with our
12356
07:41:57,840 --> 07:41:59,638
buttons here now there's two ways to
12357
07:41:59,638 --> 07:42:01,440
actually interact with our contracts one
12358
07:42:01,440 --> 07:42:03,160
is going to be doing what we did before
12359
07:42:03,160 --> 07:42:05,000
with scripts but the other way is
12360
07:42:05,000 --> 07:42:06,478
actually going to be doing directly from
12361
07:42:06,478 --> 07:42:08,000
the command line so we're actually going
12362
07:42:08,000 --> 07:42:10,080
to learn the command line Parts in this
12363
07:42:10,080 --> 07:42:11,040
project and then we're going to learn
12364
07:42:11,040 --> 07:42:13,240
how to do scripts in a later project so
12365
07:42:13,240 --> 07:42:15,600
let's pull up our terminal here and just
12366
07:42:15,600 --> 07:42:17,680
to make sure that we have this deployed
12367
07:42:17,680 --> 07:42:20,120
let's hit up a couple times and we'll
12368
07:42:20,120 --> 07:42:22,718
rerun this deploy script now in just a
12369
07:42:22,718 --> 07:42:24,000
second we're going to learn how to
12370
07:42:24,000 --> 07:42:26,000
actually interact with our contracts
12371
07:42:26,000 --> 07:42:27,600
from the command line as well similar to
12372
07:42:27,600 --> 07:42:29,520
how remix has all these but buttons that
12373
07:42:29,520 --> 07:42:32,120
we can press however first we're going
12374
07:42:32,120 --> 07:42:34,040
to make this a little bit better and
12375
07:42:34,040 --> 07:42:35,398
we're going to take a couple of
12376
07:42:35,398 --> 07:42:38,080
different approaches to not having this
12377
07:42:38,080 --> 07:42:40,200
in the command line as you saw before we
12378
07:42:40,200 --> 07:42:42,638
could use Forge create interactive paste
12379
07:42:42,638 --> 07:42:44,718
our private key in and it wouldn't be in
12380
07:42:44,718 --> 07:42:46,878
our command line we actually can't use
12381
07:42:46,878 --> 07:42:49,318
interactive for when we're sending
12382
07:42:49,318 --> 07:42:50,840
scripts at the moment I'm sure in the
12383
07:42:50,840 --> 07:42:51,840
future they'll make it a little bit
12384
07:42:51,840 --> 07:42:53,920
easier for us to do this but right now
12385
07:42:53,920 --> 07:42:56,160
we really don't want to have to do--
12386
07:42:56,160 --> 07:42:58,440
private key and paste our private key in
12387
07:42:58,440 --> 07:43:01,520
PL Tex so what else can we do what
12388
07:43:01,520 --> 07:43:03,958
alternatives can do we have now what I'm
12389
07:43:03,958 --> 07:43:06,878
about to show you once again only do
12390
07:43:06,878 --> 07:43:09,280
this for your development environments
12391
07:43:09,280 --> 07:43:11,318
do not put a real private key in here
12392
07:43:11,318 --> 07:43:12,958
the reason I'm showing you this is
12393
07:43:12,958 --> 07:43:15,478
because it is much quicker to test
12394
07:43:15,478 --> 07:43:17,040
however it's terrible to use in
12395
07:43:17,040 --> 07:43:18,318
production so this is cool for
12396
07:43:18,318 --> 07:43:20,680
development purposes this is not cool
12397
07:43:20,680 --> 07:43:23,318
for actual production purposes what
12398
07:43:23,318 --> 07:43:24,080
we're going to do is we're going to
12399
07:43:24,080 --> 07:43:26,680
create a new file called EnV and
12400
07:43:26,680 --> 07:43:28,638
whenever you create a EnV the first
12401
07:43:28,638 --> 07:43:30,478
thing you should do is go to a g ignore
12402
07:43:30,478 --> 07:43:34,798
file make sure that a EnV is in this G
12403
07:43:34,798 --> 07:43:37,160
ignore I'll explain what the dog ignore
12404
07:43:37,160 --> 07:43:39,200
does in the future but for now just have
12405
07:43:39,200 --> 07:43:41,360
that be the first thing you do in our DV
12406
07:43:41,360 --> 07:43:43,000
file we can put in what's called
12407
07:43:43,000 --> 07:43:45,080
environment variables these are
12408
07:43:45,080 --> 07:43:47,000
variables that might be a little bit
12409
07:43:47,000 --> 07:43:48,318
sensitive that we don't want to actually
12410
07:43:48,318 --> 07:43:49,638
write in the command line or
12411
07:43:49,638 --> 07:43:51,638
accidentally expose to the public one of
12412
07:43:51,638 --> 07:43:52,840
those of course is going to be our
12413
07:43:52,840 --> 07:43:57,000
private key so let's go to Anvil scroll
12414
07:43:57,000 --> 07:44:00,080
up grab that private key copy and paste
12415
07:44:00,080 --> 07:44:02,200
it in here and we have this private key
12416
07:44:02,200 --> 07:44:04,840
equals this typically you'll also see
12417
07:44:04,840 --> 07:44:09,440
RPC URL equals what's our Anvil RPC Rel
12418
07:44:09,440 --> 07:44:11,558
let this right here so we'll do
12419
07:44:11,558 --> 07:44:14,920
HTTP SL slash paste that in there and
12420
07:44:14,920 --> 07:44:17,000
great now that we have those in there
12421
07:44:17,000 --> 07:44:20,360
what we can do is now run source. EMV
12422
07:44:20,360 --> 07:44:22,160
which will add these environment
12423
07:44:22,160 --> 07:44:25,638
variables into our shell here and we can
12424
07:44:25,638 --> 07:44:28,398
do Echo private key like that and we'll
12425
07:44:28,398 --> 07:44:30,200
see our private the key actually show up
12426
07:44:30,200 --> 07:44:32,718
like so we can also do Echo dollar sign
12427
07:44:32,718 --> 07:44:36,160
RPC URL and we'll see our RPC URL
12428
07:44:36,160 --> 07:44:37,680
actually show up like this and then what
12429
07:44:37,680 --> 07:44:40,360
we could do is we could go back to our
12430
07:44:40,360 --> 07:44:42,360
Forge script and instead of typing in
12431
07:44:42,360 --> 07:44:44,360
our private key we would just do dollar
12432
07:44:44,360 --> 07:44:48,760
sign private key and dollar sign RPC URL
12433
07:44:48,760 --> 07:44:51,000
so now our RPC URL and our private key
12434
07:44:51,000 --> 07:44:53,440
at least aren't being run in our command
12435
07:44:53,440 --> 07:44:55,680
line so that it's not stored in our
12436
07:44:55,680 --> 07:44:57,760
Shell's history the issue of course is
12437
07:44:57,760 --> 07:45:00,000
that okay well now we have it stored in
12438
07:45:00,000 --> 07:45:02,680
this EnV anytime you have your key
12439
07:45:02,680 --> 07:45:04,558
stored in plain text you should be
12440
07:45:04,558 --> 07:45:06,798
afraid you should be a little bit
12441
07:45:06,798 --> 07:45:09,478
nervous so we can actually take one more
12442
07:45:09,478 --> 07:45:12,040
step to make this even more secure and
12443
07:45:12,040 --> 07:45:13,000
this is going to be one of the steps
12444
07:45:13,000 --> 07:45:14,160
that I recommend that you take when
12445
07:45:14,160 --> 07:45:15,798
you're actually working with production
12446
07:45:15,798 --> 07:45:17,958
code you definitely do not want to
12447
07:45:17,958 --> 07:45:20,318
launch production code with aemv file
12448
07:45:20,318 --> 07:45:22,558
and I'm going to summarize all this very
12449
07:45:22,558 --> 07:45:24,558
soon just stick with me I promise this
12450
07:45:24,558 --> 07:45:25,798
is a little bit boring but it's
12451
07:45:25,798 --> 07:45:27,600
incredibly incredibly important that you
12452
07:45:27,600 --> 07:45:29,200
get this right and I'm going to try to
12453
07:45:29,200 --> 07:45:30,680
prevent you from getting wrecked now
12454
07:45:30,680 --> 07:45:32,440
Foundry is a tool that is constantly
12455
07:45:32,440 --> 07:45:34,478
being improved and updated and there's
12456
07:45:34,478 --> 07:45:36,200
an issue in The Foundry repo right now
12457
07:45:36,200 --> 07:45:38,200
called improve wallet management us
12458
07:45:38,200 --> 07:45:40,718
using key store I would love a way for
12459
07:45:40,718 --> 07:45:42,398
you to actually encrypt your private
12460
07:45:42,398 --> 07:45:45,120
keys so that none of you accidentally
12461
07:45:45,120 --> 07:45:46,638
push a private key up to GitHub or
12462
07:45:46,638 --> 07:45:48,280
expose a private key that it's in PL
12463
07:45:48,280 --> 07:45:52,200
text if you run Forge script d-el and
12464
07:45:52,200 --> 07:45:54,398
you scroll up you get this wallet
12465
07:45:54,398 --> 07:45:56,120
options section where you can actually
12466
07:45:56,120 --> 07:45:58,600
pass the path to an encrypted key store
12467
07:45:58,600 --> 07:46:01,600
file and a password a key store is a
12468
07:46:01,600 --> 07:46:03,840
file that has your private key but
12469
07:46:03,840 --> 07:46:05,920
encrypted by a password instead of
12470
07:46:05,920 --> 07:46:08,120
having your private key in PL text you
12471
07:46:08,120 --> 07:46:09,280
would have it encrypted and you would
12472
07:46:09,280 --> 07:46:10,718
just need the password to decrypt it
12473
07:46:10,718 --> 07:46:13,920
that is a much safer way to deploy your
12474
07:46:13,920 --> 07:46:16,080
contracts I've added some context in
12475
07:46:16,080 --> 07:46:18,558
another issue on Foundry as well and if
12476
07:46:18,558 --> 07:46:19,920
you all could come in here and give this
12477
07:46:19,920 --> 07:46:21,920
a thumbs up that would be fantastic a
12478
07:46:21,920 --> 07:46:24,080
way to encrypt your private key into a
12479
07:46:24,080 --> 07:46:25,958
key store file natively doesn't exist in
12480
07:46:25,958 --> 07:46:28,080
Foundry yet but I've put out a bounty
12481
07:46:28,080 --> 07:46:30,000
for someone to actually implement this
12482
07:46:30,000 --> 07:46:31,600
so be sure to just check the G up repo
12483
07:46:31,600 --> 07:46:33,440
associated with this course to check to
12484
07:46:33,440 --> 07:46:35,680
see whether this feature is implemented
12485
07:46:35,680 --> 07:46:37,360
so what I'm really trying to get at is
12486
07:46:37,360 --> 07:46:39,680
for the moment a private key in ourv
12487
07:46:39,680 --> 07:46:42,398
file is cool so long as we don't expose
12488
07:46:42,398 --> 07:46:45,398
the EMV file but for real money you're
12489
07:46:45,398 --> 07:46:46,958
not going to do that we're not going to
12490
07:46:46,958 --> 07:46:49,160
do that okay for real money we're going
12491
07:46:49,160 --> 07:46:51,040
to use the dashes interactive to paste
12492
07:46:51,040 --> 07:46:53,040
our private key or we're going to use a
12493
07:46:53,040 --> 07:46:55,760
keystore file with a password once
12494
07:46:55,760 --> 07:46:57,798
Foundry adds that there are some tools
12495
07:46:57,798 --> 07:46:59,798
like dap tools e sign that you could
12496
07:46:59,798 --> 07:47:01,440
optionally download if you want to
12497
07:47:01,440 --> 07:47:03,520
deploy and interact with wallets that
12498
07:47:03,520 --> 07:47:05,120
have real money in them and it does have
12499
07:47:05,120 --> 07:47:07,760
this import keyword where you can import
12500
07:47:07,760 --> 07:47:10,240
your private key into a key store file
12501
07:47:10,240 --> 07:47:11,240
and then you would just obviously
12502
07:47:11,240 --> 07:47:13,360
encrypt that with a password so for the
12503
07:47:13,360 --> 07:47:15,120
moment this is your setup but in the
12504
07:47:15,120 --> 07:47:17,040
future this is going to be your setup
12505
07:47:17,040 --> 07:47:18,718
okay this is cool now but not in the
12506
07:47:18,718 --> 07:47:20,878
future and additionally if you go to The
12507
07:47:20,878 --> 07:47:22,558
Foundry full course f23 you go to
12508
07:47:22,558 --> 07:47:25,558
discussions and this will also be in and
12509
07:47:25,558 --> 07:47:27,080
this will also be somewhere on this side
12510
07:47:27,080 --> 07:47:29,638
at some point you'll see this the EMV
12511
07:47:29,638 --> 07:47:31,160
pledge which has a whole bunch of
12512
07:47:31,160 --> 07:47:33,878
information about working withv files
12513
07:47:33,878 --> 07:47:35,520
and keeping your private key safer for
12514
07:47:35,520 --> 07:47:36,920
the rest of this course we are going to
12515
07:47:36,920 --> 07:47:39,398
be working with this syntax because it
12516
07:47:39,398 --> 07:47:41,280
is easier however I'm really hoping that
12517
07:47:41,280 --> 07:47:43,760
Foundry in the future adds this key
12518
07:47:43,760 --> 07:47:45,638
store encryption by default so that we
12519
07:47:45,638 --> 07:47:47,360
don't accidentally expose our private
12520
07:47:47,360 --> 07:47:49,840
keys and I'm not doing this to scare you
12521
07:47:49,840 --> 07:47:51,520
but I'm doing this to impress upon you
12522
07:47:51,520 --> 07:47:53,558
the importance of making sure you keep
12523
07:47:53,558 --> 07:47:55,798
that private key and that pneumonic safe
12524
07:47:55,798 --> 07:47:56,958
the other reason that we're okay to put
12525
07:47:56,958 --> 07:47:59,280
our private key in ourv file is that
12526
07:47:59,280 --> 07:48:01,240
you have already promised me that you're
12527
07:48:01,240 --> 07:48:03,478
only going to work with a development
12528
07:48:03,478 --> 07:48:04,760
private key or a private key that you're
12529
07:48:04,760 --> 07:48:06,920
not going to add any real money into so
12530
07:48:06,920 --> 07:48:09,040
if you expose it it'll be fine but you
12531
07:48:09,040 --> 07:48:10,920
still want to practice not exposing it
12532
07:48:10,920 --> 07:48:12,680
so please take some time to read this
12533
07:48:12,680 --> 07:48:14,478
and then if you do agree to everything
12534
07:48:14,478 --> 07:48:17,878
just say I will be safe as a comment on
12535
07:48:17,878 --> 07:48:19,398
this DV pledge so I'm going to read it
12536
07:48:19,398 --> 07:48:21,160
out and it's important for you to
12537
07:48:21,160 --> 07:48:22,760
understand this moving forward so it's
12538
07:48:22,760 --> 07:48:23,878
going to be a little dry here but I am
12539
07:48:23,878 --> 07:48:25,878
just going to read it I solemnly swear
12540
07:48:25,878 --> 07:48:27,398
that I will never place a private key or
12541
07:48:27,398 --> 07:48:29,760
secret phrase or pneumonic in ainv file
12542
07:48:29,760 --> 07:48:31,958
that is associated with real funds I
12543
07:48:31,958 --> 07:48:34,360
will only place private keys in ainv
12544
07:48:34,360 --> 07:48:36,558
file that have only test at eth link or
12545
07:48:36,558 --> 07:48:38,558
other cryptocurrencies when I'm testing
12546
07:48:38,558 --> 07:48:40,520
and developing I will use a different
12547
07:48:40,520 --> 07:48:42,280
wallet than the one associated with my
12548
07:48:42,280 --> 07:48:45,318
real funds I am aware that if I forget a
12549
07:48:45,318 --> 07:48:48,120
DOT get ignore and push my keyphrase to
12550
07:48:48,120 --> 07:48:50,160
GitHub even for a split second or show
12551
07:48:50,160 --> 07:48:52,360
my keyphrase to the internet for a split
12552
07:48:52,360 --> 07:48:54,558
second it should be considered
12553
07:48:54,558 --> 07:48:56,200
compromised and I should move all my
12554
07:48:56,200 --> 07:48:57,638
funds immediately this is a really
12555
07:48:57,638 --> 07:49:00,000
important line even if you show your
12556
07:49:00,000 --> 07:49:01,798
private key to anywhere on the internet
12557
07:49:01,798 --> 07:49:03,798
for even a split second it is considered
12558
07:49:03,798 --> 07:49:05,718
compromised and you should move all your
12559
07:49:05,718 --> 07:49:08,000
funds immediately if I unsure if my
12560
07:49:08,000 --> 07:49:09,440
account has real funds in it I will
12561
07:49:09,440 --> 07:49:11,360
assume it has real funds in it if I
12562
07:49:11,360 --> 07:49:12,760
assume it has real funds in it I will
12563
07:49:12,760 --> 07:49:14,558
not use it for developing purposes I
12564
07:49:14,558 --> 07:49:18,240
aware that even in my metamask if I hit
12565
07:49:18,240 --> 07:49:19,958
create account or add account on my
12566
07:49:19,958 --> 07:49:21,958
metamask or other eth wallet I will get
12567
07:49:21,958 --> 07:49:24,240
a new private key but it will share the
12568
07:49:24,240 --> 07:49:26,440
same secret phrase slne monic of the
12569
07:49:26,440 --> 07:49:27,638
other accounts generated in that
12570
07:49:27,638 --> 07:49:29,760
metamask these are some additions that I
12571
07:49:29,760 --> 07:49:31,360
made from the last course for this
12572
07:49:31,360 --> 07:49:33,478
course I will only use funds associated
12573
07:49:33,478 --> 07:49:35,600
with my brand new neverbe used metamask
12574
07:49:35,600 --> 07:49:37,920
or other wallet and again most browsers
12575
07:49:37,920 --> 07:49:39,920
you can choose a different profile and
12576
07:49:39,920 --> 07:49:41,318
install a metamask on a different
12577
07:49:41,318 --> 07:49:43,240
profile and use that metamask for this
12578
07:49:43,240 --> 07:49:45,398
development purpose if I must use a
12579
07:49:45,398 --> 07:49:46,558
private key associated with real funds
12580
07:49:46,558 --> 07:49:48,760
in the future until I'm 100% sure what I
12581
07:49:48,760 --> 07:49:51,200
am doing I will always either use
12582
07:49:51,200 --> 07:49:53,398
encryption methods like the DAP tools
12583
07:49:53,398 --> 07:49:55,280
keystore file I'm not going to show you
12584
07:49:55,280 --> 07:49:57,080
how to work with this because some of
12585
07:49:57,080 --> 07:49:58,160
the installs might be a little bit
12586
07:49:58,160 --> 07:49:59,958
tricky but they have a way to actually
12587
07:49:59,958 --> 07:50:02,920
import and encrypt private keys to a key
12588
07:50:02,920 --> 07:50:05,080
store file use the foundaries built in
12589
07:50:05,080 --> 07:50:06,440
key store Creator which is an
12590
07:50:06,440 --> 07:50:08,958
implemented yet anybody here who is a
12591
07:50:08,958 --> 07:50:10,718
rust developer or knows some rust or
12592
07:50:10,718 --> 07:50:12,280
wants to participate definitely be sure
12593
07:50:12,280 --> 07:50:13,840
to check out this issue which is on
12594
07:50:13,840 --> 07:50:15,680
Foundry and I would love somebody to
12595
07:50:15,680 --> 07:50:18,718
take a crack at this or if you must use
12596
07:50:18,718 --> 07:50:20,558
the command line as a way to pass your
12597
07:50:20,558 --> 07:50:22,520
private keys and then delete the command
12598
07:50:22,520 --> 07:50:25,920
line history immediately afterwards if I
12599
07:50:25,920 --> 07:50:27,558
never actually deploy anything to main
12600
07:50:27,558 --> 07:50:29,160
out myself or work with the private key
12601
07:50:29,160 --> 07:50:31,440
with real funds I do not need to be
12602
07:50:31,440 --> 07:50:33,398
concerned for any of you who are getting
12603
07:50:33,398 --> 07:50:34,798
a little bit nervous about this just
12604
07:50:34,798 --> 07:50:37,040
remember if you don't work with any real
12605
07:50:37,040 --> 07:50:39,000
money you don't have to worry about this
12606
07:50:39,000 --> 07:50:41,160
okay so a lot of you people who are who
12607
07:50:41,160 --> 07:50:43,040
are newer here who are going to be going
12608
07:50:43,040 --> 07:50:44,600
through this course we're not going to
12609
07:50:44,600 --> 07:50:47,280
use any real funds so you won't have to
12610
07:50:47,280 --> 07:50:48,478
be worried about this for those of you
12611
07:50:48,478 --> 07:50:50,398
who are doing the extra credit which is
12612
07:50:50,398 --> 07:50:52,478
with real funds you will need to keep
12613
07:50:52,478 --> 07:50:54,080
this some mind moving forward and I
12614
07:50:54,080 --> 07:50:56,120
would try to load your real metamask
12615
07:50:56,120 --> 07:50:58,120
with real money with small amounts so
12616
07:50:58,120 --> 07:51:00,000
that if it all gets stolen you won't
12617
07:51:00,000 --> 07:51:02,920
lose sleep at night okay great and I'm
12618
07:51:02,920 --> 07:51:05,478
telling you all this to arm you with
12619
07:51:05,478 --> 07:51:06,840
this knowledge that you can be more
12620
07:51:06,840 --> 07:51:08,920
secure moving forward take a look at
12621
07:51:08,920 --> 07:51:10,840
this read this internalize it and if you
12622
07:51:10,840 --> 07:51:12,478
want to copy paste this on Twitter in a
12623
07:51:12,478 --> 07:51:14,318
huge tweet thread shout this from the
12624
07:51:14,318 --> 07:51:16,040
rooftops put this in an article make a
12625
07:51:16,040 --> 07:51:18,520
tick tock with this Dov pledge have an
12626
07:51:18,520 --> 07:51:20,638
absolute blast the more people who know
12627
07:51:20,638 --> 07:51:22,040
about this and the more people who
12628
07:51:22,040 --> 07:51:24,160
understand this the better thank you for
12629
07:51:24,160 --> 07:51:26,318
coming to my TED Talk all right so I
12630
07:51:26,318 --> 07:51:27,638
know that was a lot of private key
12631
07:51:27,638 --> 07:51:29,280
information and there's going to be more
12632
07:51:29,280 --> 07:51:31,478
soon too so but the reason I'm harping
12633
07:51:31,478 --> 07:51:33,558
on this is because I really really
12634
07:51:33,558 --> 07:51:34,878
really really really want to make sure
12635
07:51:34,878 --> 07:51:37,558
that all of you don't actually mess this
12636
07:51:37,558 --> 07:51:39,478
up since you are the developers you are
12637
07:51:39,478 --> 07:51:40,718
going to be the ones responsible for
12638
07:51:40,718 --> 07:51:41,958
dealing with all this and I want to make
12639
07:51:41,958 --> 07:51:44,760
sure that you get it
12640
07:51:45,920 --> 07:51:48,920
right one final option that we can do as
12641
07:51:48,920 --> 07:51:51,878
well which again saves us from having to
12642
07:51:51,878 --> 07:51:53,760
have our private key and plain text is
12643
07:51:53,760 --> 07:51:55,600
going to be using something like third
12644
07:51:55,600 --> 07:51:57,718
web deploy so we actually have Kira from
12645
07:51:57,718 --> 07:52:00,080
the third web team team to explain third
12646
07:52:00,080 --> 07:52:02,280
web deploy now she is going to use the
12647
07:52:02,280 --> 07:52:05,478
MPX command which comes with nodejs and
12648
07:52:05,478 --> 07:52:07,760
mpm installation which we haven't gone
12649
07:52:07,760 --> 07:52:09,798
over in this course but we will leave
12650
07:52:09,798 --> 07:52:12,000
some links in the GitHub repo associated
12651
07:52:12,000 --> 07:52:13,680
with this course to download that if
12652
07:52:13,680 --> 07:52:15,958
you're interested so take it away Kira
12653
07:52:15,958 --> 07:52:17,798
in this video we're going to learn how
12654
07:52:17,798 --> 07:52:21,638
to easily deploy any contract to any evm
12655
07:52:21,638 --> 07:52:24,638
chain using one simple command this
12656
07:52:24,638 --> 07:52:27,760
command requires no setup hardcoded
12657
07:52:27,760 --> 07:52:30,878
private keys RPC URLs or scripting
12658
07:52:30,878 --> 07:52:33,280
required third web handles all of the
12659
07:52:33,280 --> 07:52:35,280
complexities for you because there's no
12660
07:52:35,280 --> 07:52:38,280
need to export your private key this is
12661
07:52:38,280 --> 07:52:40,840
much more secure the deployment is done
12662
07:52:40,840 --> 07:52:43,718
through the dashboard UI using your own
12663
07:52:43,718 --> 07:52:47,160
wallet so with that said let's jump into
12664
07:52:47,160 --> 07:52:50,398
deploying our contracts so let's say we
12665
07:52:50,398 --> 07:52:53,558
have cloned this repo or written our own
12666
07:52:53,558 --> 07:52:55,200
contract this can obviously be any
12667
07:52:55,200 --> 07:52:57,280
contract at all but I have gone ahead
12668
07:52:57,280 --> 07:53:00,160
and cloned this simple storage contracts
12669
07:53:00,160 --> 07:53:02,440
just to demonstrate how we can deploy
12670
07:53:02,440 --> 07:53:04,080
our contract as you can see in the
12671
07:53:04,080 --> 07:53:06,120
sidebar um so yes I've opened this up in
12672
07:53:06,120 --> 07:53:08,280
my code editor in the sidebar there is
12673
07:53:08,280 --> 07:53:11,760
nov file I haven't set up an RPC URL I
12674
07:53:11,760 --> 07:53:14,200
haven't exported my private key there is
12675
07:53:14,200 --> 07:53:16,440
no setup needed here I want to reiterate
12676
07:53:16,440 --> 07:53:18,558
this you do not need to pre-install
12677
07:53:18,558 --> 07:53:20,760
anything there are no dependencies so to
12678
07:53:20,760 --> 07:53:22,478
deploy our contract we are going to run
12679
07:53:22,478 --> 07:53:26,958
the simple command npx third web deploy
12680
07:53:26,958 --> 07:53:28,718
so what this done is detected our
12681
07:53:28,718 --> 07:53:30,840
project type which is Foundry and also
12682
07:53:30,840 --> 07:53:33,080
could be hard hat or Brownie and then it
12683
07:53:33,080 --> 07:53:35,398
has compiled our contract and then it's
12684
07:53:35,398 --> 07:53:37,360
allowing me to select which contractor
12685
07:53:37,360 --> 07:53:39,638
deploy so I'm going to select the simple
12686
07:53:39,638 --> 07:53:41,920
storage contract so this is now
12687
07:53:41,920 --> 07:53:45,280
uploading the contract metadata to ipfs
12688
07:53:45,280 --> 07:53:47,000
and it means that our contract is going
12689
07:53:47,000 --> 07:53:49,520
to be automatically verified if you
12690
07:53:49,520 --> 07:53:51,558
would like more details on how this
12691
07:53:51,558 --> 07:53:53,360
actually works then please go ahead and
12692
07:53:53,360 --> 07:53:55,680
visit the third web developer docs which
12693
07:53:55,680 --> 07:53:57,558
you can see here which is at portal.
12694
07:53:57,558 --> 07:54:00,120
third web.com SL deploy and you can read
12695
07:54:00,120 --> 07:54:02,240
all about how this works so what's
12696
07:54:02,240 --> 07:54:04,878
happened now is that a browser tab has
12697
07:54:04,878 --> 07:54:07,318
popped up in my browser um and this
12698
07:54:07,318 --> 07:54:10,160
allows me to deploy my contract from a
12699
07:54:10,160 --> 07:54:12,920
front end so if I had construct prams
12700
07:54:12,920 --> 07:54:14,958
which I do not in this case there are no
12701
07:54:14,958 --> 07:54:16,958
construct parameters um then I would be
12702
07:54:16,958 --> 07:54:18,760
able to fill these out from the front
12703
07:54:18,760 --> 07:54:20,760
end right here next what we need to do
12704
07:54:20,760 --> 07:54:22,760
is select the chain that we want to
12705
07:54:22,760 --> 07:54:25,080
deploy to as I said this can be any evm
12706
07:54:25,080 --> 07:54:28,080
network so we can select ones that are
12707
07:54:28,080 --> 07:54:31,080
pop such as bass or we could add a
12708
07:54:31,080 --> 07:54:33,120
custom network if this is not already in
12709
07:54:33,120 --> 07:54:35,680
the list but I'm going to select Mumbai
12710
07:54:35,680 --> 07:54:37,200
when I click deploy now this is going to
12711
07:54:37,200 --> 07:54:39,440
trigger two transactions the first one
12712
07:54:39,440 --> 07:54:41,280
is going to be the transaction to deploy
12713
07:54:41,280 --> 07:54:43,120
my contract the second one is going to
12714
07:54:43,120 --> 07:54:45,120
be a message which I will sign and this
12715
07:54:45,120 --> 07:54:47,080
is a gasless step and this just adds
12716
07:54:47,080 --> 07:54:49,718
your contract to your dashboard so that
12717
07:54:49,718 --> 07:54:51,558
you have a user interface in which to
12718
07:54:51,558 --> 07:54:53,478
interact with this contract a little bit
12719
07:54:53,478 --> 07:54:54,478
like
12720
07:54:54,478 --> 07:54:56,958
remix so I'm going to click this button
12721
07:54:56,958 --> 07:54:57,920
I'm just going to sign these two
12722
07:54:57,920 --> 07:55:02,200
transaction Cs and then I will be right
12723
07:55:05,120 --> 07:55:07,878
back as you can see our contract has now
12724
07:55:07,878 --> 07:55:10,360
been successfully deployed how easy was
12725
07:55:10,360 --> 07:55:13,318
that awesome so you can see the contract
12726
07:55:13,318 --> 07:55:15,040
address here which we can copy if we
12727
07:55:15,040 --> 07:55:16,760
needed to use that later I'm just going
12728
07:55:16,760 --> 07:55:18,520
to give you a very quick overview of the
12729
07:55:18,520 --> 07:55:20,958
dashboard so there's this build tab here
12730
07:55:20,958 --> 07:55:23,200
which just enables you to build your
12731
07:55:23,200 --> 07:55:25,080
contract into a front end with easy to
12732
07:55:25,080 --> 07:55:27,240
use hooks for different languages uh
12733
07:55:27,240 --> 07:55:28,318
Hooks and functions for different
12734
07:55:28,318 --> 07:55:30,958
languages uh the Explorer tab allows you
12735
07:55:30,958 --> 07:55:33,040
to see all the read and write functions
12736
07:55:33,040 --> 07:55:34,680
on your contract so you could add a
12737
07:55:34,680 --> 07:55:37,318
person and then input the parameters
12738
07:55:37,318 --> 07:55:40,680
here you can store list the people name
12739
07:55:40,680 --> 07:55:42,878
to favorite number and retrieve all of
12740
07:55:42,878 --> 07:55:44,478
the functions that we wrote in the
12741
07:55:44,478 --> 07:55:46,680
contract you can see and interact with
12742
07:55:46,680 --> 07:55:48,520
here you can see the events on the
12743
07:55:48,520 --> 07:55:51,398
contract and the source code as you can
12744
07:55:51,398 --> 07:55:54,958
see this was a super simple easy and
12745
07:55:54,958 --> 07:55:57,718
safe way to deploy your contracts using
12746
07:55:57,718 --> 07:56:00,600
third web third web is the fastest way
12747
07:56:00,600 --> 07:56:04,160
to build web 3 apps we can have sdks in
12748
07:56:04,160 --> 07:56:06,520
multiple languages we have pre-built
12749
07:56:06,520 --> 07:56:09,520
contracts we have a solidity SDK and
12750
07:56:09,520 --> 07:56:12,040
infrastructure for your web3 development
12751
07:56:12,040 --> 07:56:14,000
needs for more information please head
12752
07:56:14,000 --> 07:56:16,080
to third web.com or visit our
12753
07:56:16,080 --> 07:56:17,878
documentation and if you have any
12754
07:56:17,878 --> 07:56:22,318
questions please head to our Discord
12755
07:56:42,558 --> 07:56:44,760
in any case let's go ahead and let's
12756
07:56:44,760 --> 07:56:46,160
learn how to interact with these
12757
07:56:46,160 --> 07:56:48,398
contracts from the command line first
12758
07:56:48,398 --> 07:56:49,798
and in later courses we'll learn how to
12759
07:56:49,798 --> 07:56:53,160
do it from scripts so we have our Anvil
12760
07:56:53,160 --> 07:56:55,440
running and we've deployed our contract
12761
07:56:55,440 --> 07:56:57,680
using our deploy using at least
12762
07:56:57,680 --> 07:56:59,440
something marginally better using
12763
07:56:59,440 --> 07:57:01,240
private key as an environment variable
12764
07:57:01,240 --> 07:57:02,798
as opposed to just pasting it right in
12765
07:57:02,798 --> 07:57:04,520
here so what we can do now is we can
12766
07:57:04,520 --> 07:57:05,878
take this contract address and we can
12767
07:57:05,878 --> 07:57:07,958
actually start to interact with it
12768
07:57:07,958 --> 07:57:11,360
Foundry has another tool built in called
12769
07:57:11,360 --> 07:57:14,160
cast and if you type cast d-el you'll
12770
07:57:14,160 --> 07:57:16,000
see we get a whole bunch of commands to
12771
07:57:16,000 --> 07:57:17,878
work with cast one of the commands that
12772
07:57:17,878 --> 07:57:20,718
we can work with is going to be send
12773
07:57:20,718 --> 07:57:22,760
which is to sign and publish a
12774
07:57:22,760 --> 07:57:24,878
transaction so what we can do is we can
12775
07:57:24,878 --> 07:57:28,798
do cast send d-el we can see the help of
12776
07:57:28,798 --> 07:57:30,718
send and we can see the arguments it
12777
07:57:30,718 --> 07:57:34,160
takes is going to be two the signature
12778
07:57:34,160 --> 07:57:37,840
and the arguments so on remix for
12779
07:57:37,840 --> 07:57:39,760
example we have our simple storage
12780
07:57:39,760 --> 07:57:41,760
contract and we deployed it if we wanted
12781
07:57:41,760 --> 07:57:44,600
to call our store function in send the
12782
07:57:44,600 --> 07:57:46,318
transaction we would just add some
12783
07:57:46,318 --> 07:57:47,958
numbers in here and then click store
12784
07:57:47,958 --> 07:57:50,558
like this right if we want to call store
12785
07:57:50,558 --> 07:57:53,600
from the command line we can do cast
12786
07:57:53,600 --> 07:57:57,200
send the address we want to do the
12787
07:57:57,200 --> 07:57:59,160
signature which which for now just know
12788
07:57:59,160 --> 07:58:01,718
is the is the function and the input
12789
07:58:01,718 --> 07:58:05,520
types it needs so we could call store
12790
07:58:05,520 --> 07:58:08,600
with a parthy u 256 because we're
12791
07:58:08,600 --> 07:58:10,478
calling the function store which takes a
12792
07:58:10,478 --> 07:58:13,958
un 256 as input parameter and then the
12793
07:58:13,958 --> 07:58:15,878
arguments or the values we want to pass
12794
07:58:15,878 --> 07:58:17,840
to our store function and we'll go ahead
12795
07:58:17,840 --> 07:58:19,840
and hit enter of course this fails
12796
07:58:19,840 --> 07:58:21,760
because we need to add our private key
12797
07:58:21,760 --> 07:58:24,920
and RPC URL so we'll hit up we'll do RPC
12798
07:58:24,920 --> 07:58:28,520
URL we'll do dollar sign RPC URL and
12799
07:58:28,520 --> 07:58:31,200
then we'll do-- private key and then
12800
07:58:31,200 --> 07:58:34,280
private key like that and now you'll see
12801
07:58:34,280 --> 07:58:36,798
we'll get all of this data about our
12802
07:58:36,798 --> 07:58:39,600
transaction back we get the block hash
12803
07:58:39,600 --> 07:58:41,558
block number contract address is blank
12804
07:58:41,558 --> 07:58:43,520
probably because it's a local chain logs
12805
07:58:43,520 --> 07:58:44,718
we can learn we'll learn about logs
12806
07:58:44,718 --> 07:58:47,520
later the transaction hash Etc now in
12807
07:58:47,520 --> 07:58:49,478
order to read this we're going to use
12808
07:58:49,478 --> 07:58:52,478
cast call which is going to read off the
12809
07:58:52,478 --> 07:58:55,958
blockchain and if we do cast call d-el
12810
07:58:55,958 --> 07:58:58,120
and we scroll up a little bit we'll see
12811
07:58:58,120 --> 07:59:00,718
call takes two signature and arguments
12812
07:59:00,718 --> 07:59:03,200
exact same as send but the difference is
12813
07:59:03,200 --> 07:59:04,958
it's like call is like doing one of
12814
07:59:04,958 --> 07:59:07,120
these blue buttons it's calling as
12815
07:59:07,120 --> 07:59:09,638
opposed to sending a transaction it's
12816
07:59:09,638 --> 07:59:11,360
just doing a view function not actually
12817
07:59:11,360 --> 07:59:14,280
sending a transaction so we'll do cast
12818
07:59:14,280 --> 07:59:17,080
call we'll paste the contract address
12819
07:59:17,080 --> 07:59:24,558
we'll call retrieve r t r i v r e t r IE
12820
07:59:24,558 --> 07:59:27,000
V did I spell retrieve wrong I don't
12821
07:59:27,000 --> 07:59:28,680
know I guess we'll find out no input
12822
07:59:28,680 --> 07:59:30,360
parameters here and no arguments so we
12823
07:59:30,360 --> 07:59:32,558
can just hit enter and we'll see we get
12824
07:59:32,558 --> 07:59:35,840
the hex value back this is where I said
12825
07:59:35,840 --> 07:59:37,520
you're going to be converting stuff from
12826
07:59:37,520 --> 07:59:40,200
hex back and forth a lot then we do cast
12827
07:59:40,200 --> 07:59:44,680
d-2 base paste the hex and say decimal
12828
07:59:44,680 --> 07:59:46,440
and we can see we get back 1 2 three
12829
07:59:46,440 --> 07:59:47,958
which is exactly what we've stored on
12830
07:59:47,958 --> 07:59:50,318
chain so if we hit up a couple times
12831
07:59:50,318 --> 07:59:53,080
back to our cast send transaction our
12832
07:59:53,080 --> 07:59:56,080
cast send command and we change 1 2 3 to
12833
07:59:56,080 --> 07:59:59,000
777 we hit enter we'll send that
12834
07:59:59,000 --> 08:00:01,760
transaction now if we hit up three time
12835
08:00:01,760 --> 08:00:03,840
two or three times we'll call cast call
12836
08:00:03,840 --> 08:00:05,600
retrieve now and we should see the new
12837
08:00:05,600 --> 08:00:08,040
number which we get back as a hex and
12838
08:00:08,040 --> 08:00:11,478
then we'll do cast d-2 base paste it in
12839
08:00:11,478 --> 08:00:15,120
deck and we do indeed see 777 returned
12840
08:00:15,120 --> 08:00:17,080
to us awesome so now we know how to
12841
08:00:17,080 --> 08:00:19,360
actually interact with our contracts
12842
08:00:19,360 --> 08:00:21,000
from the command line and this is going
12843
08:00:21,000 --> 08:00:22,240
to be the same way we can actually
12844
08:00:22,240 --> 08:00:23,958
interact with our contracts on an actual
12845
08:00:23,958 --> 08:00:28,760
test net or on an actual main net
12846
08:00:30,000 --> 08:00:32,000
all right so now you might be asking
12847
08:00:32,000 --> 08:00:33,718
okay Patrick what does this look like on
12848
08:00:33,718 --> 08:00:37,798
a test net or a live Network so let's go
12849
08:00:37,798 --> 08:00:40,798
ahead let's go to ourv file and let's
12850
08:00:40,798 --> 08:00:44,840
update this so that it's aemv file for
12851
08:00:44,840 --> 08:00:46,958
an actual test net so the first thing is
12852
08:00:46,958 --> 08:00:49,398
we're going to need an RPC URL for an
12853
08:00:49,398 --> 08:00:51,760
actual test net for an actual Network
12854
08:00:51,760 --> 08:00:54,000
and this is where in our metamasks
12855
08:00:54,000 --> 08:00:56,360
actually have inferior connections built
12856
08:00:56,360 --> 08:00:59,120
in remember before we went to our
12857
08:00:59,120 --> 08:01:04,398
settings networks eum main net we saw oh
12858
08:01:04,398 --> 08:01:06,478
we saw we have this inferior connection
12859
08:01:06,478 --> 08:01:08,000
we can't use this one because this one's
12860
08:01:08,000 --> 08:01:10,000
designed specifically for our metamask
12861
08:01:10,000 --> 08:01:11,440
so we're going to have to get our own
12862
08:01:11,440 --> 08:01:14,080
RPC URL for an actual test net well one
12863
08:01:14,080 --> 08:01:15,240
of the things we could do is we could
12864
08:01:15,240 --> 08:01:17,160
run our own blockchain node but a lot of
12865
08:01:17,160 --> 08:01:18,840
people don't want to do that so what a
12866
08:01:18,840 --> 08:01:20,318
lot of people do is use something called
12867
08:01:20,318 --> 08:01:22,760
a node as a service to do this what I'm
12868
08:01:22,760 --> 08:01:24,240
going to recommend you do is actually
12869
08:01:24,240 --> 08:01:26,478
come over to The Foundry full course
12870
08:01:26,478 --> 08:01:29,040
repo scroll down down and there's going
12871
08:01:29,040 --> 08:01:30,558
to be a section called deploying to a
12872
08:01:30,558 --> 08:01:32,718
test net or a main net if we click this
12873
08:01:32,718 --> 08:01:34,638
link we'll actually go ahead and we'll
12874
08:01:34,638 --> 08:01:37,280
get sent to the Alchemy platform where
12875
08:01:37,280 --> 08:01:40,200
we're going to sign up for a free notice
12876
08:01:40,200 --> 08:01:41,520
of service that we can actually send
12877
08:01:41,520 --> 08:01:42,920
transactions to and we're going to go
12878
08:01:42,920 --> 08:01:45,200
ahead and sign up for their platform you
12879
08:01:45,200 --> 08:01:46,958
can sign up with Google sign up with SSO
12880
08:01:46,958 --> 08:01:48,558
whatever you want to do I'm going to go
12881
08:01:48,558 --> 08:01:50,600
ahead sign in with Google I'm indeed
12882
08:01:50,600 --> 08:01:52,440
human we're going to come to their user
12883
08:01:52,440 --> 08:01:54,318
interface that looks something like this
12884
08:01:54,318 --> 08:01:55,920
we're going to deploy this to sepolia
12885
08:01:55,920 --> 08:01:57,558
but remember go to the recommended test
12886
08:01:57,558 --> 08:01:59,840
n section of this course so what we're
12887
08:01:59,840 --> 08:02:01,398
going to do now that we're in here is
12888
08:02:01,398 --> 08:02:03,160
we're going to go ahead and create a new
12889
08:02:03,160 --> 08:02:05,478
app and you can name it whatever you
12890
08:02:05,478 --> 08:02:08,680
want I'm going to call it tooa testing
12891
08:02:08,680 --> 08:02:09,958
I'm just going to copy this for a
12892
08:02:09,958 --> 08:02:12,000
description this is on the ethereum
12893
08:02:12,000 --> 08:02:15,478
Chain but on ethereum spolia we're not
12894
08:02:15,478 --> 08:02:17,520
going to do any advanced features we'll
12895
08:02:17,520 --> 08:02:20,240
go ahead to create app and now we have
12896
08:02:20,240 --> 08:02:23,360
this ethereum seoa app where we can view
12897
08:02:23,360 --> 08:02:25,840
details we can see how often we're
12898
08:02:25,840 --> 08:02:27,120
calling this and we can see different
12899
08:02:27,120 --> 08:02:28,878
details about our notes Noe and if we
12900
08:02:28,878 --> 08:02:32,040
hit view key we see we have this https
12901
08:02:32,040 --> 08:02:33,760
endpoint and this is going to be the
12902
08:02:33,760 --> 08:02:36,000
exact same thing as that Anvil or ganach
12903
08:02:36,000 --> 08:02:38,080
or metamask endpoint that we saw and
12904
08:02:38,080 --> 08:02:39,760
we're going to go ahead and copy this
12905
08:02:39,760 --> 08:02:42,478
and back in our b v what we could do is
12906
08:02:42,478 --> 08:02:45,760
we we can create a new RPC URL called
12907
08:02:45,760 --> 08:02:50,040
sepolia RPC URL equals and we'll paste
12908
08:02:50,040 --> 08:02:52,398
that in here now we have an RPC that
12909
08:02:52,398 --> 08:02:54,280
points to an actual test St with our
12910
08:02:54,280 --> 08:02:56,520
private key we can't use this as our
12911
08:02:56,520 --> 08:02:58,240
private key because this is in Anvil
12912
08:02:58,240 --> 08:02:59,840
private key and it doesn't have any real
12913
08:02:59,840 --> 08:03:01,520
money in it and it doesn't have any
12914
08:03:01,520 --> 08:03:04,120
testet eth in it but what we can do is
12915
08:03:04,120 --> 08:03:06,520
instead we can use our one of our
12916
08:03:06,520 --> 08:03:08,958
private keys in our metamask so if we
12917
08:03:08,958 --> 08:03:11,920
switch back to sapoia in our metamask we
12918
08:03:11,920 --> 08:03:13,200
can pick one of our accounts that
12919
08:03:13,200 --> 08:03:14,440
actually has some money in it I'm going
12920
08:03:14,440 --> 08:03:17,120
to pick account number one we'll hit the
12921
08:03:17,120 --> 08:03:20,440
three little dots Account Details export
12922
08:03:20,440 --> 08:03:22,920
private key and remember it's okay for
12923
08:03:22,920 --> 08:03:24,638
me to show the private key here because
12924
08:03:24,638 --> 08:03:26,478
this is just a dummy private key but
12925
08:03:26,478 --> 08:03:28,638
I'll add my password in and remember I'm
12926
08:03:28,638 --> 08:03:30,080
never going to actually do any real
12927
08:03:30,080 --> 08:03:33,958
money with this and I'll copy this done
12928
08:03:33,958 --> 08:03:37,280
and paste this in here and maybe I'll
12929
08:03:37,280 --> 08:03:40,000
maybe I'll comment this line out inmv
12930
08:03:40,000 --> 08:03:43,040
file this hashtag or this pound sign is
12931
08:03:43,040 --> 08:03:44,920
what the comment is but maybe we'll do a
12932
08:03:44,920 --> 08:03:47,120
new private key equals and I'll paste
12933
08:03:47,120 --> 08:03:48,958
this in here and now I have the private
12934
08:03:48,958 --> 08:03:51,840
key for metamask I have the RPC RL and
12935
08:03:51,840 --> 08:03:53,520
those are all I need to actually deploy
12936
08:03:53,520 --> 08:03:56,000
a transaction so what I can do now pull
12937
08:03:56,000 --> 08:03:57,558
my terminal back up so we're going to
12938
08:03:57,558 --> 08:03:59,280
run this command to actually deploy this
12939
08:03:59,280 --> 08:04:03,200
to a real test net from our Foundry
12940
08:04:03,200 --> 08:04:06,120
using Alchemy as our node as a service
12941
08:04:06,120 --> 08:04:08,638
and you'll see in the user interface of
12942
08:04:08,638 --> 08:04:10,240
alchemy you'll see a transaction
12943
08:04:10,240 --> 08:04:11,840
actually come through our node This Is
12944
08:04:11,840 --> 08:04:15,000
Us sending a transaction to a real node
12945
08:04:15,000 --> 08:04:17,120
and we'll be able to see the stats here
12946
08:04:17,120 --> 08:04:19,440
on our Alchemy dashboard so let's go
12947
08:04:19,440 --> 08:04:21,478
ahead let's do this again so first we're
12948
08:04:21,478 --> 08:04:24,200
going to need to run source. AMV to make
12949
08:04:24,200 --> 08:04:27,958
sure all of our AMV stuff is loaded then
12950
08:04:27,958 --> 08:04:31,680
we're going to run Forge script script
12951
08:04:31,680 --> 08:04:33,878
deploy simple storage. s.o and I'm
12952
08:04:33,878 --> 08:04:36,040
hitting tab to autocomplete
12953
08:04:36,040 --> 08:04:41,760
here-- RPC URL sepolia RPC URL with the
12954
08:04:41,760 --> 08:04:45,760
little dollar sign D- private key dollar
12955
08:04:45,760 --> 08:04:48,080
sign private
12956
08:04:48,080 --> 08:04:51,440
key-- broadcast if you don't add the D-
12957
08:04:51,440 --> 08:04:53,680
bradc it won't actually send it it'll
12958
08:04:53,680 --> 08:04:56,558
simulate sending it now if I hit enter
12959
08:04:56,558 --> 08:04:58,638
we'll see a compile and now we're
12960
08:04:58,638 --> 08:05:01,478
running this script deploy simple
12961
08:05:01,478 --> 08:05:03,920
storage. s.o which actually deploys it
12962
08:05:03,920 --> 08:05:06,280
and we'll see we went ahead and deployed
12963
08:05:06,280 --> 08:05:08,440
our contract simple storage on the
12964
08:05:08,440 --> 08:05:10,958
sepolia Chain we see all these details
12965
08:05:10,958 --> 08:05:12,638
about it it's sending the transaction
12966
08:05:12,638 --> 08:05:16,318
right now it's storing the latest run
12967
08:05:16,318 --> 08:05:18,798
under the broadcast folder under its
12968
08:05:18,798 --> 08:05:20,920
chain ID in here in this run latest.
12969
08:05:20,920 --> 08:05:23,360
Json and after a brief delay we'll see
12970
08:05:23,360 --> 08:05:25,798
it went through and what we can do is we
12971
08:05:25,798 --> 08:05:29,798
can grab this hash go over to sea.
12972
08:05:29,798 --> 08:05:33,200
etherscan.io paste that hash in here and
12973
08:05:33,200 --> 08:05:35,840
we'll see we actually successfully sent
12974
08:05:35,840 --> 08:05:38,520
a transaction and if we click on our
12975
08:05:38,520 --> 08:05:40,920
contract address we just created we'll
12976
08:05:40,920 --> 08:05:42,920
see we actually just created this
12977
08:05:42,920 --> 08:05:45,638
contract on a real test name we go back
12978
08:05:45,638 --> 08:05:47,318
to our Alchemy dashboard and we hit
12979
08:05:47,318 --> 08:05:50,318
refresh we'll see we actually sent we
12980
08:05:50,318 --> 08:05:52,680
sent some requests we scroll down we can
12981
08:05:52,680 --> 08:05:54,080
see some of the different requests we
12982
08:05:54,080 --> 08:05:57,638
sent eth send raw transaction was the
12983
08:05:57,638 --> 08:05:59,558
request that we sent to actually send
12984
08:05:59,558 --> 08:06:02,040
our transaction to the blockchain but we
12985
08:06:02,040 --> 08:06:03,840
also got some stuff about the chain ID
12986
08:06:03,840 --> 08:06:06,558
fee history
12987
08:06:07,798 --> 08:06:10,080
Etc one thing that you'll notice though
12988
08:06:10,080 --> 08:06:11,840
when looking at this on ether scan is
12989
08:06:11,840 --> 08:06:14,798
that the contract o it's just a whole
12990
08:06:14,798 --> 08:06:16,520
bunch of bite code here right this isn't
12991
08:06:16,520 --> 08:06:19,000
very readable what we can do is we can
12992
08:06:19,000 --> 08:06:21,080
actually verify this contract and now
12993
08:06:21,080 --> 08:06:22,878
I'm going to show you the hard way first
12994
08:06:22,878 --> 08:06:24,280
and I'm going to teach you the easier
12995
08:06:24,280 --> 08:06:27,160
way later but you can manually verify a
12996
08:06:27,160 --> 08:06:28,080
contract
12997
08:06:28,080 --> 08:06:30,680
on ether scan or other block explorers
12998
08:06:30,680 --> 08:06:34,040
by selecting verify going to solidity
12999
08:06:34,040 --> 08:06:35,718
this is a single file contract so we're
13000
08:06:35,718 --> 08:06:37,398
going to do single file I know that we
13001
08:06:37,398 --> 08:06:38,558
were on
13002
08:06:38,558 --> 08:06:42,120
0.8.9 and our open source license is MIT
13003
08:06:42,120 --> 08:06:44,318
we'll hit continue we'll go back to our
13004
08:06:44,318 --> 08:06:46,958
simple storage. soul and we'll copy the
13005
08:06:46,958 --> 08:06:49,558
whole contract scroll down we'll hit
13006
08:06:49,558 --> 08:06:52,878
paste optimization is going to be yes
13007
08:06:52,878 --> 08:06:55,478
there's no Constructor args no contract
13008
08:06:55,478 --> 08:06:57,280
Library addresses no Miss settings I'm
13009
08:06:57,280 --> 08:07:00,360
not a robot and we hit verify and public
13010
08:07:00,360 --> 08:07:01,478
sometimes this can be a little bit
13011
08:07:01,478 --> 08:07:03,240
tricky to get right and we're going to
13012
08:07:03,240 --> 08:07:05,558
work with programmatic verification
13013
08:07:05,558 --> 08:07:07,638
pretty soon that makes it a lot easier
13014
08:07:07,638 --> 08:07:09,840
but if we did it correctly what'll
13015
08:07:09,840 --> 08:07:11,958
happen then is if we click on our
13016
08:07:11,958 --> 08:07:14,000
contract address here and we go to
13017
08:07:14,000 --> 08:07:15,600
contract and we scroll down we can
13018
08:07:15,600 --> 08:07:17,600
actually see our contract right in ether
13019
08:07:17,600 --> 08:07:20,878
scan this will also give access to these
13020
08:07:20,878 --> 08:07:23,920
read and right contract buttons which we
13021
08:07:23,920 --> 08:07:26,680
can see it now looks really similar to
13022
08:07:26,680 --> 08:07:28,360
what's on remix and we can actually
13023
08:07:28,360 --> 08:07:30,280
interact with our contract right from
13024
08:07:30,280 --> 08:07:32,638
etherscan or another block Explorer like
13025
08:07:32,638 --> 08:07:34,440
I said that's the manual way to verify
13026
08:07:34,440 --> 08:07:36,558
your contracts and you can run into a
13027
08:07:36,558 --> 08:07:37,958
lot of issues doing that so I don't
13028
08:07:37,958 --> 08:07:39,680
recommend doing it I recommend doing the
13029
08:07:39,680 --> 08:07:40,798
programmatic way which I'm going to
13030
08:07:40,798 --> 08:07:43,318
teach you very
13031
08:07:44,398 --> 08:07:46,920
soon all right so now we're just about
13032
08:07:46,920 --> 08:07:49,080
done with our very basic project here
13033
08:07:49,080 --> 08:07:51,080
which is fantastic we've learned a ton
13034
08:07:51,080 --> 08:07:52,760
already but there's a couple things we
13035
08:07:52,760 --> 08:07:55,120
want to keep in mind here moving forward
13036
08:07:55,120 --> 08:07:56,558
and one of those things is when it comes
13037
08:07:56,558 --> 08:07:59,440
to formatting so we are using the vs
13038
08:07:59,440 --> 08:08:01,760
code autof formatter to Auto forat our
13039
08:08:01,760 --> 08:08:04,120
code but if somebody else comes and I'm
13040
08:08:04,120 --> 08:08:05,520
going to actually save with without
13041
08:08:05,520 --> 08:08:07,040
formatting if somebody else comes to our
13042
08:08:07,040 --> 08:08:09,798
code base we're going to want to have
13043
08:08:09,798 --> 08:08:11,798
them format it the exact same way that
13044
08:08:11,798 --> 08:08:14,040
we format it so what we can do is we can
13045
08:08:14,040 --> 08:08:17,120
use the forge format command which if we
13046
08:08:17,120 --> 08:08:19,240
run it you see favorite number actually
13047
08:08:19,240 --> 08:08:20,520
went ahead and formatt it so I'm going
13048
08:08:20,520 --> 08:08:22,878
to save without formatting again run
13049
08:08:22,878 --> 08:08:24,638
Forge format and it's going to Auto
13050
08:08:24,638 --> 08:08:26,398
format our code here so this is a
13051
08:08:26,398 --> 08:08:28,120
command that will automatic format all
13052
08:08:28,120 --> 08:08:30,360
of our solidity code awesome and
13053
08:08:30,360 --> 08:08:33,240
additionally for every single repo you
13054
08:08:33,240 --> 08:08:34,920
ever work with you always want to make a
13055
08:08:34,920 --> 08:08:38,478
readme.md file so right click new file
13056
08:08:38,478 --> 08:08:41,440
readme.md I actually already made one
13057
08:08:41,440 --> 08:08:42,878
over here and this is where you're going
13058
08:08:42,878 --> 08:08:44,840
to put information about your project
13059
08:08:44,840 --> 08:08:47,080
here I put some notes about the private
13060
08:08:47,080 --> 08:08:48,600
key usage which I'm just going to delete
13061
08:08:48,600 --> 08:08:50,798
for now readme files are generally where
13062
08:08:50,798 --> 08:08:52,398
you put information about your project
13063
08:08:52,398 --> 08:08:54,718
instructions to work with it places to
13064
08:08:54,718 --> 08:08:56,718
contact you really any information that
13065
08:08:56,718 --> 08:08:58,558
another open ource developer should know
13066
08:08:58,558 --> 08:08:59,718
when they want to interact with your
13067
08:08:59,718 --> 08:09:01,360
project because we are going to push
13068
08:09:01,360 --> 08:09:03,200
this up to GitHub as well we're not
13069
08:09:03,200 --> 08:09:04,718
going to push this up to our GitHub
13070
08:09:04,718 --> 08:09:06,638
because it's kind of easy but in the
13071
08:09:06,638 --> 08:09:08,040
next project we're actually going to
13072
08:09:08,040 --> 08:09:09,760
push the code up to GitHub and I'm going
13073
08:09:09,760 --> 08:09:11,760
to teach you how to do that readme.md
13074
08:09:11,760 --> 08:09:14,600
are this markdown syntax remember how we
13075
08:09:14,600 --> 08:09:16,160
were talking about answering questions
13076
08:09:16,160 --> 08:09:18,280
or asking questions using markdown
13077
08:09:18,280 --> 08:09:19,840
syntax well this is going to be the
13078
08:09:19,840 --> 08:09:23,240
exact same if I do a hashtag or pound
13079
08:09:23,240 --> 08:09:25,160
sign like this and I say hello and then
13080
08:09:25,160 --> 08:09:27,440
some text down here and if I hit save
13081
08:09:27,440 --> 08:09:29,160
what I can do is I can actually preview
13082
08:09:29,160 --> 08:09:31,760
this markdown so in my extensions over
13083
08:09:31,760 --> 08:09:34,080
here we're going to look for a markdown
13084
08:09:34,080 --> 08:09:35,958
extension actually already have one
13085
08:09:35,958 --> 08:09:39,280
markdown allinone or markdown preview or
13086
08:09:39,280 --> 08:09:41,160
whatever you want to install and we can
13087
08:09:41,160 --> 08:09:43,478
do open up our Command pet with command
13088
08:09:43,478 --> 08:09:47,160
shift p or view command pallet we can do
13089
08:09:47,160 --> 08:09:50,478
markdown preview open preview like this
13090
08:09:50,478 --> 08:09:52,120
and we can see what this looks like as
13091
08:09:52,120 --> 08:09:54,600
if it was on a GitHub repo we can see
13092
08:09:54,600 --> 08:09:57,000
Hello is Big we can see our text down
13093
08:09:57,000 --> 08:09:59,398
here is small and if I were to do like
13094
08:09:59,398 --> 08:10:01,718
some back Texs like this I can say like
13095
08:10:01,718 --> 08:10:04,398
code here save that look at our preview
13096
08:10:04,398 --> 08:10:05,958
again we can see this is formatted now
13097
08:10:05,958 --> 08:10:09,360
as code you can also do command shift V
13098
08:10:09,360 --> 08:10:11,080
to automatically go to preview mode or
13099
08:10:11,080 --> 08:10:13,840
it might be control shift V for Windows
13100
08:10:13,840 --> 08:10:15,398
and Linux users there's a lot of
13101
08:10:15,398 --> 08:10:17,040
different ways to go preview your
13102
08:10:17,040 --> 08:10:20,120
markdown and remember if formatting your
13103
08:10:20,120 --> 08:10:22,878
your readme is difficult usually AIS do
13104
08:10:22,878 --> 08:10:24,558
a pretty good job at formatting your
13105
08:10:24,558 --> 08:10:26,160
markdown for you if you just ask them
13106
08:10:26,160 --> 08:10:29,160
politely
13107
08:10:30,318 --> 08:10:32,200
now Alchemy has a couple of other really
13108
08:10:32,200 --> 08:10:34,120
cool features about it especially when
13109
08:10:34,120 --> 08:10:35,798
it comes to learning more about what's
13110
08:10:35,798 --> 08:10:37,760
actually happening with our transactions
13111
08:10:37,760 --> 08:10:39,718
whenever we send a transaction to a
13112
08:10:39,718 --> 08:10:41,638
blockchain node it actually enters
13113
08:10:41,638 --> 08:10:43,798
something called the M Pool it's
13114
08:10:43,798 --> 08:10:45,398
basically the place where transactions
13115
08:10:45,398 --> 08:10:47,878
go before they get actually sent and the
13116
08:10:47,878 --> 08:10:49,600
Alchemy dashboard is a great place to
13117
08:10:49,600 --> 08:10:52,280
actually view those transactions and see
13118
08:10:52,280 --> 08:10:53,878
their status so I'm going to go ahead
13119
08:10:53,878 --> 08:10:56,040
and turn it over to veto from the
13120
08:10:56,040 --> 08:10:57,680
Alchemy team who's going to expl explain
13121
08:10:57,680 --> 08:10:59,840
more about what Alchemy has to offer
13122
08:10:59,840 --> 08:11:01,558
some of the other cool parts of alchemy
13123
08:11:01,558 --> 08:11:08,920
and more ZK Stark ZK Nar Z proof z Oh W
13124
08:11:08,920 --> 08:11:11,200
oh I'm I'm sorry I'm Jam Jam everyone
13125
08:11:11,200 --> 08:11:13,120
and welcome this brand new video I'm V
13126
08:11:13,120 --> 08:11:15,360
and today I'm going to walk
13127
08:11:15,360 --> 08:11:17,478
to this is not my
13128
08:11:17,478 --> 08:11:21,558
channel this is not even AR's Channel
13129
08:11:21,558 --> 08:11:23,920
what oh my God this is the latest
13130
08:11:23,920 --> 08:11:25,840
Patrick Collins video about Foundry that
13131
08:11:25,840 --> 08:11:27,958
everyone must watch oh well well welcome
13132
08:11:27,958 --> 08:11:31,200
everyone I am VTO and thank you Patrick
13133
08:11:31,200 --> 08:11:33,240
for hosting this comeu I guess my job
13134
08:11:33,240 --> 08:11:35,200
today is to tell you a bit more about
13135
08:11:35,200 --> 08:11:38,000
what Alchemy is what we do how we do it
13136
08:11:38,000 --> 08:11:39,958
and how you can get the most out of it
13137
08:11:39,958 --> 08:11:42,120
well before getting started let me
13138
08:11:42,120 --> 08:11:45,120
quickly quickly introduce myself I am
13139
08:11:45,120 --> 08:11:47,718
BTO lead developer experience at Alchemy
13140
08:11:47,718 --> 08:11:49,760
blog hand developer and web free content
13141
08:11:49,760 --> 08:11:51,878
creator on a mission to aboard 1 million
13142
08:11:51,878 --> 08:11:54,558
developers onto web free of course today
13143
08:11:54,558 --> 08:11:56,520
we're not here to talk about me but we
13144
08:11:56,520 --> 08:11:58,398
here to talk about how Alchemy can app
13145
08:11:58,398 --> 08:12:00,638
your decentralized applications scale to
13146
08:12:00,638 --> 08:12:04,520
billions of users so to get started what
13147
08:12:04,520 --> 08:12:07,558
is alchemy well Alchemy is a node
13148
08:12:07,558 --> 08:12:09,600
provider and web free developer tooling
13149
08:12:09,600 --> 08:12:11,920
platform powering hundreds of thousands
13150
08:12:11,920 --> 08:12:14,520
of web three and web to Applications out
13151
08:12:14,520 --> 08:12:17,760
there things like openc Nifty Gateway
13152
08:12:17,760 --> 08:12:21,520
but also zerox Argent Dapper but as well
13153
08:12:21,520 --> 08:12:24,760
as big massive web to companies such as
13154
08:12:24,760 --> 08:12:27,760
Adobe Shopify and stripe the question
13155
08:12:27,760 --> 08:12:29,680
here probably is why do these companies
13156
08:12:29,680 --> 08:12:33,000
use us why Alchemy well that's the
13157
08:12:33,000 --> 08:12:36,160
question we try to answer here briefly
13158
08:12:36,160 --> 08:12:38,958
the thing is when you need to develop an
13159
08:12:38,958 --> 08:12:40,958
application chances are you won't run
13160
08:12:40,958 --> 08:12:43,000
the servers you'll code your code will
13161
08:12:43,000 --> 08:12:46,080
run on and most likely you won't even
13162
08:12:46,080 --> 08:12:48,318
develop the deployment and integration
13163
08:12:48,318 --> 08:12:50,760
pipelines for it to do this you will use
13164
08:12:50,760 --> 08:12:54,520
services such as AWS Azure Google Cloud
13165
08:12:54,520 --> 08:12:57,200
well Alchemy does exactly this but for
13166
08:12:57,200 --> 08:13:00,520
web free you can see it as the AWS of
13167
08:13:00,520 --> 08:13:04,398
web free with apis sdks libraries that
13168
08:13:04,398 --> 08:13:05,920
will simply make your developer
13169
08:13:05,920 --> 08:13:08,798
experience better but how do we do that
13170
08:13:08,798 --> 08:13:11,040
well we do it in mainly three ways the
13171
08:13:11,040 --> 08:13:14,120
first one is the super node a blockchain
13172
08:13:14,120 --> 08:13:16,798
propriatary engene that acts as a load
13173
08:13:16,798 --> 08:13:18,680
balancer on top of your node and make
13174
08:13:18,680 --> 08:13:20,840
sure you always got the latest available
13175
08:13:20,840 --> 08:13:23,318
data from the blockchain on top of the
13176
08:13:23,318 --> 08:13:25,680
super node we built the announced apis
13177
08:13:25,680 --> 08:13:28,000
the announced apis are set of apis that
13178
08:13:28,000 --> 08:13:29,558
will allow you to pull data from the
13179
08:13:29,558 --> 08:13:32,120
blockchain with ease here you can see
13180
08:13:32,120 --> 08:13:34,000
how we envision this with the Alchemy
13181
08:13:34,000 --> 08:13:35,878
supernode at the center as the core
13182
08:13:35,878 --> 08:13:38,318
infrastructure powering its ecosystem
13183
08:13:38,318 --> 08:13:40,760
all around such as our announced apis
13184
08:13:40,760 --> 08:13:42,680
but also our monitoring tools and of
13185
08:13:42,680 --> 08:13:44,798
course supporting all the chains that we
13186
08:13:44,798 --> 08:13:47,360
support to date and we'll get back to it
13187
08:13:47,360 --> 08:13:49,798
in a few seconds but the question is of
13188
08:13:49,798 --> 08:13:51,958
course how do you get started well the
13189
08:13:51,958 --> 08:13:53,478
first thing that we're going to do is
13190
08:13:53,478 --> 08:13:56,040
navigate in on alchemy.com and we're
13191
08:13:56,040 --> 08:13:57,840
going to create a new account creating
13192
08:13:57,840 --> 08:14:00,160
an account on alchemy.com is completely
13193
08:14:00,160 --> 08:14:02,558
free and actually cool thing is that
13194
08:14:02,558 --> 08:14:04,398
you'll be able to scale your application
13195
08:14:04,398 --> 08:14:06,398
using our Premium plan because it's
13196
08:14:06,398 --> 08:14:09,200
quite generous so don't be concerned
13197
08:14:09,200 --> 08:14:11,120
about paying anything everything you'll
13198
08:14:11,120 --> 08:14:13,120
see today and probably in Patrick's
13199
08:14:13,120 --> 08:14:16,200
course is completely free to use let's
13200
08:14:16,200 --> 08:14:18,240
go back creating a new account in this
13201
08:14:18,240 --> 08:14:19,958
case I would just sign in of course I
13202
08:14:19,958 --> 08:14:21,718
already have an account so I click on
13203
08:14:21,718 --> 08:14:24,478
sign in and as soon as we'll open this
13204
08:14:24,478 --> 08:14:26,240
window you will see all of your
13205
08:14:26,240 --> 08:14:28,440
applications of course if this is the
13206
08:14:28,440 --> 08:14:30,638
first time you loging in on Alchemy you
13207
08:14:30,638 --> 08:14:32,600
will only see the demo application but
13208
08:14:32,600 --> 08:14:33,958
no worries we're going to learn how to
13209
08:14:33,958 --> 08:14:36,638
create a new application right now super
13210
08:14:36,638 --> 08:14:39,120
important click on create app and let's
13211
08:14:39,120 --> 08:14:41,280
give it a name so we're going to call it
13212
08:14:41,280 --> 08:14:43,398
Patrick is cool and I'm going to use
13213
08:14:43,398 --> 08:14:45,160
underscores just because of personal
13214
08:14:45,160 --> 08:14:47,318
preference feel free to use spaces or
13215
08:14:47,318 --> 08:14:49,440
name your application the way you want
13216
08:14:49,440 --> 08:14:51,000
we're going to also give a description
13217
08:14:51,000 --> 08:14:53,398
this is optional you don't have to but I
13218
08:14:53,398 --> 08:14:57,520
really think that Patrick is cool and
13219
08:14:57,520 --> 08:15:00,318
then we're going to select a chain as we
13220
08:15:00,318 --> 08:15:02,478
said before we support the majority of
13221
08:15:02,478 --> 08:15:04,680
evm compatible chains as you can see
13222
08:15:04,680 --> 08:15:07,318
here we support ethereum polygon P also
13223
08:15:07,318 --> 08:15:10,958
ZK evm as well as optimism and AAR and
13224
08:15:10,958 --> 08:15:13,080
on top of that we support Solana and non
13225
08:15:13,080 --> 08:15:16,160
evm chain here you can select your chain
13226
08:15:16,160 --> 08:15:18,160
and here you can select your network in
13227
08:15:18,160 --> 08:15:20,318
this case we will go for eum mayet but
13228
08:15:20,318 --> 08:15:22,440
feel free to try out all the other
13229
08:15:22,440 --> 08:15:24,840
networks and test Nets of course we have
13230
08:15:24,840 --> 08:15:27,760
one for all of these um main net that we
13231
08:15:27,760 --> 08:15:30,878
support so I will create the new app and
13232
08:15:30,878 --> 08:15:33,160
once the app has been created I can just
13233
08:15:33,160 --> 08:15:36,200
go and search for my name so Patrick is
13234
08:15:36,200 --> 08:15:40,160
cool and click on my application here we
13235
08:15:40,160 --> 08:15:43,120
go once the application has open you
13236
08:15:43,120 --> 08:15:45,440
will be able to see the application
13237
08:15:45,440 --> 08:15:48,120
specific dashboard and this is a big
13238
08:15:48,120 --> 08:15:50,160
change big game Cher for all de
13239
08:15:50,160 --> 08:15:51,798
centralized application developers
13240
08:15:51,798 --> 08:15:54,000
because this gives you full visibility
13241
08:15:54,000 --> 08:15:56,360
over your application and infrastructure
13242
08:15:56,360 --> 08:15:58,558
health you'll be able to see things such
13243
08:15:58,558 --> 08:16:02,040
as latency compute units that that is
13244
08:16:02,040 --> 08:16:04,680
how many RPC calls are eating your notes
13245
08:16:04,680 --> 08:16:06,478
as well as the success rate of your
13246
08:16:06,478 --> 08:16:08,718
calls the throughput and so on and so
13247
08:16:08,718 --> 08:16:10,718
forth super useful when you need to
13248
08:16:10,718 --> 08:16:14,680
debug so let's say that here you see 98%
13249
08:16:14,680 --> 08:16:16,840
of success rate you'll be able to
13250
08:16:16,840 --> 08:16:18,958
understand why your transactions are not
13251
08:16:18,958 --> 08:16:20,760
going through well let's actually do an
13252
08:16:20,760 --> 08:16:22,878
example let me go back and find an
13253
08:16:22,878 --> 08:16:25,798
application that has actual codes so
13254
08:16:25,798 --> 08:16:28,638
here we go I just navigated to this demo
13255
08:16:28,638 --> 08:16:30,680
key application that as you can see has
13256
08:16:30,680 --> 08:16:33,638
a ton of calls but also as you can see
13257
08:16:33,638 --> 08:16:36,360
it has a success rate of
13258
08:16:36,360 --> 08:16:39,920
98.5% that means that 1.5% of our calls
13259
08:16:39,920 --> 08:16:42,478
are failing to go through but how do you
13260
08:16:42,478 --> 08:16:44,120
understand that how do you debug this
13261
08:16:44,120 --> 08:16:46,798
well if you not using Alchemy chances
13262
08:16:46,798 --> 08:16:48,920
are that to debug your RPC calls you
13263
08:16:48,920 --> 08:16:50,878
will have to spin up your own nodes or
13264
08:16:50,878 --> 08:16:53,040
be run a local node and in that case
13265
08:16:53,040 --> 08:16:54,878
you'll be able to see the logs coming
13266
08:16:54,878 --> 08:16:56,958
from the node otherwise there is no
13267
08:16:56,958 --> 08:16:58,478
possibility to see the logs coming from
13268
08:16:58,478 --> 08:17:00,000
the node this is not something you will
13269
08:17:00,000 --> 08:17:02,878
see on E scan using Alchemy you'll be
13270
08:17:02,878 --> 08:17:05,120
able to see all the issues related to
13271
08:17:05,120 --> 08:17:07,120
your calls as well as the known issues
13272
08:17:07,120 --> 08:17:10,040
related to your calls in this dashboard
13273
08:17:10,040 --> 08:17:13,040
so let's say that we have 1.5% of call
13274
08:17:13,040 --> 08:17:14,520
not going through what we can do is go
13275
08:17:14,520 --> 08:17:17,478
on the recent invalid request dub and
13276
08:17:17,478 --> 08:17:19,080
here all the requests that didn't go
13277
08:17:19,080 --> 08:17:21,440
through will be listed as well as the
13278
08:17:21,440 --> 08:17:23,478
reason why they didn't go through for
13279
08:17:23,478 --> 08:17:25,600
example here we have an e Sand Road
13280
08:17:25,600 --> 08:17:27,520
transaction that didn't go through
13281
08:17:27,520 --> 08:17:29,398
because there weren't sufficient gas
13282
08:17:29,398 --> 08:17:31,840
funds but let's take another one here
13283
08:17:31,840 --> 08:17:33,798
execution reverted for example means
13284
08:17:33,798 --> 08:17:35,160
that probably there is a problem with
13285
08:17:35,160 --> 08:17:38,000
the smart contract so as you can see the
13286
08:17:38,000 --> 08:17:40,280
bugging as well as you can see other
13287
08:17:40,280 --> 08:17:42,238
information on the left hand side but I
13288
08:17:42,238 --> 08:17:44,040
will go back at this in a few seconds
13289
08:17:44,040 --> 08:17:45,878
because I want to show you another tool
13290
08:17:45,878 --> 08:17:47,760
that is even more precise to see the
13291
08:17:47,760 --> 08:17:50,280
information about the acttion request
13292
08:17:50,280 --> 08:17:52,318
here you'll be able to debug your RPC
13293
08:17:52,318 --> 08:17:55,000
calls with super Ease on top of that as
13294
08:17:55,000 --> 08:17:57,160
I was saying we have other tools to help
13295
08:17:57,160 --> 08:17:59,600
you debug and get more visibility on
13296
08:17:59,600 --> 08:18:01,360
your application so if you click on the
13297
08:18:01,360 --> 08:18:03,638
menu and here what we can do is navigate
13298
08:18:03,638 --> 08:18:06,360
on the M Pool and the manool is actually
13299
08:18:06,360 --> 08:18:08,000
just like the manool that you might
13300
08:18:08,000 --> 08:18:09,440
think about when you're thinking about
13301
08:18:09,440 --> 08:18:11,360
ethereum so it's a place where all of
13302
08:18:11,360 --> 08:18:13,638
your transactions are and you can see
13303
08:18:13,638 --> 08:18:15,120
the status of the transaction the
13304
08:18:15,120 --> 08:18:17,080
information about the transaction what
13305
08:18:17,080 --> 08:18:18,760
if the transaction is going through if
13306
08:18:18,760 --> 08:18:20,440
didn't go through if it's spending for
13307
08:18:20,440 --> 08:18:23,000
hours if you got mind how much it cost
13308
08:18:23,000 --> 08:18:25,760
and so on and so forth so let's say we
13309
08:18:25,760 --> 08:18:28,200
we just navigated on our mempo Watcher
13310
08:18:28,200 --> 08:18:30,160
and here we have all the transactions
13311
08:18:30,160 --> 08:18:32,238
going through on our applications here I
13312
08:18:32,238 --> 08:18:33,840
have a bunch of applications so that's
13313
08:18:33,840 --> 08:18:35,920
why I'm seeing a lot of transactions
13314
08:18:35,920 --> 08:18:37,600
here on the top you can see all the Mind
13315
08:18:37,600 --> 08:18:39,520
transactions so the transactions that
13316
08:18:39,520 --> 08:18:42,600
already went through like can me mind or
13317
08:18:42,600 --> 08:18:45,398
validated the pending transactions um
13318
08:18:45,398 --> 08:18:47,000
let me just select one application
13319
08:18:47,000 --> 08:18:48,680
because of course otherwise it's going
13320
08:18:48,680 --> 08:18:51,000
to take a long time here you have all
13321
08:18:51,000 --> 08:18:52,840
dep pending transactions that mean all
13322
08:18:52,840 --> 08:18:54,638
the transactions that are waiting to be
13323
08:18:54,638 --> 08:18:56,958
mined or validated and here you you have
13324
08:18:56,958 --> 08:18:58,920
dropped and dropped and replaced so
13325
08:18:58,920 --> 08:19:00,360
transactions that have been dropped
13326
08:19:00,360 --> 08:19:02,120
cancelled or replaced by other
13327
08:19:02,120 --> 08:19:04,398
transactions with the same non same call
13328
08:19:04,398 --> 08:19:08,318
data and the same gas fees or dropped
13329
08:19:08,318 --> 08:19:10,280
means there are transactions that have
13330
08:19:10,280 --> 08:19:12,718
been cancelled and won't be validated or
13331
08:19:12,718 --> 08:19:15,318
mind but on top of that you can get even
13332
08:19:15,318 --> 08:19:18,360
more information on these calls on these
13333
08:19:18,360 --> 08:19:20,958
transactions if I click here on the ash
13334
08:19:20,958 --> 08:19:23,200
this won't bring me on ether Canal will
13335
08:19:23,200 --> 08:19:25,200
bring me on the M poool transaction
13336
08:19:25,200 --> 08:19:27,760
summary page and here I can see all the
13337
08:19:27,760 --> 08:19:30,080
information about the transaction I can
13338
08:19:30,080 --> 08:19:32,398
see how much gas it costed uh which
13339
08:19:32,398 --> 08:19:34,680
network it was on of course uh the
13340
08:19:34,680 --> 08:19:37,360
transaction hash as well as the from
13341
08:19:37,360 --> 08:19:39,200
address so who send the transaction and
13342
08:19:39,200 --> 08:19:41,200
who's sending the transaction to as well
13343
08:19:41,200 --> 08:19:43,798
as the value inside transaction the time
13344
08:19:43,798 --> 08:19:47,360
it took to get sent and the time it took
13345
08:19:47,360 --> 08:19:49,958
to get um validated this is more clear
13346
08:19:49,958 --> 08:19:51,638
on validated transactions where
13347
08:19:51,638 --> 08:19:53,478
everything has already be filled out so
13348
08:19:53,478 --> 08:19:55,638
I can go back in my mind
13349
08:19:55,638 --> 08:19:59,478
page so here we go I can select one and
13350
08:19:59,478 --> 08:20:01,478
as you can see here I have all the
13351
08:20:01,478 --> 08:20:04,238
information so I have Max veper gas I
13352
08:20:04,238 --> 08:20:06,318
have the transaction type so this was
13353
08:20:06,318 --> 08:20:09,360
using the EAP 1559 and a bunch of other
13354
08:20:09,360 --> 08:20:12,120
information about the transaction itself
13355
08:20:12,120 --> 08:20:13,920
super helpful to debug and get full
13356
08:20:13,920 --> 08:20:16,478
visibility over it all right now that we
13357
08:20:16,478 --> 08:20:18,318
have quickly gone through how Alchemy
13358
08:20:18,318 --> 08:20:21,318
Works what it is and how it's features
13359
08:20:21,318 --> 08:20:23,440
can help your developer experience
13360
08:20:23,440 --> 08:20:25,878
become way better and develop faster I
13361
08:20:25,878 --> 08:20:27,120
don't want to steal much much more of
13362
08:20:27,120 --> 08:20:28,840
your time while learning during this
13363
08:20:28,840 --> 08:20:30,600
amazing course so what I'm going to do
13364
08:20:30,600 --> 08:20:32,600
is leave you with a couple of resources
13365
08:20:32,600 --> 08:20:34,398
that will make your developer experience
13366
08:20:34,398 --> 08:20:36,798
with Alchemy even better the first one
13367
08:20:36,798 --> 08:20:38,920
is our documentation so our
13368
08:20:38,920 --> 08:20:41,080
documentation has everything you need to
13369
08:20:41,080 --> 08:20:44,360
get started using our apis SDK libraries
13370
08:20:44,360 --> 08:20:46,200
and also tools that we didn't have the
13371
08:20:46,200 --> 08:20:48,040
time to go through today such as our
13372
08:20:48,040 --> 08:20:50,280
generalized custom graphql web books
13373
08:20:50,280 --> 08:20:52,280
that allow you to pull data real time
13374
08:20:52,280 --> 08:20:53,878
from the blockchain through graft
13375
08:20:53,878 --> 08:20:56,000
queries on top of that you will also
13376
08:20:56,000 --> 08:20:58,200
have tutorial and guides to build your
13377
08:20:58,200 --> 08:21:00,440
applications and complement the
13378
08:21:00,440 --> 08:21:02,798
knowledge you're creating during this
13379
08:21:02,798 --> 08:21:05,200
course of course follow us on Twitter at
13380
08:21:05,200 --> 08:21:08,080
Alchemy platform or Alchemy learn and if
13381
08:21:08,080 --> 08:21:09,440
you want to shoot me a message telling
13382
08:21:09,440 --> 08:21:10,878
me the amazing things that you're
13383
08:21:10,878 --> 08:21:12,558
building while learning from the
13384
08:21:12,558 --> 08:21:14,958
Patrick's course please shoot it at
13385
08:21:14,958 --> 08:21:17,840
vostock on Twitter thank you so much
13386
08:21:17,840 --> 08:21:19,798
Patrick once again for hosting us and
13387
08:21:19,798 --> 08:21:22,478
thank everyone for sticking with us for
13388
08:21:22,478 --> 08:21:24,760
12 minutes it's been a pleasure see you
13389
08:21:24,760 --> 08:21:28,520
around and happy building
13390
08:21:30,398 --> 08:21:31,760
but for this one you should be
13391
08:21:31,760 --> 08:21:33,238
incredibly proud of yourself you just
13392
08:21:33,238 --> 08:21:36,280
did an entire project in Foundry huge
13393
08:21:36,280 --> 08:21:38,160
congratulations so let's do a quick
13394
08:21:38,160 --> 08:21:39,760
recap of everything we learned and then
13395
08:21:39,760 --> 08:21:41,798
we'll move to the next project and yes
13396
08:21:41,798 --> 08:21:43,718
we are going to push our next project up
13397
08:21:43,718 --> 08:21:45,478
to GitHub and a lot more advanced
13398
08:21:45,478 --> 08:21:47,200
Foundry and a lot more advanced tooling
13399
08:21:47,200 --> 08:21:49,080
here so let's do a quick recap of what
13400
08:21:49,080 --> 08:21:51,080
we learned so far well first we learned
13401
08:21:51,080 --> 08:21:52,798
how to create new Foundry projects with
13402
08:21:52,798 --> 08:21:55,440
Forge Das Das and knit which will give
13403
08:21:55,440 --> 08:21:57,238
us all of these folders on the left hand
13404
08:21:57,238 --> 08:21:58,760
side here to actually start working with
13405
08:21:58,760 --> 08:22:00,280
our projects in a more professional
13406
08:22:00,280 --> 08:22:02,000
environment we learned about some of the
13407
08:22:02,000 --> 08:22:04,718
basic Foundry commands such as cast
13408
08:22:04,718 --> 08:22:07,238
Anvil and Forge Forge is used for
13409
08:22:07,238 --> 08:22:08,558
compiling and interacting with our
13410
08:22:08,558 --> 08:22:11,000
contracts cast is used for interacting
13411
08:22:11,000 --> 08:22:12,080
with contracts that have already been
13412
08:22:12,080 --> 08:22:14,680
deployed and Anvil is used to deploy a
13413
08:22:14,680 --> 08:22:16,920
local blockchain similar to ganach which
13414
08:22:16,920 --> 08:22:18,398
is another local blockchain that we
13415
08:22:18,398 --> 08:22:20,360
worked with we learned that whenever we
13416
08:22:20,360 --> 08:22:22,798
send a transaction on our metamask we're
13417
08:22:22,798 --> 08:22:25,160
actually making an HTTP post request to
13418
08:22:25,160 --> 08:22:27,000
this RPC URL
13419
08:22:27,000 --> 08:22:29,760
and we can also take an RPC URL from a
13420
08:22:29,760 --> 08:22:31,920
node as a service like Alchemy and use
13421
08:22:31,920 --> 08:22:34,040
it to actually send transactions from
13422
08:22:34,040 --> 08:22:36,600
our Foundry projects we learned both how
13423
08:22:36,600 --> 08:22:39,160
to actually compile our code in Foundry
13424
08:22:39,160 --> 08:22:41,478
and then also write a script to deploy
13425
08:22:41,478 --> 08:22:44,000
it directly in solidity we've learned
13426
08:22:44,000 --> 08:22:46,120
some very basic information about
13427
08:22:46,120 --> 08:22:48,280
keeping our private Keys safe for the
13428
08:22:48,280 --> 08:22:49,200
rest of the course we're going to be
13429
08:22:49,200 --> 08:22:51,798
working with aemv file but when we work
13430
08:22:51,798 --> 08:22:53,680
with real money we might not want to
13431
08:22:53,680 --> 08:22:55,600
actually have our private key in plain
13432
08:22:55,600 --> 08:22:57,718
text ever so we learned how to deploy
13433
08:22:57,718 --> 08:22:59,040
our contracts to a blockchain
13434
08:22:59,040 --> 08:23:00,638
programmatically and then we learned how
13435
08:23:00,638 --> 08:23:02,440
to interact with them using the cast
13436
08:23:02,440 --> 08:23:05,200
keyword and send to send transactions
13437
08:23:05,200 --> 08:23:07,238
and then cast call to read from those
13438
08:23:07,238 --> 08:23:09,080
contracts we've learned how to autof
13439
08:23:09,080 --> 08:23:11,920
format our contracts with Forge format
13440
08:23:11,920 --> 08:23:13,840
and we learned the manual way to
13441
08:23:13,840 --> 08:23:16,000
actually verify one of our contracts on
13442
08:23:16,000 --> 08:23:19,600
the blockchain we learned a lot here so
13443
08:23:19,600 --> 08:23:22,000
be absolutely sure to take a minute to
13444
08:23:22,000 --> 08:23:24,360
go on a walk go get a cup of coffee go
13445
08:23:24,360 --> 08:23:26,318
grab some ice cream go post on Twitter
13446
08:23:26,318 --> 08:23:27,680
that that you've taken an extra step in
13447
08:23:27,680 --> 08:23:29,638
your web 3 developer Journey you should
13448
08:23:29,638 --> 08:23:31,200
be incredibly proud of yourself for
13449
08:23:31,200 --> 08:23:33,200
getting this far like I said earlier
13450
08:23:33,200 --> 08:23:35,120
installing some of these tools like vs
13451
08:23:35,120 --> 08:23:37,200
code and Foundry can be one of the
13452
08:23:37,200 --> 08:23:39,478
hardest parts of this entire course so
13453
08:23:39,478 --> 08:23:40,958
if you're in here if you're working with
13454
08:23:40,958 --> 08:23:43,160
me you're doing fantastic we've got a
13455
08:23:43,160 --> 08:23:45,200
lot more to go but just by getting this
13456
08:23:45,200 --> 08:23:47,558
far you've done incredibly well so with
13457
08:23:47,558 --> 08:23:50,200
that being said take that break remember
13458
08:23:50,200 --> 08:23:52,520
breakes are good for your brain take
13459
08:23:52,520 --> 08:23:54,798
that break and we'll see you in the next
13460
08:23:54,798 --> 08:23:57,798
one996730
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.