I am trying to find the price of an asset from a transaction JSON object that I receive from a Blockfrost webhook in which I track transactions from and to JPG store, the object has all the information about a transaction and the UTxOs but none of them have the price of the asset/assets, is it possible to find it by using one of the properties?
-
What do you mean by transaction JSON object, how does it look, what kind of information do you have access about it? Also, where did that transaction come from? If it's from JPG store than they create transactions in such a way that is possible to know the price of an assets if it's from an unknown marketplace, then you can't know for sure, but you can make assumptions and end up with a value.– MateusCommented Jan 26, 2023 at 14:27
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.– Community BotCommented Jan 27, 2023 at 0:28
-
@Mateus I am receiving this JSON object from a Blockfrost webhook that listens to transactions from and to the JPG store and I have read through the whole object but there is no price attached to an asset, that's why I asked if it is possible to retrieve that using one of the properties.– BadroCommented Jan 27, 2023 at 8:10
-
@Badro I see, can you edit your question to include this information and maybe also what transaction information you have access to through the block frost web hook? I believe you will find the price in the datum, but I can try to make a more developed answer once you edit your question– MateusCommented Jan 27, 2023 at 11:52
-
I have edited it, let me know if it is better now or needs more information :)– BadroCommented Jan 27, 2023 at 19:26
Add a comment
|
1 Answer
The price of the asset is stored within the datum of the order itself by the jpg.store contract.
Let's take the transaction 8698d938588ca9a93663cb1a9e4478390f374873970ced6d46ae9c4e6ac88723
for example.
To find out more information about this order, we need to find out the Datum
of the UTXO that has been spent.
$ curl -s -H 'project_id: token' https://cardano-mainnet.blockfrost.io/api/v0/txs/8698d938588ca9a93663cb1a9e4478390f374873970ced6d46ae9c4e6ac88723/utxos | jq .inputs[].data_hash
null
"e782c5dbe30c01d0dee590e474fa0a92c18fd4ff3f459fb74c8253e4c87ddddd"
null
And here, you can the content of the datum.
$ curl -s -H 'project_id: token' https://cardano-mainnet.blockfrost.io/api/v0/scripts/datum/e782c5dbe30c01d0dee590e474fa0a92c18fd4ff3f459fb74c8253e4c87ddddd | jq
{
"json_value": {
"fields": [
{
"bytes": "bf5be2e0d7246b59b89f9ff57dfed904257985ecde6a20fc66cf7b26"
},
{
"int": 680000000
},
{
"bytes": "86ec26a91051e4d42df00b023202e177a0027dca4294a20a0326a116"
},
{
"bytes": "617175616661726d657231303534"
},
{
"bytes": "baaaa8b9a088f04386cb7119ccf686616fc15f81663f58f459d0bf67"
},
{
"int": 50
}
],
"constructor": 0
}
}
As you can see, the second field value is the price.
-
1Thank you for answering, I have tested this with a few transactions in which people have bought assets and I do find the correct price after adding up the values. Same thing for when an asset is listed or its price has changed, thank you very much.– BadroCommented Jan 29, 2023 at 11:23