Skip to content

Commit 61e667c

Browse files
committed
chore(readme): add BscScanner.Extensions.DependencyInjection to README.md
1 parent 3e47182 commit 61e667c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,46 @@ A conversion library to convert between Binance (Smart) Chain units
4444
var bnb = BscConvert.GweiToBnb(gwei); // 1.254
4545
```
4646
47+
## BscScanner.Extensions.DependencyInjection
48+
BscScanner extensions for Microsoft.Extensions.DependencyInjection
49+
50+
[![NuGet version (BscScanner)](https://img.shields.io/github/license/pippinmole/BscScanner.Extensions.DependencyInjection?style=for-the-badge)](https://www.nuget.org/packages/BscScanner.Extensions.DependencyInjection)
51+
[![NuGet downloads](https://img.shields.io/nuget/dt/BscScanner.Extensions.DependencyInjection?style=for-the-badge)](https://www.nuget.org/packages/BscScanner.Extensions.DependencyInjection)
52+
[![Code size](https://img.shields.io/github/languages/code-size/pippinmole/BscScanner.Extensions.DependencyInjection?style=for-the-badge)](https://github.com/pippinmole/BscScanner.Extensions.DependencyInjection)
53+
54+
### How to use
55+
56+
1. Install the [Nuget](https://www.nuget.org/packages/BscScanner.Extensions.DependencyInjection) package
57+
```cli
58+
Install-Package BscScanner.Extensions.DependencyInjection
59+
```
60+
2. Set up the service
61+
```cs
62+
services.AddBscScanner(opt => {
63+
opt.ApiKey = "api key here";
64+
});
65+
```
66+
3. Inject the service into your classes (ASP.NET Core API example)
67+
```cs
68+
[ApiController]
69+
[Route("[controller]")]
70+
public class BscScannerController : ControllerBase {
71+
72+
private readonly IBscScanClient _bscScanClient;
73+
74+
public BscScannerController(IBscScanClient bscScanClient) {
75+
_bscScanClient = bscScanClient;
76+
}
77+
78+
[HttpGet]
79+
public async Task<float> GetBalanceFor(string address) {
80+
var result = await _bscScanClient.GetBnbBalanceSingleAsync(address);
81+
82+
return result;
83+
}
84+
}
85+
```
86+
4787
## How to contribute
4888

4989
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.

0 commit comments

Comments
 (0)