Vitalis.Cbor
0.1.0
dotnet add package Vitalis.Cbor --version 0.1.0
NuGet\Install-Package Vitalis.Cbor -Version 0.1.0
<PackageReference Include="Vitalis.Cbor" Version="0.1.0" />
<PackageVersion Include="Vitalis.Cbor" Version="0.1.0" />
<PackageReference Include="Vitalis.Cbor" />
paket add Vitalis.Cbor --version 0.1.0
#r "nuget: Vitalis.Cbor, 0.1.0"
#:package Vitalis.Cbor@0.1.0
#addin nuget:?package=Vitalis.Cbor&version=0.1.0
#tool nuget:?package=Vitalis.Cbor&version=0.1.0
<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">
<a href="https://www.nuget.org/packages/Chrysalis"> <img src="https://img.shields.io/nuget/v/Chrysalis.svg" alt="NuGet"> </a>
</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 🚀
- (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.
- Transaction Handling: Introduce capabilities for building and signing Cardano transactions.
- Advanced Address Management: Implement address generation, derivation, and other associated functionalities.
Getting Started 📦
To use Chrysalis in your .NET project:
You can install Chrysalis via NuGet:
dotnet add package ChrysalisExample 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
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 | Versions 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- NSec.Cryptography (>= 24.4.0)
- SauceControl.Blake2Fast (>= 2.0.0)
- System.Formats.Cbor (>= 9.0.3)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Vitalis.Cbor:
| Package | Downloads |
|---|---|
|
Vitalis.Network
Fork of Chrysalis. |
|
|
Vitalis.Wallet
Package Description |
|
|
Vitalis.Tx
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 268 | 4/29/2025 |