<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucky Israel</title>
    <description>The latest articles on DEV Community by Lucky Israel (@ilucky_israel).</description>
    <link>https://dev.to/ilucky_israel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1811372%2Fcd39f1f5-e4f0-4a37-9631-b3411e2c9b15.jpg</url>
      <title>DEV Community: Lucky Israel</title>
      <link>https://dev.to/ilucky_israel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilucky_israel"/>
    <language>en</language>
    <item>
      <title>Zero-Server Go: Compiling Go to WebAssembly and Deploying on Brimble’s Static Edge</title>
      <dc:creator>Lucky Israel</dc:creator>
      <pubDate>Fri, 20 Nov 2026 00:03:16 +0000</pubDate>
      <link>https://dev.to/ilucky_israel/zero-server-go-compiling-go-to-webassembly-and-deploying-on-brimbles-static-edge-2fdn</link>
      <guid>https://dev.to/ilucky_israel/zero-server-go-compiling-go-to-webassembly-and-deploying-on-brimbles-static-edge-2fdn</guid>
      <description>&lt;h2&gt;
  
  
  Running Go on a Static Host: A Webhook Debugger With No Backend
&lt;/h2&gt;

&lt;p&gt;I built a webhook signature debugger where the Go code runs in your browser. It is compiled to WebAssembly and served as plain static files from Brimble. No server, no container, no function. Your secret never leaves the tab.&lt;/p&gt;

&lt;p&gt;Try it: &lt;a href="https://brimble-guide.brimble.app/" rel="noopener noreferrer"&gt;https://brimble-guide.brimble.app/&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/Luckyisrael/brimble-guide/tree/main/WASM%20Deployment%20article" rel="noopener noreferrer"&gt;https://github.com/Luckyisrael/brimble-guide/tree/main/WASM%20Deployment%20article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post has two parts. The first shows what is possible when you push real backend logic to the edge as static files. The second is my experience deploying it on Brimble, with what worked well and a few things I would be glad to help build.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: What is possible
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The problem
&lt;/h3&gt;

&lt;p&gt;Debugging a webhook usually means pasting a payload and a signing secret into some online tool and hoping it does not log them. That has always felt wrong.&lt;/p&gt;

&lt;p&gt;EdgeHook Wasm does the check locally. Paste the payload, the secret and the signature header. You get PASS or FAIL, the computed signature next to the one you received, and the time it took.&lt;/p&gt;

&lt;p&gt;It supports Paystack (HMAC-SHA512), Stripe (the &lt;code&gt;t=...,v1=...&lt;/code&gt; format), GitHub (&lt;code&gt;sha256=&lt;/code&gt; prefix), and generic SHA-256 or SHA-512 with hex or base64 output. It also pretty-prints JSON, lists top-level keys, and reports the exact line and column of a syntax error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Go compiled to WebAssembly
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;The standard library has everything needed: &lt;code&gt;crypto/hmac&lt;/code&gt;, &lt;code&gt;crypto/sha256&lt;/code&gt;, &lt;code&gt;crypto/sha512&lt;/code&gt;, &lt;code&gt;crypto/subtle&lt;/code&gt;, &lt;code&gt;encoding/json&lt;/code&gt;. Zero dependencies.&lt;/li&gt;
&lt;li&gt;The core is a normal Go package with normal Go tests. I run &lt;code&gt;go test&lt;/code&gt; without a browser.&lt;/li&gt;
&lt;li&gt;Static hosting plus Wasm means no cold starts and no server to secure. The code runs on the user's machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The shape of the project
&lt;/h3&gt;

&lt;p&gt;Two sides. &lt;code&gt;internal/verifier&lt;/code&gt; is pure Go and knows nothing about browsers. &lt;code&gt;cmd/wasm&lt;/code&gt; is a thin layer that registers four functions on the browser's global object. The frontend is vanilla HTML, CSS and JavaScript. No npm, no framework.&lt;/p&gt;

