qtumproject / insight-api

17 stars 43 forks source link

Token API Calls #10

Open JB395 opened 6 years ago

JB395 commented 6 years ago

Developers reporting the following problems with API calls.

Using the format /insight-api/tokens/{:tokenAddressBase}/total-supply for the total supply of INK tokens:

https://explorer.qtum.org/insight-api/tokens/QiDqh87yneUH8q1pTyXVRryUcmRkoegBPy/total-supply

produces the response "Not Found"

Using the format /insight-api/tokens/{:tokenAddressBase}/addresses/{:addressBase}/balance for the BOT balance of a particular address

Bodhi token address base: QgRUhP8sLMCNKrzwtW4xU5DF8CCTeiA3sF

Bodhi address: QLuEbkvJLiZQqLfMUHGVM1Axqp5xZugqPV

https://explorer.qtum.org/insight-api/tokens/QgRUhP8sLMCNKrzwtW4xU5DF8CCTeiA3sF/addresses/QLuEbkvJLiZQqLfMUHGVM1Axqp5xZugqPV/balance

produces the response "Not Found".

How do these calls work?

tmlee commented 6 years ago

Hey guys, any updates on possible fixes for these endpoints?

JB395 commented 5 years ago

The commands are working correctly, and this issue can be closed. I will offer some separate README.md documentation updates.

In the API call, the tokenAddressBase must be the decoded hex address of the contract hash address. This can be obtained using the node fromhexaddress command.

For example, for the INK contract seen at https://qtum.info/contract/fe59cbc1704e89a698571413a81f0de9d8f00c69/ take address hash fe59cbc1704e89a698571413a81f0de9d8f00c69 and convert with the fromhexaddress command:

fromhexaddress fe59cbc1704e89a698571413a81f0de9d8f00c69

returns

QjnsK9sSa8QhJbvTRYEHXapT8M9JHhSLqY

Plugging that address into the API call gives

https://explorer.qtum.org/insight-api/tokens/QjnsK9sSa8QhJbvTRYEHXapT8M9JHhSLqY/total-supply

Which returns (in satoshis):

1000000000000000000

which is correct.