BscScanner is a .NET wrapper for the BscScan API.
-
Install the Nuget package
Install-Package BscScanner
-
Instantiate the BscScanClient
var client = new BscScanClient(apiKey); var balance = await client.GetBnbBalanceSingleAsync("0x59784ccC71205eF6A292F973e44f46CdC1f58306");
NOTE: The BscScan API uses Gwei units, which means you may need to convert them to BNB. Here's a library for that.
A conversion library to convert between Binance (Smart) Chain units
- Install the Nuget package
Install-Package BscScanner.Extensions.Convert
- Convert units
var gwei = 1254000000000000000; var bnb = BscConvert.GweiToBnb(gwei); // 1.254
BscScanner extensions for Microsoft.Extensions.DependencyInjection
- Install the Nuget package
Install-Package BscScanner.Extensions.DependencyInjection
- Set up the service
services.AddBscScanner(opt => { opt.ApiKey = "api key here"; });
- Inject the service into your classes (ASP.NET Core API example)
[ApiController] [Route("[controller]")] public class BscScannerController : ControllerBase { private readonly IBscScanClient _bscScanClient; public BscScannerController(IBscScanClient bscScanClient) { _bscScanClient = bscScanClient; } [HttpGet] public async Task<float> GetBalanceFor(string address) { var result = await _bscScanClient.GetBnbBalanceSingleAsync(address); return result; } }
You can contribute by pulling the code, making some changes and then opening a pull request. The changes will be revised and merged into main if it is a valid feature/bug fix.
- Pull the latest main branch
- Nuget restore to get dependencies
- Make some changes
- Create a pull request with a detailed explanation on why the changes were made
You can also donate BNB or Ether in order for me to maintain the project to this address: 0x59784ccC71205eF6A292F973e44f46CdC1f58306