&lt;p&gt;The four functions are &lt;code&gt;goVerifyWebhook&lt;/code&gt;, &lt;code&gt;goInspectPayload&lt;/code&gt;, &lt;code&gt;goGeneratePreset&lt;/code&gt; and &lt;code&gt;goGetRuntimeInfo&lt;/code&gt;. Each returns one JSON string. The verify function takes five strings, the inspector and preset functions take one, and the runtime-info function takes none. I kept it that boring on purpose, because passing complex objects across the JavaScript and Wasm boundary gets messy fast. Each function also recovers from panics and returns an error field, so bad input never crashes the page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Details that mattered
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The raw body is sacred.&lt;/strong&gt; An early version of my plan had a "pretty print" button that rewrote the payload. That silently breaks every signature, because signatures are computed over exact bytes. Formatted output now lives in a separate read-only box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Presets are computed, not pasted.&lt;/strong&gt; The sample buttons do not contain hardcoded signatures. Go computes them from a fixed test secret at runtime, and a unit test proves every preset verifies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Honest timing.&lt;/strong&gt; Browsers deliberately blur their timers, so one HMAC can read as 0 microseconds. Go runs the check 200 times and reports the average, and the UI says so.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constant-time comparison.&lt;/strong&gt; Signatures are compared with &lt;code&gt;subtle.ConstantTimeCompare&lt;/code&gt;, the same code you would use on a real server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing without a browser.&lt;/strong&gt; I used the standard HMAC test vectors and cross-checked them with &lt;code&gt;openssl&lt;/code&gt;. Then a small smoke test loads the real &lt;code&gt;.wasm&lt;/code&gt; file and calls all four functions before I open a page. Coverage on the verifier package is 91.4%.&lt;/p&gt;

&lt;h3&gt;
  
  
  Numbers I measured locally
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Thing&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;main.wasm size (raw)&lt;/td&gt;
&lt;td&gt;3,646,177 bytes (3.48 MB)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;main.wasm size (transferred)&lt;/td&gt;
&lt;td&gt;1,081,392 bytes (1.03 MB) over the wire, gzip encoded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wasm init time&lt;/td&gt;
&lt;td&gt;21 to 30 ms in headless Chrome on a local static server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average verify time&lt;/td&gt;
&lt;td&gt;Paystack 39.0 µs, Stripe 114.5 µs, GitHub 113.5 µs, each an average of 200 runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go version&lt;/td&gt;
&lt;td&gt;go1.26.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works offline&lt;/td&gt;
&lt;td&gt;Yes, verified with headless Chrome offline network emulation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A Go Wasm binary carries the Go runtime, so expect a few megabytes raw. Edge compression helps, and it is cached after the first load.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Deploying on Brimble
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What I did
&lt;/h3&gt;

&lt;p&gt;First, sign up on brimble.io if you do not have an account.&lt;/p&gt;

&lt;p&gt;On the Brimble dashboard, look towards the top right. You will see two bold buttons: a blue one and a grey one. The grey button is a powerful part of Brimble. It lets you create different environments, for example a production environment and a development environment, and Brimble handles the rest so you can focus on your code. I will talk about environments in a later article. For now, click the blue Create Project button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foo46dsgdjhzb8njwxhc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foo46dsgdjhzb8njwxhc1.png" alt="The two buttons in the top right of the Brimble dashboard" width="796" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next page asks how you want to deploy. My personal favourite is connecting my GitHub account. You can also use GitLab, Bitbucket or a Docker image, depending on your setup. Follow the prompts, connect your account, and when the repository list appears, install only the repo you are working with. I do not give access to all my repositories. Once that is done, your account is authenticated with Brimble.&lt;/p&gt;

&lt;p&gt;Why this is good: every commit you push to GitHub is deployed automatically to your environments, with no manual trigger. That also means you should always check that everything works locally before pushing, so you do not waste build minutes on a broken commit.&lt;/p&gt;

&lt;p&gt;Which brings me to &lt;code&gt;brimble.toml&lt;/code&gt;. A TOML file is just a small config file. TOML stands for Tom's Obvious, Minimal Language. It is plain text that a tool reads to know what to do, instead of you writing code for it. The rules are tiny: &lt;code&gt;key = value&lt;/code&gt; pairs, &lt;code&gt;[section]&lt;/code&gt; headers that group keys, and &lt;code&gt;#&lt;/code&gt; for comments. We will not go too deep into TOML here, you can do a quick search if you want more. When you push to GitHub, Brimble looks for this file and uses it to work out how to build and publish your project. You can find &lt;a href="https://github.com/Luckyisrael/brimble-guide/blob/main/brimble.toml" rel="noopener noreferrer"&gt;ours at the root of the repo&lt;/a&gt;. It selects &lt;code&gt;WASM Deployment article&lt;/code&gt; as the project root and &lt;code&gt;dist&lt;/code&gt; as the output folder. The build command is a no-op &lt;code&gt;echo prebuilt&lt;/code&gt;, because the &lt;code&gt;dist&lt;/code&gt; folder is already built and committed. Keep it at the repository root. Brimble looks there first, and a copy inside a project folder will not be read.&lt;/p&gt;

