Skip to main content

.Net


CardanoSharp Koios SDK

Overview

This library helps .NET developers integrate with Cardano using the Koios API

Installation

Add Nuget

Type the following command:

dotnet add package CardanoSharp.Koios.Client

Examples

Below there is an examples to study, while to see the full library documentation you can go here

Retrieves the latest block
using CardanoSharp.Koios.Client;

namespace CardanoExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create an instance of the IBlockClient
            IBlockClient blockClient = RestService.For<IBlockClient>("https://api.koios.rest/api/v0");

            // Retrieve the latest block
            Block[] latestBlock = blockClient.GetBlockList().Result;

            // Display the hash of the latest block
            Console.WriteLine("Latest Block Hash: " + latestBlock[0].Hash);
        }
    }
}

This example creates an instance of the IBlockClient using the RestService.For method and retrieves the latest block from the blockchain by calling the GetBlockList method on the blockClient instance. Finally, it displays the hash of the latest block by accessing the Hash property of the first item in the latestBlock array.