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

Loading player…

Ethereum Foundation 🛠 Scripting with Remix

ETHGlobalWed, Oct 9, 2024, 12:00 AM

A workshop on Scripting with Remix! Embark on a journey with ETHIndia, where innovation thrives, collaboration knows no bounds, and hierarchies fade into self-sovereign ownership. The most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long adventure to advance the Ethereum ecosystem at ETHIndia in December of 2023! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

[Music] hey hey hello everyone um this is anik from uh remix project etherum foundation and welcome to e India okay um so everybody who has worked on on this smart contract development ever has definitely came across this remix ID and mostly people use this remix ID for solidity related development and here we are going to talk about that how you can even use the scripts within within the remix ID itself so if you have a script which is like even a JS or typescript file you can run that in the remix itself so if you will create any uh workspace using uh the predefined workspace templates on the remix ID you will see some scripts out there already given so those scripts can be run within the remix ID how can you run them basically you can right click on a on a on that particular file that you want to run and there is the this option uh run you can just click on that and then that script will be running and if there are any logs those will be coming in the remix terminal there is another way to the script if you want to do it a bit a bit quick so you can just open it into the editor and on the left top there is this green play button which you can just quickly press and your script will be running moreover uh if you are a keyboard user like you doing things quick uh using the keyboard so you can use our keyboard shortcut for that that is control shift s okay so that is the thing that you you can use the you can run the script within the remix now we will see the use cases of it that how it can be helpful during the hackathons during the quick development process so what remix provides basically you can you can uh integrate one particular script with your smart contract how you can do that you can use this natp tag which is custom defined this NP tag is shown here uh custom uh Dev run script and and then you can give the path of your script moreover you can go to your solidity compiler plugin that that you have been using for a long time and then there is this new button which says compile and run a script so you can just click on that button or just can use the that particular keyboard shortcut that is control shift s and as soon as you will press that button so that script will be running for example I I I am just showing you one particular script what it is doing it is just uh having one particular console log and then I can go to my contract file solidity file and on the top of the file in the npec I can add it like this I can add the this particular tag add the custom Dev run script and then the file path moreover you can go to solidity compiler plugin and can run this solid this compile and run a script button and if there is a successful compilation of that particular contract only then it will be running that integrated script so logs from those scripts will be displaying in this in this remix terminal so you can see that that that uh the log that we defined in this file the compilation successful log it is visible in the terminal here another use case can be with the deployment so if you will create any workspace using uh remix workspace templates there are some predefined uh deployment files using different libraries you can use the ether library for that or web3j library for that so similarly you can integrate that particular deployment script with your contract so as soon as your contract is successfully compiled it will be just deploying that contract so that can be very helpful when you are just making changes in your contract and you just want to quickly deploy it so it will be just doing the compilation and deployment all together and you will be seeing your logs and address and other things in the remix terminal you can you can extend this script to interact with the methods also okay so if you guys are aware that uh we I mean the remix supports the unit test written using mocha and chai so these test can be can be put into a typescript or JavaScript file and then they can be run within the remix ID itself so if you will uh create a basic remix basic workspace you will get this uh storage. test.js file which is basically containing some some initial level uh unit test you can extend this file to put your logic there and then what you can do you can just integrate this test running with the contract also in the same manner so what you'll be doing you will be making the changes if your tests are like failing uh your unit tests are failing you can make the changes in the contract and then you can just click on this compile and run script or just click control shift s and it will be running those unit tests soon after your contact compilation and your result I mean the result of these unit tests will be displayed in this remix terminal it will be showing the sh summary also that how many tests are passed and how many tests are filled okay that was the unit test part uh coming to contract verification contract verification is very much integral part of solidity development if you are like going to deploy your application on on on Main then contract verification becomes essential so what you can do you can verify your contract on ether scan using the scripts on remix these Scripts are kind of pre-written so you can get them by clicking on this hamburger icon near to this workspaces label and you will see this option add ether scan scripts as soon as you will click on it it will just add some particular scripts in your current workspace what are these scripts about so there is one particular script which is containing the logic to verify the contract on ether scan so if you have ever verified the contract on eth scan so whenever we do it we just we just get one particular gu ID and using that gu ID we can track the status of it so there is this second script that is helping in getting that particular uh status of that particular gu ID what we can do we can prepare one third script as per our needs and we can just import those scripts as I have uh done in this in this file so you can import those ether scan scripts and then you can you can give the desired values and yeah your ether scan API key will be needed because we it internally will hit the ether scan apis so you can provide uh all the values required and then you can just run this script the result from this script will be coming on the remix terminal so you can see the result uh we have received the receipt and then we have used the GU ID from the receipt to where to check the status of that particular contract verification okay so you all have been aware that gkp or G knowledge proof have been in in Trend in these days so what remix um supports in the field of gkp recently we have okay so first a small knowledge about uh this zero knowledge proof so what we do in Z proof we basically we basically prove prove that this information is Right without revealing that particular information and this is creating lots of use cases so remix supports this circum framework so basically circum allows you to write your own arithmetic C uh circuits for this the Zer knowledge proofs there is this circuit programming language which you can use to write your own logic and then basically when you will compile it there is a definition compiler for this when you will compile you will get a generated solidity code also that you can use for uh for the solidity uh verification purpose so we have some predefined workspace templates for that you can just go to create workspace and on the bottom you will see these three uh new uh workspace templates for now I I'm just going to have uh show this hash Checker template when you will create this hash Checker template what is it is doing it is basically verifying the hash of four values without revealing those values so you will get this file that is having this extension do circum so we call it circuit in the in the terminology of uh this circum compiler and then there are some scripts to run the setup and then to run the verification of the zero knowledge proof to compile file these C circuits you will need this circum J uh gkp compiler you can activate it from the plugin manager or whenever you will create a new circom gkp uh template it will be activated automatically so you can just compile that contract and then there will be related artifacts in your workspace you can then run those scripts for the setting up uh for setting up this zero knowledge proof process it basically use this snar JS library and yeah the in if you will create this workspace it is it's read me file containing all the details so you can you can just uh go through that and it will be giving more information on that okay so if these days we did not talk about the AI so that will be difficult uh I think so what we have recently introduced in our release last week we have introduced this solidity co-pilot some of you can be aware of about its name so what you do when you just type some code in solidity it just shows you some code suggestion as soon as you type and it is an opin feature so you can just enable that from the setting section of remixd and we have released it into the alpha manner so we will need your feedback on that I can just show you that how you can activate it so you can just go to settings section and check this particular box load and activate co-pilot it will take some time just wait for it as of now uh do not close this uh particular dialogue it will take four or 5 minutes to download that particular AI model and then you will be just using it so if you are looking to just write an erc20 contract as soon as you will type like contract erc20 it will show you some of the suggestions and you can press tab to adopt those suggestions and then it will show you the further things so I have some screenshots here because uh it is difficult to like demo it on this low Wi-Fi so you can see it that as soon as you will type it will show you some suggestions as soon as you will press tab to adopt those changes it will show you the next thing another thing is that like if you are working on a owner contract and you want some custom function what you can do you can use triple slashes for that and you can just ask anything I mean ask any code you can just say write a function to change oner and you can just press enter and it will show you that particular code if you are okay with that you can just press Tab and that will be added in your code file and further you can ask for another method like read owner and it will be like coming further on this on your code file it can work slow a bit because it is is still in Alpha phas but it is there okay moreover what we can do I mean when we do the development nowadays I think uh beyond the stack Overflow we just go to ask thing to chat GPD so what you can do you can ask things to chart GPD uh directly from the remix ID if you are getting any comparation error in your contract you can just click on this ask GPD button and it will be getting the answer for you so if you will see these green boxes it is just also showing you that how you can fix your code and that is Al that is happening in within the remix ID itself so that can be quick when you are like doing uh things during the hackathon if you are looking to ask anything custom you can use remix terminal for that you just need to write GPT and your question there so for example if I say okay gbt where is this at India it will just show you the answer in that uh remix terminal itself and that is it thanks for being here and for more queries you can you can uh join this you can scan this QR code to join remix Discord and yeah we can talk there and we can have some queries here also

Automatic transcript — names and jargon may be misspelled.