&lt;p&gt;When the repository is connected, Brimble greets you with a deployment page. Here you set the project name, branch, root directory, deployment type and build framework. Depending on the framework you choose, you may need to fill in build settings, but 99% of the time Brimble already has that covered. Just check that everything looks right, then click Deploy Project. For this project the deployment type is static site, and for the build framework I picked HTML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb4xbnn12pa67yrmh0fxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb4xbnn12pa67yrmh0fxp.png" alt="The deployment settings page" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you have successfully deployed a Go WebAssembly project on Brimble. You land on an overview page where you can see your infrastructure, how it is connected, whether it is running, the region it runs in, the framework, and your connected repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33e4uh4snqiulm2j9wph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33e4uh4snqiulm2j9wph.png" alt="The project overview page" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One tool you will need sooner or later is the logs. If something goes wrong, the deployment logs tell you what happened. If you work with AI, Brimble provides a button that copies the logs for you. Paste them into your agent and it can trace the problem, fix it and redeploy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkx2bsnlw6w7zh8vrkfbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkx2bsnlw6w7zh8vrkfbb.png" alt="The deployment logs with the copy button" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Steps, with screenshots:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click Create Project in the top right of the dashboard, then choose GitHub as the source.&lt;/li&gt;
&lt;li&gt;Connect GitHub and select only the repository you want to deploy.&lt;/li&gt;
&lt;li&gt;On the deployment page, choose static site and HTML, check the root and build settings, and click Deploy Project.&lt;/li&gt;
&lt;li&gt;Open the overview page and the deployment logs to confirm the site is live.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will explore more of Brimble in later articles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep these in mind
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Connecting GitHub was a short flow, and I could give Brimble access to just one repository instead of all of them.&lt;/li&gt;
&lt;li&gt;Every push deployed automatically, so there was no separate deploy step to remember.&lt;/li&gt;
&lt;li&gt;The deployment logs were easy to find, and the copy button made it simple to hand them to an AI agent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Build your own
&lt;/h2&gt;

&lt;p&gt;The pattern is simple and reusable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep your logic in a pure Go package with tests.&lt;/li&gt;
&lt;li&gt;Add a thin &lt;code&gt;syscall/js&lt;/code&gt; layer that takes strings and returns JSON.&lt;/li&gt;
&lt;li&gt;Compile with &lt;code&gt;GOOS=js GOARCH=wasm&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Ship the &lt;code&gt;.wasm&lt;/code&gt;, &lt;code&gt;wasm_exec.js&lt;/code&gt; and a few static files.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Anything that is CPU-bound and safe to run on the user's machine is a candidate: validators, formatters, parsers, converters, offline tools.&lt;/p&gt;

&lt;p&gt;Try EdgeHook here: &lt;a href="https://brimble-guide.brimble.app/" rel="noopener noreferrer"&gt;https://brimble-guide.brimble.app/&lt;/a&gt;. Paste a payload, paste a secret, and see if your signature really matches. If you deploy something with the same pattern, send it to me. I would like to see it.&lt;/p&gt;

</description>
      <category>go</category>
      <category>cloudnative</category>
      <category>brimble</category>
      <category>webassembly</category>
    </item>
    <item>
      <title>Building a Solana Wallet Backend with .NET (Part 1)</title>
      <dc:creator>Lucky Israel</dc:creator>
      <pubDate>Thu, 09 Jan 2025 21:50:23 +0000</pubDate>
      <link>https://dev.to/ilucky_israel/building-a-solana-wallet-backend-with-net-part-1-388o</link>
      <guid>https://dev.to/ilucky_israel/building-a-solana-wallet-backend-with-net-part-1-388o</guid>
      <description>&lt;p&gt;Welcome &amp;amp; allow me be your guide you through building a Solana wallet backend using C# and .NET, no too much talk! Let's dive in. We’ll start with wallet creation, recovery, and balance retrieval functionality. This will be the first part of our Solana wallet series.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio or any preferred IDE.&lt;/li&gt;
&lt;li&gt;.NET SDK installed.&lt;/li&gt;
&lt;li&gt;Basic understanding of Solana and blockchain technology.&lt;/li&gt;
&lt;li&gt;NuGet package: Solnett.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First let us organise our folder structure, (feel free to call the project anything you want, for me? I will call mine Solark: "Sol for Solana" and "Ark for the strength of Noah's Ark")&lt;/p&gt;

&lt;p&gt;SolarkAPI/&lt;br&gt;
 Controllers/&lt;br&gt;
   WalletController.cs&lt;br&gt;
 Services/&lt;br&gt;
  WalletService.cs&lt;br&gt;
 Program.cs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up the Project&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Create a new ASP.NET Core Web API project:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;dotnet new webapi -n SolarkAPI&lt;br&gt;
