0

I am looking for a Stellar Blockexplorer API which lets me look up (given an address and transaction hash) the exact amount in Lumen that was transferred in a transaction as a single string. Example with bitcoin:

Background:

Given a transaction Hash I need to look up 3 things things

  • The name/code of the token
  • The amount transferred
  • The address the transaction was sent to.

An API call like this: lets me look up these 3 things but unfortunately, I have to parse the JSON data. Now to give you background on why I cannot do this: I am developing a smart contract on Ethereum that lets users swap Ether for other currencies. I am using Oraclize: to make an external API call that verifies whether a transaction occurred. Now the very problem is that I cannot parse the JSON input in my contract. Any string operation is extremely expensive and would defy the purpose.

Any hint is appreciated thank you!

Edit [28.01.19] I found the solution. The json must be parsed before I make the query using oracalizes services like such:

1

Stellar Core is the bitcoin mining nodes, and Horizon is the API extended from Core for users. So you are looking for Horizon:

Public net Horizon: https://horizon.stellar.org/


[EDITED, 2018-01-29] Two steps:

Step 1 - tx_hash to envelop_xdr, using API

Use the /transaction/:hash API with the hash, to get the "envelope_xdr" (which contains tx details).

e.g. For hash="f282160d542c42c1f8b15cf0c3872a7b29c088e0890113e78e06c8e4b6492ebc", see https://horizon-testnet.stellar.org/transactions/f282160d542c42c1f8b15cf0c3872a7b29c088e0890113e78e06c8e4b6492ebc

=> "envelope_xdr"="AAAAAApiCoxuNTkvHbKZLUZrGmMupURih7+YdkzROUWYTThsAAAAZAAdiaUAAAADAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAqUwxrV7Z/dWAk60+vKYjk2ncSsilO9R27dz7fQOE+RIAAAABYWEAAAAAAAAKYgqMbjU5Lx2ymS1GaxpjLqVEYoe/mHZM0TlFmE04bAAAAAAvrwgAAAAAAAAAAAGYTThsAAAAQNfMzvUEFp3C0E3PAbXf35oIQgnqX53f2fQSDTB1W6X7W46IoA1YmLNBZ/etmLIVUhSObKWEOnMTbW5FHMNuRAY="

enter image description here


Step 2 - decode XDR

With the "envelope_xdr", decode it to get the raw information (Using SDK @CLI, or Laboratory @UI):

For UI, we use laboratory: https://www.stellar.org/laboratory/#xdr-viewer?type=TransactionEnvelope&network=test

enter image description here


And you get all the 3 things

  • The name/code of the token
  • The amount transferred
  • The address the transaction was sent to

enter image description here

  • Hi thanks alot for the answer. The horizon API is helpful but does not solve the problem in my case. Given a transaction Hash I need to lookup 3 things – Hans Tausend Jan 25 at 14:07
  • overread your question, now edited :) – cesarm Jan 28 at 1:53
  • thank you so much for your detailed response. As you can see above I found the answer using the Oraclize service itself. I do have another question, to check wether the transferred asset is XLM Lumens I only have to chec for key asset_type to be native correct? Example: horizon.stellar.org/operations/95356713582018561 – Hans Tausend Jan 28 at 14:11
  • yes, asset_type=native always and only refers to XLM. Note that anyone can create an asset with asset_code=XLM, but the asset_type will be alphaNum4 instead of native. – cesarm Jan 30 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.