Skip to content

Instantly share code, notes, and snippets.

@tunnckoCore
Last active July 15, 2023 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tunnckoCore/9af0b6b194ad1d2580c4f379c3eb05ae to your computer and use it in GitHub Desktop.
Save tunnckoCore/9af0b6b194ad1d2580c4f379c3eb05ae to your computer and use it in GitHub Desktop.

New (old) Way of Trading.

I think I solved the problem of safe #Ethscriptions trading.

A multi step process, but safe and sane. Basically, offers-based.


1/ Here's how it could work:

What if.. a seller ethscribe his "sale intention", a JSON like

{
  "ethscriptionId": "0x04da8bcd15ad1c5c820249aea49b06793ba3b96704e3960fe885d238a99799a7",
  "price": "420690000000000000",
  "sellerAddress": "0xA20C07F94A127fD76E61fbeA1019cCe759225002"
}

Note: There can be "token": "contract address of ERC20 token" which will mean the price is in tokens, not in ETH.


Which should be signed with their wallet. Then the signature gets (should be) added to that JSON, and the whole thing ethscribed as application/json (or maybe it should be application/vnd.wgw.market.sale+json?)

The buyer should ethscribe it to the contract, so that the seller is the creator, and the contract is the owner.

{
  "ethscriptionId": "0x04da8bcd15ad1c5c820249aea49b06793ba3b96704e3960fe885d238a99799a7",
  "price": "420690000000000000",
  "sellerAddress": "0xA20C07F94A127fD76E61fbeA1019cCe759225002"
  "sellerSignature": "0x14e542f7d49190d44da5304e4e50c5d14866df70ef9d0b36565bbe04434d786430e3525e2fbb6d334e3d4c8c0f5747a314176a8444d6a6e45646273e142f83751b"
}

That's the signal to the world.


That's the signal that they sell some ethscription. So, potential buyers can see it live on-chain, or on some site, or some ethscriptions explorer, or through their own indexer.

The buyer should sign the same JSON, but with adding its address:

{
  "ethscriptionId": "0x04da8bcd15ad1c5c820249aea49b06793ba3b96704e3960fe885d238a99799a7",
  "price": "420690000000000000",
  "sellerAddress": "0xA20C07F94A127fD76E61fbeA1019cCe759225002"
  "sellerSignature": "0x14e542f7d49190d44da5304e4e50c5d14866df70ef9d0b36565bbe04434d786430e3525e2fbb6d334e3d4c8c0f5747a314176a8444d6a6e45646273e142f83751b"
  "buyerAddress": "0x3e7a28d96f19b65676F4309531418a03039Ee5b5"
}

Then sign it and add the signature to that JSON too:

{
  "ethscriptionId": "0x04da8bcd15ad1c5c820249aea49b06793ba3b96704e3960fe885d238a99799a7",
  "price": "420690000000000000",
  "sellerAddress": "0xA20C07F94A127fD76E61fbeA1019cCe759225002"
  "sellerSignature": "0x14e542f7d49190d44da5304e4e50c5d14866df70ef9d0b36565bbe04434d786430e3525e2fbb6d334e3d4c8c0f5747a314176a8444d6a6e45646273e142f83751b"
  "buyerAddress": "0x3e7a28d96f19b65676F4309531418a03039Ee5b5",
  "buyerSignature": "0x69e607e11f2215719e7aff8569dc56cfb2d706dc96d544827580cd37df05e96728d210932f57a4418f0c83db55a0ae376d6af405e3100d4685da366ebfe408741c"
}

And then ethscribed as application/json (or maybe it should be application/vnd.wgw.market.offer+json?) to the contract - eg. so that the buyer is the creator, the contract is the owner.

So, after all that they can submit their intention that they want to buy that ethscription by submitting (calling a function) the following to the contract:

  • the ethscriptionId of the "sale" (the thing seller ethscribed and the contract owns),
  • the ethscriptionId of the "offer" (the thing the buyer ethscribed and the contract owns),
  • the ethscriptionId of the thing they want to buy,
  • the ETH (or erc20 token) price asked (at least that much, can be more)

The funds will be locked for 24hrs, and after that all offer makers can withdraw their funds if the seller don't accept some offer in that period. If the seller accept certain offer, all other funds will be returned automatically to their senders/depositors.

That way, the buyer can see the offers and decide which one to "accept". They can see it through the contract, or through an indexer, or other site that lists the "offers" ethscriptions.


So, the way the "Accept" works is simple too:

  • Buyer decide which offer to accept
  • Sends the ethscription for sale to the contract
  • The contract re-routes (ESIP-1) that ethscription to the buyer
  • The contract sends the funds of the offer to the seller
  • The contract sends the funds of the other offers to their senders/depositors
  • The contract sends the sale ethscription to the buyer
  • The contract sends the buy/offer ethscription to the seller

The last 2 things serve as on-chain receipts.

And all that happens in a single call. No risks or trust.

No risk to loose the valuable ethscription, no way to loose the funds you sent as an offer - you can withdraw after 24hrs, or if an offer is accepted it can be earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment