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

Loading player…

Remix for Hackathons by Rob Stupay

Ethereum DenverMon, Oct 9, 2023, 12:00 AM

Remix is a "no setup" tool to get you started playing with smart contracts. Most people begin their blockchain journey using Remix. This talk will teach you all the latest Remix tricks to get you hacking in style! Rob Stupay Communications Manager Remix Ethereum Foundation Rob strives to find the poetry in Web3 projects, Web3 documentation, Ethereum, and Remix https://twitter.com/ryestew

Transcript

Welcome to Remix for Hackathons. I'm so glad you've all come today. So, as you can no, you can't see it. There's a remix logo there. But that's not what you're here for.

You're not here for our logos. Uh you're here to fake it till you make it. Learn the how, the where, and make it a family affair. depends and dependencies making sure it work when it don't want to work silly chains and lipstick in the pig. So let's begin first.

Has anyone here used remix before? Oh, so you don't need this slide. So if I'm talking about the icon panel, side panel, you know where it is. uh and the terminal and the settings panel, you know how to get them cuz I'm telling you now. And if you click the plug-in manager, you'll see the plug-in manager.

So, you can activate different plugins, but you can also activate plugins off the home tab, which is over uh wh there. But I'm going the wrong direction. Also, if you're right clicking in the file explorer, you get this context menu here with all kind of choices and uh fig to make it if you want to learn solidity go to learn it. So, click that icon or go find learnth in the file in the uh plug-in manager and you get all these tutorials. You can learn the solidity course is great.

Uh go check them out. Uh and this is a solidity beginner course. Uh, and there are little tests in there and uh everything's taken from solidity by example war or com I forget. Anyway, uh and you can see answers and then you can uh here's how to answer your questions and remix by uh at the top of every side panel you can click that carrot and it comes down to a link to the documentation. [Music] So the first thing to know about Remix is that it's not like a Google doc.

So if your browser really crashes hard, you're going to lose your work unless you backed it up somewhere. And if you back it up, you could put it in a git repo or you could uh save it to your hard drive by sharing a folder on your hard drive with remixd. Uh and so that's what the file explorer looks like normally. And uh and that's what a file explorer a workspace in the file explorer looks like when you have a git repo attached to it. And here's how you get remixed d running.

So you can share a folder on your hard drive with remix. You go to the uh file explorer and you click the workspace pull down and you get connect to local host and you get a modal that gives you a bunch of instructions about what to do to get this mpm package running on your computer. So you get remix running and the the command for the remix is very complicated. It's remixd d. So for collaborating uh it's good to use git.

It's easy to get git. Go to the hamburger menu in the file explorer and you get to get clone and then you get the a modal to show you what to do. Uh, and you can manage branches in the file explorer on a on a uh repo file a workspace that's got associated with it. Down in the bottom there, you click that thing and then the branches come up over here. Ah.

Oh. Uh, what did I do here? Oh, yeah. Okay, the branches came up there. And then here's the DGT operations.

Uh Git operations are managed through DG. So you got to activate the DG plugin to get DG going. And then you can um put in your GitHub settings. And uh then you can uh yeah, it's putting in your GitHub settings. And then you can push and pull to GitHub from Remix.

And then you can once you got a a repo going and you commit some changes, then you can get a diff going on what the changes are by clicking one of the files that's changed. You can see the diff. Uh but you don't need to run manage get off of Remix. You can just do it on your hard drive if you're connecting your hard drive via remixd. Uh you can make a gist to get help which is super easy.

go to the file explorer, rightclick, publish folder to gist if you do it on a folder or publish uh file to gist. But uh you got to have your your git uh credentials done in settings in the settings panel. And then uh just there uh then you got to justify your code when you're hacking. So you betterh comment your code and the best way to comment it is with natspec. Uh I hope you guys all know nospec uh and then when you get natspec going uh that gets compi that's gets stuck in the compilation result and that means that uh you can use the eth doc generator and viewer you got to activate both of them and when you compile a file uh I can't see anything there.

Oh, after you compile it, you get this stuff in ETHOC generator and then you can generate the um documentation and if you have uh uh Infura node for IPFS then you can publish your uh documentation to IPFS and you can draw UML diagrams. Oh, and look, the screen turned white, which means there different uh themes in Remix, which is easy to get to by clicking the settings panel at the way bottom of the settings panel. You can get to the theme settings, but here we're generating UML and you click GML and you click UML and oh, there it is and you can zoom around there. Uh, and you can clean up your code by uh we're not quite closed. That's mean.

Don't listen to that man behind the curtain. Format code. Linting. He's getting me off. He's [ __ ] with my trip over here.

Linting. Activate Saul llinter. Get your Oh, yeah. And if you close all the tabs in the file explorer, you get poof the little shortcuts, which is nice because it's good to know that controls is for compiling a contract. So you don't have to always go back to the solidity compiler.

And if your teammates are using truffle harder foundry, uh here's some techniques. uh you enable. So, first of all, if you're using uh somebody who's if you're sharing a hard hat folder, you got to connect to the folder via remixd. And then when you do that, you uh hit that button over there, which turns into the file, you click that enable hard hack compilation over there. And then when you compile it, a file named remix compiler config.

