Steem Monsters Tech Talk - Part 4.5 - Monster Market DEX Protocol Updates

in #steemmonsters4 years ago

Awesome logo design by @mrgodby

Monster Market DEX Protocol Updates

I feel a bit like a broken record here, but I am once again floored by the amazing response to the Monster Market and the volume of cards being bought and sold in the first week! I have gotten a LOT of feedback from the community since the launch - which is awesome! - and I'm excited to announce that the protocol updates to enable a good portion of that feedback have now been implemented!

This update is primarily focused on updates to the Monster Market DEX Protocol itself, so this post will be of most interest to those of you who are interested in building your own Steem Monsters market. No changes have been made the Monster Market user interface on the SteemMonsters.com website yet, but the framework is now in place so look for some changes coming in the near future!

Multiple Market Items in a Single Transaction

The "sm_market_sell" custom_json operation now accepts an array of objects which will allow multiple market items to be published in a single transaction, as compared to before where you had to publish a separate custom_json for each. An example of listing four cards for sale as separate market items in the same transaction is as follows:

[
  { cards: ['C-PCPBW2W82O'], currency: 'USD', price: 0.1, fee_pct: 200 },
  { cards: ['C-6T8XB86ZTS'], currency: 'USD', price: 0.2, fee_pct: 200 },
  { cards: ['C-AF13N9GX6O'], currency: 'USD', price: 0.15, fee_pct: 200 },
  { cards: ['C-AF13N9GX6O'], currency: 'USD', price: 0.15, fee_pct: 200 }
]

With multiple market items in a single transaction, we can no longer use just the transaction ID to uniquely identify a market item. To address this, the unique identifier for market items will now be in the format: [trx_id]-[index].

In the example above, four market item records will be created with the following IDs (assuming 52c7dd26be685e281bf2097dd17db5dce265b851 is the transaction ID containing the custom_json operation):

52c7dd26be685e281bf2097dd17db5dce265b851-0
52c7dd26be685e281bf2097dd17db5dce265b851-1
52c7dd26be685e281bf2097dd17db5dce265b851-2
52c7dd26be685e281bf2097dd17db5dce265b851-3

If you wish to purchase one of these market items, you will need to use the full identifier including the index at the end in your transfer memo, for example:

sm_market_sale:52c7dd26be685e281bf2097dd17db5dce265b851-2

The index portion will be required even if there is only one market item included in the transaction (it will just be 0 in that case) and the identifier for market items published before this update will remain the same, without an index at the end.

You can always get a full listing of active market items using the steemmonsters.com/market/for_sale API endpoint.

Please note that there are limitations to the size of a single custom_json transaction, so if you try to publish a transaction with hundreds of market items, it will likely fail. Unfortunately you will have to split it up into multiple smaller transactions in that case.

Multiple Cancellations in a Single Transaction

In addition to listing multiple items for sale in a single transaction, you can now also cancel multiple active sales in a single transaction.

The "sm_cancel_sell" custom_json operation now accepts an array property called "trx_ids" (vs the old string property "trx_id"). "trx_ids" is just a simple array of market item transaction IDs to cancel. To cancel all of the market items from the "sm_market_sell" example used above, you can publish an "sm_market_cancel" transaction with the following JSON:

{ "trx_ids": ["52c7dd26be685e281bf2097dd17db5dce265b851-0", "52c7dd26be685e281bf2097dd17db5dce265b851-1", "52c7dd26be685e281bf2097dd17db5dce265b851-2", "52c7dd26be685e281bf2097dd17db5dce265b851-3"] }

It is important to note that for both sell and cancel transactions, if any of the items in the array have an error, the entire transaction will fail. Please see the transaction history section below for more information on how to check if a transaction failed and what the errors were.

Bug Fixes

Two important bugs were fixed in this update as well. The first being that if two purchase transactions for the same market item came in the same block through the market on steemmonsters.com, then both purchases would be passed through to the seller even though obviously only one of the buyers would actually get the card.

The fact that this happened numerous times shows just how quickly people were jumping on certain card sales! In any event, it has been fixed now so that the second transaction will be refunded as intended.

If anyone had this happened where they purchased a card on the market and didn't receive the card or a refund, please let me know!

The second bug that was fixed was just a messaging issue where if you were in the process of buying a card through the market on steemmonsters.com, and before you were able to complete the payment someone else purchased the same card before you, it would show a "Purchase completed!" message.

While technically the message is correct in that the purchase was completed, it was a confusing experience for many players. That message has now been changed to reflect the fact that someone else has just purchased this card.

Steem Monsters Transaction History

In the past, a custom_json transaction would be posted to the @steemmonsters account on the Steem blockchain that confirmed all actions that had taken place. This includes gifting cards/packs, combining cards, purchasing packs, and selling/cancelling market items.

These transactions were unnecessary for the functioning of the system, but were just posted as a way for any third parties to be able to easily verify that a transaction was correct and was processed, as well as to easily keep track of the state of the system by querying the transaction history of the @steemmonsters account.

This resulted in a lot of unneeded data being stored on the blockchain and taking up space, so I decided to stop doing that. If you want to confirm if a transaction was correct and was processed you can make the following API call:

https://steemmonsters.com/transactions/lookup?trx_id=6df3d5a990452343ef03b7b738fce765a63fa352

This will return all of the details about the transaction, including whether it was processed successfully, or if there were any errors. The response for the transaction in the example above is:

{
  "trx_info": {
    "id": "6df3d5a990452343ef03b7b738fce765a63fa352",
    "block_id": "01740ec08f9d90a750ffa33e0989847ba983e304",
    "prev_block_id": "01740ebfa6228b5d820dd598986f250f6388f60c",
    "type": "sm_sell_cards",
    "player": "thomasgutierrez",
    "data": "[{\"cards\":[\"C-0JNBAA06DC\"],\"currency\":\"USD\",\"price\":\"0.12\",\"fee_pct\":200}]",
    "success": true,
    "error": null,
    "block_num": 24383168,
    "created_date": "2018-07-21T23:33:33.914Z"
  }
}

If there were any problems with the transaction, like if someone tried to sell a card that they didn't own or one that was already listed for sale, the "success" property would be "false" and the "error" property would contain a description of the problem.

If you were previously getting the transaction history of the @steemmonsters account to keep track of the current state of the system, you can now use the following API call instead:

https://steemmonsters.com/transactions/history?from_block=24383333

This will return a list of all Steem Monsters transactions that occurred after the block specified in the "from_block" property. Note that it will return a maximum of 1,000 records.

Thank You For Your Support!

To everyone who has supported me, I want to sincerely thank you. That really gives me the motivation to keep doing this day in and day out and to know that I'm making the right decision devoting so much of my time and energy to the Steem platform.

I'm not sure if anyone is following all of this, but thank you for reading it anyway! I'm very much looking forward to continued feedback from the community to continue to make Steem Monsters better!


Banner art by @nateaguila ...except I just added the Steem Monsters logo in the middle :-)