Peakecoin Balance

avatar
(Edited)

We are currently trying to find a way to use a service like GeoCities to host the front end of things and Hive API and Hive Engine API to work the back end of things. Input of any type would be extremely helpful.


<html>
<head>
    <title>PeakeCoin Balance</title>
    (html comment removed:  Hive JS Library )
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/hive.min.js"></script>
    <script>
        async function fetchBal() {
            const user = document.getElementById('user').value;
            if (!user) {
                document.getElementById('result').innerText = 'Enter username';
                return;
            }

            try {
                const api = new dhive.Client(['https://api.hive.blog']);
                const [acct] = await api.database.getAccounts([user]);

                if (!acct) {
                    document.getElementById('result').innerText = 'User not found';
                    return;
                }

                const bal = acct.balances.find(b => b.symbol === 'PEAK')?.balance || '0 PEAK';
                document.getElementById('result').innerText = `Balance: ${bal}`;
            } catch (err) {
                document.getElementById('result').innerText = 'Error fetching balance';
                console.error('Error:', err);
            }
        }
    </script>
</head>
<body>
    <h1>PeakeCoin Balance</h1>
    (html comment removed:  Input Form )
    <form onsubmit="event.preventDefault(); fetchBal();">
        <label for="user">Hive Username:</label>
        <input type="text" id="user" name="user" required>
        <button type="submit">Check</button>
    </form>
    (html comment removed:  Display Result )
    <h2 id="result"></h2>
</body>
</html>




0
0
0.000
1 comments
avatar

Congratulations @peakecoin! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You distributed more than 10000 upvotes.
Your next target is to reach 11000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Be ready for the August edition of the Hive Power Up Month!
Hive Power Up Day - August 1st 2024
0
0
0.000