New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

📣 FEVM Summit — Programming On The FEVM - Zak Ayesh

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Zak Ayesh of Protocol Labs for a talk titled "Programming On The FEVM". What use is computing without storage? For too long, blockchains have been defined by a frustrating tradeoff—should my decentralized network focus on compute, or on storage? We've seen incredible innovation on both sides—Ethereum the world's largest computer—and IPFS & Filecoin, the world's largest decentralized storage networks. While we've seen thousands of groundbreaking DApps developed harnessing the power of these technologies, under the hood, they require complex scaffolding, disjointed layers, or complicated developer patterns. Sometimes even, decentralized storage is disregarded, opting instead to return to the "easier" centralized methods. A small team of builders at Protocol Labs set out to change that, and with the Filecoin Virtual Machine (FVM), have turned the Filecoin blockchain into a programmable platform that developers can deploy programs to, finally uniting compute and data on a single network. But they did not stop there... The FEVM creates a runtime within the FVM which simulates the Ethereum Virtual Machine, making all smart contracts which compile to EVM bytecode, such as Solidity contracts, executable on the Filecoin blockchain. With completely decentralized compute and storage united once more—we're more excited than ever for this new frontier—and for what you'll build. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Applause] [Music] awesome okay great so we're gonna go right in to our next conversation which is going to be an actual Workshop so um this is going to be the longest Talk of the day it's going to be kind of a full end-to-end Workshop of how to program on the fevm um so we're really excited to have Zach here um from the fbm team to kind of walk through this workshop with us uh so yeah I'll turn it over to Zach to share his screen and and jump in from here but yeah really nice to have you here and uh thank you for being here awesome thanks Jacob excited to be here and hey everyone um excited to see what everyone Builds on the fvm and the F evm specifically and that is what my Talk's going to be on so let me go ahead and share my screen all right so yep today I'm going to be going over a demo on programming on the fevm and if you're familiar at all with the evm um programming on the f evm is almost exactly the same so this is a note I've been including at the beginning of my presentations um and I see a lot going around but when you're programming in the web 3 space there's a lot of terminology and a lot of new projects and a lot of new technology and information can get really overwhelming and it can really feel like you don't know a lot or you don't know what you're doing this jargon here was some notes I was taking just a couple of weeks ago in Lisbon so I went there for a bunch of protocol labs and file coin you know conferences and uh this was me trying to understand the like addressing schemes and uh file coin from my co-workers right so I'm over here I'm learning this all with y'all um so you know don't feel lost um don't feel bad to ask questions uh We're All in This Together all right so I'm gonna try to focus this on um just a straight demo uh we'll do a little bit of work in remix um a little bit of work and hard hat and I'll point out some resources you can go to and um if you didn't know uh the first metamask transaction was actually tested just about a month ago um right before uh Phil Lisbon uh so the engineering team has been working at a Breakneck Pace to get all of the evm features that you're used to working with in um the ethereum world and um yeah so we just had the first minute match transaction and um just got some events uh added in keep on the lookout for more features being added in all right so we're gonna go through remix um if you're not familiar remix is a online IDE for developing uh evm smart contracts specifically in uh solidity um and yeah this is kind of a great first place to test test out like any ideas you have just to get used to evm development if you're not used to it um so let's go ahead and um first thing you're going to want to have do is add in a metamask extension to your browser right so I already have it downloaded but you can go to you know type in metamask click on here and follow the instructions to download metamask um the the walkthrough here is pretty clear and once you have metamask installed um I know they were kind of talking about this in the last talk but just to walk you through it you can go to chainlist.org which I already have up right here and we're going to be doing everything on testnet uh mainnet is not yet ready so we're going to go ahead and click here test Nets we're going to type in wallaby so that's the name of the file coin test net and you can click connect wallet and it will add in the information straight into metamask I already have it added in since I've been working with it but just so you can see what that flow is like okay so once we've got um you know uh we've got wallaby added into our metamask you're going to want to get some tea fill in there right so I already have uh some t-fill but again to show you how that's done step by step the first thing you're going to want to do is get your T4 address right so in ethereum world all addressing is done with 0x you know and then yada yada your hex but in file coin the dressing scheme is different and you know every runtime that eventually is added on to the fvm could have its own addressing scheme right so this is why the F4 addressing scheme was created right so if you go to explore.gift glyph.io slash ethereum you'll have this handy little screen here um that kind of automatically connects to your metamask and converts your um ethereum address to the equivalent F4 address which is just kind of an abstracted away address where we can add any other addressing scheme too right and if we switch it to wallaby net you'll see the only difference is it's a T4 right for testnet address so this T4 address corresponds to this ethereum address that will basically be only important for the next step because now we are going to get pestnut funds so if I copy the T4 address I got here we go to wallaby.network paste it in got to go through the captcha these captures are always really interesting you can get some funny ones today we got cupcakes of course they try to trick Us by putting regular cakes in so I think I can select all that yep and just select send and that should send 5000 t-fill straight to your uh metamask wallet again this is test net currency so unfortunately not real real fill we're not just printing real money here but that would be awesome okay so now we've got uh metamask we've got the network added on metamask and we've got funds to pay for transaction fees in our wallet uh we will go ahead and go to remix all right so um here's kind of a layout on remix um the main things that you will need here are the file um the file uh sub tab here if you go down um you'll see a compiler a deploy Tab and a debugger so we're going to start over here in the file explorer and we're just going to go ahead and click on the storage contract so remix has a bunch of built-in simple contracts just used as an example you'll see a storage outsole is a simple read write contract um you know it has a single variable number a function store which will set that variable to a value and retrieve we'll get its latest value so if we go into the compiler tab hit compile we need to make sure everything is good it's compiling storage.

