I am a server-side developer who started learning solidity a few weeks ago.

I am writing smart contracts for practice.

Currently, I am stuck conceptually and need help from industry experts.

Imagine a smart contract that contains a pool of funds (e.g. 100 DAI). Further, imagine that the said smart contract is Ownable. How do I create functionality whereby the owner can instruct this smart contract to, say, buy (or bid on) an NFT?

I can see the ERC721 anatomy here. There does not seem to be bid or buy methods built into this smart contract. How do I go about designing this smart contract? An illustrative example with an explanation of the pattern would be great.

1 Answer 1


NFTs are auctioned in various ways on various platforms. An auctions could theoretically be completely centralized - an owner says they're taking bids until a certain time, potentially even off-chain, and at the end of the time, the bidder informs the winner they have won, accepts their payment, and sends the NFT. There wouldn't be much you could do with a contract in that case.

What I think is more common is for there to be an auction contract in the middle. At the beginning of the auction the NFT is transferred to the auction contract, and the auction contract releases the NFT to a certain address under certain circumstances. In this case, your contract won't need to interact with the actual NFT contract, but with the auction contract. CryptoKitties's auction code can be seen in their verifiable contract here for example (you'll have to scroll down a bunch), and OpenSea's seems to be here.

Once you know what kind of auction contract you want to have your contract interact with, you'll be able to import an interface of the target contract, and then have your bidding contract interact with it in the exact way you would've had it interact with the NFT itself originally.

Good luck!

  • Same goes for outright buying the NFT as well (in cases where "direct buying" exists)? I was thrown off because I read that NFTs preserve ownership history. So it seemed like buy or bid would be a native part of the NFT smart contract. Now you make it seem like all those are optional features tacked on by various implementors on a discretionary basis. The core NFT ERC721 contract is rudimentary. Commented Apr 12, 2021 at 9:07
  • 1
    I would assume buying would work as a first-price auction - a contract in the middle owns the NFT and knows the price, and the first time it is sent the funds (properly) it transfers the ownership of the NFT to the buyer
    – Linum Labs
    Commented Apr 12, 2021 at 11:12
  • Thanks for shedding light on the subject. Commented Apr 12, 2021 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.