Ethereum Foundation 🛠Getting Started with Fe
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join us for a Fe workshop presented by the Ethereum Foundation! From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] my name is Grant um I work on a project called fee it's a language it's a rust like language the compilers in R and targets evm um I work at the ethereum foundation and there's three others on the team so um yeah basically in this short amount of time I want to introduce you to the language and uh help you find useful resources if you want to take a picture this is I've written this up just and the minutes before um this is like all the stuff that I'll be covering so um if you want to if you want to learn about our language uh you can go to f.org there you'll find this these top right tabs you'll find a link to our Discord and under learn you'll find our documentation so a lot of the stuff I'll be covering is here also you can find the the uh binary for the latest version on the front page so um to get started you can just download that but yeah I highly recommend taking a picture of this if you're interested in working on fee we're offering 5K in prizes those are bounties for you to Simply Implement something in fee um considering the features that we support um you know you you might find yourself an advantage using our language and you could uh you know maybe cash out pretty good here yeah so um I will just demonstrate the compiler real quick so typically you'd go through here you download it um and then you put it on your system path or whatever um but for the sake of this I'll just have the D the binary in my uh in the directory that I'm working in and will do that okay so this is what it looks like when you execute the binary um you get the types the types of commands that you would expect to find in a b in a compiler CLI um build that's for building your project um building the contract artifacts check that's for performing analysis so if you're just interested in the type checking results um you know new for creating a new project test for testing your project we provide a built-in test Runner um built on top of our evm that's the same test Runner that Foundry uses but we just we just distribute it with the CLI um and then we recently added this verification stuff for onchain verification um if if you want to create a project with some boiler plate code in there you can just run the CLI um new come with a name you don't need those do my project okay so now I've got a new project quickly go over the directory structure here so if you're familiar with rust um you'll know that there is a toml file in the root of your project directory that is the Manifest of your project so that describes what the project is so it gives a name a version and also dependencies so we support file system dependencies um you know at some point we'll add like a package manager and stuff but um if you want to add some sort of library or something um you can add that under your Depend dependencies and it'll just compile right in the project it's a pretty Advanced system you know we support circular dependencies um basically we're using the um the basis of the rust analyzer which isn't even being used in the rust C compiler uh so yeah that'll all work pretty well um we support um structs enims with pattern matching we support generics so yeah let me just get into it um so now we have this project um let's take a look at the source directory now what you'll see here is we're importing a module utils here um this utils provides oh you can't see this at all I'm sorry okay well that's good enough um yeah you guys couldn't even see the C stuff either that's too bad okay what time is it I've still got time yeah so um here's just a simple utils module you know you can imagine you're working on a project you don't want to stuff everything in one file um it seems like the standard for a lot of development in this ecosystem is you just copy and paste things into a file that's not really acceptable here um so yeah say you want to put something in utils you can you can write your util utility functions um you could create your utility stres enims traits whatever you want and um Define them as public so if you want something to be exported from a module um you need to Define it as public you can also write tests inside of a module and uh execute those with the test sub command um in the main file in this project we've uh just generated this this main contract which just exposes a g 42 function so contracts and fee are pretty similar to uh solidity contracts the this is not like a design that we're committing to longterm but um people are just used to this um contract design so we've just implemented it in a very similar way to solidity at some point we would like to provide Alternatives but you know right now we're just sticking with this because it's easy and there's really not a whole lot of downsides to it so yeah uh public functions uh conform to the same encoding decoding that uh you'll find in solidity contracts um and yeah so basically what we have here is we have this uh public function being exposed on the contract which can be called and we're just using this git 42 UIL function um in the UIL file it's called G 42 but we support you know renaming things which is kind of nice um yeah so now we'll just uh go ahead and do some testing okay so as you can see um both of these tests are passing so in this test main what we're doing is we're creating a contract now we're using we're using this context type to create the contract um and that's defined in the standard Library we're not importing it because it's included in the Prelude but if you wanted to see exactly how context works you can go to our repository you can look in the crates um Library folder and you'll find the standard Library definitions um yeah also you can see we have uh explicit mutability semantics which is very nice um it can really help you with uh writing code that behaves in a predictable way we have some compiler magic taken place right here um context is also treated like a special object in certain cases basically we have this um we have this create function which is defined on uh on contract types and you can call it you just have to you have to P pass in a mutable instance of context um yeah in order for us to have a like full language implementation of uh contract creation uh we're going to need a more advanced type system so this is just one of those cases where in order to provide a palatable user experience we need to build something into the compiler but in this test what we're doing is we are creating an instance um we're deploying an instance of this main contract and then we're calling it uh yeah so now let me just show you what happens if we break something there are some downsides to the test Runner basically um when something reverts we just spit out the Reverb message so that's going to be um the same encoding format of the ER message that slity uses but we just haven't gotten around to decoding of things if you wanted to say like debug your program you can create an event and I won't get too much into the specifics here but everything that I'm doing here is explaining the documentation and I'll also uh just introduce maybe a few errors to uh demonstrate what here I'll just make this the wrong type and then we'll see what the N I put that in the wrong one sorry I meant to do that in the main. Fe test so let me just move this over real quick okay now we should get a comp compiler message here um can you guys still see that it looks like it's fine um yeah so we have uh you something that's really important in general when you're designing languages to provide error message eror messages that can be easily understood um and that's a high priority of ours um yeah so pretty straightforward explanation as to what we're supposed to do here bull is used here as a value but it expects a u 256 oh Sor sorry kind of on autopilot here yeah it expected bu it expected um Ty 56 but I got a bull yeah um okay so we'll fix that error and then we'll look at the uh we'll run it so it's saying the test has failed again let me just uh quick fix that so we can get that noise out of there this is something in the LA last hackathon that people um this is something in the hackathon that we were at last uh people asked for basically just uh uh being able to debug test and something that we added I didn't save this unfortunately um there we go so we're not seeing that event yet in order to do that we need to pass in the uh logs flag so we'll decode the the logs for you here so if you end up using fee in your project um this is just a helpful thing that you might want to look into um yeah let's see nine minutes left so yeah so we're getting this nice syntax highlighting in vs code um this makes it a lot easier to uh see what you're doing if you want this as well um you're going to need to get the uh the fee vs code extension um and what we we have a few vs code extensions out there because we've had a few like a few different developers create them um but as of right now there's only one that's that's uh like you know working and that's the one that's created by Fang developers and is on version 002 so yeah if you want to get this um you can just download the extension but make sure you get the right one again that's felay developers all right let's see if there's anything else I wanted to go over yeah so um let me just reiterate again we have three prizes there it's all uh split um between 5K so yeah we're just asking that you use fee in your project or you could you know just just Target fee and um yeah maybe since since we support libraries you could write something like a cryptography Library you could maybe Implement like a memory M map type things that are generally useful these are the kinds of things that we would really like to see as hackathon submissions um but you know if you just feel like using fee um for like an application you know that's that's definitely something that we'll consider too uh yeah and if you uh is anyone here familiar with the MD book documentation format yeah so it's really nice this is uh you know something that rust has popularized say you want to look into deploying a fee project with Foundry you can just go to our documentation search Foundry you'll find a quick start guide um you can ALS you can also write tests you know in Foundry um on contracts you know so you can reuse a lot of that tooling here the test Runner that we support that's that's built into the compiler that's you know that doesn't really have anything to do with this this is just a separate thing um but since so many people are familiar with with foundary we've we've made sure to integrate with their existing tooling uh yeah and then uh if you find yourself really deep in the weeds and the documentation is not helping you with your project you can go to our repository if it loads um and uh go to this crates directory here you can find the standard Library implementation you can also find a whole Suite of tests you know mostly testing the standard Library so you can find like uh use of pre compiles in fee obviously pre- compiles and you can't see any of this I keep forgetting let me Zoom it let me zoom in yeah so say you want to uh see how you'll work with any of the pre-compiled um you can just go into our test direct crates test directory and you can find usages of all the promiles um you know here's here's the use of EC recover um we have labeled parameters so yeah anytime anytime you want to call a function um if it requires that you label parameters and you have to do that it ends up making the code look a lot more readable especially when you're dealing with like a function like send a value or something where you just have all these random parameters I for one can never remember which what order they're in what anything means um so like you know just uh just having the compiler check to make sure that you're passing in the uh the parameter that you expect is really nice well uh yeah does anyone have any questions can yes so you know we we conform to the solidity ABI there are um distinctions between the solidity type system and the the Fe type system ultimately we would like to have a library that um provides full support for interacting with solidity contracts but as of right now you'll find limitations when it comes to like dynamically sized things um I know there are there are workarounds um you can figure out solutions to things but generally like you know statically sized things work work totally fine and then yeah there can be some issues with dynamically sized things in fee you can um Define a call function um which you can find if you were to search are like the um like the dundore like syntax in uh python where it's like underscore underscore like that um that's that's the Syntax for both Constructor and this call function because they're kind of like these special case functions which you can Define on contract so right like the underscore init function um allows you to Define the initial initialization of the contract and then the call function allows you to define the call Handler for the function so say you just want to totally bypass the uh solidity the contract AI that solidity uses you can just write a call function you can define a call data reader and then you can just decode against that call data reader however you want so you know if you were to write a function that is you know if you absolutely needed to write something that uh handled dynamically sized data you can do it that way are they what uh yeah so we're working on one um but it's dependent on a refact sorry we're working on one but it's dependent on a refactor of the front end but yeah we do have someone that is dedicating half time to it and it's very good progress so we hope to roll that out in the next three months to six months only syntax highlighting that's correct yeah he's asking about um uh language server protocol um we're working on one um currently the vs code plugin just supports syntax highlighting uh slightly higher I'd say yeah um but again yeah he's asking where does the gas consumption set slightly higher um but so in our standard Library we provide an evm module um which provides direct access to all of the op codes that are provided in UL so if you want to write something that's pretty close to assembly you can just do that the higher level abstractions since we're kind of a younger language haven't been fully smoothed out so there might be some inefficiency there yeah so one more question if anyone has one how can inter oh um well yeah I mean I would recommend okay so he's asking how can you interact with the fee contract yeah so we we generate a Json ABI right um and again we've we've kind of like hooked into some existing solidity Foundry tooling so I would recommend using Foundry for something like that um and you just you know you won't have any issues because we conform to the same contract model as solidity all right thank you very much
Automatic transcript — names and jargon may be misspelled.