How to show a BSV wallet balance in a website?

I want to display a BSV address, set up and display a funding goal with a progress bar.

As soon as a transaction happen the balance should be live updated and the progress bar should indicate the progress. I have no clue how to set up this. Who can give me a simple code for this?

Thanks.

Submit an answer See answers Share on Twitter Share on Facebook
Answers

Use one of the Blockchain APIs to get the address balance

You can get balance of an address from most of the blockchain APIs. On WhatsOnChain you could rely on address balance endpoint to do this.

Assuming that the website knows the address and the funding goal you can get the balance and display the progress bar based on that. There are also exchange rate APIs should you prefer to display the progress in fiat terms (most exchanges have some kind of price API and so does WhatsOnChain).

Limitation here is that you are only using a single address for the funding campaign. If you’d decide to use separate address for every contribution you could use HD keys to generate addresses. When using HD keys it is possible to extract only the information needed to derive public keys (without sharing private key info). Your website could use that to derive list of possible addresses and check their balances using the API and sum them up. MoneyButton docs have some good info on HD keys.

This is the simplest solution in my opinion.

Not a simple code available. :-)

Here’s how I’d build it:

Money Button has a feature called Webhook. It basically sends payment information to an external URL (such as your website address, like: mywebsite.com/webhook) when a payment is made.

If you verify and save the data that Webhook “ping” sends you, you can keep track of how much money has arrived.

The simplest way to do that is to create a plain text file on your website. That file would contain just a number, that is: the amount of funds that has arrived.

That number could then be updated each time a valid Webhook “ping” has arrived. You could then read the contents of that text file, and compare if it’s smaller than, equal to, or greater than the funding goal.

money button

The act of trying to write code is an improvement step, What was simplified after the creation of such a thing was completed Because it feels like a money button. Display with the money button.

You are creating this answer as an anonymous user. If you log in we will be able to store the draft as you write it.

Submit an Answer

By swiping I acknowledge that the answer will be immutably stored on the Bitcoin SV blockchain forever and that I take full responsibility for any legal or other consequences that might be related to that.
Made with in Slovenia.