[Music]
all
right
oops all right good afternoon everyone
I'm super excited to be here with you
today uh and I hope that you're as
excited as I am uh so my name is uh
Clement or Clon with the French accent
uh and today we are going to talk and
actually we are also going to write some
H
so uh first I would like to ask you
whoever or first like who knows what f
is okay that's pretty nice and whoever
like tried writing some have
already okay so we have a lot of
beginners that's perfect uh one last
question like are you like knowledgeable
do you know how BL chain works are you
like a developer uh what would be like
uh do we have like many beginners in
blockchain development
here oh like okay inary
maybe
experts oh okay I'm impressed okay now I
have a lot of pressure all right
so yeah so now you might be wondering
like what the hell is H maybe you know a
little bit about it maybe you already
wrote some um have
contracts um well we are going to start
with like the basics with the definition
that you can find on the website so
basically Huff is a low-level
programming language designed for
developing highly optimized contract
that run on the evm so well since you
guys are experts you know exactly what
this means but maybe it would be a bit
obscure or isoteric for some people so
we can have a look like a deeper look so
when it comes to Smart contract
development you have like many different
choices you can use like the most common
ones like solidity or Viper the like the
the usual languages that people are
going to use but there's a bit more to
it you can use for example like inline
assembly so just like adding some
assembly like this like on top of your
solidity code you can lose like a
solidity Standalone assembly gold Ule
you can use half so we're going going a
bit deeper uh in the iceberg and if
you're like a crazy person you can write
memonic by code directly but I wouldn't
recommend
it so obviously you guys know this is
just like a very simple solidity smart
contract uh very basic we just have like
one value we can read uh write this
value and then we can read this value uh
pretty high level very simple to
understand we have like the equivalent
in
Viper um same thing kind of high level
then here we have something a a bit more
interesting so here we're using inline
assembly so we are trying to double a
little bit with the
evm um pretty straightforward also just
some uh different ways to to do
things this will be the complete
um assembly or uu so it's like the
Standalone assembly uh version so it's
we have a bit more code but things are
still like a bit
simple uh then yeah if you want to have
some fun you have like uh the memonic
bite code with just like all the
instructions with some exad decimal
values and this is just like uh what the
compiler will output you can also write
this by hand but it might take some
time so now you you might be wondering
like why have why should we use have
because we have many options they seem
to be quite reasonable they seems to be
quite flexible we can do like most of
these things with them like most like
Unis swap is written in solidity we have
like curving Viper we can do pretty much
anything well we have to go back a
little bit into history and basically
have was created at first by the Aztec
team it was in 2018 and they were
working on like a smart contract called
um bear with me wire strudel I don't
know what this means but that was the
name of the contract and basically just
like a elliptic curve something similar
to zcash and they they they wanted to
write this in solidity they tried it but
the results were not convincing they
tried to use some assembly but still it
wasn't there so
they started to think about making some
kind of way to be able to write assembly
but with extra function extra features
and so this is uh how they came with the
idea of writing half of making
half so this is like uh the I think the
first half code ever written so you can
see it's still it looks like a bit what
we have now some stuff were removed I
think like uh yeah like template we
don't have this anymore but most of the
the things are still there up to up to
this
date but when Aztec decided to create
half they had like very different
intentions at what we have now and like
I think I took this quote from their R
me actually so they said like half was
designed with a complete disregard for
semantics safety or basic consistency so
any similarities to production code are
purly incidental and have should on new
account be used by anybody so yeah this
is more or less what they said about
have they just wanted to build this tool
for them and the goal was not to really
to spread it it was open source but it
was not meant to be like
shared but what happened so we know that
obviously if you're here today uh like
the the story and like the road that
that was like taken is quite quite big
and actually have evolved a lot since
then uh one day like some guy decided to
write to take the code and write like a
new compiler in JavaScript and some
people decided to write then a new
compiler in typescript and more people
came and they decided to write a brand
new compiler in Rust and then more
people came and they said maybe it's
time to write like a new compiler in
Rust again like from scratch so we have
like many different people many
different contributors uh just to this
picture from GitHub I think many of them
are missing but it's like maybe the main
contributors uh that contributed to the
core uh many other people contributed to
other things like writing libraries or
like making uh I don't know like writing
articles or making presentations to have
but this is more or less like
a all the people that
contributed and this is what I showed
you earlier in in solidities or in Viper
and this is like the same code in half
so as you can see it's not that big is
it's maybe a bit scary but we don't have
much code actually it's kind of simple
uh we are going to go through it in a
bit but uh first uh let's answer this
question so like really why the hell
should I use
half uh I think that's an honest
question and
uh yeah let's answer this question so
first I think what's really nice when
you're using Huff is that you have
access to like all the up codes it's not
the case when you're using inline
assembly even if you're using like
Standalone assembly you cannot choose
like all the up codes uh you cannot like
manipulate the stack for example you
have like many restrictions um when you
are using H you have access to well
pretty much anything that that you want
that's the the first thing um also we've
been talking about gas costs so this
chart might be it's not very like uh
precise it's maybe a bit outdated I took
it one year ago I think uh Patrick
Collins shared it on Twitter so I I just
like been reusing it but it gives you
like an idea like this is like the we
are comparing the cost to like create
this uh contract to deploy a
contract and here we're just like
comparing the cost to read and write uh
like um read and write operations so
using half Viper solidity Etc so it's
not exact but it can give you like a
rough idea of how we can optimize the
code obviously there are some stuff that
are in the solidity and Viper code that
we don't have but yeah more freedom you
can do whatever you want if you want to
remove many safety features you can do
it so you can make your Cod like more
optimized
so some very specific use cases if
you're into me if you want to write BS
if you want to do like very specific
smart contract you can use half because
it will be like purely optimized to
exactly what you want to do and you can
like reduce the gas cost like
uh in a interesting
way uh yeah you can also do some crazy
things like this guy for example wrot
Unis swab V2 in half which is
quite impressive actually uh I remember
some people wanted like to deploy uh
deck that was purely written in half I
don't know if this ever happened but
that was like a crazy
ID uh we have this also heridity which
is like a way to run uh half code inside
of solidity by injecting the code yeah
it's a bit isoteric exotic I don't know
you will call it uh the way you want but
this is like uh at the boundary of uh of
the the what what we can do and maybe
it's not a good idea to do this either
but I think like the best uh use case
for uh half basically just to teach you
how the evm works so you can become the
evm
Chad um yeah because what we have been
seeing that uh since half has been
created or revived we can say it this
way many people like me got interested
into have and we can learn a lot about
the evm and then we can get more
familiar with it and just become a
better developer so when you will be
writing solidity code you know exactly
like what the code is doing uh you can
maybe write some optimizations in inline
assembly or if you're debugging
something so it will give you like a
better understanding of like how the evm
works how under the hood everything is
happening and and yeah like today uh I
mean it's been a while already but I
mean like nowadays there are many tools
like for example if you want to write
some Huff uh you can use like Foundry uh
to test your contract so it's it's
extremely simple there's a template for
that and then there are also like
libraries like hmates so if you want to
write something then I don't know like
an erc20 there are already like a
template that was made uh but I think
like the best use case for this library
is is to just go through all the
contracts and try to understand how they
work I think it's like maybe has like uh
all the same contract as soulmate maybe
I'm not sure but many stuff like ownable
like many create three libraries stuff
like that so it's very impressive
also so yeah I think now it's time I
made like a small introduction so I
think now it's time to maybe start going
deeper into
half so I think we're going to do this
in two parts actually first I'm just
going to go through like all the
features that we have in Rust so you
guys can get like a more uh like a
better understanding of what we can do
and how we can do it and then we'll get
to write some actual code so yeah as I
said basically like half is like some
kind of Assembly Language with many
convenience
features
and yeah first I'm just going to go
through like how the evm works I'm sure
like all of you know but maybe there's
like one two people that are not very
familiar with it so I just want to um be
sure that we are all on the same page so
this is a stack this is
where uh most of the manipulations or
handle like if you want to uh store
values if you want to compute stuff like
everything will be happening into the
stack so the way it works is very simple
you have here like a pile you're just
like stacking values from like uh the
top the bottom to the to the top so
you're just like adding new values on
top if you want to remove a value you
will pop the last value that you just
added and what is going to happen is
that let's say we have like a b c and d
and then you want to multiply something
so you're going to use the multiply up
code then what is going to happen that
the evm is just going to take like the
two latest values and it will multiply
them and it's going to put them back
into the the
stack uh yeah this is just like another
representation of the stack so still the
same thing um just be aware we have like
a plenty of space like
1,24 values uh the thing is that we can
only get like the three uh two first
values because we have only like up
codes
for now we only have up codes to get
value up to the 30 uh second value this
will change maybe with the eof but for
now this is the way things Works um and
this is why we have like a stack too
deep in solidity also um then we have
the memory which is like another area to
save some values the memory is very
simple you have like an address and
value addresses and values they are
using like 32 Byes so basically you can
just store whatever you want uh wherever
you want just have to follow the this
pattern uh the storage is following the
same um pattern and we also have the
tring in storage which is also the more
less the same
thing uh and this is the call data so
call data when we are referring to to it
is just like a value that uh someone is
passing to your contract when they're
calling them so this is a swap on Unis
swap V2 uh obviously if you don't know
like
um you might not know what are these
numbers but basically in your contract
you're supposed to so don't don't worry
too much about that but yeah basically
we can see like the the first bites just
the signature of the the function and
then all the other values like after all
the zeros these are just like um values
like amounts for example that are passed
around or maybe addresses
uh yeah just like a very cool website if
you want to be or get more familiar with
like the how The evm Works uh you can go
on evm do codes uh there are many
different sections the first one is like
up codes which is this is what I showed
you earlier just like a list of all the
up codes just explaining exactly how
they work how they work it's like a very
very uh convenient uh and then you have
the playground so you can write some
solidity code uh U code I think also
like uh memonic by code and then you can
just hit the the Run button and you can
see like what's happening step by step
into the memory the stack the storage
transend and storage the return return
values so it's it's extremely convenient
and it's a great resource just to to use
like to to learn how the evm works
there's like a half uh Fork for this but
might not be updated so I'm not going to
to show it here and yeah I guess it's
time to just go through like all the the
things we have in half so first like in
half you can like have um you we have
the interface definition which is
something very similar to what we have
in solidity or Viper or whatever you can
just like Define functions you can
Define events you can Define uh errors
also it's not there but you can also do
it um and then you just have to pass
like some parameters so this will be
useful in two cases either to Define
like a function so people can call your
smart contract or if you want to call
like another contract let's say like an
year C20 then you can Define the
transfer function and then you will use
this definition later on to call the
contract uh we do have some build
functions in half so we have the
function signature the even hash and the
ear function uh these three functions
Works more or less the same way and it's
related to the interface definition once
you define let's say for example approve
and you want to call approve then you
will be able to use like function Sig
and you put just approve um inside of
the parentheses and it will give you the
signature of the function so you can
call it the same thing for the event if
you want to emit an event or if you want
to revert then you can use that for the
error and get the the
selector we have also a right pad which
is just like shifting a value from the
left to to the right and then we have
like table start and table size
basically it's like a way to write
switch statements uh in half we'll get
to that uh in a bit
though and yeah this is what I showed
you like uh at the top we're just
defining like two errors Panic error and
error like that's very original uh but
yeah then later on we want to revert and
then what we are going to do we can just
do like a uncore underscore a and then
we just put the um name of the ER you
want to use and then this will add the
selector inside of our code and then we
can just like uh in this case we are
reverting with some parameters so we can
just like sore these parameters inside
of the
memory then we just have to call the
revert
function so another thing that we can
Define actually um constants so I think
it's pretty straightforward you have a
number you can just Define like a number
so it's like o x 420 this is an EXA
decimal value but you can also Define um
numbers uh using like decimal values
most of the people do it this way and
then whenever you want to use the your
constant then you just have to put the
name inside of some brackets and then we
just like uh input the the right
value uh then we have jump labels so
jump labels are defined within a macro
or a function we'll see what they a bit
later but basically like it's very
simple you have just like a piece of
code like for examp example success here
success is just defined by this um
instruction so like we we store
something and then we just return and so
what is going to happen if you look at
the top I think there's like a pointer
yeah if if you look here basically we
are doing something here and then we say
okay we want to jump to the success so
we just have to call the label success
and we jump to it and this piece of code
will be executed so it's quite
straightforward also
so you can also do it with jump e so you
can add like a a condition to to this
jump and then we have functions so
functions can have like uh arguments
that you can pass here and yeah there is
one weird thing here so takes and
returns so this is something that can
help you know what the function is
expecting um from the stack and what the
function will left into the stack so
basically what is going to happen is
that this function uh is expecting like
three um values in the stack and after
its execution it will left uh it will
leave sorry like one uh
value uh in into the stack so as far as
I know this is not enforced by the
compiler but it's more like a way for
you to just like know uh more or less
what you should have how you can manage
the the stack
and yeah so basically functions so we
have functions and macros and like the
big differen is uh that functions they
are um copied only once uh the compiler
is going to take the code of your
function and it's just going to put it
at the end of uh all the the bite code
and whenever you're going to call a
function then um in the execution of
your code it's going to jump to the
where the function is and when the
function has been executed is going to
jump back and keep on with the execution
of your
code which is different from macros in
the case of macros what is going to
happen every time you're going to invoke
this macro then the compiler is going to
copy the old code and directly put it in
your bite code uh what was compiled so
this means that if you're using like
macros then the size of your smart
contract might be a bit larger but might
be cheaper guys wise because you will be
like avoiding like jumping around back
and
forth and also by the way yeah so uh we
don't have it here but basically macros
they accept like parameters and you have
also the takes and returns uh
indications so we have like two
important macros that you need to know
we have the
Constructor it works the same way as
solidity actually so basically if you
want to ex some code uh when you're
deploying your contract then you just
have to put it into the Constructor um
and we have the main macro the main
macro is uh well quite simple this is
like the entry point of your smart
contract so whenever someone is going to
call your smart
contract Dom main macro will be executed
so this is where you want to do like a
the function uh dispatching or things
like that but we we're going to see that
in a in a minute
uh we have jump tables so it's pretty
small and a bit long so yeah just a way
to do like um um switch statements uh in
half so maybe we can see that a bit
later so yeah let's code so I think it's
time now to write some actual code so
yeah we need uh I hope like you guys all
have a laptop otherwise it's going to be
a bit boring for you I'm sorry so we are
going to write some code uh we are going
to use the template that is using
Foundry so if you don't have Foundry you
can install it uh using this
commands I'll just give you like a few
minutes to start installing stuff
so if you already have Foundry you can
install directly uh have like this is
like
the version manager I would say so you
can run this maybe I should have put
this two into the same slide I'm
sorry it just tell me if you guys all
have the first step done then we can
move
forward if you have any questions uh
about have or about how to install
things you can just ask me now I think
yeah
oh which version do you have
page okay is this like the yeah half up
should be like the okay check check your
Wi-Fi because I know like the Wi-Fi is a
bit long
now SC sh
try again
maybe
War that's that's pretty annoying I'm
sorry I don't I'm not sure how to help
you
here uh let's see
what is the Ripple you you
opened
oh yeah it's a bit weird we're going to
use Foundry so it's just going to like
uh do everything but I think like the
yeah yeah it should be working try yeah
try just like uh have C Dash capital V
and then just to see if yeah I mean it's
saying it's saying compiling so yeah
it's you have the right version yeah
yeah I think if you want to output
something there's like a command if you
check if you try help we tell you yeah
there is something like an output yeah
bite code stuff like that yeah it's a
bit it's a bit weird no is all right so
if you guys have Foundry we can move
forward uh then you just need to install
half and once you've done this uh you
can install uh so this is installing the
packet manager not the package sorry the
version manager then you can install the
latest version and this should be
working so you should get like have
uh
0.3.2 something like that and Forge
whatever like should should be working
should be giving you like some
outputs
Yep this
one let me see if I can give you like
all the commands that would be
easier it's not loading
all
good you have now you have L okay oh
it's still installing oh yeah I
hope it's not going to take too much
time worst case scenario like I I still
have some slides so I can show you guys
but it would be better if we can just
like code
along yeah all
good
nice yeah installing
downloading okay
all good over
here
nice uh it's half
C nice
Perfect all good or installing that's
nice all right I'm just going to give
you a few more minutes because I see
many people still downloading it takes a
few minutes I think to install
everything did
you okay oh perfect
nice all good
all good here yeah
okay do you guys need help or you good
good yeah thank you okay yeah you have
like both
versions everything is working oh
perfect all right yeah let's move
forward uh where's the clicker
yeah we're just going to be writing like
two very simple contracts today I don't
know how much time it will take like we
have two hours but yeah since you guys
are experts I'm joking but like I feel
like it will be pretty straightforward
so maybe it will not take like the whole
the whole time uh yeah if you do half up
you do havec uh Dash capital V Forge
Dash capital V you have if you have
everything working here
then uh what you can do you can clone uh
this repo just like a very basic
template uh I've made using the actual
Foundry template so you should be able
to clone this I just hope it's public so
just let me know if it
works and when you have this uh there
will be like one um exchange if you're
in vs code there will be one extension
that is that is suggested uh it's called
like a half Language by half language uh
and it will just give you like a syntax
like colors stuff like that there is
also debugger but we're not going to use
that today so yeah just let me know if
like uh okay perfect good I'm relieved
nice uh it should be so do you have vs
code if you open the repo in vs code it
should like pop up the suggested
extension other otherwise it's called
like half language I
think you got it
perfect yeah it would be better to be
using some having some colors otherwise
it's going to be a bit hard just to see
what what we're doing uh yeah I'll just
give you a few minutes because I think
the slide just after this yeah like
after this we're just going to be
cooking so I just want to be sure that
everyone can follow
right exion
okay good yeah it looks like we are all
set so what we are going to do we are
going to be writing our first half
contract so I think there might be a
source uh folder if maybe it's not there
anymore I don't know but you can just
make like a CR um Sr C folder then you
can write the first uh like create the
first file you can name it the way you
want compute. half or whatever you want
and then we are going to be writing some
code so this is the first contract we
are going to be writing today it's uh
extremely complicated you will see this
construct is just going to take two
values and multiply uh yeah no not
multiply actually add these values
together and then just going to return
them so as you can see it's extremely
hard to understand um yeah so let's just
like follow along if you guys have your
setup already you can code at the at the
same time so the first thing we want to
do that we are just going to define a
function so here as you can see uh this
is what we're doing here
let's call it I don't like compute you
can call it ad or whatever just it
doesn't really matter um and so this
function is going to accept two
parameters so we need like one u in 256
and why not another u in 256 and then
it's going to return well something very
original one U went
256 so this is just like like the
function that uh we Define and this
definition will be used by US inside of
our have contract but it will also be
used by the people that want to interact
with our
contracts so then we have this which is
a macro here that we are calling compute
um so we can Define this macro here just
a way to organize our Cod will be also
another way would be just to shove
everything into the main macro but
that's now we are like a educated people
so we are not going to to do that uh I'm
going to go through what's in there in a
second but first I want to talk about
the main macro which is just here so as
I said earlier the main macro is the
first thing that is going to be uh
called when someone is calling your
contract this is like the the entry so
in our case uh it's pretty simple so
let's go let's go through it so okay you
guys can so maybe you're writing at the
same time so I will slow down I'm
sorry so yeah first I think the the
easiest thing is just to write the first
uh function definition on top and then
you can go directly to this don't write
this so now we'll do it just after
yes
yeah uh
here
oh yes yes so why are we returning
nothing here we are not like leaving
anything in the stack it's because we
are returning here and this return is
actually uh the end of the call so we
are when we are returning something in
half we are actually like
returning uh values from the call so
it's like the end of the
call it's it's I know it's a bit the the
names may be a bit confusing right yeah
because we have returns with which is
not actually returning but just leaving
stuff in the stack so that's true that's
it can be a bit confused
using so yeah I'll just uh are you guys
ready or not to go through the the main
macro all right okay let's go so now we
are going to do what we are calling like
function
dispatching uh we have like a very basic
implementation but it works the exact
same way for example in um solidity of
Viper there are many different ways to
do this but this is like the most common
way so
basically uh what is going to happen is
that someone is going to call our smart
contract they will send us some call
data and we just want to know okay what
do they want to do like what is going to
happen so what we are going to do is
very simple we say we want to load the C
data so all the values that were uh
given to us but we want to load it uh
starting from like the the first the
first bite we want to load it from the
start and then I maybe you know this or
maybe you don't know but basically like
uh function signatures they only have
like four bytes so how does it work when
someone is calling a contract in
solidity or like uh in the evm like the
the standards that when you're calling a
smart contract the first bites the first
uh um the four first bytes or the
function um
selector so what you are going to do
that when you receive the call data you
are like okay I want to know what which
function we should uh call inside of our
contract so I'm going to check uh in the
cold data what the guy wanted me to to
talk wanted to to call so we are going
to load the all call data here and this
like magic number um the value is like
uh 20 24 bits so it's like 28 bytes and
so what is going to happen here we put
in the stack like the whole like the
whole call data so we have everything
and then we say we want to move to the
right like all the call data so we are
going to move everything to the right
but we are moving to 28 bytes so we are
going to leave uh a value which is only
what you can do like 32 bytes minus 28
and you have four bytes so this is like
the the function selector and so yeah we
have a function selector so we know
which function the sender wants to call
but now we need to check okay so do we
have this function maybe we don't have
it maybe it's a mistake so what is going
to happen here we are are going to uh do
exactly like the function dispatching so
we are going to load here our function
signature so this is what we have
compute it's here this is what we Define
and this is what we are expecting and
then we're going to do like equals so
equal here is going to check if what we
loaded here what we sliced from the call
data the function signature function
selector we have is equal to this one
the the function signature that we are
expecting and then we say okay so if
it's equal then we'll have a zero here
uh no sorry um we'll have a one if it's
not equal we have zero and then we are
just going to call the jump if up code
and the jump if up up code is very
simple if this is zero then we're just
going to continue if this is one we are
going to jump to here compute the jump
label I showed you uh I explained to you
this earlier so maybe this is a bit
confusing just let me know if we need to
slow down okay you have question uh go
ahead what is it doing
exactly on the on the function signature
how is that could you explain dive
deeper into that yeah sure so basically
uh this this is uh the same thing as
solidity when you have like a uh
encoding something or if you define a
function in solidity you can get like
the signature you can get like the four
bytes and this is the same thing here uh
we Define this function here like this
is like our function and oh I see so
it's actually Computing the signature
function signature from the compute
exactly it's it's Computing the hash so
the hash of this and then it's just
going to slice and only get the four
first bytes okay could you go back a
little bit on the call data piece so is
it just leaving on the stack the call
the four bytes of the function uh
signature so basically here we are going
to it's a bit weird because like you
know you have to add the value on the
stack and then you call the instruction
so it's a bit hard to explain because I
need to explain like uh back and forth
what the values or but basically you're
like I want to from the start I want to
load the C dat
so you will be loading the C data from
the the first bite from the bite zero uh
but you are going like to load 32 bytes
what is going to happen is that this
function is going to take like a slice
of 32 bytes and put it into the stack so
you will have uh so four bytes for uh
the function uh signature but then you
will have 28 bytes which will be like uh
non it will be our case it won't be
nonsense but it will be this uh the
first parameter but even it won't even
be like the whole parameter because this
is like 32 bytes so yeah maybe yeah I
should have put like a graph or
something it's it's hard to explain this
uh just like this but yeah it would be
helpful if you had like the stack on the
on the right hand side idea I'll see if
I I can do something uh yeah I'll see if
I can do something actually after but
yeah basically the idea that you all
loading here 32 bytes of cold data
starting at the position zero but in
this case we only want the first four
bytes so we say okay let's just move to
the
right uh this element in the stack and
we want to move it to 28 bytes so we
move it like this and so we are left
with four bytes which is the function
signature so on the stack all that's
left from the call data is the F uh the
first four bytes which is the function
signature exactly got it and after we
just check okay is this like a valid
function signature because someone can
just be like spamming our contract so we
need to to do like a proper check uh
which function do they want to call um
so we are going sorry we are going to
use uh to sorry we are going to load our
own function signature what we Define
here into the stack so basically the
stack will we will be their function
signature our function signature on
top and then we'll just do like equal
and both values will be removed and
equal would just leave a zero if they're
not uh equal if they are not like the
same and you will put one if like both
signatures are the same uh I just want
to yeah there is like d here duplicate
one uh this is not needed here so not
going to talk about it we'll see that
after but this is not needed here so
don't worry about it um and yeah so we
are are checking here and yeah like the
the final thing to do is just to jump
accordingly if the um function signature
is valid if we have something that we
are
expecting then we jump here to compute
and in our case we decided to make
things proper way so we Define like a
macro for compute the other solution
would be just to shove all the code here
but uh it's just cleaner to to do it
here and yeah if they don't have like
the a valid function signature we're
just going to revert uh we don't care
they they don't uh they're not like uh
asking for the right function so we are
not like uh reverting uh with any extra
data we're just returning zero value
value just reverting the transaction but
we could have been like reverting and
say like anything you want like wrong
function signature or
whatever um all right do you have any
questions yes I'll give you the
mic I see by the looks of the function
and the main functions you have a reth
and return it's all recursive inside of
the AVM or is just for showing they have
a repair or function this are this are
up codes yeah I refer this H the evm is
recursive when the when the codes oh do
you mean like uh is this going like to
fail the whole transaction or continue
the transaction the execution until you
put the return on RT or revert yeah if
you revert here I mean it's the same
thing in solidity you can revert here
but then uh the call can continue it's
the same continue infinitely until the
gas is oh no sorry okay I I understand
it uh not the right way uh this is the
end of the the transaction but it will
continue if there are like more things
after uh other uh upod to execute but if
you just if you reach like the end in
this case we are reverting but it
depends on like uh well how you're
writing your contract and who is calling
your contract because like if you I
don't know like
uh I mean it it depends I don't know
exactly how to ENT this but uh yeah like
basically it will consume gas but if you
reach the end of the goal then it will
just stop consuming gas you know because
it's only consuming gas when it's like
executing operations but if there is
nothing left to execute then the
transaction will just stop okay so if I
remove the return or or the revert H it
just stops completely uh if you do that
uh if you remove the return here I'm not
sure what you will do actually
um that's a good question I think we'll
stop because uh this is here actually in
like the the code this will be compiled
at the end of our contract and then if
you do this then after the contract has
ended so I think it will just stop but
otherwise you can if you forgot
something you can make a loop uh if you
put like here something then it will
jump here and go here and jump here like
it will be a loop he will consume all
the gas and just River twist out of gas
actually okay perfect thank you uh
question about the 0x00 cold data load
uh yes so that sounds a bit heavy is
that the most efficient way of getting
the extracting the the selector mhm okay
yeah because you can when you're using
like cold data load you can only load
like 32 bytes you're loading like a
whole piece of information into the
stack then you have to move forward to
um to get uh the the the actual function
selector there is another way actually
and I think you can load like a single
bite uh from the cold data but that that
is not standard so you can do it but
it's not like the standard way so you
you could be like loading I don't like
the first uh uh you say okay this is
like one and if this is one we compute
or we we go to something that will add
if this is two then we can go to
something that will do minus uh
substract things like that but the
standard way is like for for
byes um yes so we can continue so
basically once you
uh yeah once you are going to compare
here and then you have like as I said
like two different uh cases two
different scenarios either you can
revert so we are just reverting like the
the hard way oh we we might be going to
our macro
here and the macro is kind of simple so
we know that we have like two uin uh 256
that we need to have into the stack
because we want want to add them
together and return the sum of these two
values so we are going to do the exact
same thing as we did here uh I mean
called the same
function and so in this case we know
that the four first bytes or the
function uh signature so we are going to
ignore them and we say okay put into the
stack so called Data load but put into
the stack the C data starting at the by
uh four so ignore the first four bytes
and then put uh the call data so this
will take 32 bytes of call data and put
it into the stack then we just have to
compute and we say okay we already
loaded four bytes for the function
signature we already loaded 32 bytes for
uh the first parameter the first you 2
56 then it looks like it could be 36
byte that we already loaded so here's
the value
36 so we are going to say okay you have
to load into the stack uh the next value
which is located after 36 bytes
um so am I clear I know this is a bit a
bit heavy if you have any question feel
free to ask them I don't want to lose
any anyone or maybe I already lost some
of you I don't
know so uh back to the first couple of
lines inside main um so I get that we're
putting uh the the function signature on
the stack yep and
then so at the end of the second line is
that uh if it's equal then compute jump
or it or does it say if it's equal
compute I I guess I'm getting confused a
little bit the naming conventions and
like you've got you know the you're
defining function compute and then you
also have a label compute and so yeah
don't I'll explain so basically yeah
okay I I I understand what you mean okay
so yeah the the naming was maybe a bit
wrong but basically here compute we have
our
function and this is only related to to
this this and this are related
that's it and then this compute is the
jump label that we are defining here so
these two are related but that that
that's it there are no other
relationship um and so okay sorry one
final thing on that so where it's doing
the the equals uh does it know
automatically to just pick the first one
off the stack and then compare it to
function signature compute so because
here we loaded like the function sign
from the call data so we have like at
the top of the stack we have one
function signature the one that the
sender gave us and then here we are
loading we are putting into the stack
our own function signature so when we
are calling uh equal it will say okay I
need two elements from the stack two
values from the stack and we'll just
take like the two first values which are
the values we need and then so we have
into the stack like either one or zero
and we say okay we might want to go to
the compute jump label which is here and
then we say okay go for it but only if
uh we have a one uh if you have a zero
then keep on reading the next code so we
will just keep on reading the next code
which is just like reverting and revert
just say uh okay I want to revert do you
want to return some values from the mem
memory but we say yeah return Z like
zero value from the memory that that's
it the the return here is very very
simple uh more questions
yes uh yeah basically yeah yeah and so
this is like the most I think convenient
thing uh when you are like writing stuff
like this because if you want to try to
write like a uh mimic bite code
basically you can you you can write all
of this without H but uh uh instead of
having like compute here and here uh
instead of having something that you can
read you will have to put like a value
and this value will be like a location
inside of your code so you will you will
say for examp for example sorry I want
to go to uh like the the in my code to
the location I
like 148 but if you add more code here
then you have to change this value you
know so this like this is just uh for us
to be able to do this like a very in a
convenient way um yes so we are jumping
to compute and as I told you just like a
macro so it's very very simple in this
case we are loading our two values here
we know that we are have to avoid the
first uh four bytes so this is like the
next 32 bytes this is the next 32 bytes
after the first uh 36 bytes and what is
going to happen is that we have value a
and value B inside of the stack so we
just have to call add and add is exactly
what I showed you earlier so it just
like uh with multiply just taking like
two values from the stack it will add
them together and boom they put back
into the
stack and what is going to happen here
is that it's pretty simple you'll see we
have one value into the stack and well
we now we want to return it because we
did all of this but now we need to
return our value so return here is very
simple uh you can only return stuff from
the memory so we have to put our uh
result the the sum that we just computed
in to the memory it's very simple we are
going to use the M store up code and M
store takes one value here and one
location inside of the memory and then
we just call M store so what we've done
here that we are putting here um at the
location zero the value of AD so the
value of AD can be anything up to 32 uh
bytes obviously but it can be anything
and yeah we have like value in the
memory
yes wait for the mic sorry isn't there a
cost for putting that value in memory I
mean it's not like yeah obviously yeah
but why not why not return it from the
stack because it's not possible it's not
possible yeah the way uh you can see
like uh I'll show you okay let me just
go back a little
bit um we
are okay we are here so basically you
you can see like uh we don't have the
return um function here
obviously uh okay but if you go on this
website it's evm code you will see like
all the up codes are explained here and
you will see like stack input so
basically this is like when I was
talking about the stack this is like
what is expected and this is what will
be uh left into the stack so in our case
we are taking Like A and B and we are
adding them so we go from two elements
uh from two elements to one element into
the stack and you can see like there is
a description here and if you go down
let me share my screen actually because
this is like a interesting question can
you uh
yay uh all
right all right let me see
evm all right so if you go down here I'm
not going to take like too much time on
this but basically let's do
research M store here you can see like
um this is explaining how uh M store
works and if you go to uh return you
will see like
uh uh the explanation will it will just
tell you okay stack inputs uh so the
definition is like the offset and the
size so basically this means that uh we
need to tell uh where we want to load
the value from so it obviously inside of
the memory and the
size that's uh that that's it so if you
can you go back to the can you go back
to the presentation thank you perfect
uh yeah so it's just how it works we
don't have a choice in this case but I
just wanted to show you the the website
because it's going to explain to you
exactly like all the like all the op
codes uh work actually it's pretty
pretty interesting and even if you are
not doing like going to do like some
crazy things with have if you just use
like evm codes and this um and half then
you can just learn and have some fun
understanding how things work it's still
quite uh quite interesting oops I went
way too
far uh yeah no wait this is the second
one uh this is the test that's the one
uh yeah that's the right one so yeah and
then we have uh yeah as I just just said
like return so return is expecting two
values so we have the first value which
is the size uh what we want to return so
in our case it's 32 bytes so it's like
0x 20 in exad decimal you will see like
many have code are return like all the
values are in exad decimal I guess
because it's cooler I don't know but
it's like more by convention so you know
that you want to return a u in 256 so
you have to return 32 bytes and this is
the location in memory you can see we
just stored it here uh the zero like uh
like madm um and so we can just like
call return and and that's it we have
our whole contract so if you guys have
the code ready you can try writing a
test
actually so this is how tests are
working with
fundry uh and half uh so we have
something called like a half deployer
and this is pretty convenient because
it's going to uh take your contract
compile it for you and then you can just
deploy it so if you're familiar with
Foundry you you will see it's the exact
same experience as writing regular tests
very easy very simple very
convenient uh the only small difference
I think that might be a better way to do
this but we'll do it like this today we
just need to redefine our interface here
so we say this is our contract compute
and then we just like copy paste what we
defined uh here we just need to put it
again here in an interface I think
that's a better way to do it but I'm not
going to to show it today
because yeah we might be running out of
time so yeah this is quite
straightforward you make like a a new
test file then you just have to put like
compute test is test whatever uh just
like a um storage value for your your
contract and then what is going to
happen is that uh you just have to cast
it so we Define the interface here so
you just cast it or you can keep the
address as you want and then you just
going to use the have deployer and you
do like that sorry you do like that
deploy and you put the name of your
contract I think the name of the
contract the contract is actually the
name of the
file um yeah so if you do this the
contract will be deployed and then you
can write your F first test so in this
case we're just like expecting uh random
values that would be fuzzed and yeah we
say Okay so the contract should return C
and we we can just check that c is the
sum of of A and
B I'll give you a few
seconds do you have any questions or
anything like that you're struggling
with like I I know this is a lot of a
lot of things all at once uh it can be a
bit tedious to set up everything so if
something is not working uh we still
have like a less than one hour but we
can take some time
to to fix some
issues can you just explain the math a
little bit uh obviously um you've got
unchecked there
so all of these un 256s can wrap yeah
and yeah just just to explain the bounds
on the uh is it just yes so I'm I'm just
uh doing here uh unchecked because uh if
we go here in our I'll go back to the
next slide I'm sorry for those who are
copying the code but if you go here like
add we have no uh overflow check so if
we are just doing like a
assert like the sum here and we have we
don't have unchecked then solidity will
do like a overflow check and then the
code will revert or we won't have the
same result as our have code uh but yeah
that that's an interesting question
because here in solidity now we have the
Overflow check but we don't have it in
in half so maybe like something that you
guys can do is a way to prevent the half
contract from uh the sum from
overflowing so that could be an
interesting exercise I think there's
already a li like like a small library
in half mate that can allows you to do
this but it could be quite simple to to
code
actually hey sorry one more question um
you mentioned that over here um bit off
topic you mentioned that uh advantage of
using Huff is you have complete access
to all the op codes um what is one use
case that you've found where you can
particularly exploit that to achieve
something that you haven't been able to
do in another
language uh it's so personally I haven't
been like doing I haven't been coding
for production things uh I was more as I
said like in the
beginning I really wanted to learn how
the evm was working and actually just
like writing some have was like the best
way because writing resources is a bit
tedious but otherwise like I've seen
many people doing like um uh yeah um me
boats boats or things like that they're
using half and yeah I mean like you have
more you have access to many things and
what what is interesting also is that
you're not writing solidity code you're
not writing like uh or even Viper um so
you can do like a as we we saw earlier
like the function dispatching if you are
just writing your own butt for your own
purpose you don't care about that so you
can remove like uh a lot of the safety
features from solidity because if you
know exactly what you want to do you can
achieve it this way but uh yeah like
some some stuff also in uh like main
difference is also you have access to
more up codes I don't have like an examp
example here but I would say yeah like
there are so many other cases but for
this one specifically I'm sure we can
find it but I don't have it in
mind
yeah
yeah yeah could be a example
yeah all
right so yep okay let me
see oh you put like a uh you went eight
yeah just put like a
256
yeah
yes yeah I think think yeah if you have
like compilation failed I think there is
one step that we haven't been doing yet
and it's just
installing uh the packages so if you
have this obviously if you have the
first contract and then you have this
then you can try uh just be sure to have
everything installed so you can just run
like Forge
install uh because now you might not
have the have deployer module or
whatever it's called Uh and then if you
run like Forge test it should be working
I hope so I tried in my
machine same thing like uh here you went
eight the result you should just use
like
256 yeah let's see if it works I hope it
will
work oh
all right let me know if it's
working yeah the test is passing hell
yeah yeah you have them the
mic is there a way to uh write half
codes like in L in solidity yeah
actually there is one I this is
something I I showed earlier uh like
there is something called
idity I guess it's called this
way but this is very very experimental
and like this is leading to many uh
where is
this it's here yeah so it works but I
don't think this should ever be used in
production because like the way it works
that it's just injecting it's compiling
your code it's
injecting uh your code so I I think I
mean if you uh so if you really want to
use have for something in production I
guess like uh something interesting
would be just to have like
a deploy maybe a library or contract so
I don't like some kind of precompiled
just make a contract that is Computing
something you deploy it and then you can
call from solidity you can call this
contract but uh yeah like this is highly
experimental uh it hasn't been updated
in a year so I think it was more made
for for fun that than something
else so are all the tests
passing
no you forgot the unchecked
sorry I just I just saw this yeah if you
because so basically you have the exact
issue that I was explaining so like here
if you don't put the uncheck then the
test will revert because um adding these
values will cause an overflow and we
still have like overflow checks in uh uh
in the
test any issues
okay all right so we covered the first
contract uh yeah I have another one if
you guys are are interested and we still
have 45 minutes if you want to suffer a
little bit
more failing test okay let's
see uh okay did you put the
checked
oh yeah yeah yeah that's
uh okay let me okay the code I think the
half code looks
great yeah yeah it it doesn't
matter uh yeah that's unfortunate
okay if so if the tests uh are failing
uh you can still check uh if you open on
uh you can open this uh like a URL in
your
browser and you can check or you can
change the branch directly I've made
another branch called
finish and you should have the first
test
uh this one I mean the contract and the
test I hope they will work but if they
don't work maybe there's a bug in my
code I don't know so if you can find it
then that would be amazing maybe I made
a mistake
somewhere yeah so it's passing so what
I'm thinking now
maybe I don't know maybe some values
yeah found
it that's that's really funny do you
have
yes have toore it in yeah when you are
returning something yeah
what what if it's st's
you cannot return from the stack you
need to put into memory this is the way
return Works return can only read from
the
memory this
one where is
your oh try to rename this to Source Sr
c yeah here if you put contracts I think
it won't work it's just naming
conventions try try this and let me
know yes
uh compute is the name of your
file
yeah yeah you uh yeah yeah actually I
think I know maybe it works okay
perfect okay let's
see it's the issue ah cter example
that's that's
funny okay go back to the file have yeah
uh
let me
see yeah yeah no the problem is in the
code now let me see call data you're
loading the right oh you forgot add uh
after go data uh no no before
before uh yeah yeah nice all right any
any
issues still failing oh gosh
yeah what was the
issue oh no compilation try to do like
a
uh uh yeah try to run uh do like Forge
test Das Das
Force oh
oh that's that's weird why is he running
a test if you don't have a a test oh it
says revert yeah I
it's oh
yeah I'm I'm not sure exactly check on
the other Branch uh you can switch the
branch go to the finished Branch if you
want uh yeah if it doesn't work after I
can I can look into but I think we we
are going to move forward because feel
like you guys have the code
working uh so yeah we still have like 40
minutes so maybe we can go through
another
contract
uh yes so this one is more or less the
same thing it's not exactly the same
thing but we are going to cover one
extra uh one extra op code so now in
this case what we want to do is
that we you will see it's very simple we
just want to be able to get a value from
the sender and store this value and if
the sender wants to read this value then
we are just going to return it so once
again very very basic contract but this
will allow us to uh cover a few
different
things so in this case well we are going
to start by the interface definition
once again so we are going to Define two
values the first value is just uh two
functions sorry and the first function
is just set value so in this case we
want well U into 56 which is
very original and then we're just going
to make like another function called get
value and in this case we don't want to
get we don't want to set something but
we want to return
something and then we are going to cover
something else so we are going to make
make a new constant called uh value
location and so we are going to use this
which is like a yeah some kind of
built-in function that we haven't seen
yet called free storage
pointer and basically what this function
does uh it's very simple it's just going
to give you uh the location a location
where uh the storage is free so in this
case if we call it now it will be zero
because the first uh location that is
free is located at index zero very
simple if you call it again it will be
one because we have this value already
taking the first slot so the slot zero
and then after we can take the slot zero
one two
Etc any questions
no all
right um and then we are going to go
directly to the main entry point so this
is going to be almost the same code as
we as we did
actually so we are loading the C data
from the start we are shifting to the
right uh 28 bytes and what is going to
happen here that uh I told you earlier
that we don't care about the uh
duplicate one the DB one but in this
this case we need it because what is
going to happen here that here we have
the function signature that we received
from the sender in the
stack and we want to keep it for later
so we are going to duplicate it so what
is going to happen is that we will have
two times the function signature we
received from the
sender then we're just going to be doing
exactly what we did earlier so we are
going to load uh for example the first
set value the signature of the set value
function so we want to check okay maybe
the sender they want to set the value
okay let let's see so yeah we load the
set value function signature and we do
equal and yeah maybe it's equal maybe
it's not we don't know so we said okay
you can jump to set if the value that we
just received is uh equal to set value
and then you know the drill it will do
it will go here and then to the macro
set value and it will go here but if
it's not the case then what is going to
happen is that well jumpy is just going
to do nothing and so we will go back
here and in this case also dump one here
like dump one sorry is not needed but
yeah don't worry about it but this means
that
here uh when we called equal we we
consume the first value that we loaded
here and we consume this value too so
luckily we duplicated this value into
the stack so this means that we have
value a two times the value a then the
value B then they are consumed so we are
left with the value a so then we can
load the function signature of get value
then we have the value a and the
signature of get value and then we can
do the same thing again equal and if
it's equal we can jump to the get uh
macro and so we go here and then we
execute it
here it is clear or not no
I'm I'm sorry I'm sorry uh do you do you
maybe you have a question and uh you can
answer like you you have a specific
point that you don't understand and
maybe I can explain it like in a
different way can you have a mic over
here
please thank you clo um so dup one is
that duplicating the okay it is
duplicating the stack exactly the dup
one is duplicating the first item of the
stack on the stack so it's duplicating
the call uh the the function signature
of the sender yeah so it's duplicating
the function signature that we received
and so basically the D one here uh is
just a way for us to avoid doing this
again because we could be doing this and
then we do this we don't duplicate but
if uh it's not like uh if the standard
is not willing to execute that value
then well we have to check if they want
to execute get value so we we need the
function signature again so we could be
doing this again but it will be costly
it will cost so then don't you have the
function signature on the stack three
times uh because you call duplicate one
twice yeah this one is an error oh okay
I'm sorry about that this one is an
error because I just like uh copy pasted
that that line and then I change this I
mean there's no there's no harm because
you're not doing anything after you have
the function signatures this could be
leading to some issues in our case we
are just reverting right after so it
doesn't matter but I can show you after
like for example in the case of erc20 or
something like that uh but yeah you can
have like uh many different things so
you will duplicate every time but on the
last time it's not needed you're right
okay all right that makes sense so um
question so when you do the equal
it's actually taking two values that's
on the stack well no well taking one
value that's already on the stack and
the other value is the one that's
computed uh as part of that call uh it's
taking like when you're doing uh yeah
equal is going to take so uh this so we
have this value in the stack right
that's on the stack and then so you can
imagine that here we duplicate so this
means that this value is here it's like
we are cloning
it if you don't mind I'm just going to
interrupt you quick because the question
I have is the function signature that
looks like a macro is that putting the
value of that it's Computing the the
function signature of get value right
and is it putting it on the stack and
then the equal equal function is
Computing the equal between those two
values that are on the stack okay thank
you yeah because so this is exactly what
you said here equal is going to take the
first element of the stack and the
second element of the stack so
that was duplicated from this so we have
like uh here our stuff that was computed
and add it to the stack and then the
stuff we just computed ourself perfect
thank
you uh yeah and then it's kind of simple
here like uh to set the value well we
just go to the macro here set value and
well this is exactly what we've been
doing earlier we know that uh we need to
avoid the first uh four bytes because
this is the function signature so we
don't really care about it so we just do
okay we want to load uh 32 bytes
starting after the four uh bytes and
then we are going to use a different up
code that we never used called s store
so you can see like previously we've
been using M store which is very well
explicit memory store and in this case
we want to store in the storage because
the user is setting a value so we want
to keep it for a long time so we are
going to call s store and s store Works
in a very similar way to M store it
takes like one um location and one value
and so what we are doing here in this
case I showed you this earlier when we
talked about constants we are just going
to use like uh within brackets we are
going to call Value location which was
defined by free storage pointer which
should be zero so this means that we
want to St store in the storage at this
location the value that is starting at
the cold data after the first four bytes
so kind of simple it's just weird that I
think the weirdest thing here that you
are just doing things in Reverse you
have to put element in the stack and
then you have to call a function that
will take all the elements uh in the
opposite direction so it's a bit weird
to think that way but you get used to it
and yeah like you mention like many
times like the the stack how it works uh
and so like a convention some people are
doing and actually I think there's a
tool for that uh some people here like
uh add comments and within the brackets
they just put what is in the stack so
they will say okay here we have a value
here so because we loaded this value and
then they say we have a pointer here so
the stack is like the pointer and the
value and they they say okay we are
calling uh storage uh store so it's
going to use two values so then the
stack is empty so it's like also a nice
way to be able to track what you're
actually
doing question yep so um on the stack if
what is the first argument is it the one
at the topmost and then the second
argument is the one below it yes so when
you're calling a function it will take
like the one at the top and it will go
like it will remove them one by one so
it will always take what is on top okay
so the topest one is the first argument
in the function signature and then the
second yeah in this case yeah would
first use like the function signature so
if you are doing like minus you will do
this uh minus
this uh um yeah so this function this
macr sorry is kind of simple and then
uh I
think I think there might be an issue
actually with the code yeah okay let's
let's see how it how it works I wrote
this uh the test was passing actually
but I think there might be an issue from
what you were saying earlier so let's
see
uh then uh the get value macro is kind
of similar to what we've been doing but
yeah we're just going to use like a new
up code called uh storage
load uh and it's it's very simple you
just say I want to load into uh
the uh the stack I want to load uh the
sorry I want to load into the stack the
value that is stored at this location so
we're just going to use the our value
location constant here we put it into
the bracket then we just say yeah I want
to load this value and the value will be
put into the
stack and
then same thing as before we put this
value at the position zero into the
memory and then we call return and we
say you can return 32 bytes starting at
the position Zero from from the memory
and they will return the value so kind
of straightforward yeah just a a
different kind of question here uh if I
if there's a smart contract that's on
the that's been deployed but the code
was not published can you um decompile
it into Huff uh I think there's a
decompiler yeah I'm not I'm not sure if
it's
really uh powerful but I think there's
one yeah there's one because I was just
thinking in terms of reverse engineering
the smart contract right you can use it
actually yeah that's pretty pretty
nice and more convenient that reading
the the bite code
directly um yes so I think that's it for
this contract it's kind of
straightforward we already saw like the
function
dispatching uh and like to store into
the storage or to load from the storage
it's very simple um yeah do you have any
questions so far
yeah are you put
stop I'm not sure yeah I think it's
needed I'm not sure if it's needed or
not
let's let's see you can check with the
other
Branch uh go to the Finish word c is the
same I'll let you check and I'll be back
after uh any extra
questions yes how does um Huff compare
to Yol
uh well I think
like well the main difference is that uh
as we were saying like earlier you have
more uh Power in the sense that even in
y you cannot manipulate the stack I
think uh there are a few things that you
cannot do uh in half you can like you
you can like duplicate elements in the
stack you can like swap them yeah you're
free to do whatever you want so you you
can do like more optimized things
um I would say that's about it but yeah
I guess it's also depends on the use
cases but yeah I'm not aware of many
contracts that were written in pure U
but uh yeah if you're using like U like
inline assembly in solidity then I mean
the the obvious reason would be just to
you to be optimizing very small uh
portions knits of of
code uh if you want
to yeah so this is the test for the
contract uh that we just wrote so still
very very simple straightforward we are
also using the half deployer and yeah I
add did some console log just for the
the sake of it
but basically
still quite straightforward
word I'll just give you a few minutes if
you want to write the the test and try
out
you you don't
need yeah
yeah are you running the oh but you are
running the test from counter then maybe
the other
test okay
okay yeah just let me know if the the
tests are passing or if you're having
any any
issues for
how is it
going all good
it's a oh you added more things nice
okay cool all
right yeah that that's uh I don't have
another contract after that so if you
want to we we can just be like a
talking if you have more questions or if
you want to I don't know add something
else into the code and you want me to
let you know how we could work feel free
to yep
what what's uh the issue
now
failing ass
fa what is doing increments
yeah oh okay you want to oh I see nice
Okay cool so yeah you're loading the
cold data then you are
loading uh it's good actually it should
be working it's
the yeah
yeah to be honest try try adding like a
return I think that might be the the
issue sure I'm not
sure here we're not adding it yeah I'm
just think we might need it
[Music]
uh yeah I could be paste the just uh
return nothing just to see this will
return something so just uh
so what you need for example if you put
like zero zero return it would just end
a transaction so you don't have to
return something you can just like uh
put this to return
transaction uh to yeah to stop the
transaction and if uh are you familiar
with
fundry read
okay oh it works perfect okay that was
it nice okay all good yeah if the tests
are failing you might want to add uh
here I think it would be better
especially if you change the code uh
here you can do like uh you can add
after that line uh return so like this
but instead of having like 20 here you
can just like put Z zero return so here
you can just like return nothing so this
will just let know that uh uh after
calling this macro then you just have to
end the transaction cuz otherwise what
could happen is that uh set value is
executed and then you go here to jump
label and then get value is executed
also so you have some weird scenarios so
I think it would be just better to do
like a add return here just return
nothing just Z zero
return this should fix things if if you
have this uh it's not working try to do
what I just said
yeah function just like
yeah yeah stop also works but I'm not
sure about the gas
costs yeah you can stop also but I'm not
sure about the G we should check because
sometimes stop is just like consuming
the rest of the the G or things like
that so what yeah you can yeah you can
just research and see like
a alt execution oh yeah yeah you can if
you click here you have more oops
details yeah successfully yeah you can
yeah it it works with you can also add
stop yeah that's another way to just uh
uh and the execution of the macro safely
yes
sure
uh yeah if you're like overloading you
mean I think you that's a good question
that's a good question I need to check
to be honest I have never done it in
half so I I don't know but uh that's uh
I I don't even know if it works
actually let me let me check but I
that's a good question
yeah I don't know I have I don't have
the answer now but
uh all right so we have like 10 minutes
left 12 exactly but uh yeah I think
maybe you had
enough uh as youone if you have more
questions feel free to ask them I will
be happy to answer them if you want to
cut like a few more minutes but
otherwise uh well just want to say thank
you guys for I lost the clicker
again uh thank you guys for attending
this Workshop I was pretty excited to
see many many people and I was happy to
see that you guys were staying until the
end and working and building the the
contracts and even adding more more
stuff so that's pretty pretty cool so
yeah that's it you can if you are
interested you can follow Huff on
Twitter uh there's the website there's
the Discord um we are working on half
two uh the new compiler is being the
compiler is being re re returned uh from
scratch actually uh we are going to be
working also on the euf support and many
other uh things so yeah feel free to
follow for for more good stuff