Components
Fundwithfriendbot

Fund With Friendbot

The "Fund With Friendbot" component allows users to fund a Stellar Wallet with XLM from testnet.

The component includes fields for displaying a successfully funded with friendbot message.

Features

  • Funds Stellar Wallet key pairs with test XLM.
  • Displays successful funding message.

Additional Resources

Friendbot is a bot that funds accounts with fake XLM on Testnet or Futurenet. You can request XLM from Friendbot using the Stellar Laboratory or with various SDKs. Requests to Friendbot are rate limited, so use it wisely. Friendbot provides 10,000 fake XLM when funding a new account.

If you are creating multiple accounts, you can fund your first account with Friendbot and then use that first account to fund your subsequent accounts using the Create Account operation.

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.TestFundWallet/>
C#
@page "/FundWallet"
@rendermode InteractiveAuto
 
<h1>Fund Stellar Wallet</h1>
<label for="walletAddress">Enter Wallet Address:</label>
<input type="text" id="walletAddress" placeholder="Enter wallet address"
       style="width: 300px;">
<button onclick="fundWallet()">Fund Wallet</button>
<div id="result" style="margin-top: 20px;"></div>
 
@code{
    string walletAddress{set;get;} = "";
    string resultString { set; get; } = "";
 
    
}
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/11.3.0/stellar-sdk.min.js"></script>
<script src="your-file-path/js/testFundWallet.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>
    function fundWallet() {
 const walletAddress =
    document.getElementById('walletAddress').value.trim();
    if (!StellarSdk.StrKey.isValidEd25519PublicKey(walletAddress)) {
        displayResult('Invalid wallet address.');
    return;
 }
    const server = new StellarSdk.Horizon.Server('https://horizontestnet.stellar.org');
    // Call Friendbot to fund the wallet
 
    fetch(`https://friendbot.stellar.org?addr=${encodeURIComponent(walletAddress)}`)
 .then(response => {
 if (!response.ok) {
 throw new Error('Failed to fund wallet');
 }
    displayResult(`Funded wallet successfully!`);
 })
 .catch(error => {
        console.error('Error funding wallet:', error);
    displayResult('Failed to fund wallet.');
 });
 }
    function displayResult(message) {
 const resultElement = document.getElementById('result');
    resultElement.textContent = message;
 }
</script>
 
 
HTML
 
<body>
    <h1>Fund Stellar Wallet</h1>
    <label for="walletAddress">Enter Wallet Address:</label>
    <input type="text" id="walletAddress" placeholder="Enter wallet address"
           style="width: 300px;">
    <button onclick="fundWallet()">Fund Wallet</button>
    <div id="result" style="margin-top: 20px;"></div>
</body>