OpenSea 🛠 Basic and Advanced Seaport Techniques - Ryan Ghods
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join Ryan Ghods of Opensea for a workshop titled "Basic and Advanced Seaport Techniques" Thank you for joining us for ETHSanFrancisco—our first west-coast hackathon in nearly four years. This was officially our biggest event ever 🎉 👥 1700 attendees 🗺 from 46 countries 🌱 38% new to web3 📮 284 projects And: ETHGlobal just turned five! 5️⃣🎂 Thanks to every single one of you for making this community great 💙 --------------------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.com Email us at: hello@ethglobal.com #ethereum #web3 #blockchain #eth
Transcript
foreign [Applause] [Music] thanks for coming all right so I'm going to talk about uh basic and advanced Seaport techniques if you guys aren't aware Seaport is a base protocol that openc has developed and it's our Marketplace that can trans transfer and handle nfts and your rc20s um so let's get started so the way Seaport works is you have an order and an order has two main components to it an offer and a consideration an offer is what you are offering and a consideration is what you expect to receive back uh for that order there are two other components one is called The Zone and one is called a conduit so a Zone can be an external contract that basically gives an approval or disapproval if an order is valid or not and that can be used several ways we will go in at the toward the end of the presentation uh and then a conduit is who are who you're giving your token approvals to uh to help uh transfer and manage your your tokens and the approvals and the reason that um the conduit is nice to have separate than the seaport contract itself is that Seaport can be upgraded or changed or moved to other address and then the conduit can still be used for the approvals so you don't have to reapprove um the conduit if the seaport contract has changed the seaport contract would just use the same conduit two other components of a Seaport order versus the salt which is kind of like a Randomness Factor but lately what we've been doing is we've been including our four byte domain hash so openc.io if you cause that cache it and take the first four bytes we've been um prepending that to the salt and that helps kind of um with order attribution and finding out who is uh fulfilling or creating the order and then um the counter is an account level thing every order you create will be set to your current counter and if you increment your counter it's a way to kind of bulk cancel all the orders that are below that counter so here's a diagram of how Seaport kind of works under the hood it's a little bit complicated but it goes over at the very top um the things we've kind of gone over already which is the offer and consideration and the zone and the conduit key which is a way to reference uh the conduit is standardized but the conduit Keys like which version of a conduit you're using not version but which um uh like kind of operator that has created the conduit so all those go into the order and then when you have an order you can do several things with it you can fulfill the order you can do a match order which we'll go into which is kind of like an advanced kind of matching you can validate the order on chain and what that does is you can pay some gas up front to validate it on chain and then if someone fulfills that order later um the the gas cost to fulfill is actually cheaper and then you could cancel an order which renders it invalid when uh when you fulfill their match an order it goes into this left part of the diagram which is just kind of a series of contracts that help combine and and set up the order for for the Fulfillment uh and then as kind of the last part uh the the order is verified and you know the time the signature the order status are all verified before um the tokens can be transferred so if you've ever gone to the seaport repository um we have a set of optimized contracts and a set of reference contracts so if you're kind of trying to learn what's going on uh it's nice to go to the reference contracts and see uh to read the code and it's it's quite digestible the optimized contracts use a lot more kind of inline assembly and kind of little tricks to help uh reduce the kind of gas usage of the contracts so uh creating orders so if you've ever created an order on openc you sign something like this and this is kind of what we went over it's all the components of what an order looks like it starts with um the message and the offer the offer which in this case uh it's a nft and the ID of it is id31 and then the consideration is the first consideration item is the one that goes to the owner of nft so that's what they're getting paid and then the second one is the open C Marketplace fee if there was a Creator fee here the third component of the consideration item would be the Creator fee payment and then you have the start time end time um Zone Zone hash salt and conduit key and the counter which it kind of went over so um validating order on chain is pretty cool because as I mentioned it makes it cheaper to fulfill later uh it also emits an event called order validated on chain so this is something you can do with like contracts if you have a contract that automatically wants to list the nft on Seaport you can do this and then other people can understand that the order has been kind of like made available to be fulfilled and then there's eip-e127 so that was eip712 which is kind of manually signing in order uh which you've probably seen like with metamask it pops up and you sign it yourself that's with the eoa if you have a contract that's signing an order there's this eip1271 which is a standard interface that provides is valid signature and that's how like a contract can create an order on seaboard and yep that allows like um smart and multi-sig wallets to to create um if you did order validated that's on chain you pay a little bit of gas but if you sent it to the openc API that would be off chain and it wouldn't cost any guess and then canceling an order um if you validate it on chain you can cancel it even if you created the order off chain in most cases you still want to cancel it Unchained because if someone found that order or got it later they could you know kind of execute it as they as they want and then the other option is incrementing the counter which is the account level kind of nonce all right fulfilling orders so the very kind of basic way to fulfill an order is fulfill order fulfiller is the caller and it takes all the offer items and matches them with consideration items um so this is a very standard way to fulfill an order the other type of fulfillment is a fulfilled basic order and what this does is it puts certain constraints on what a basic order is in this case it's orders that have like a single offer item and have consideration items and they're all in erc20 or native but what this does is allow us to use the call data in the method signature um and access that more so that it costs less gas to use for batch fulfillment there's fulfill available orders and you supply an amount of orders and you supply the max amount you want to fill this is helpful if you know you're for example you're putting in 10 floor orders and you say you know I'd like up to five of these then if certain ones are taken during the processing then you can still kind of allow the transaction to go through and uh with the fulfill available orders you supply a fulfillment array which optimizes for fewer transfers which also helps on the gas usage um one kind of advanced method that's available on the contract is match orders and it's not used very often but what you can do in this case is uh Mev Searcher who finds orders that have that they can match together if there's a remaining amount after what you can do is create a consideration item to pay yourself the leftover kind of amounts at the end of the at the end of the order if you didn't do that the amount would just stay with the the person who offered it and they would only be charged the amount that they were the order was matched okay and then we'll talk a little bit about zones um zones are really cool because it kind of allows for pre or post-order kind of validation or ratification so some ideas of zones is like a dynamic nft metadata Zone and what that could be is like you know as an experimental concept if you had an nft that had metadata that if it changes it changes the value of the um of the nft itself then you might want to cancel the orders that are out for the for the nfts so if you had a Zone that had a kind of a registry of of knowing when and I have to use metadata changed then when Seaport calls out to the zone to ask if the order is valid then it could deny kind of the the parameters of the order based on uh what the contract with the Zone itself kind of knows um a compromised nft registry is another interesting way of creating a Zone because the Zone because it has control to say whether an order is valid or not if you had a Zone that had a registry or a Merkle root of of understanding um which nfts may or may not be compromised then it could if it was marked as compromised then it could deny the order and not allow people to transact for it on the on the marketplace for front running resistance um this is another cool idea for a zone so if you take a Zone and you do uh kind of a commit reveal where you tell the Zone okay like I I'm interested in this in the seaport order I want to kind of like reserve it then the Zone would make sure that only that caller would then maybe in some time frame 10 or 15 minutes only they could um complete the order and then after that period it could be open again kind of to the public but that'd be a cool way to kind of create um a more kind of a secure way to use like the public mempool but not allow people to get the their nfts kind of snatched in the process and then another Cool Zone would be like uh Oracle based price validation so if you could find an oracle that has uh like nft floor prices or um the price of nft based on its Rarity then the Zone could enforce that if the value is too low um it could deny the order being fulfilled and sometimes that helps in the case where nft is stolen and it's listed for much lower than floor just to kind of get rid of it this could help protect in those kinds of situations so um a little bit of alpha it's working on Seaport V2 and one of the concepts in there that that we're working on now is a um is a uh an order type that's a contract so this allows us to do kind of more advanced contracts um that can handle orders uh right now as we kind of went over in order either has to be signed by an eoa or a contract and in Seaport V2 we're exploring ideas how we can make contracts more powerful to kind of create orders on the Fly based on different parameters and and custom logic that and contract itself could hold so yeah yeah here's some helpful links the seaport repository um the discussions page is a great place where a lot of people have asked questions and while you guys are here if you can't find me you can post questions in there and we'll we'll try to get to them and and help you kind of uh answer any problems or questions you may have Seaport JS is also a great kind of accessory utility Library um has a lot of helpers you know if you're working a node or JavaScript it has a lot of things already built out like driving order hashes and things that can be helpful utilities and um and yeah there's a Seaport order validator as well it's a on-chain contract that you can call out to that can do that does like almost 50 to 60 kind of on-chain validations for balances and approvals um that we recommend kind of checking out it's pretty cool so yeah thanks for attending uh I'd love to open up for any questions if you guys have any about Seaport or building on it and uh yeah
Automatic transcript — names and jargon may be misspelled.