Non-custodial ERC-20 Payment Processing by Bojan Joveski of Coinbase Commerce
ETHGlobal·Fri, Oct 9, 2020, 12:00 AM
Bojan Joveski of Coinbase Commerce gives a talk at ETHBoston, an ethereum focused hackathon that took place Sep. 6-8, 2019 at Northwest Building, Harvard Campus. The talk explains how they implement ERC-20 payments on their platform. ETHBoston was a hackathon organized by ETHGlobal and a team of hackers, developers and enthusiasts interested in building and creating in the ethereum ecosystem. The ethereum focused hackathon took place for 3 days at Northwest Building, Harvard Campus in Cambridge, MA. For more information visit eth.boston and ethglobal.co
Transcript
hello everybody my name is Gwen and I work for cannabis commerce today were going to talk about how we implement that year c20 payment for acceptance of our platform so this is kind of like the overall agenda of the dog first we're gonna talk a little bit about like how crypto processors work why they're important what role is her we're gonna talk a little bit about years 2014 and why is it important and how we solve it and then you gonna have to go on and for pacific Rubicon tweet to the minimum person contracts these are you virtual machine that we've used them a lot they are like we think that they are very cool and I think that they can be applied into like a variety of like use cases that go way beyond payment processing so what this movie scores will be try to get easiest way to accept Kripke we counted by batteries included meaning that we want to make it like super easy for developers and just like merchants to accept with the crisis started two years ago and since then we've developed a lot of integration with third-party websites like what makes our product interest in from philosophy as well as from from my content we disappear posted but noncustodial closed the meeting that is don't beat around in Eastern Europe to use their product you just like sign up on our website they're like essentially we handle everything for you but you're not festival meaning that point base of over 20 miss comers neighbor has access to their private piece all the transactions are completely clear severe and everything that happens it's like to naturally kind of experiment we cannot see spawns we cannot like stop anything irides between the merchants and when we started we started with supporting VidCon material like plain and between cash and since then we support a few SBC and like we stopped essentially explains what things we needed to do and how we are post and included Missy Missy stable point developed by coinbase its implemented as some ears at 20,000 so everything that is here basically can be applied to any other here's the point ok so that's pretty much like what payment processors do big kind of like accept payments on behalf of the merchants they handle all visiting stuff and let's kind of like dive into like what actually happens when a when a payment occurs so let's meet Mike Carol the customer and many merchants and let's say that meant want to sell some bananas the carrot they are in many ways that kind of like this interaction didn't happen in the very very simplest case we can imagine that Carol just sent some ether into Matt's account and met just give these being works in real life but unfortunately Brooks in great steamer if you have like anything turned will think more more scalable because if soon enough to get the gonna show up like you don't know who paid for for these particular behind if met Cheers he's only address to everybody then it can be possible working to know if they might be us for proof from Carolina might open section cash for something else that that transaction occurred but these thing becomes like Harry party and very cumbersome very quickly and especially if you think that most of the customers that we have to be they come from exchanges and they don't really have like a wave of providing any additional data like that and effects just like saving simply information does not work South our competitors developed like payment protocols that are very cool and they solve this issue by making like an artistic flow between your posterior you're kind of like private bullet and essentially the merchant server but this again like excludes a lot of people that use exchanges and we want to make our products to be like the easiest and simplest everybody so our solution essentially includes this widget this region here has like blue 14 numbers the first one is just like the amount that you need to pay for for this particular transaction and the second one is like the more important points like that address that is like a mini kitchen determining address for this particular charge that has never been kind of like that has never existed on the blockchain before and it's very important that all of these addresses are unique because we can make things we know that these address is completely associated with Garros purchase in France lentil depth address we know that it must have been care of the patroness so kind of like in a little bit more visual way like when carol was provided bananas we generate a new address for this interaction 0x banana she sent some ether to that address and while doing so she pays like some transaction fees at this point the interaction is done by coinbase commerce would send all the appropriate notifications met the merchants receive those funds but imagine kind of like like the like like we use this one point - like to spend them somehow and the way that he does that thing is that he signed some transaction originally from like that intermediaries that he controls maybe base piece for that this works very well for aetherium but there is like slight issue that we're going to get to about years to 20 we all kind of like this intermediary steps where we generated whiskey addresses but already because that we're introducing this kind of like pop that needs to be forwarded and four years to 20 tokens we would have the same thing we have like the unique address for this particular instance Carol's and some USBC tokens she pays transaction fees in eater and this also works out well everything works but like one man wants to reach her the USBC tokens there we get to an issue we need to pay east material because that's like immaterial the way that kind of a Miss transactions work is that the intermediary address that Miss address banana needs to contain not eat food powder for the transaction fees but because this is like a newly generated leadership that does not contain anything it's essentially impossible this does not work and there are a couple of ways to kind of like go around this thing in the very simplest is that well maybe we don't really need this intermediary team that maybe just like Carol Anne called a proof from function and that's also of our issues but then again Carol cannot use change or any kind of plain simple wallet each requires specific web to compatible wallet for death that kind of transaction or death was just one start there first another thing is that meaning men can just like because it a little bit of it at that intermediaries that will be used with are for the transaction fees but this also becomes like super tricky to implement like super fast because the transaction cost is like variable we don't know they showed cusamano will need to be spent as well as the gas price in curing is like subject to essentially market conditions so it's like super card $16 [Music] we just started so that I look like who does seem like this tricky situation where where on one side you need like these like injuries based systems but we kind of like also need eater on those addresses that that we cannot find thankfully aetherium lets us create contracts and we can use like smart contracts to like so listing this is like a tan line are so smart contract that this essentially the base of our solution of how we do that thing when we initialize this over there contract we get like a destination that's like mad respect the merchants final destination that they want the consent and the only team that is contract them to it has like just like single function rush tokens that can be called by TT body in whenever that function is called whenever that function is called the fast automatically get transferred from like this intermediary address to the final destination something to be kind of like noted that we'll get back a little bit later is that these flash tokens function is completely open to anybody there is no guard by owner only or anything like that it's like freely available to let everybody to go so we kind of like olfactory diagram now we have like Carol that wants to buy the bananas at the unique address but now it's not like just like a simple address is like a smart contract that's initialized with and that's final destination she sent the USBC tokens to that address and whenever mint wants to Twitter the pants instead of like him sending some teachers anybody in the world whether his scheme whether it's on eBay sweaters like any other third party all his flash function and whenever his watch flash function gets called the USBC automatically gets transferred to next address and I do hope that at this point you can kind of like see how all these where were there's solar power problems we could essentially deploy a bunch of disc orbiters whenever somebody pays we would call the plush function and essentially the funds would go wherever they need to go so this is so good like the good things about what this solution is that it's like address based so anybody could pay from whether they have like a mobile wallet whether they have like what trick compatible or they're just using an exchange it's completely noncustodial because like anybody can access these contracts and mobile it could prevent the funds reaching their final resting and we don't really need any if two in the account itself to like handle these pages which is all pretty good the bad thing about these contracts is that like it's a lot of repetitive it's like very hard to deploy because the way that what we've described so far we would need to be employing this pool of contracts beforehand we don't know how many we need to employ they're all cosplay it's all very expensive to manage so if you try to kind of like avoid listening at scale in like you know like realize it's it's becoming like very like super master person so what are we gonna focus on like for the rest of this college is kind of like the batteries and strategies that we've used to kind of like mitigate the websites and all of those things are something that I think is like very readily applicable to like any any address to a lot of other situations any situation that yes this kind of like simple repetitive things that we need to do you need to kind of play do them on a per session or per user or something base would benefit from these metrics the first thing that people can do to kind of like mitigate the cost and the complexity of this thing is the use of vector a vector is essentially a singleton contract that deployed once that contains the logic of the contract and knows how to generate union contracts so this is like the forerunner Factory over here like we just buy like I mean a forwarder function that can deploy a new forward once we have like this Factory in the blockchain we go from something this is like over here we are seeing the remote root section that essentially deploys action that deploys the forwarder so the cold over here contains all the logic of like how forwarder is being initialized what does it mean to like flash all of those things and we ended that's like a lot of logic compare that thing with like at least like couple appliances down there that only contain the base efficient existing says like a like you know like I have a single ton Factory on the blockchain call it and called the init function both of these functions perform the same logic at the end of the day either one of them will end up with a new coroner being deployed and approaching and they're kind of like indistinguishable like functionally speaking from one another but essentially the email rewards us for using less space in the first case like we like 1.7 kilobyte weight of the tree section and we used like 440 KF gas and we've reduced that to like less than 200 bytes of data data with like 240 thousand units of gas so this is a pretty significant savings that that kind of like it's good but we still have like problems with it how many of you know how essentially like addresses are calculated in the atrium what change it's like a little bit of a mess but pretty much we have the original way that like when you when you deploy an address essentially you take some caching function of the parent address a number known as nonce the nonce is like an increase in counter associated with the parent account of like how many transactions have originated from Delhi and this essentially means that there is like a global state serializable state of of kind of like you know like account that transactions going from here and it's very very very hard to build production systems that depend on us it's very easy to get something wrong it's very easy to create a transaction with like something that's valid there that's like just like cool oh I guess that makes the whole kind of it makes depending on future addresses but very very very hard but thankfully with the latest of material for that happens like earlier this year we have something that's called creative and great to remove this essentially in placing global dependency on the knots or something that's like very explicit now we passed an assault that these kind of like determined by the developer and also adheres the code but like that's like slightly less important what this means to me kind of like real life like it was also like a very kind of a technical terms these are the changes that we need to do to start using creative so you can see that like the first in the first line you can look like clearly see but like in the first line we are passing I think since it's all parameter before that they were its function was like performed by the implicit console and then gathered to changes is that we still create use created instead of like the implicit amount that was not fast now we pass the salt to the creative function this is a huge beam in terms of operational availability kind of like security and getting like some trusting that the code is doing doing the right things is because like right now we asked like the users of this factory can know where this border for breeders who be deployed without really knowing the state of the block without really knowing when how many contracts have been deployed from this factory without having to have like any cars in this thing this allows us to essentially simulate a lot of this essentially that gives us that possibility that we can calculate these addresses forwarding addresses a priori without appointment to the blockchain we can show them to the final customers people like her all Carol can a to the to that address and mommy after she has paid we can then deploy the contract the contracts and we're we were certain the build we deployed at the right address we were certain that nothing bad can happen with that so it's a huge win for any kind of like deal developer or like hardware wallets or something that does not need to constantly directly the blockchain and hoisting and if she never pays you never come yes and also the gear is like a very security kind of like Oh whenever you interact with these things you want to have like a symmetry between how much it costs for an attacker to essentially deplete your pants with the print emergent plants and how much you can kind of play you need to spend so this one aligns those two things well together because we need to like be redeployed contracts on the blockchain then it's very easy for somebody to just like to cleave the merchants pawns by making thousands of contracts and never being in one of them but it would be an area they need to incur cost on their own first of all it's some kind of bull chain before it's before it's actually used so it's like very very good stuff together think that we've done to make this being the reality and to make you stink like useable and like kind of like production scale is we use that what's called minimal toxic contracts which is like a very near miracle feature that allows to go from like a transaction of this size to transaction that goes up like that size what we see in the code below is like a huge food schuster direction both like in bytes as well as like you guess and essentially like the transaction below is deploys a contract that you can think of like a swing linked to any any other contract on the blockchain so the transaction below this is I don't expect you to understand there's various thing but like this is like everything that it does is like you because like new contracts that gets initialized with like a single address and any any call to this like very very small tiny proxy contracts would get like this kind of like genomic relay and ASIC this is probably the smallest interest that can exist under watch-chain because it just kind of like says like hey like you know like I was caught with something I don't know what it is but I do know that like my parents can answer this question so we use this thing to essentially come up to this topology of our contract so it's like how our system works to be in production would have liked a single over the factory that knows how to produce these things it has like a fixed address a single term that we've deployed once and we can forget about it and whenever emergent counts we deploy a forwarder with their final destination and from that point onwards or any interaction moves like any of their customers with any materials out there we recalculate on floor mattress whenever a clone whenever we're good to deploy I would paint one of those addresses only then we go in like which we like deploy the clock and that cloned doesn't know anything it's just as a like you know like I don't know about anything but I know that like my forwarding parent knows about it is if you just like essentially the free documentation for either the forward or not this Venetian and that's that's like yeah like overall like what we've done here is that now we developed like a smart contract that are like easy to use for anybody regardless they don't require web free support there noncustodial like anybody could even even agree right now we manage all of this contract deployment but that's not like any strict requirement the merchants and themselves call this contract they're completely open anybody could call these contracts in my class the console and we've sold the repetition problem like what we deploy it's like super minimal it's like very reliably to kind of like compute these addresses we are we can be certain that we cannot as anybody in terms of like non salvation or most management and they're like relatively cheaply deployed the especially if you consider that we can reuse this contracts so once we don't just hit this thing today but I'm finished with that we will eat like once like once this thing becomes like what only we could let me use the contracts that we have and from that point onwards it becomes like SSS s she s just like kind of like calling very surely free so that's pretty much everything about what we could have like what we had we can kind of like have questions if you guys would about any of this stuff yeah when you create the contracts for words where the average that make your question exit what is the address where is that so you can think that that's like the merchants final destination right now we deposit to kind of like the merchants befall to curiam address based on their like kind of like a t30 to see so the big would kind of like import their seeding like from like sound like any other electric party bullet and see all their balance but you could imagine that that destination can be like a setting you know like determine like somewhere in like the last word in the setting so it can be like that I can exchange or something so like the console automatically like go there it's not currently a team primarily from like you expected because if you end up if you put here kind of like exchange enters there it will be very hard to kind of like do you like what's your balance of how much money you perceive what does it mean to withdraw those funds like it gets like very tricky very fast form like UX perspective and product perspective but technically it's technically there is nothing preventing we thought about self-destructed in the contract afternoon for four together ESL eld starting contract will reduced by I think 15k the guests past and that's definitely something it was great you can actually recreated the contract at that address you need to again well that's true something that's a little bit tricky with way to do an especially we move proxy contract is that there is like a weird dependency on but it introduces a locum if you want to make this thing completely open if you want to make this thing kind of like very simple to use it gets like very quickly very fast if not enough cost benefit what are the money that you get back 15k once more yeah that's like one reason the other reason is that not a good thing that we'll get to a point where we can't have like these pool of addresses that have been paid and because these are kind of like one-time things like you know like if a customer pays to the merchant we need to monitor that that there's product a while for like a week just to make sure that somebody doesn't pay something twice or something but that pretest we can reason that endless for economic interaction with in that case that do you mean - pretty much yeah this is the you I just left there yeah but right now it's for just less it's technically we could on the technical side we could support any years to 24 countries like which really no limitation it's like anything like one line of code some word to say like more clearly spoken it's like it's like a prologue mission at this point it's definitely doesn't part of the UX I think it's partly also just adoption that you're actually 20 tokens that you would add and there's still a little bit of a gap on users using adopt music going because it's only time et okay with it so I just just generally has that fertile but if you start seeing more adoption I just chose EC row that years of 20 tokens and I can prioritize that anyway I see this is a really good UI if I could just find out maybe there's more and if you would be that your more degrees to accuse the contracts and like you know if you end up the disposition being the Dow contra magically get splashed and you know like who paid for a lot we can you can know that thing from like the product itself but you're more than welcome to do is like a contrast to that girl yet I mean I guess like we're finally gonna say sometimes so have any questions
Automatic transcript — names and jargon may be misspelled.