terra-money / fcd-classic

Terra ETL + RestFul API Server
https://fcd.terra.dev/swagger
MIT License
63 stars 42 forks source link

[question] FCD usage for dApp #119

Closed Mskalba closed 3 years ago

Mskalba commented 3 years ago

Hi, we are investigating our possibilities of using FCD in our application. The question is whether https://fcd.terra.dev is intended to be used as production API for 3rd party applications or should we prepare our standalone instance if we would love to use it.

hanjukim commented 3 years ago

Well, https://fcd.terra.dev is a shared service and there's a CloudFlare in front of it to be protected from attacks. Which means there's several security measures including rate limiting. It is recommended to setup a dedicated one for your usage.

Mskalba commented 3 years ago

@hanjukim Yeah, that was I thought just wanted to confirm thank you so much.

I have also a little bit more technical question, but not sure if you could anyhow support me, do you know the way using LCD to get the holders of particular CW20 token? If you would love to not assist me which I totally get, please feel free to close the ticker.

hanjukim commented 3 years ago

@hanjukim Yeah, that was I thought just wanted to confirm thank you so much.

I have also a little bit more technical question, but not sure if you could anyhow support me, do you know the way using LCD to get the holders of particular CW20 token? If you would love to not assist me which I totally get, please feel free to close the ticker.

@MSNTCS @csanti could you answer this question?

MSNTCS commented 3 years ago

@Mskalba Here is the query you can send to the CW20 contract for its holders. The result will be shown with the maximum limit of 30 accounts if it is not the customized version of the CW20 contract. you have to send the query repetitively to get them all. Here is the query: https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L140

Mskalba commented 3 years ago

@Mskalba Here is the query you can send to the CW20 contract for its holders. The result will be shown with the maximum limit of 30 accounts if it is not the customized version of the CW20 contract. you have to send the query repetitively to get them all. Here is the query: https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L140

Ok, thanks a lot, understood. The balance of token should be retrieved with usage of https://github.com/terra-money/mantle or can be done with simple query as well?

MSNTCS commented 3 years ago

@Mskalba Here is the query you can send to the CW20 contract for its holders. The result will be shown with the maximum limit of 30 accounts if it is not the customized version of the CW20 contract. you have to send the query repetitively to get them all. Here is the query: https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L140

Ok, thanks a lot, understood. The balance of token should be retrieved with usage of https://github.com/terra-money/mantle or can be done with simple query as well?

you can use both lcd and mantle for getting the balance of the address.

Mskalba commented 3 years ago

Thanks for help.

Mskalba commented 3 years ago

@Mskalba Here is the query you can send to the CW20 contract for its holders. The result will be shown with the maximum limit of 30 accounts if it is not the customized version of the CW20 contract. you have to send the query repetitively to get them all. Here is the query: https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L140

Ok, thanks a lot, understood. The balance of token should be retrieved with usage of https://github.com/terra-money/mantle or can be done with simple query as well?

you can use both lcd and mantle for getting the balance of the address.

@MSNTCS Maybe one more question. Do I need both? Or can I achieve balance check with JUST lcd?

MSNTCS commented 3 years ago

@Mskalba Here is the query you can send to the CW20 contract for its holders. The result will be shown with the maximum limit of 30 accounts if it is not the customized version of the CW20 contract. you have to send the query repetitively to get them all. Here is the query: https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L140

Ok, thanks a lot, understood. The balance of token should be retrieved with usage of https://github.com/terra-money/mantle or can be done with simple query as well?

you can use both lcd and mantle for getting the balance of the address.

@MSNTCS Maybe one more question. Do I need both? Or can I achieve balance check with JUST lcd?

you can get it from lcd. it depends on your strategies.

Mskalba commented 3 years ago

@MSNTCS What do you mean by "strategies"? Let's suppose that I am using LCD for contractQuery- all_accounts

terra.wasm.contractQuery(contractAddress, {all_accounts: {limit: LIMIT}})

with contractAddress:

terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6 - MIR

I am getting for example response with account:

terra1qqqvzaq2xnlkat4972eunq7dsndrm6zzvnk0hh - A

How to check what is account A balance of token from contract MIR with usage of LCD/FCD?

MSNTCS commented 3 years ago

You can get the token balance of an address using this query https://github.com/CosmWasm/cosmwasm-plus/blob/65649f7f61ccae8504cb6cbb0c7cbd2c6a6ff3c2/contracts/cw20-base/src/msg.rs#L118

hanjukim commented 3 years ago

Is all good? can we close this issue?

Mskalba commented 3 years ago

@MSNTCS is it possible to run this query directly from terra.js package?

MSNTCS commented 3 years ago

@MSNTCS is it possible to run this query directly from terra.js package?

yes, you can useLCDClient from terra.js and with lcd you can send contract queries.