A simple solution to make bidding/offers functionality for the Ethscriptions Protocol. All that happens through the secure ESIP-2 transfer event.
There is bidder, and there is an owner of ethscription. The bidder decides that it wants to make an offer (createOffer
) for an ethscription, and the owner of that ethscription can choose which offer to accept
.
The bidder creates a JSON ethscription and sends it to the owner of the ethscription, gets the ethscriptionId
of that transaction, and calls the createOffer
function with it and with the price
, ethscriptionId
and an expiry date. The bidder, with that call, also deposits the price it wants to pay.
The owner sees that "bid ethscription" and can go accept that offer by calling acceptOffer(bidEthscriptionId, ethscriptionId)
. Before that though, it should deposit the ethscription to the contract.
Bidder can cancel the bid at any time. In case when an owner has deposited its ethscription, but not called the acceptOffer
yet, and the bidder cancel the offer, then the ethscription is automatically returned.
In case an offer is accepted, the other bidders must use the withdrawBid
method to withdraw their funds. Meaning if you created multiple bids to one ethscription, you should call it multiple times for each bid you made.