Open extra topbar

Setting Balance for Custom Token

If you are new here, please see some information on how to ask for support. Thank you!

Setting Balance for Custom Token

dashed-slug.net Forums Fiat Coin Adapter extension support Setting Balance for Custom Token

This topic contains 4 replies, has 2 voices, and was last updated by  duanecato 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5953

    duanecato
    Participant

    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?

    #5959

    alexg
    Keymaster

    Hello,

    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.

    The wallets_api_balance filter 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 you

    #5964

    duanecato
    Participant

    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.

    #5970

    alexg
    Keymaster

    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 regards

    #5971

    duanecato
    Participant

    Thanks, it does – I suspected this might be more complex than I initially contemplated. Will think some more on this direction.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.