soul it says all right it's fine and now we need to deploy our compiled code to the filecoin wallaby testnet so one of the most important things you need to do here is Click injected provider metamask this will tell um remix hey I want to communicate with metamask metamask is going to be the Gateway I send transactions through and um you know otherwise if you stay on remix VM that's just like a local copy of the blockchain of uh like an ethereum blockchain in remix right so I select an injected provider and if we look at that account it indeed matches the account in my metamask wallet all right so we'll select storage make sure that's selected hit deploy right now metamask is going to come up with a transaction saying hey this is going to cost gasps bees any transaction that you write to the wallaby test net just like a regular Network calls transaction fees right so this is why we filled up our wallet with tfill earlier so I'm going to go ahead and click confirm and this will probably take a minute so it takes 30 seconds for the wallaby test net to include the transaction and then there's this whole design pattern that the team implemented called delayed delayed execution so it'll then get executed and 30 seconds later uh give us a transaction receipt so it actually takes a whole minute to get this transaction in um so while we're waiting for this to go through and we'll we'll come back and interact with it I'll go ahead and move on and talk a little bit about the mock file coin apis right um so you know we we have the zondax team present earlier about these but these are extremely useful tool uh going forward um these will kind of enable you to test uh what it would be like to develop with all these file coin native features that you don't have on other blockchains right these apis are still being worked on to like fully open um that's what we're mocking them for now um so this will kind of give you the tools to really uh really build interesting new applications like data dials our storage lending markets because you'll have the storage deals which are already native to follow coin uh available to you in solidity so yep still taking its time and uh well we'll go after this after uh remix is done deploying is we'll talk about the harder hat starter kit right so remix again is great for um great for kind of just getting your feet wet and testing out smart contract development but not uh the best for when you want to get into a professional workflow and actually develop um smart contracts that you want users to use and you want to make sure are secure right so hard hat is a kind of a local development environment you can install on your computer and use it to automate all your deployments and tests it doesn't have the GUI but gives you a lot more power okay so remix is still taking its time they may just have to move on if the transaction is getting stuck we can try reloading it and give it another shot sometimes remix kind of airs out so go to storage we'll compile it switch to injected provider metamask and deploy confirm and hopefully this transaction goes through if not we may need to speed it up all right but for now uh we'll go ahead and move on to hard hat right so you can find the hard hat and the file the hard hat starter kit and the uh file coin uh GitHub right here so we'll go ahead and click on this so filecoin Dash project slash fevm starter kit and okay so here you'll have like kind of a base project set up uh with a bunch of instructions in the reading me on how to get it started we're going to go ahead and follow these instructions and get going with the hard hat starter kit all right so um here I have a terminal open I'm running Mac Mac OS see I'll try to get this text bigger so everyone can see it's got a test folder here and I'm going to type in the command git clone and we can come here to code copy the URL paste it in right so that that clones are uh repo into the test folder I will CD into it tab to auto complete and we'll go ahead and open this in vs code right so I have the vs code shortcut installed code Dot and we've opened up that folder in vs code of course you can just go into your you know file folders and open it that way but I prefer to do as much from the terminal as possible and um yeah yeah well so you'll kind of see the structure of a hard hat project we have uh contracts where you'll put the smart contracts you want to actually deploy onto the blockchain you have the deploy uh script right here which will you can kind of go in and customize and tell it what contracts you want to Target to deploy to the blockchain and how you want to deploy them and tasks where you know you get a lot of uh where hard hat really shines is where you can write these customizable scripts to do just about anything you want interact with smart contracts you know write data read data um you know test some things um you know tasks uh is a very powerful uh kind of feature of hard hat right so we'll open a terminal Within hard hat here and we're just going to type in yarn in the terminal right so this will install all of our download and install all of our packages right and again all of these instructions are in the readme and you know on the GitHub so while this is going let me just double check on that remix see if it's gone through nope someone's holding up my transactions they may not have enough gas fee so I'll try speeding them up right here bump them up and see if that goes okay so back to the starter kit right um so our yarn install has completed um and from here what you're going to want to do is again in order to interact with the blockchain you need a wallet like metamask you need a private key that's stored in that wallet right and this is very important that uh you never share this private key right so uh the private key basically is your wallet it gives you the right to make transactions for that account um and so what we're going to do is we're going to make a file here we don't want it there we want it in the main repo I'm just going to type dot EMV right and we're going to type in private key all caps equals and uh quotes here and we'll go back to our meta mask really doesn't want to deploy um we'll go back to our metamask we'll go to Account Details export private key and you're going to have to type in your metamask password and again I'll never show this to anyone I'm kind of live streaming this because it's on testnet and I never use this for anything else other than test net development this is kind of a dummy account for me but we'll copy the private key and we'll throw it in here and safe right so now Hard Hat Knows okay this is the account I'm going to assign all of my transactions with all right so hey Zach hey how's it going good uh do you want to just zoom in a little bit on the font size for some of these these two windows here just so that people can see on the stream a little bit better oh sure yeah you can do command plus yeah exactly perfect yeah I've got an I've got an ultra wide over here so it's easy for me to forget on streams appreciate that no problem okay yeah so hopefully everyone can see that a bit better um yeah so we've saved our private key on um in our in our project so now the now Hard Hat Knows uh what wallet we're going to use to transact with the blockchain um and we can actually run our first hard hat task so if I type in yarn art hat get address I believe this address is not just address yep get address enter but typed in git addresses yarn hard to get address not addresses right um it'll kind of do what that glyph tool was doing in the background in the browser only this time it'll do it in a hard hat so it'll calculate the F4 address which we used with the faucet right here and our actual ethereum address for the most part um you're going to be using this you know as you act interact with fevm everything works just like the evm so other than sending test net fill you can use this ethereum address here for the kind of the remainder of the tutorial right and if you want to check out the logic for that task we can open the task folder click get address and you'll see here you know the logic we're doing when we're actually running this command all right so let's like use this and actually deploy a smart contract interact with it so if we click here on uh simplecoin.soul we have a very simple contract right a very simple contract um simple coin and this is kind of like a very basic form of like an erc20 contract right an erc20 token um you know just for demonstration purposes so I wouldn't actually make a token this way but um you know it has a mapping which a maps maps any addresses to balance a Constructor which sets our initial balance to 10 000 so there'll only ever be ten thousand of uh simple coin in existence and uh two functions or three functions send corn give balance and Eve and get balance um we're really going to be using get balance and uh you know send coin so let's go ahead and deploy this contract if you yarn hard hat deploy now there is a bug in a hard hat kit at the moment um with the deploy script that is being worked on as we speak but um it sends the deploy transaction the contract does get deployed but then it returns an error so you actually have to run it um run it it'll error out you know it's going to compile it successfully and see it's going to say deploying simple coin um this will return an error and then you just run it again and click resume transaction and it will uh it'll actually return the receipt of the deployment um but to save us some time I actually have another vs code open right here so after you actually deploy all the contracts um you'll get this deployments tab right here right this shows that you have successful deployments right so if I click on simplecoin.json this shows me the address at which it's deployed and um a bunch of the metadata all the Json API data we need for that contract it also deployed so there's a folder here with the mock apis so I copied over the mock API from Zandex and put in the put them in here so anyone can kind of interact with them and um you know start building with them immediately uh the main two ones are the minor API and Market API these again mock all of the internal file coin Logic for getting any kind of Market data any kind of storage deal data and data on specific storage providers who are the miners right but we're going to be messing with a simple coin in this demo right so um we have a simple coin deployment at an address right right here in the Json right and we're going to interact with it so again remember when we deployed this simple coin contract The Constructor assigned 10 000 simple coin um to my address right so I should have ten thousand there if we go to task you'll see there is a simple coin folder and we have a get balance task right so this is basically going to go in and it's going to read our um read our smart contract and call that method get balance and you know show us a balance for a given address that we push in we just need to give it two parameters contract and account contract the contract we're interacting with where it's located it's addressed and the address of the account we want to balance for we'll just type it in from scratch so if we do yarn hat and then you're gonna do Double Dash for the first parameter and we'll type in contract and we'll go to our deployments uh again we'll go to simplecoin.json and we'll copy this uh in and actually I forget to put I need to put quotes around here all right and then we'll do account and again that's the account of uh which I have it right here um but the account of the wallet we deployed the con uh the contract with that's our wallet since it's the one with ten thousand you know again almost forgot my quotes and quote enter darn hard hat get balance oh I didn't actually type in get balance okay so yeah yarn hard hat get balance contract you know put your contract in account put your account in and quotes enter so I was saying re reading simple coin owned by our account on network wallaby and we have ten thousand right and um the task is in here right now but you can make a a simple task for sending the sending the simple coin as well all right so that's just kind of like a basic overview of the the hard hat you know starter kit and what you can do in hard hat you can write tests and put those in there and have a whole test directory um you know all this has kind of be developed on the fly so if feel free to open up any issues on the actual GitHub um and we'll try we'll be uh kind of looking over them and being in the Discord helping people out with any issues they may that may occur and again trying to fix that deployment issue we're getting at the moment um but yeah you know very very powerful tool um if you're going to actually kind of get serious and want to speed up your development I would highly suggest learning this um especially since it has the mock apis built in if you want to take advantage of those you can kind of go through them and use them again to mock those solidity calls we also have the forums I'm sure they've been called out earlier but there you'll find some tutorials some high level sketches of things like how to make uh basic designs for data dials and lending markets please go ask questions there we'll try to be monitoring them and answering questions over the weekend if you have any and yeah thank you um you know the fevm is a kind of an exciting development in the fvm life cycle as it allows the fem to take advantage of all this evm tooling that already exists and that you may or may not be familiar with um and um yeah it just allows a new paradigm of applications to be built with these file coin native uh Primitives that are the storage deals right this off-chain storage that's such an important component in web free applications if we really want a decentralized web um and with that that's that's what I got for the for the demo um I hope you enjoyed it and I'll I'll see you around in the in the forums and in the Discord um trying to help out answer any questions so thanks again amazing thank you Zach uh we do still have a little bit more time in case there's anything else we wanted to kind of Deep dive a little bit deeper into I also just asked the chat to see if they have any questions on their end um as they were going through this although it looks like um sort of most people got their questions answered as you went through the demos um yeah I mean if there's nothing else you want to dive into it I think the default fun question to ask is just you know what would you like to see built this week and or this weekend and you know what are you most excited about um seeing as an outcome from this this upcoming weekend yeah you know I think a couple of the the speakers have kind of mentioned it before me but um you know anything kind of using those mock apis I think would be awesome because those are the unique features that are on filecoin um when the evm was created it wasn't kind of created as a thought of hey we want this to have all the same like applications as the evm or compete with the evm we want unique applications that can uh be built to take advantage of these storage deals right um all these off-chain storage miners they have this native primitive storage deals that has all the metadata of those deals and make cool applications like data dials or lending markets right um you know I think data dials are extremely interesting um you know there's a lot of problems in the world where people just need data right like a lot of scientific um researchers need large sets of data to run their models on and you know if people can kind of come together and create Primitives to allow people to crowdsource and crowdfund this data in a decentralized way I think that'd be that would be really awesome right and the lending markets as well like lending markets like hey you know for the first time instead of just having um kind of like an Ave an over collateralized lending platform instead you can have a miner who comes in and posts their future earnings as uh kind of collateral right so it will require some underwriting on the behalf of the the lender to like say hey do I trust this Miner to make my money back but you know if there's this Earnest Miner who wants to come in and provide storage to the network but they don't have the fill up front to stake you know someone can lend them that fill it can be stake trustlessly and uh you know all future Revenue up to a point can be given to the to the person to help you know jump start that that miners uh career basically amazing okay well very cool um thank you Zach and thanks for watching datados is a very natural segue into uh the next part of the the summit anyway um so yeah of course anybody who has any questions I I think Zach you're probably going to be around all weekend I'm guessing um probably Google build um so thank you for that um and uh and and yeah looking forward to seeing what everybody builds and thanks again for for helping us out with this SEC yep yep no problem thank you

Automatic transcript — names and jargon may be misspelled.