Chrysalis 0.7.2

dotnet add package Chrysalis --version 0.7.2
                    
NuGet\Install-Package Chrysalis -Version 0.7.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chrysalis" Version="0.7.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chrysalis" Version="0.7.2" />
                    
Directory.Packages.props
<PackageReference Include="Chrysalis" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Chrysalis --version 0.7.2
                    
#r "nuget: Chrysalis, 0.7.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Chrysalis&version=0.7.2
                    
Install Chrysalis as a Cake Addin
#tool nuget:?package=Chrysalis&version=0.7.2
                    
Install Chrysalis as a Cake Tool

<div align="center"> <h1 style="font-size: 3em;">Chrysalis: Cardano Serialization Library for .NET 🦋</h1> <h4>A .NET Serialization Library for Cardano</h4> </div>

<div align="center">

Forks Stars License Contributors Issues Issues Closed

<a href="https://www.nuget.org/packages/Chrysalis"> <img src="https://img.shields.io/nuget/v/Chrysalis.svg" alt="NuGet"> </a>

C#

</div>

Chrysalis is an open-source .NET library designed to help you create, build, and sign Cardano transactions. As a C# serialization library, Chrysalis facilitates the serialization and deserialization of Cardano blockchain data structures. With a strong focus on adhering to the Cardano standards and enhancing the .NET Cardano developer ecosystem, Chrysalis aims to provide developers with a reliable and consistent toolkit for working with Cardano.

🚧 NOTE: This library is currently a work in progress. Feedback and contributions are welcome!

Features ✨

  • Cardano Serialization: Convert Cardano blockchain data structures to and from CBOR (Concise Binary Object Representation), allowing seamless and efficient data exchanges while reducing manual handling.
  • Utility functions: Use provided functions to intuitively interact with the Cardano data types and serialization formats.
    • Bech32 Address Encoding/Decoding: Simplifies the encoding and decoding of Cardano addresses, ensuring compatibility with widely used formats. This allows you to handle Cardano addresses seamlessly.
  • Extension Functions: Simplifies the retrieval of values from Cardano data types by providing functions to access various variables within the data structures.
  • Extensive Data Model Support: Use a wide range of pre-built Cardano data types, including Transactions, Assets, MultiAssets, and more.
  • Smart Contract Interaction: Utilize Chrysalis' Cbor types in Datum creation and interact with Cardano smart contracts.
  • Cross-Platform Compatibility: Use Chrysalis in any .NET project, including .NET Core, .NET Framework, Xamarin, and more. This not only allows you to assemble Cardano data through C# but other .NEt languages such as F# or VB.NET.

Roadmap 🚀

  1. (De)serialization Support: Achieve complete serialization and deserialization for any Cardano data type described in CDDL https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/conway.cddl.
  2. Transaction Handling: Introduce capabilities for building and signing Cardano transactions.
  3. Advanced Address Management: Implement address generation, derivation, and other associated functionalities.

Getting Started 📦

To use Chrysalis in your .NET project:

  1. You can install Chrysalis via NuGet: dotnet add package Chrysalis

  2. Example Usage 🧑‍💻

    CBOR (De)serialization

        var serializedTransaction = CborSerializer.Serialize(originalTransaction);
        var deserializedTransaction = CborSerializer.Deserialize<TransactionBody>(serializedTransaction);
    

    Block Deserialization and Serialization

        byte[] serializedBlock = CborSerializer.Serialize(originalBlock);
        BlockEntity deserializedBlock = CborSerializer.Deserialize<BlockEntity>(serializedBlock);
    

    Access Deserialized Transactions, Transaction Inputs, and Transaction Outputs from a Deserialized Block

        IEnumerable<TransactionBody> transactions = originalBlock.TransactionBodies();
        foreach (TransactionBody tx in transactions)
        {
            IEnumerable<TransactionInput> inputs = tx.Inputs();
            IEnumerable<TransactionOutput> outputs = tx.Outputs();    
        }
    

    Access a Transaction Input's Transaction Id and Index

        foreach (TransactionInput input in tx.Inputs())
        {
            string id = input.TransacationId();
            ulong index = input.Index();
        }
    

    Access a Transaction Output's Address and Balance

        foreach (TransactionOutput output in tx.Outputs())
        {
            string addr = output.Address().Value.ToBech32();
            Value balance = output.Amount();
            ulong lovelace = balance.Lovelace();
            MultiAssetOutput multiasset = balance.MultiAsset();
        }
    

    Serialize Transactions in a Block

        for (uint x = 0; x < transactions.Count(); x++)
        {
            CborSerializer.Serialize(transactions.ElementAt((int)x))
        }
    

    Bech32 Address Encoding or Decoding

        var addressBech32 = "addr...";
        var addressObject = Address.FromBech32(addressBech32);
        var addressBech32Again = addressObject.ToBech32();
        var paymentKeyHash = addressObject.GetPaymentKeyHash();
        var stakeKeyHash = addressObject.GetStakeKeyHash();
    

