Skip to content


Repository files navigation




Getting startedInstallationUsage

Getting started

To use this SDK, first go to and create your project to retrive your API token.

Setup environment

blocfrost-dotnet supports the following environment variables.



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. One of them is shown in the sample below.


The SDK is hosted on, so you can directly import it using your favorite package manager.

$> dotnet new console -n blockfrost-client
$> cd blockfrost-client
$> dotnet add package Blockfrost.Api
$> dotnet add package Blockfrost.Extensions


Using the SDK is pretty straight-forward as you can see from the following example.

Cardano Services

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 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)

 * 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
string txid = await cardano.Transactions.PostTxSubmitAsync(signedTx);

System.Console.WriteLine($"Your Transaction was transmitted to the {network}");

 * 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

$ 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
Tip: 38978334
Tip: 38978334
Tip: 38978334
Tip: 38978334
Tip: 38978334
Tip now at Epoch 160 Slot 38978436 Block 2965007