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

Loading player…

Handling the revert exceptions in Solidity by Mudit Gupta (Devcon5)

DevconFri, Oct 9, 2020, 12:00 AM

Speaker

Mudit Gupta

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/5/catching-exceptions-in-solidity When a revert happens in solidity, all the state changes done in that transaction are rolled back. All the changes done in sub calls are also rolled back. If a contract A tries to do a token transfer in contract B but contract B reverts, all the changes done by contract A will also be rolled back. This is fine for some cases but sometimes there might be a need to ignore or handle this revert in the smart contract itself. The talk will demonstrate how reverts and other exceptions can be caught in Solidity. Speaker(s): Mudit Gupta Skill level: Intermediate Track: Developer Infrastructure Keywords: technical Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

Transcript

[Applause] from Vienna and I'll be talking about a short topic or finding little exceptions it's all relative so by default if an induction will reverse the whole state is devoted on everything done before that is rebutted anything so for example if you're going up that's transfer and one of the transfer fees all the other transfers will free Lisbeth sometimes you might want to just skip that transfer and let the others continue it's not needed be possible it's already is 0.5 and earlier versions but it is of non-feature in solitaire 0.6 that is the upcoming me diversion but even if not right now we can't emulate this try/catch behavior using little everyone's so I will be talking about will go down one disadvantage of using low-level parts is that it'll buy us some of these targets that is all signify provides so if you use this technique you should know that you might be missing some strategies so this is a sample good I know you might not be able to see but how it essentially works is the it's a two-step process first you generate the core data but you have to use to call a low-level smart contract user role everyone in that you enter the function name and the parameters and the data that we have to pass particle then solidly using the function in Corvette selector will generate core data that will be passed on in the United States to call he needs that can be used for any small contract the next step is to assess for this my contract using a low-level con so of nodal because God says that it will never ever if these subsequent controverts it will return false as a result time they will be able to handle the reverb yourself so in this case you can see and to England oil coal and if it reverts it will return the result response if it goes successfully it will return the result as true if it returns false then I love you and the luckiest may be love it somewhere the rest on rats it will and if it was true I can just continue with my process my past function and I don't have to worry about it anymore it's a bit clunky right now but in solidly 0.6 it's very clean I think it's something that I'd really love to use it which of that bus main thing - functions will become easier with us so this issue on github you can follow it tracks the progress of the implementation in solid it is 0.6 I hopefully you will be able to enjoy if you need more info or the this morning for my godmother you can visit our as me and that's my shop thank you [Applause]

Automatic transcript — names and jargon may be misspelled.