js gets created. And then the compilation actually happens in hard hat but it gets picked up by remix. So you can be working in hard hat and remix and and also uh if you're working in another tool like hard hat or or uh truffle or foundry you can remix can if you're sharing the folder with remixd remix can grab the compilation result and pull it into the deploy and run module. And that means you can work in these other programs and deploy it from remix or debug it in remix debugging. Uh I'll show you quick a little bit later.

Uh but here's a way of recording your transactions in Remix. In the deploy and run module, you'll see the transaction recorder and you click it down. You can save a bunch of transactions which puts it into a JSON file and then you can save these transactions and rerun them if it doesn't quite work right or you can pass this JSON file to a colleague and they can run the same transactions in their uh computer. So you can you know get share the state and share working out bugs that way. You can also draft quickly by uh making a script in Remix that runs uh ethers.

js or web3js and then you can run that script uh to set the state of the contract which is uh and then you can just click a button compile and run. So you compile it and then it'll run the script and set the state of the contract and then when it fails then you can figure out where it fails and you can go back fix that and then hit the button again and see where it goes and then when then you can take the next step and put the next step in the JS file to uh take the next step. 8 minutes and 42 seconds left. So you have to know about importing dependencies and just importing files that you want to just play with. So if you want to just import a file, uh go to the home tab and there's these uh just GitHub IPFS.

That's just for playing with files. But for dependencies, uh you know, just load a dependency like you normally would in any of these other tools and it grabs it from unpackaged.org and opens it up in the dependencies folder in the file explorer. But don't edit those files because they're dependencies. Uh so that's like a pulled it in a bunch of dependencies and then uh you'll see oh yeah and so there's autocomplete on imports it it autocompletes all of open zeppelin contracts all of unis swap and whatever else is in the local file system there and uh here's for adapting contracts which uh you hackers will need to do uh make a new workspace this is for making work takes place templates.

Uh here you when you click that pull down you get all these different kind of templates. There's a bunch of coins templates and there's a multi-IG and then there's the default space. But if you choose a open Zeppelin one uh you can get these further features of making it mintable, burnable and uh upgradeable especially with a UPS uh because there's more functionality in Remix for managing proxy contracts with a UPS pattern. Uh and then you can also initialize it forget too right in the uh this pulld down. Uh yeah what's that about?

I don't know. So uh that's the uh all those uh dependencies are pulled in and you can go or you can go to the open zeppelin wizard and check out all the you know put the burnable dependable not dependable but anyway uh and then it pulls it into remix when you click the that open and remix button in etherscan if you go to a uh what you call it a uh verified contract you can pull up the contract and ether Ether scan and then you just switch out etherscan.io for remix.ethereum.org and blammo it opens up in uh Remix in the editor or you can go to cookbook.

dev which is an incredible resource and uh you go here and there's a gazillion uh contracts there and they've have an edit in remix button which is super great and if you want to talk to them they're right here. Talk to them after. Uh, and here's a quick trip to the debugger. Uh, you got a uh in the terminal you just click the debug button after you have a run a transaction and it opens up the debugger panel. Uh, and then you can step through the code.

It'll show you the the op codes, the bite code and a whole lot of other features. uh they can put break points in uh and you can jump to the next breakpoint and stuff like that. There's console logs in Remix which is basically you just got to import the um that functionality. Uh that's there's an example of that in one uh storage I think in the default contracts. uh deploying to a chain you never heard of and links to L2 bridges.

So there's these this is the now the in the in the deploy and run in the environment section there's this huge long list now uh you can deploy to the local chains of course to use a local chain you got to get the chain running so get the chain running and click that and it'll work uh but you can also now there you can fork mainet and you can fork to a custom net and uh you can just put the block number that you want to fork to and it'll network. Also, you can connect to wallet connect, which is great for testing your DAPs because that's how your users will be using your DAP uh to choose uh what am I talking about here? Oh, yeah. Uh L2s. So, uh you don't know what chain you want to go to or they gave you the chain we're going to deploy to the swarm the swarm digest chain and you don't know what the specs are to put that into MetaMask.

So, You just click the this button. It'll go to chainless.org and then it'll set up MetaMask to wait to do what you want. Uh if you don't have any optimism ETH or uh or arbitron ETH and you go to the L2 optimisms and click that one, it'll go to the bridges for those two chains. Uh it's the same thing.

I'm going the wrong way. Oops. So now you want to get to the ABI, click the AI button in the consolidity compiler. It'll bring up a modal. No, it'll just copy it.

Comp uh to get the to get the compilation details. It'll bring up a modal and get you all kind of interesting things. Now you want to chose the judges. Good stuff. So, uh you can all you can just use the interface in the deploy and run and just show them this and then they can interact with your contract.

Not only can show judges that, you can show clients that or you can use a one-click DAP. So, you got to load the one-click DAC plugin and it makes a very basic uh front end. So you activate that and then you uh put in your deployed contract because first you got to deploy your contract and then you just stick the address. Of course to find your address of your deployed contract it's on the deployed instance in the deploy and run there's a button to copy. So, shouldn't be that hard to find it.

And then you copy it there. And then this will open up uh you click that link that gets generated and then it comes to uh it opens up oneclick app and then you can see your functions here and then it's less noisy and the judges might be able to follow your train of thought as you're convincing them how brilliant your hack is. And that's it. And if you want to join our Discord server, take a picture. Any questions?

What? Um, great talk. Yes. Thanks. I guess that's it.

Thank you everyone.

Automatic transcript — names and jargon may be misspelled.