Cowlony smart contract part2

How OpenSea listings work and why should you care?

Part1 of the series is here, we encourage you to check that out too.

OpenSea is currently the largest marketplace for NFTs. By design without nearly any extra development, it supports the basic functionalities of the ERC721 standard. The reason we write this short post anyway is to address the mechanism of how the listings and sales are handled. In short, there is a recommended method to get gas-free listings enabled on OpenSea. Based on our experience in the space more and more contracts implement this now but it is still far from being general knowledge.

OpenSea maintains a proxy account for each of its users and does the token listings and sales through these proxies to provide a smooth and seamless experience. You can think of this as your account (or identifier) on OpenSea which is also associated with your wallet. The proxy account needs approval from the smart contract to be able to act on behalf of the owner’s address. This approval can be handled in two ways.

Without pre-approval

By default, you can submit an approval request for your proxy account the first time you list a token from a given collection. This is supported by the ERC721 standard, it only has to be done once once per collection but it has its gas fee. The benefit of this solution is that the owners can decide whether they approve their OpenSea proxy account or not. Others could also say that in this way there is no need for extra development on the contract side, but this should not be a valid argument.

Example flow without pre-approving OpenSea’s proxy

Gas-free listing

The more desirable solution is to implement a little bit of additional logic into the smart contract, which could call out to OpenSea’s proxy to verify that a given proxy address is associated with the token’s owners. This way there will be no need for the mentioned first approval and OpenSea listings will be cleared automatically, gas-free for token holders.

Example flow with pre-approving OpenSea’s proxy

We decided to use the second method to save money on gas and computation resources on the chain. We take this topic seriously since it is related to the access rights of our cows. The described pre-approval flow is recommended by the OpenSea documentation with a provided example implementation. Also, it is discussed in several smart-contract optimisation articles (the-gas-efficient-way-of-building-and-launching-an-erc721-nft-project-for-2022) and also used in reputable large projects such as the Moonbirds collection.

Part3 is coming, stay tuned
cowlony

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store