Smart Contract Datums 📝

Cbor Types Example Image

Datum Example

    public record AssetClass(CborBytes[] Value) : CborIndefiniteList<CborBytes>(Value);
    public record AssetClassTuple(AssetClass[] Value) : CborIndefiniteList<AssetClass>(Value);

    [CborSerializable(CborType.Constr, Index = 0)]
    public record SundaeSwapLiquidityPool(
        [CborProperty(0)]
        CborBytes Identifier,
        
        [CborProperty(1)]
        AssetClassTuple Assets,
        
        [CborProperty(2)]
        CborUlong CirculatingLp,
        
        [CborProperty(3)]
        CborUlong BidFeesPer10Thousand,
        
        [CborProperty(4)]
        CborUlong AskFeesPer10Thousand,
        
        [CborProperty(5)]
        Option<MultisigScript> FeeManager,
        
        [CborProperty(6)]
        CborUlong MarketOpen,
        
        [CborProperty(7)]
        CborUlong ProtocolFees
    ) : RawCbor;

How to Contribute 🤝

Interested in contributing to Chrysalis? Great! We appreciate any help, be it in the form of code contributions, documentation, or even bug reports.

  • Fork and Clone: Fork this repository, clone it locally, and set up the necessary development environment.
  • Branch: Always create a new branch for your work.
  • Pull Request: Submit a pull request once you're ready. Ensure you describe your changes clearly.
  • Feedback: Wait for feedback and address any comments or suggestions.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Chrysalis:

Package Downloads
Argus.Sync

A ASP.NET Framework for Indexing Cardano Data storing it in PostgresSQL

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.7.2 141 4/4/2025
0.7.1 154 4/4/2025
0.7.0 157 4/3/2025
0.6.0 105 2/21/2025
0.5.24 359 1/20/2025
0.5.23 162 1/10/2025
0.5.22 205 12/23/2024
0.5.21 105 12/22/2024
0.5.20 114 12/20/2024
0.5.19 95 12/20/2024
0.5.18 108 12/20/2024
0.5.17 115 12/19/2024
0.5.16 115 12/18/2024
0.5.15 102 12/18/2024
0.5.14 103 12/17/2024
0.5.13 95 12/17/2024
0.5.12 85 12/17/2024
0.5.11 96 12/17/2024
0.5.10 98 12/17/2024
0.5.9 97 12/17/2024
0.5.8 109 12/17/2024
0.5.7 147 12/14/2024
0.5.6 110 12/13/2024
0.5.5 131 12/12/2024
0.5.4 106 12/11/2024
0.5.3 96 12/10/2024
0.5.2 102 12/10/2024
0.5.1 101 12/10/2024
0.5.0 105 12/10/2024
0.4.2 118 11/27/2024
0.4.1 89 11/27/2024
0.4.0 128 11/22/2024
0.3.1 107 11/22/2024
0.3.0 111 11/5/2024
0.2.8 115 10/21/2024
0.2.7 140 10/20/2024
0.2.6 157 10/18/2024
0.2.5 110 10/17/2024
0.2.4 105 10/17/2024
0.2.3 110 10/16/2024
0.2.2 284 9/20/2024
0.2.1 118 9/19/2024
0.2.0 98 9/19/2024
0.1.9 652 9/13/2024
0.1.8 144 9/11/2024
0.1.7 132 9/11/2024
0.1.6 134 9/11/2024
0.1.5 124 9/6/2024
0.1.4 124 9/5/2024
0.1.3 124 9/5/2024
0.1.0 73 9/3/2024
0.0.7 108 10/10/2023
0.0.6 92 10/6/2023
0.0.5 93 10/6/2023
0.0.1 62 9/3/2024