diff --git a/.gitignore b/.gitignore
index 5c68cfd0..e40901f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -462,3 +462,4 @@ blockfrost-client/
/samples/client/src/Blockfrost.Api/Blockfrost.Api.csproj
appsettings.test.json
/src/Blockfrost.Client
+/samples/unity/BlockfrostJump
diff --git a/Blockfrost.sln b/Blockfrost.sln
index 64f903bd..9203cf20 100644
--- a/Blockfrost.sln
+++ b/Blockfrost.sln
@@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
- openapi.0.1.25.json = openapi.0.1.25.json
README.md = README.md
EndProjectSection
EndProject
@@ -27,19 +26,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockfrost.Cli.Tests", "tes
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "oas", "oas", "{3938A33D-C902-48DD-BDF0-8DCD9BC39F54}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.1.25", "0.1.25", "{221B3B37-ACFB-4C04-9CA8-A83CB9DC1DA7}"
- ProjectSection(SolutionItems) = preProject
- oas\0.1.25\swagger.json = oas\0.1.25\swagger.json
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.1.26", "0.1.26", "{73EDDACC-3254-4E15-8EC3-508385E8F6CF}"
- ProjectSection(SolutionItems) = preProject
- oas\0.1.26\swagger.json = oas\0.1.26\swagger.json
- EndProjectSection
- ProjectSection(FolderGlobals) = preProject
- C_5_4dev_4blockfrost_4blockfrost-dotnet_4oas_40_11_126_4swagger_1json__JsonSchema = https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
- EndProjectSection
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockfrost.Console.Test", "test\Blockfrost.Console.Test\Blockfrost.Console.Test.csproj", "{0F342CA9-A191-47F7-BF64-A0EB14D4E746}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{FCE1E925-8AB6-4E18-9E74-20AE53414A8B}"
@@ -156,8 +142,6 @@ Global
{80E9918A-8CF7-4B47-8F05-72CE7E97A80C} = {86F79F6F-A241-4878-B7B1-0855AB3A1787}
{E83379B1-4BDD-48C9-965B-06B017C7DEA2} = {11189388-1C21-49B7-B232-A35714953484}
{8835EBF6-45C1-4814-9A85-992759C09014} = {86F79F6F-A241-4878-B7B1-0855AB3A1787}
- {221B3B37-ACFB-4C04-9CA8-A83CB9DC1DA7} = {3938A33D-C902-48DD-BDF0-8DCD9BC39F54}
- {73EDDACC-3254-4E15-8EC3-508385E8F6CF} = {3938A33D-C902-48DD-BDF0-8DCD9BC39F54}
{0F342CA9-A191-47F7-BF64-A0EB14D4E746} = {11189388-1C21-49B7-B232-A35714953484}
{AB571829-7B88-4BFD-B95C-B0DA80366890} = {FCE1E925-8AB6-4E18-9E74-20AE53414A8B}
{3D67EBE3-651F-45A1-B2FC-7204D5C296A6} = {3938A33D-C902-48DD-BDF0-8DCD9BC39F54}
diff --git a/README.md b/README.md
index 6a9e15ca..59d1a72f 100644
--- a/README.md
+++ b/README.md
@@ -15,34 +15,155 @@
-## Migration to v1
+### Migration to v1
-The current release of blockfrost-dotnet introduced major API changes breaking existing implementations.
+*The current release of blockfrost-dotnet introduced major API changes breaking existing implementations.*
-See the [migration guide](https://github.com/blockfrost/blockfrost-dotnet/wiki/Migration-Guide) to resolve these issues.
+*See the [migration guide](https://github.com/blockfrost/blockfrost-dotnet/wiki/Migration-Guide) to resolve these issues.*
## Getting started
-To use this SDK, you first need login into to [blockfrost.io](https://blockfrost.io) create your project to retrive your API token.
+To use this SDK, first go to [blockfrost.io](https://blockfrost.io) and create your project to retrive your API token.
-## Installation
+### Configure environment variables (optional)
-### Add package
+`blocfrost-dotnet` supports two environment variables.
+
+```ps
+$> $env:BFCLI_NETWORK
+testnet
+
+$> $env:BFCLI_API_KEY
+yourawesomeapikeyforblockfrostio
+```
+
+> Make sure you have configured them if you add `blockfrost-dotnet` using `services.AddBlockfrost();`
+>
+> There are other extension methods to configure `blockfrost-dotnet` where the environment variables are not required. We will look at one of them in the sample below.
+
+### Setup
The SDK is hosted on [nuget.org](https://www.nuget.org/packages/Blockfrost.Api/latest), so you can directly import it using your favorite package manager.
-```console
-$ dotnet new console -n blockfrost-client
-$ cd blockfrost-client
-$ dotnet add package Blockfrost.Api --version 0.0.4
+```sh
+$> dotnet new console -n blockfrost-client
+$> cd blockfrost-client
+$> dotnet add package Blockfrost.Api --version 0.3.0
+$> dotnet add package Blockfrost.Extensions --version 0.3.0
```
๐ง๐ง๐ง ***Please report any issues you find [here](https://github.com/blockfrost/blockfrost-dotnet/issues/new)*** ๐
+### Usage
+
+Using the SDK is pretty straight-forward as you can see from the following example.
+
+#### Cardano Services
+
+```cs
+using System.IO;
+using Blockfrost.Api.Extensions;
+using Blockfrost.Api.Models.Extensions;
+using Blockfrost.Api.Services;
+using Blockfrost.Api.Services.Extensions;
+using Microsoft.Extensions.DependencyInjection;
+
+/*
+ * Parameters
+ */
+string apiKey = "YOUR_BLOCKFROST_PROJECT_ID";
+string network = "NETWORK_OF_THE_PROJECT_ID";
+string sender_address = "SENDER_ADDR";
+string receiver_address = "RECEIVER_ADDR";
+string signedTx = File.ReadAllText("path/to/your/signed/transaction");
+
+/*
+ * Init Services using apiKey and network
+ */
+var cardano = new ServiceCollection()
+ .AddBlockfrost(network, apiKey)
+ .BuildServiceProvider()
+ .GetRequiredService();
+
+/*
+ * Show metrics for your account
+ */
+var metrics = await cardano.Metrics.GetMetricsAsync();
+var opt = new System.Text.Json.JsonSerializerOptions() { WriteIndented = true };
+System.Console.WriteLine($"Metrics: {metrics.ToJson(opt)}");
+
+/*
+ * Show sender UTxO
+ */
+var utxoSender = await cardano.Addresses.GetUtxosAsync(sender_address);
+long totalSender = utxoSender.SumAmounts("lovelace");
+System.Console.WriteLine($"Sender Total: {totalSender} lovelace");
+
+/*
+ * Sum receiver UTxO
+ */
+var utxoReceiver = await cardano.Addresses.GetUtxosAsync(receiver_address);
+long totalReceiver = utxoReceiver.SumAmounts("lovelace");
+System.Console.WriteLine($"Receiver Total: {totalReceiver} lovelace");
+
+/*
+ * Query tip
+ */
+var tip = await cardano.Blocks.GetLatestAsync();
+long? latestSlot = tip.Slot;
+
+System.Console.WriteLine($"Tip now at Epoch {tip.Epoch} Slot {tip.Slot} Block {tip.Height}");
+
+/*
+ * Send submit tx
+ */
+System.Console.WriteLine(signedTx);
+string txid = await cardano.Transactions.PostTxSubmitAsync(signedTx);
+
+System.Console.WriteLine($"Your Transaction was transmitted to the {network}");
+System.Console.WriteLine($"https://explorer.cardano-{network}.iohkdev.io/en/transaction?id={txid}");
+
+/*
+ * Wait two blocks
+ */
+tip = await cardano.Blocks.WaitAsync(
+ count: 2,
+ interval: System.TimeSpan.FromSeconds(5),
+ callback: latest => System.Console.WriteLine(latest.Slot),
+ cancellationToken: System.Threading.CancellationToken.None
+);
+System.Console.WriteLine($"Tip now at Epoch {tip.Epoch} Slot {tip.Slot} Block {tip.Height}");
+```
+
+### Run the sample
+
+```sh
+$ dotnet run
+Metrics: [
+ {
+ "time": 1631750400,
+ "calls": 3
+ },
+ ...
+]
+Sender Total: 988258310 lovelace
+Receiver Total: 10000000 lovelace
+Tip now at Epoch 160 Slot 38978334 Block 2965005
+
+Your Transaction was transmitted to the testnet
+https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=2b1ca81b94c5dd737fe939444264046c6fbbe96ff403e49ee99e8022b0e512bb
+Tip: 38978334
+Tip: 38978334
+Tip: 38978334
+Tip: 38978334
+Tip: 38978334
+Tip now at Epoch 160 Slot 38978436 Block 2965007
+```
+
### Command line tool
Before you install the command line tool, make sure the environment variables `BFCLI_API_KEY` and `BFCLI_NETWORK` exist.
@@ -61,12 +182,11 @@ yourawesomeapikeyforblockfrostio
$> pwd
{$SolutionDir}\src\Blockfrost.Cli
-$> dotnet tool install bfcli --add-source nupkg --version 0.0.xyz
-
-Tool 'bfcli' (version '0.0.xyz') was successfully installed.
+$> dotnet tool install bfcli --add-source nupkg --version 0.2.1
+Tool 'bfcli' (version '0.2.1') was successfully installed.
$> dotnet bfcli -v
-bfcli v0.0.xyz
+bfcli v0.2.1
A .NET Cross Platform Tool / Console App for interacting with Blockfrost API.
USAGE: bfcli (OPTION | COMMAND)
@@ -85,77 +205,6 @@ is_healthy
True
```
-## Usage
-
-Using the SDK is pretty straight-forward as you can see from the following example.
-
-### Cardano
-
-```cs
-using System.IO;
-using Blockfrost.Api;
-using Blockfrost.Api.Extensions;
-using Microsoft.Extensions.DependencyInjection;
-
-var apiKey = "YOUR_BLOCKFROST_PROJECT_ID";
-var network = "NETWORK_OF_THE_PROJECT_ID";
-var sender_address = "SENDER_ADDR";
-var receiver_address = "RECEIVER_ADDR";
-var signedTx = File.ReadAllText("path/to/your/signed/transaction");
-
-var provider = new ServiceCollection().AddBlockfrost(network, apiKey).BuildServiceProvider();
-var blockService = provider.GetRequiredService();
-var addressService = provider.GetRequiredService();
-var transactionService = provider.GetRequiredService();
-
-var utxoSender = await addressService.UtxosAllAsync(sender_address,100,0,ESortOrder.Asc).ConfigureAwait(false);
-int totalSender = utxoSender.Sum(m => m.Amount.Sum(a => int.Parse(a.Quantity)));
-System.Console.WriteLine($"Sender Total: {totalSender} lovelace");
-
-var utxoReceiver = await addressService.UtxosAllAsync(receiver_address,100,0,ESortOrder.Asc).ConfigureAwait(false);
-int totalReceiver = utxoReceiver.Sum(m => m.Amount.Sum(a => int.Parse(a.Quantity)));
-System.Console.WriteLine($"Receiver Total: {totalReceiver} lovelace");
-
-var tip = await blockService.GetLatestBlockAsync();
-int? slot = tip.Slot;
-
-Console.WriteLine($"Tip now at Epoch {tip.Epoch} Slot {tip.Slot} Block {tip.Height}");
-Console.WriteLine(signedTx);
-
-var txid = await transactionService.SubmitAsync(signedTx);
-
-Console.WriteLine($"Your Transaction was transmitted to the {network}");
-Console.WriteLine($"https://explorer.cardano-{network}.iohkdev.io/en/transaction?id={txid}");
-
-while(slot == tip.Slot)
-{
- Console.WriteLine("Waiting for next block...");
- await Task.Delay(TimeSpan.FromSeconds(3));
- tip = await blockService.GetLatestBlockAsync();
-}
-
-Console.WriteLine($"Tip now at Epoch {tip.Epoch} Slot {tip.Slot} Block {tip.Height}");
-```
-
-
-```sh
-$ dotnet run
-Sender Total: 988258310 lovelace
-Receiver Total: 10000000 lovelace
-Tip now at Epoch 152 Slot 35399692 Block 2855047
-{
- "type": "Tx MaryEra",
- "description": "",
- "cborHex": "83a3008182582002ffae369...c14003ce7b54b487197c40df6"
-}
-Your Transaction was transmitted to the testnet
-https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=2b1ca81b94c5dd737fe939444264046c6fbbe96ff403e49ee99e8022b0e512bb
-Waiting for next block...
-Waiting for next block...
-Waiting for next block...
-Tip now at Epoch 152 Slot 35399711 Block 2855048
-```
-