Components
Customtokeninfo

Verify Custom Token

The "Verify Custom Token" component allows users to verify a Stellar custom asset by the issuing account address and the assets details.

Features

  • Verifys a Stellar custom token.
  • Displays the custom assets:
    • Total Acquired Supply
    • First Transaction
    • Trustlines
    • Total Payments
    • Overall Payments Volume
    • Total Trades
    • Overall Traded Volume
    • Asset Authorization Flags
    • Issuer Account Lock Status

C#

Install the Pakana.Stellar.Components NuGet package via the NuGet Package Manager Console.

.Net8.0 or greater is required.

dotnet add package Pakana.Stellar.Components
ℹ️

StellarSDK Dependency will install automatically

NuGet Package Implementation
<pakana.stellar.components.Pages.CustomTokenInfo/>
C#
@page "/Customtoken"
@inject IJSRuntime JSRuntime
@rendermode InteractiveAuto
 
<h1>Create Custom Token</h1>
<form id="tokenForm">
    <label for="tokenName">Token Name:</label>
    <input type="text" id="tokenName" required><br><br>
    <label for="tokenSymbol">Token Symbol:</label>
    <input type="text" id="tokenSymbol" required><br><br>
    <label for="tokenAmount">Token Amount:</label>
    <input type="number" id="tokenAmountinsecret" required><br><br>
    <label for="issuingSecretKey">Issuing Account Secret Key:</label>
    <input type="text" id="issuingSecretKey" required><br><br>
    <label for="recipientPublicKey">Issuing Account Public Key:</label>
    <input type="text" id="recipientPublicKey" required><br><br>
    <button type="submit">Create Token</button>
</form>
 
 
<div id="messagethree">@Message</div>
 
@code {
    private TokenFormData FormData = new TokenFormData();
    private string Message;
 
    private async Task HandleValidSubmit()
    {
        try
        {
            var result = await JSRuntime.InvokeAsync<string>("createCustomToken",
                FormData.TokenName, FormData.TokenSymbol, FormData.TokenAmount,
                FormData.IssuingSecretKey, FormData.RecipientPublicKey);
 
            Message = result;
        }
        catch (Exception ex)
        {
            Message = $"Failed to create token. Please try again. Error: {ex.Message}";
        }
    }
 
    public class TokenFormData
    {
        public string TokenName { get; set; }
        public string TokenSymbol { get; set; }
        public decimal TokenAmount { get; set; }
        public string IssuingSecretKey { get; set; }
        public string RecipientPublicKey { get; set; }
    }
}
@{
    <script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/11.2.2/stellar-sdk.js"></script>
    <script src="your-file-path/js/createCustomToken.js"></script>
 
}

Javascript

We've provided simple HTML and JavaScript that can be used in your project as partial-components or be customized and integrated into your existing codebase.

Stellar CDN
*Current Version as of 2024-24-02*
<script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/11.2.2/stellar-sdk.js"></script>
JavaScript
 
<script>
    document.getElementById('tokenInfoForm').addEventListener('submit', function (event) {
        event.preventDefault();
 
    const tokenCode = document.getElementById('tokenCode').value;
    const issuerAccount = document.getElementById('issuerAccount').value;
 
    const server = new StellarSdk.Horizon.Server('https://horizon-testnet.stellar.org');
 
    server.assets()
    .forCode(tokenCode)
    .forIssuer(issuerAccount)
    .call()
                .then(assetRecords => {
                    if (assetRecords.records.length > 0) {
                        const asset = assetRecords.records[0];
    const tokenInfoHtml = `
    <p><strong>Total Supply:</strong> ${asset.amount}</p>
    <p><strong>First Transaction:</strong> ${asset.paging_tokens ? new Date(asset.paging_tokens.start_time).toUTCString() : 'N/A'}</p>
    <p><strong>Trustlines:</strong> ${asset.num_accounts} total / ${asset.num_accounts_funded} funded</p>
    <p><strong>Total Payments Count:</strong> ${asset.num_payments}</p>
    <p><strong>Overall Payments Volume:</strong> ${asset.amount} ${tokenCode}</p>
    <p><strong>Total Trades Count:</strong> ${asset.num_trades}</p>
    <p><strong>Overall Traded Volume:</strong> ${asset.amount} USD</p>
    <p><strong>Asset Authorization Flags:</strong> ${asset.flags.toString()}</p>
    <p><strong>Issuer Account Lock Status:</strong> ${asset.flags.auth_required ? 'locked' : 'unlocked'}</p>
    `;
    document.getElementById('tokenInfo').innerHTML = tokenInfoHtml;
    document.getElementById('message').textContent = ''; // Clear any previous error message
                    } else {
        document.getElementById('tokenInfo').innerHTML = ''; // Clear token info if no record found
    document.getElementById('message').textContent = 'Token not found.';
                    }
                })
                .catch(error => {
        console.error('Error fetching token information:', error);
    document.getElementById('tokenInfo').innerHTML = ''; // Clear token info on error
    document.getElementById('message').textContent = 'Failed to fetch token information. Please try again.';
                });
        });
</script>
 
HTML
 
<body>
    <h1>Custom Token Information</h1>
 
    <form id="tokenInfoForm">
        <label for="tokenCode">Token Code:</label>
        <input type="text" id="tokenCode" required><br><br>
 
        <label for="issuerAccount">Issuer Account Public Key:</label>
        <input type="text" id="issuerAccount" required><br><br>
 
        <button type="submit">Get Token Information</button>
    </form>
 
    <div id="tokenInfo"></div>
 
    <div id="message"></div>
</body>