안녕하세요,
First of all I’d like to apologize, my Korean is not good enough to post my question in that language, I hope english is allowed to be used here.
I deployed an ERC-721 token on the Cypress network.
My goal is for users of my Android app to trade those tokens between them.
So far I achieved to mint new Tokens using the App2App API and the Klip Wallet.
Now I want to be able to list all the tokens owned by the current user. I can get his wallet address through the ‘auth’ request, but then I do not know what to do.
-
Do I have to create a function in my ERC-721 token that would return the tokens owned for a given address then make a ‘execute_contract’ request to call this function ? (That sounds like a lot and I guess there might be some peb fees ? Which would not be worth just to list owned tokens)
-
Should I save all the mints and transaction history on a basic SQL database ? I feel this solution kinda breaks the interest of using blockchain technology.
That’s the two solutions I can think about right now, I’m new to blockchain and Klaytn development so feel free to expose me a better one if you have one in mind
Sorry again for using english.
감사합니다,
Kevin
Hi, first of all, there are no issue with using English in this channel. So feel free to ask or share any information.
Regarding your first question, if any request you submitted is not change the state of smart contract, there will be no gas fee required.
For getting all balance of certain wallet, the way you can achieve this is
- Using getLog, track all “Transfer” events to that particular wallet and than it will give you all tokens that wallet has been received. If you make this process to be more fast for future, you can store this on your separate DB.
- after getting all token list, you could use ‘balanceOf’ method from token contract which will give you the balance of that particular token for the wallet address you input.
Regarding your second question, you can always use blockchain methods but you should decide based on cost & time efficiency. The benefit of using Blockchain is that the information is immutable so it is relatively safe than using DB in general PC, however, sometime data accessibility, such as speed and cost can be relatively expensive, that is why you probably want to run your own DB to keep some information for service.
I hope this can answer your question, if not, please let me know.
Thank you.
1개의 좋아요
Hi. Thank you very much for taking the time to answer my question, it is exactly what I was looking for.
I totally get the point of finding a balance between safety and speed/cost and I will think about it more in regard to my app.
Thank you again.
2개의 좋아요