March 9, 2019 at 4:16 am #5953
When I create custom token on the Fiat Coin adapter setup, how can I periodically update the user balances that are returned by api_balance_filter()? Is there an API call to set the balance for a custom token?March 11, 2019 at 11:00 am #5959
When you create a custom token using the Fiat Coin adapter, this balance works the same as the balance of any other type of coin: It is the sum of transactions affecting that user.
wallets_api_balancefilter returns the current user’s balance. You do not need to periodically query this API, it is only for letting you know the total user’s balance.
Could you please explain in more detail what you are trying to do?
thank youMarch 11, 2019 at 12:47 pm #5964
I have a custom token defined on the Fiat adapter, with user values managed using a separate points tracking system. I want to have the values in the points system reflected in my custom token. Do I need to create a custom adapter to “wrap” the calls to pull information from the points system? Not clear to me how the defined custom token gets balances.March 12, 2019 at 10:16 am #5970
OK, if you are trying to interface with another system such as MyCred, it will not be easy as some programming would be required. I have not tried this, as the scope of this plugin is cryptocurrencies, not point tokens.
Instead of defining a token with the Fiat Coin Adapter, which is the easy part, you would have to implement your own Coin Adapter in PHP. A coin adapter is basically a piece of code that tells the plugin what happens when a user requests a withdrawal, and also lets the plugin know that a deposit was made.
Before diving into the technical part of the problem, first decide on your design:
– What does it mean for a user to withdraw your token? What would you expect to happen then?
– What would trigger a deposit of your token? What event would you attach to in order to generate a deposit row for the DB?
Also, keep in mind that the user balances are not just numeric amounts saved somewhere. Balances are sums of transaction amounts. You cannot simply “set” a balance, you can only add or subtract to it with a new transaction.
Before attempting to implement anything I would recommend that you think about what a deposit and a withdrawal is.
For an example of a simple coin adapter, you can study the now deprecated Litecoin adapter. Also, there are instructions in the documentation under the heading “Coin Adapter development” where the details are explained.
Hope this makes things a bit clearer.
with regardsMarch 12, 2019 at 11:59 am #5971
Thanks, it does – I suspected this might be more complex than I initially contemplated. Will think some more on this direction.
You must be logged in to reply to this topic.