The Charity NFT Auction on Hedera is Open for Bids and Builders
Sep 21, 2021
by Gehrig Kunz
Product Marketing at Hedera Hashgraph
One ambitious potential for blockchain and public ledgers
is their ability to disrupt entire marketplaces. Traditional web 2.0
marketplaces like eBay, Airbnb, and Uber inherently rely on centralized
infrastructure to facilitate exchanging goods and services. These
centralized intermediaries take a percentage of each transaction, often
ranging from 15-30%.
The bold vision is to decentralize marketplaces like these,
moving transactions to take place entirely on a public ledger. By doing
so, buyers and sellers in the marketplace can have a more equitable
To some degree, this transition has already begun. NFT
marketplaces have taken the world by storm in recent months. From NBA
TopShot to OpenSea, we've seen millions of dollars exchanged for Lebron
highlights, Bored Apes, and other digital assets.
Despite the wide variety of marketplaces, you will find that most of them fall short when delivering a modern user experience. Poor UX isn't the application's fault but is often a symptom of the application’s underlying blockchain's limitations.
Gas fees on networks like Ethereum can be highly variable, at times making it impractical to acquire low-valued assets. Even when we pay these fees, the transactions can take minutes or hours to process. I have personally been outbid by someone more willing to pay higher gas fees. It's all far from ideal.
Hedera offers a different way forward for developers and their users. A marketplace on Hedera benefits from:
Typically, a decentralized NFT marketplace connects a buyer to a seller via a smart contract. The smart contract handles the logic and transfer between a bid and distribution of the NFT. This entire exchange happens fully on-ledger.
You can think of our auction validator network as a layer-2 network or protocol on Hedera. In our Charity NFT auction, the validator network consists of seven members: DOVU, Fluent Finance, Gomint.me, Hedera, IvyX, ProvenDB, and SEUNwater. Collectively these seven nodes are responsible for managing the:
State of an auction
HBAR bids and refunds
Distributing the NFT to the winner
For each of these critical decisions, the validator network comes to a collective consensus. To achieve this, we rely on a combination of Hedera services and features, including Hedera Consensus Service, Hedera Token Service, multi-sig accounts, and scheduled transactions.
State of an auction
Hedera Consensus Service manages the state of each auction and its configuration. In simplified steps, this works as follows:
The validator network agrees to use a specific Hedera topic for all auctions
Each validator's public key is added to the topic's write access control list
Each auction update is sent as a new message to the topic
By recording the status of each auction on the public ledger, we ensure that each validator is in sync. Furthermore, the information is available for everyone in the world to monitor and verify.
When a new auction is created, a few things happen:
A new Hedera account is made for the item's auction controlled by the validator's multi-sig keys
The NFT to be auctioned is transferred to the new multi-sig account
A message is written to the Hedera topic specifying this auction's configuration
Each validator then independently confirms if the NFT has been transferred to the auction's account. Once checked, the validator's client UI updates, and the auction is officially open for bids.
When an auction is active, and hbar is sent to the auction's account, each validator checks to see if the bid is a potentially winning bid. In other words, confirming if it is the highest bidder and meets all qualifications as defined in the `auctionCreate` message such as the minimum bid increase required.
Upon a successful new winning bid confirmation, a scheduled transaction is sent to Hedera to refund the hbar from the previous winning bid back to its bidder. Once enough validators sign this transaction, four out of seven in our case, the hbar transfer is executed and the now losing bid is refunded.
Scheduled transactions are what make validators possible; they give us the ability to collect the required signatures on the network in preparation for its execution. Without scheduled transactions, we would need to manually collect our validator's signatures each and every time prior to submitting our transaction.
Transfer NFTs to Winners
Once an auction is over, based on the initial `endtimestamp` found in the `auctionCreate` transaction, the validator nodes check to see if the `reserve` has been met. If the latest bid is greater than the required reserve, the validator nodes again create a scheduled transaction. This time when the transaction is executed, the NFT is transferred to its winner.
In the case of our example Charity NFT Auction, we require all winners to complete KYC verification. This identity check process is not required within the codebase but is an optional parameter. It is also worth noting that in order for the NFT to be received by the token, the winner's account must first associate the token ID with their account.
To bids and building
Layer-2 validator networks extend and enhance what's possible with their layer-1 counterpart. Validator networks offer an alternative to smart contracts on Hedera to increase the programmability possible with Hedera tokens, among other functionality, while offering low-latency and predictable fees. In our auction example, the validator network is able to decentralize some of the auction’s application logic like managing bids and awarding their winners.
There is much work to be done for the grand vision of decentralized marketplaces to be fully realized; key infrastructure and standards around identity, reputation, and dispute resolution must be created to name a few. With Hedera’s advancement in scheduled transactions to enable validator networks and smart contracts 2.0 more robust decentralized marketplaces can begin to be created.
The NFT auction example should invite you to ask several questions. A few key ones being: 'should I use a smart contract or a validator network?', 'What level of decentralization is required for my use case?', 'Do we need staking or slashing for stronger validator incentives?'. The beautiful thing about open source is that anyone can expand upon this code to make it their own. All code for the auction from token creation to UI can be found in the hedera-nft-auction GitHub repository.