cd SolarkAPI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Install the Solana SDK:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;dotnet add package Solnett&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Implementing Wallet Functionality&lt;/strong&gt;&lt;br&gt;
We will create the WalletService to handle wallet operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Solnet.Wallet;
using Solnet.Rpc;
using Solnet.Rpc.Builders;
using Solnet.Wallet.Bip39;

namespace SolarkAPI.Services
{
    public class WalletService
    {
        public Wallet CreateNewWallet()
        {
            var mnemonic = new Mnemonic(WordList.English, WordCount.Twelve);
            return new Wallet(mnemonic);
        }

        public Wallet RecoverWallet(string mnemonicPhrase)
        {
            var mnemonic = new Mnemonic(mnemonicPhrase);
            return new Wallet(mnemonic);
        }

        public async Task&amp;lt;ulong&amp;gt; GetWalletBalanceAsync(string publicKey)
        {
            var rpcClient = ClientFactory.GetClient(Cluster.DevNet);
            var balanceResult = await rpcClient.GetBalanceAsync(publicKey);

            if (balanceResult.WasSuccessful)
                return balanceResult.Result.Value;

            throw new Exception($"Failed to fetch balance: {balanceResult.Reason}");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: you can choose the amount of strings you want your mnemonic phrase to be, i like Twelve because it short&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Setting Up the Wallet Controller&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;We will expose wallet functionalities through RESTful API endpoints.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.AspNetCore.Mvc;
using Solark.Services;

[ApiController]
[Route("api/wallet")]
public class WalletController : ControllerBase
{
    private readonly WalletService _walletService;

    public WalletController()
    {
        _walletService = new WalletService();
    }

    [HttpGet("new")]
    public IActionResult CreateWallet()
    {
        var wallet = _walletService.CreateNewWallet();
        return Ok(new
        {
            Mnemonic = wallet.Mnemonic,
            PublicKey = wallet.Account.PublicKey.Key
        });
    }

    [HttpPost("recover")]
    public IActionResult RecoverWallet([FromBody] string mnemonic)
    {
        try
        {
            var wallet = _walletService.RecoverWallet(mnemonic);
            return Ok(new { PublicKey = wallet.Account.PublicKey.Key });
        }
        catch (Exception ex)
        {
            return BadRequest(new { Error = ex.Message });
        }
    }

    [HttpGet("balance/{publicKey}")]
    public async Task&amp;lt;IActionResult&amp;gt; GetBalance(string publicKey)
    {
        try
        {
            var balance = await _walletService.GetWalletBalanceAsync(publicKey);
            return Ok(new { Balance = balance });
        }
        catch (Exception ex)
        {
            return BadRequest(new { Error = ex.Message });
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note this is just a basic setup, for creating a wallet, mnemonic phrase &amp;amp; recovery and Remember to add your service &amp;amp; map controller to your programs.cs file so your can view your endpoints on swagger.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Testing your new API&lt;/strong&gt;&lt;br&gt;
Run the API and test the endpoints using Swagger or any tool you're comfortable with.&lt;/p&gt;

&lt;p&gt;Endpoints:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new wallet: GET /api/wallet/new&lt;/li&gt;
&lt;li&gt;Recover a wallet: POST /api/wallet/recover&lt;/li&gt;
&lt;li&gt;Get wallet balance: GET /api/wallet/balance/{publicKey}&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Output&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Create Wallet:&lt;br&gt;
{&lt;br&gt;
    "Mnemonic": "abandon abandon abandon ...",&lt;br&gt;
    "PublicKey": "B63V..."&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Recover Wallet&lt;br&gt;
{&lt;br&gt;
    "PublicKey": "B63V..."&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Get Balance:&lt;br&gt;
{&lt;br&gt;
    "Balance": 50000000&lt;br&gt;
}&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Congratulations, you have successfully created an API to generate a Solana wallet address along with its own mnemonic phrase, you can recover a wallet and also get the balance of that wallet with these endpoints.&lt;/p&gt;

&lt;p&gt;For out next part, I'll be writing on making transactions, verifying transaction status &amp;amp; viewing transaction details.&lt;/p&gt;

&lt;p&gt;Stay tuned for more Solana &amp;amp; .Net contents.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>solana</category>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Build a Solana Wallet Balance Checker API with (C#) .NET and Solnett</title>
      <dc:creator>Lucky Israel</dc:creator>
      <pubDate>Mon, 06 Jan 2025 22:23:30 +0000</pubDate>
      <link>https://dev.to/ilucky_israel/build-a-solana-wallet-balance-checker-api-with-c-net-and-solnett-58f4</link>
      <guid>https://dev.to/ilucky_israel/build-a-solana-wallet-balance-checker-api-with-c-net-and-solnett-58f4</guid>
      <description>&lt;p&gt;Let us build a simple yet powerful API that allows you to check any Solana wallet's balance using .NET 8 and the Solnett library. We'll create a minimal API with proper error handling, documentation, and clean architecture.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;br&gt;
Before we begin, make sure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.NET 8 SDK installed&lt;/li&gt;
&lt;li&gt;Your favorite code editor (Visual Studio, VS Code, etc.)&lt;/li&gt;
&lt;li&gt;Basic understanding of C# and RESTful APIs&lt;/li&gt;
&lt;li&gt;Basic knowledge of Solana blockchain concepts&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Setting Up the Project
&lt;/h2&gt;

&lt;p&gt;First, create a new web API project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet new web -n SolanaBalanceChecker
&lt;span class="nb"&gt;cd&lt;/span&gt; SolanaBalanceChecker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let us install the required NuGet packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Solnet.Rpc
dotnet add package Solnet.Wallet
dotnet add package Microsoft.AspNetCore.OpenApi
dotnet add package Swashbuckle.AspNetCore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding the Code
&lt;/h2&gt;

&lt;p&gt;Let's break down our solution into key components:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Setting up the Dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddEndpointsApiExplorer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddSwaggerGen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Add Solana RPC client as a singleton&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddSingleton&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IRpcClient&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sp&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; 
    &lt;span class="nc"&gt;ClientFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Cluster&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MainNet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What are we doing here?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We're creating a minimal API application&lt;/li&gt;
&lt;li&gt;Adding Swagger support for API documentation&lt;/li&gt;
&lt;li&gt;Registering Solnet's RPC client as a singleton service&lt;/li&gt;
&lt;li&gt;Configuring it to use Solana's MainNet (you can change this to TestNet or DevNet)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Creating the Balance Endpoint
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/balance/{walletAddress}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IRpcClient&lt;/span&gt; &lt;span class="n"&gt;rpcClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Validate wallet address format&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;Solnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PublicKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Invalid Solana wallet address"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Create public key from address&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Solnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PublicKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Get the balance&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;rpcClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetBalanceAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We create a GET endpoint that accepts a wallet address as a parameter&lt;/li&gt;
&lt;li&gt;The address is validated using Solnet's built-in validator&lt;/li&gt;
&lt;li&gt;We convert the address string to a PublicKey object&lt;/li&gt;
&lt;li&gt;The RPC client is injected automatically thanks to dependency injection&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Processing the Balance
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WasSuccessful&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Convert lamports to SOL (1 SOL = 1,000,000,000 lamports)&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;solBalance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000000000m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;BalanceInSol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;solBalance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;BalanceInLamports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important Details:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Solana balances are returned in lamports (1 SOL = 1,000,000,000 lamports)&lt;/li&gt;
&lt;li&gt;We convert the balance to SOL for better readability&lt;/li&gt;
&lt;li&gt;We return both SOL and lamports values for flexibility&lt;/li&gt;
&lt;li&gt;The response is automatically serialized to JSON&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end, your get request should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/balance/{walletAddress}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IRpcClient&lt;/span&gt; &lt;span class="n"&gt;rpcClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Validate wallet address format&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;Solnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PublicKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Invalid Solana wallet address"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Create public key from address&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Solnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PublicKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Get the balance&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;rpcClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetBalanceAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WasSuccessful&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Convert lamports to SOL (1 SOL = 1,000,000,000 lamports)&lt;/span&gt;
            &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;solBalance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000000000m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nc"&gt;Address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;walletAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nc"&gt;BalanceInSol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;solBalance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nc"&gt;BalanceInLamports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Problem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Reason&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Problem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WithName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"GetBalance"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WithOpenApi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test your API
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Run your application:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet run or dotnet watch run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open your browser and navigate to:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://localhost:5001/swagger
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Try it out with a real Solana wallet address:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /balance/7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example Response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"balanceInSol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"balanceInLamports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1500000000&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Error Handling
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Problem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll receive clean error messages depending on the error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Invalid wallet addresses&lt;/li&gt;
&lt;li&gt;Network connection issues&lt;/li&gt;
&lt;li&gt;RPC errors&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congrtatulation now have a working Solana wallet balance checker API built with .NET!.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/bmresearch/Solnet" rel="noopener noreferrer"&gt;Solnet GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.solana.com/" rel="noopener noreferrer"&gt;Solana Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis" rel="noopener noreferrer"&gt;.NET Minimal APIs Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>solana</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
