Smart Contract Development with dapp.tools – Manuel Polzhofer
Ethereum Denver·Fri, Oct 9, 2020, 12:00 AM
This talk is from ETHDenver, the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Manuel Polzhofer of dapp.tools Abstract: At Centrifuge, we develop, test and deploy our smart contracts with Dapp tools https://dapp.tools/ a command-line friendly development tool-kit by DappHub. Dapp tools are inspired by the Unix philosophy and are awesome for deploying and querying Ethereum transactions. This is an overview of the tool-kit including (dapp and seth) and share our experience of developing our Tinlake smart contracts with dapp.tools. This talk was recorded Saturday, February 15, 2020. ETHDenver 2020’s content themes included DeFi; DAOs and Token Engineering (TE); Gaming and Usability; Protocols and Interoperability; and Public Good and Social Impact. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2020 event was February 14-16 in Denver, Colorado and hosted 2000+ blockchain enthusiasts, developers and community members from 50 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/jteMn5c 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/
Transcript
hi everybody I'm Manuel I'm I'm working at centrifuge from here from Berlin and today I want to talk about smart contract development with depth tools so because we were using depth tools I think for the last eight months for all our smart contract development and I won't basically give a general introduction to depth tools and yeah our experience using a framework framework for smart contract development which is not so widely known so maybe the good a good first question is what's actually out there maybe you have an amazing that year you want to develop some smart contracts and there are actually a lot of tools you can use in our days for example some people might know there is remix which is like this browser tool you can easily create smart contracts from a web browser I think the most the number of the most well-known tool is truffle and I also a bunch of other tools like open Zeppelin is really cool for also if you want to have proxy contracts and today I want to talk about tap tools and yeah if you're curious I also found a cool link from consensus where there's just basically listing out all the available tools for smart contract development but it's also not about development but also about querying the blockchain trading transactions yeah so what is what what is actually Deadpool's and why actually we are really liking it it's a comment line friendly tools for smart contract developments and what I really like so you don't need to use all of your tools maybe you only want to use the debugger you only or maybe you only want to use safe which is sort of they're a command-line interface for creating transactions and it was actually developed by Deb hop and there are some projects which are currently using it I think the most famous one is maybe maker with multi collateral die but also chai was for example implemented which is like this IRC 20 tokens for tie saving rates and actually we're using at a centrifuge for our teen leg smart contract developments Janna put here like the link on github and actually what I really like DEP tools are inspired by the UNIX philosophy maybe some of you already know and it's like it's like back from 70s for Iraq actually really cool rules for writing programs like write programs that only do one thing and do it well or write programs that would actually work together make it easy to write the test and to run programs and that's like I think a really cool philosophy because then you can sort of just use certain parts of this framework for example if you only want to key back or you only want to use certain things yeah and it's also really cool you maybe can check it out there's a bunch of videos on on YouTube about the UNIX philosophy but you're talking in the 70s already about how I can actually pipeline all these nice command-line tools together yeah it's what actually depth tools so it's a bunch of tools or I already mentioned it and it's like that which is basically the tool for for building testing the packing and deploying so it is much contract and tender is like safe which is sort of for querying transaction from the comment line and you can also I was a really cool thing is you can also use it together with a lecture so it's sort of like you can make a transaction with your lecture from command line which is really cool and they actually implemented their own implementation of the EVM in Haskell and this is this used for example for unit tests and also it's used for the in the debugger and actually like they implemented all the new EBM up code so it's a fully general state compliant and there's no problem if you using it for testing all of your smart contracts yes maybe a quick background why we actually got choosing dev tools for developing our smart contracts it's a quick background on centrifuge so we started out developing a peer-to-peer network which basically allows to exchange document and a peer-to-peer network which was implemented in golang and was to use was using the p2p and and we just had some smart contracts or sort of anchoring document routes on a cerium it we also supported a way where you can base tokenize documents and yet we were dealing with some and if t registries but basically like two years ago we only had like two three four contracts and we'll just start using truffle but then we sort of up and every sort of ending up developing more smart contracts and we were just like analyzing okay what's what's available what tools are out there for developing smart contracts and we were already aware of self which is this nice comment command-line interface frank in directing with this you're in blockchain and like back in June last year we're developing all our smart contracts with dev tools and current just to give you a rough overview currently we have like three it's between three or four devs working on our contracts and our contract basis like me around twenty modular contracts and we also manage different deployments yeah so that's sort of the background on us so how do we actually get started if you're interested in playing around with tap tools so you can just just curl and it's it's using mixing a background which is a functional package manager but it's straightforward to install I can wait for a bit yeah and so I'm just starting now with that which is the tool for example if you just want to sort of develop your smart contracts it's like super straightforward you can just for example type DEP in it and it will create like this project structure here and it's nothing surprising in the end it's like they're using some kind of flip folder for managing external dependencies there's the output folder which is storing all the AP files and the contract binary isn't any resource folder I mean the source for you can also write your contract code and unit tests yeah here at for example I just showed how how a unit test looks like and it's also if you ever eaten unit test super straightforward so I give a general setup method there's a one sort of base contract which you can use for testing and then you can just write your your tests with assertion as normally everybody's aware of so it's super easy to get started using tap for testing smart contracts yeah so I will I will demo some stuff afterwards where it's like okay I can easily execute run all your tests and what actually is happening so it's not like if you maybe some people are familiar with ganache or previous evil it was called test RPC it was always need to start it in the background and it's using for most of the tests the chase an RPC interface for communicating but it is like if you just type test the app test it spins up the he VM in the background and what I really like it's it's super fast compared to with ganache can show you after some benchmarks with it so it's really it makes really fun to develop the contracts and tests and because it's super straightforward yeah and for example if you want so let's say I have a nice IRC 20 contract and I just want to deploy it with SAP it's also super straight for us you can just type ok tap create afterwards it's the contract name and then you can just pass the parameters in there which the contract might need in the constructor yeah and then also the supporting never really nice debugger and it's also the also supporting lock outputs which is just basically using events but you can really see it in the comment line interface and I've now I think a small example let's see it's just a little bit of code let's say we I'm gonna actually I just wrote here a sample test I'm using an IRC 20 contract I'm setting up this IRC 20 contract in the setup method and then I'm here basically minting on this test I'm meeting some some IRC 20 tokens I'm using AK here this is one if it's just called when you want to because I'd normally IRC 20 is using for the numbers 10 to the power of 18 and I'm actually minting one ever on one of this currency token and then I want to send it to Ellis and what you can see here I'm actually doing I'm actually making a mistake because I only have one and I want to actually send two so this test case will fail and I can show you so I can just run see oil this kinda trust if one test and this test is failing it's just a code I was showing previously and now I can just start the debugger I can see so here in the first thing I need to basically it's all in the command line interface me to select the test I want to get back and currently I only have one desk so it's straightforward and what I can do here is now I can see a lot of stuff it's actually all the AVM bytecode what I was really cool by can just for example here step to the end and then I can already see what's happened because I can see here oh actually this call was reverting because yeah in insufficient balance and you can really see here okay there was the air the first thing was successful it was just basically like this call for minting this one coin and afterwards when I was calling this transfer form so transfer from is the method for sending a transaction of an IRC 20 method and here you can see here was actually failing and then you can also say for example over I want to go some step spec and I can really see for example here the stack which is used just takes a while and I can see actually here here's the IOC 20 implementation when use the IRC 20 fermentation from die and here I can see here was this require check if if I have enough balance and sort of here it was failing [Music] yeah and actually also it's super straightforward to install dependencies maybe you want to use other let's say you want to use open Zeppelin or Sam so you can straight forward just your step install and it will install the dependencies in the background okay yeah maybe some some background on our code base so what we are basically doing is we rewrote a bunch of smart contract which allows basically that you can pool and if these together and if these in our case are representing real-world assets and we're using this and if these two basically for example get funding from from maker multilateral die and we sort of internally pooling them to design of these together and we creating IRC 20 contracts and current in our is it IRC 20 and IRC 20 token and currently we have like upon about 200 roughly 220 tests in our code base and we use like different tests use unit tests and also super system tests like in unit tests using a mock contract but currently our execution time is around 10 13 seconds depending on the machine for executing all these tests and it's way faster than for example with ganache yeah and it's it's also a reason why it's faster because you're writing all all our artists in solidity a lot of projects may be using just JavaScript tests to test for testing the functionality of their contracts which is might may be straightforward if you already are a JavaScript developer but it makes me more a sense to write a lot of tests in solidity because it's also a way to getting better better better getting a better Soviet solidity developer but just using the language more often because a lot of projects are ending up just some small solidity contracts but it's a way if you write a lot of tests if read a lot of mock contracts it's getting easier yeah to get different solidity and yeah actually also about talked about a little bit about deploying smart contracts so what I would we are actually doing is using a contract factory pattern for deploying our smart contracts because the really cool thing about that is that you can just actually deploy the byte code of your conflicts ones for example if you're using it on on main net it's basically for using a factory the pipe code is only deployed once to them to main that and then you don't need to pay that much gas if you redeploy the contract so example and yet here is using this kind of factory pattern to just deploy your contract factory wants and afterwards you can just always call this factory again if you need a new instance of your contract and it's actually also allows if you're using a factory it allows nice coding patterns like using this create to up code which is a way that you can basically define the new EVM up code where you can basically define the address of your contract to get every for salt because previously it was just always using the nonce of your address and this is basically a way that you can easily define the address in advance yeah and what we're also doing is let's say it will explain it afterwards a bit better it's using also deploy our contract for deploying our contract it is basically a way to ensure that we're doing it in the right order and it before example permissions are given correct to you yeah and then in the end then we sort of ending up okay we're ready to deploy our contract but somebody needs to call the deployer contract so the deployer contract needs to be deployed as well and therefore using just SEF the command line interface I can just show you roughly how it looks like if you're using this pepper and it's you got opted it from maker and we're using it currently in our code base but the idea is maybe yet say it just have two contracts contract a and contract P and you sort of it have some kind of dependency that you need to first deploy a contract a and it's true P only and it's in and contract P needs to deploy it afterwards nobody can actually - I'm just assuming already two factories are deployed and then I'm creating like this deployer contract and passing like the factories for this Factory al for this factory P and May some additional baram's and then I have like two methods for deploying like this contract because normally it's really expensive to deploy contracts if they're if they are bigger and it is a way that you can manage actually the gas and it's a refers to called called deploy a and afterwards I'm calling here I'm gonna call deploy be I'm checking if actually the first conflict was already deployed and if that's not the case it would actually fail here because you're the reason why does this require so there's actually only one way how you can use this deployer you always need to call Laurier first and it's only possible afterwards to call deploy be any questions on that okay yeah and now I just want to show you but what you can do with staff so staff is super straightforward as already mentioned the only thing what you need to do is you need to set at least two environment variables one is like for the address you wanna like to use and the second one is you obviously need some some history room note in the background cook your logo your local Jeff note or for example you can just use in Euro and you can also use a reflector together yeah and here maybe I can also show this live what actually wanna show life now is sending one die if you want I can also can send in your address and I can send one die to you this is my twitter handle which is check in two minutes if the address is there I will use that one afterwards suggest we're short of some example address but first so if you want to for example send one die from the command line you need actually the IRC 20 address of the Thai contract on may not you can see here you can choose the type selfs and then you need actually the Thai contract and then you need like okay which method I actually wanna call on is IRC 20 and there's one method called transfer from we are basically providing the source and destination and the amount you actually understand and afterwards you just need to pass the the from and the to address the from address is actually in that case my own address and then I just need some to address and it's actually tricky because it's one dice actually not the number one you need to be aware like one die is 10 to the power of 18 and then he actually to be aware did you need to do it in hex but I will use just an example address so what I'm first maybe showing here it's better yeah [Music] I'm just showing here this is like my my environment file file I'm just using your a Maynard in Euro link and this is basically my my my address for my local Jeff key store and what I'm also said in here is a gas price it's a cupid quicker descent for sending this transaction [Music] making sure small source is fine you can say same for checking if I'm a may not and I can just say okay I've also some cheat sheet here for me for actually setting this amount to one this is like just the code I'm using for getting the hex code of 10 to the power of 18 you can send that and here I'm just saying okay the tie at WrestleMania at an anaconda CCF it's and die I'm defining now the method I want to call and I can just say [Music] yeah obviously here in the case I need to end on my past passphrase yeah now I can actually check it's there yeah I might take a while because it's may not but I'm just now sending the address so I'm sending one guy to myself but I think that's basically it from my side and it's centrifuge we're also currently hiring Russ engineer because we're building our own train on substrate with a preacher a cerium so if your ass developer or US engineer please reach out afterwards but as I think I still have some time for questions in case somebody has a question all right yeah this is like for just checking because I'm just using like in Fuhrer link to check if I'm a Maynard if I'm an rinkeby or if I'm on a local gas mode it's just a mere way to ensure okay is everything set correct yeah okay [Music]
Automatic transcript — names and jargon may be misspelled.