EthCC 2: Jacques Dafflon
Ethereum Paris·Wed, Oct 9, 2019, 12:00 AM
EthCC 2 The Ethereum Community Conference is created by the community, for the community. It brings together great minds and forethinkers, and allows the community to grow. follow us : @AssethFR https://ethcc.io
Transcript
okay hi hi guys I have all my friends in the room that's great okay so hello everyone welcome my name is Jack I'm one of the author of year C triple seven then you took in standard and today I'm going to talk about how it improves a bit safety and security and like what to do when you implement or when you interact with air see triple seven so very quick intro for those of you that are not familiar with it it defines a single send process both for regular accounts and contract so there's no more approve transfer from from year C 20 under contracts react when they receive tokens based on the tokens recipient hoch there is a clearly defined lifecycle for tokens so we defined what minting is what burning is and you have a really explicit lifespan for for tokens we remove the ambiguity and issue with the simul so it's always 18 I'll get on that later we define the concept of operators which is any address that can send tokens including tokens from some other address we have hooks as the one I mentioned before to react whenever your tokens are being sent or received and the whole thing is backward compatible with year C 20 if you're not familiar with it I encourage you to watch last year's talk I did to introduce the standard it's on YouTube I'll publish the slides as well so you can have the link so safety aspect so I'm talking about something that's like unplanned or accidental so many pollution you make that has unintended consequences the first one is triple 7 prevent locking of tokens by mistake so if the contract doesn't state explicitly that is able to receive and handled tokens trying to send tokens to that contract will fail and so you have to explicitly implement a hook saying yes I can handle tokens that's the first thing and obviously if you implement the hook but don't actually handle the tokens then you can intentionally lock tokens in a contract but there is no unintentional lock the decimal was very confusing in year C 20 it was an optional function so in triple 7 we simply set it to 18 so there is no decimal function in here C triple 7 it's just 18 and whenever you have amounts you have to convert them you do have to check for granularity which is the minimum amount of tokens you can sign at once it's a simple modulo operation you take the amount as an integer before playing the 18 decimal conversion and based on the granularity as indicated by the token contract you can see that the amount you're sending is actually within the granularity indicated for security aspect so this is more like hackers and trying to protect or defend against people trying to steal tokens or lock tokens or abuse token contracts there is no more approvers condition that is present in your C 20 unless you implement the year C 20 methods but your C triple7 does not have that issue there is better control over how you can spend your token using the hooks or we can receive them so for example you can actually define your phone as an operator that can send tokens from your cold wallet storage and so you can have a massive amount of token on the phone can just spend them freely but you put a hook in there that will give a quota and so if your phone gets stolen you will be able to one revoke the phone as an operator to not spend tokens on between the time where it's get stolen gets revoked if the hackers or the thief try to spend the tokens there is a quota system in place that you can put in your hook so they can't steal all of your tokens just a limited amount so that's just one of the example of how we can improve the safety of your own tokens there are a concept of operators allows you to move functionality outside of the of the token contract so if there's an issue of inner ability with this with this functionality you can always unauthorized the operator you can deploy any operator with the fix without affecting the token contract you don't have a vulnerable token contract and the other thing I just forgot to mention is that you can reuse existing operators so I can deploy an operator and then you guys can actually use it for your own token without having to implement it or copy pasting the implementation it's already there and that contract can be audited to make sure it's it's correct so an example of a hook here we have a very simple hook with a quota so you can verify so what you do is you define a simple function to set a quote on you say okay well for this token this is my daily quota or then you implement tokens to send function on the token to sends just make sure that you have the updates the time frame of the the window of the quota so daily and resets it every day whenever you call the function and then you just simply check that the amount you're sending doesn't exceed the quota and then if it's correct you just update the use part of the code on you can have this system and within a 24-hour period you can never spend more than the quota no matter who spends token so that's the the quota example for operators here we have like our payment processors so what happens is you define a dispatcher address that can basically spend your token through that operator and you set the recipient address and then what you have is a simple function and this address can spend your token but they can only send it to an address you decide on that means you can authorize a third-party payment processors to do transfer on your behalf but you always control who receives the token and you can imagine a service like this where this service does your transaction for you in a safe way and you don't have to pay for that for gas and maybe you pay a monthly subscription for that service so here is an example of what not to do this is a simple hook you can deploy first thing is don't check for the operator that is authorized or not this is part of the token contract so you don't have to do it in there secondly and more importantly we're not checking the message sender of the function which means this applies to all the tokens that you have not a specific token so you have to be very careful with this to apply the logic also - operator - to each token individually secondly here we have a system a little check that's kind of like I'm locking the token for a set amount of time for like a pre-sale or something like this and in this case this is a behavior that whoever designed the token wants to enforce and all the users but the hook is controlled by the users so you don't want to put those types of features in a hook that the user can just bypass by not using the hook this is something you put either in the token contract or better we use the minting which is part of the lifecycle and give them signed messages for them to mean their token after the pre sale so they can check that they can have two token in a trust this way just looking at a contract where they don't have them before and then that's that's the better way to do it finally we have here another system in the hook which takes a fee on then sends it to whoever collects the fee for the transfers so if you want to do like a fee system or something like this again don't put it in there because you can just bypass it a better solution is put this in an operator so you can't force the users to to use your operator but you can force them to use the operator when they send money back to you so you can have a hook and say I only accept money from that operator that way the users can trade tokens between them freely but if they want to use your service with the tokens they can easily do it through your operator and they have the fee at that point that's also a better a better way to do it so as a overview of this what we do is 18 decimals that's really important just apply it all the time if you hold any triple7 tokens I'll try to use those hooks to improve your secure security in your safety and keep your asset safe when if you want to design a token if you're someone creating a token try to use operate restore to reuse existing operators are not put too much features into your token contract and open it to vulnerabilities and harder could reviews as well and audits if you're using an operator as a token holders and you don't like it we can always revoke it so just be careful what you authorize and remember to unauthorized whatever you don't feel comfortable with and finally as a token provide as a token designer or a service provider a good pattern is also to require oh I want you to use my operator to to cash out or to use my service that way you can enforce the behavior that way but you don't force to behavior for every transfer just one related to you and overall try to keep your code clean even if you don't work in 307 but like try to keep it simple and this is also what operators and hooks allows you to like speed your code in small comprehensible pieces of code i I went somewhat quickly with this so I can take some questions if you have any feel free if anyone has question I think we have a couple minutes did you guys understand anything mmm yeah grief so what's the status of getting the EP through so yeah that's the one the big question everybody's asking I'm happy to give in a bit on that now three plus seven relies on relied on your C 820 which was the registry to deal with the hooks the latest solidity upgrades affected that and so we had to do a new version so there is a new AIP I'm waiting to merge it and that's a copy of the old one with the fix forever was broken and that is ready to go now I'm just I need a couple minutes once it's merged to put it into last call that's a two weeks delay for triple7 it's almost ready I'm working on it I had other things to do before I had there was a bit short in time but now I should have more time and we will I just have to basically update the reference implementation to solid ET 0.5 clean up a bit the code which already did in a few last few days under the standards and then hopefully put it to last call two weeks plus whatever time I need before to clean it so I really hope by the end of the month at the latest but I can't guarantee it so please don't go crazy if if on the 2nd of April it's still in last call or something but that's the titanum timeline I would like to have here are there very many projects that are looking to push this forward like that are waiting for last call i yeah i so I know a couple projects that want to use triple 7 if you go look on the issues is also people that are interested to use it and they're pushing for it which is a good thing I don't know specifically for which project those people want to use it but they are interested by it and hopefully many people will use it that's that's the idea more question no okay great thank you very much thank you and if you do come up with a question after you walk out feel free to come and meet me at any point during the conference I'll be happy to answer any questions you have thank you guys [Applause]
Automatic transcript — names and jargon may be misspelled.