Chrysalis 0.7.6
See the version list below for details.
dotnet add package Chrysalis --version 0.7.6
NuGet\Install-Package Chrysalis -Version 0.7.6
<PackageReference Include="Chrysalis" Version="0.7.6" />
<PackageVersion Include="Chrysalis" Version="0.7.6" />
<PackageReference Include="Chrysalis" />
paket add Chrysalis --version 0.7.6
#r "nuget: Chrysalis, 0.7.6"
#:package Chrysalis@0.7.6
#addin nuget:?package=Chrysalis&version=0.7.6
#tool nuget:?package=Chrysalis&version=0.7.6
<div align="center"> <img src="assets/banner.png" alt="Chrysalis Banner" width="100%">
<a href="https://www.nuget.org/packages/Chrysalis"> <img src="https://img.shields.io/nuget/v/Chrysalis.svg?style=flat-square" alt="NuGet"> </a> <a href="https://github.com/SAIB-Inc/Chrysalis/blob/main/LICENSE.md"> <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License"> </a> <a href="https://github.com/SAIB-Inc/Chrysalis/fork"> <img src="https://img.shields.io/github/forks/SAIB-Inc/Chrysalis.svg?style=flat-square" alt="Forks"> </a> <a href="https://github.com/SAIB-Inc/Chrysalis/stargazers"> <img src="https://img.shields.io/github/stars/SAIB-Inc/Chrysalis.svg?style=flat-square" alt="Stars"> </a> <a href="https://github.com/SAIB-Inc/Chrysalis/graphs/contributors"> <img src="https://img.shields.io/github/contributors/SAIB-Inc/Chrysalis.svg?style=flat-square" alt="Contributors"> </a> <br> <a href="https://dotnet.microsoft.com/download"> <img src="https://img.shields.io/badge/.NET-9.0-512BD4?style=flat-square" alt=".NET"> </a> <a href="https://cardano.org/"> <img src="https://img.shields.io/badge/Cardano-Compatible-0033AD?style=flat-square" alt="Cardano"> </a> </div>
📖 Overview
Chrysalis is a native .NET toolkit for Cardano blockchain development, providing everything needed to build applications on Cardano. From CBOR serialization to transaction building and smart contract interaction, Chrysalis offers a complete solution for .NET developers.
Key Components:
- 📦 Serialization - Efficient CBOR encoding/decoding for Cardano data structures
- 🔄 Node Communication - Direct interaction with Cardano nodes through Ouroboros mini-protocols
- 🔑 Wallet Management - Address generation and key handling
- 💳 Transaction Building - Simple and advanced transaction construction
- 📜 Smart Contract Integration - Plutus script evaluation and validation via Rust FFI
✨ Features
- 🔐 Type-Safe Data Models - Strong typing for all Cardano blockchain structures
- ⚡ High Performance - Optimized for speed and efficiency
- 🧩 Modular Architecture - Use only what you need
- 🚀 Modern C# API - Takes advantage of the latest .NET features
- 🔗 Complete Cardano Support - Works with all major Cardano eras and protocols
📥 Installation
# Install the main package
dotnet add package Chrysalis
Or install individual components:
dotnet add package Chrysalis.Cbor
dotnet add package Chrysalis.Network
dotnet add package Chrysalis.Tx
dotnet add package Chrysalis.Plutus
dotnet add package Chrysalis.Wallet
🧩 Architecture
Chrysalis consists of several specialized libraries:
Module | Description |
---|---|
Chrysalis.Cbor | CBOR serialization for Cardano data structures |
Chrysalis.Cbor.CodeGen | Source generation for optimized serialization code |
Chrysalis.Network | Implementation of Ouroboros mini-protocols |
Chrysalis.Tx | Transaction building and submission |
Chrysalis.Plutus | Smart contract evaluation and validation |
Chrysalis.Wallet | Key management and address handling |
💻 Usage Examples
📦 CBOR Serialization
Define and use CBOR-serializable types with attribute-based serialization:
// Define CBOR-serializable types
[CborSerializable]
[CborConstr(0)]
public partial record AssetDetails(
[CborOrder(0)] byte[] PolicyId,
[CborOrder(1)] AssetClass Asset,
[CborOrder(2)] ulong Amount
): CborBase;
[CborSerializable]
[CborList]
public partial record AssetClass(
[CborOrder(0)] byte[] PolicyId,
[CborOrder(1)] byte[] AssetName
) : CborBase;
// Deserialize from CBOR hex
var data = "d8799f581cc05cb5c5f43aac9d9e057286e094f60d09ae61e8962ad5c42196180c9f4040ff1a00989680ff";
AssetDetails details = CborSerializer.Deserialize<AssetDetails>(data);
// Serialize back to CBOR
byte[] serialized = CborSerializer.Serialize(details);
Extension Method Pattern
Chrysalis uses extension methods extensively to provide clean access to nested data structures:
// Without extensions, deep property access is verbose and differs by era
var hash = transaction.TransactionBody.Inputs.GetValue()[0].TransactionId;
// With extension methods, access is simplified and era-agnostic
var hash = transaction.TransactionBody.Inputs().First().TransactionId();
// Extensions support common operations
Transaction signedTx = transaction.Sign(privateKey);
🔑 Wallet Management
Generate and manage addresses and keys:
// Create wallet from mnemonic
var mnemonic = Mnemonic.Generate(English.Words, 24);
var accountKey = mnemonic
.GetRootKey()
.Derive(PurposeType.Shelley, DerivationType.HARD)
.Derive(CoinType.Ada, DerivationType.HARD)
.Derive(0, DerivationType.HARD);
var privateKey = accountKey
.Derive(RoleType.ExternalChain)
.Derive(0);
var paymentKey = privateKey.GetPublicKey();
var stakingKey = accountKey
.Derive(RoleType.Staking)
.Derive(0)
.GetPublicKey();
// Generate address
var address = Address.FromPublicKeys(
NetworkType.Testnet,
AddressType.BasePayment,
paymentKey,
stakingKey
);
string bech32Address = address.ToBech32();
Console.WriteLine($"Bech32 Address: {bech32Address}");
🔄 Node Communication
Connect directly to a Cardano node:
try {
// Connect to a local node
NodeClient client = await NodeClient.ConnectAsync("/ipc/node.socket");
await client.StartAsync(2);
// Query UTXOs by address
var addressBytes = Convert.FromHexString("00a7e1d2e57b1f9aa851b08c8934a315ffd97397fa997bb3851c626d3bb8d804d91fa134757d1a41b0b12762f8922fe4b4c6faa5ffec1bc9cf");
var utxos = await client.LocalStateQuery.GetUtxosByAddressAsync([addressBytes]);
// Synchronize with the chain
var tip = await client.LocalStateQuery.GetTipAsync();
Console.WriteLine($"Chain tip: {tip}");
// Available mini-protocols - accessed as properties
var localTxSubmit = client.LocalTxSubmit;
var localStateQuery = client.LocalStateQuery;
var localTxMonitor = client.LocalTxMonitor;
}
catch (InvalidOperationException ex) {
Console.WriteLine($"Connection failed: {ex.Message}");
}
catch (Exception ex) {
Console.WriteLine($"Protocol error: {ex.Message}");
}
💳 Transaction Building
Build and sign transactions with the fluent API or template builder:
// Simple transaction using template builder
var senderAddress = address.ToBech32();
var receiverAddress = "addr_test1qpcxqfg6xrzqus5qshxmgaa2pj5yv2h9mzm22hj7jct2ad59q2pfxagx7574360xl47vhw79wxtdtze2z83k5a4xpptsm6dhy7";
var provider = new Blockfrost("apiKeyHere");
var transfer = TransactionTemplateBuilder<ulong>.Create(provider)
.AddStaticParty("sender", senderAddress, true)
.AddStaticParty("receiver", receiverAddress)
.AddInput((options, amount) =>
{
options.From = "sender";
})
.AddOutput((options, amount) =>
{
options.To = "receiver";
options.Amount = new Lovelace(amount);
})
.Build();
// Execute the template with a specific amount
Transaction tx = await transfer(5_000_000UL);
Transaction signedTx = tx.Sign(privateKey);
📜 Smart Contract Interaction
Interact with and validate Plutus scripts:
var provider = new Blockfrost("project_id");
var ownerAddress = "your address";
var alwaysTrueValidatorAddress = "your validator address";
var spendRedeemerBuilder = (_, _, _) =>
{
// Custom Logic and return type as long as it inherits from CborBase
// ex: returns an empty list
return new PlutusConstr([]);
};
var lockTxHash = "your locked tx hash";
var scriptRefTxHash = "your script ref tx hash";
var unlockLovelace = TransactionTemplateBuilder<UnlockParameters>.Create(provider)
.AddStaticParty("owner", ownerAddress, true)
.AddStaticParty("alwaysTrueValidator", alwaysTrueValidatorAddress)
.AddReferenceInput((options, unlockParams) =>
{
options.From = "alwaysTrueValidator";
options.UtxoRef = unlockParams.ScriptRefUtxoOutref;
})
.AddInput((options, unlockParams) =>
{
options.From = "alwaysTrueValidator";
options.UtxoRef = unlockParams.LockedUtxoOutRef;
options.SetRedeemerBuilder(spendRedeemerBuilder);
})
.Build();
var unlockParams = new(
new TransactionInput(Convert.FromHexString(lockTxHash), 0),
new TransactionInput(Convert.FromHexString(scriptRefTxHash), 0)
);
var unlockUnsignedTx = await unlockLovelace(unlockParams);
var unlockSignedTx = unlockUnsignedTx.Sign(privateKey);
var unlockTxHash = await provider.SubmitTransactionAsync(unlockSignedTx);
Console.WriteLine($"Unlock Tx Hash: {unlockTxHash}");
CIP Implementation Support
Chrysalis supports various Cardano Improvement Proposals (CIPs), including:
// CIP-68 NFT standard implementation
var nftMetadata = new Cip68<PlutusData>(
Metadata: metadata,
Version: 1,
Extra: null
);
⚡ Performance
Chrysalis is optimized for performance, with benchmarks showing it outperforms equivalent libraries in other languages, including Pallas (Rust). Our benchmarks show superior performance in key operations:
<div align="center"> <p><strong>Performance with Database Operations</strong></p> <p>Chrysalis (609.56 blocks/s) vs Pallas Rust (474.95 blocks/s)</p> <img src="assets/chrysalis_bechmark_with_db.png" alt="Benchmarks with DB" width="70%"> </div>
<div align="center"> <p><strong>Performance without Database Operations</strong></p> <p>Chrysalis (4,500 blocks/s) vs Pallas Rust (3,500 blocks/s)</p> <img src="assets/chrysalis_bechmark_no_db.png" alt="Benchmarks without DB" width="70%"> </div>
Key performance advantages:
- Faster block deserialization (approximately 28% faster than Rust)
- Optimized chain synchronization
- Lower memory footprint (reduced allocations)
- Excellent scalability for high-throughput applications
These benchmarks were performed using BenchmarkDotNet with proper warm-up cycles, multiple iterations, and statistical analysis.
🔄 Cardano Era Support
Chrysalis provides comprehensive support for Cardano's evolution:
<table> <thead> <tr> <th>Era</th> <th>Phase</th> <th>Status</th> <th colspan="3">Feature Support</th> </tr> <tr> <th></th> <th></th> <th></th> <th align="center">Serialization</th> <th align="center">Block Processing</th> <th align="center">Transaction Building</th> </tr> </thead> <tbody> <tr> <td><strong>Byron</strong></td> <td>Foundation</td> <td align="center">🚧</td> <td align="center">❌</td> <td align="center">❌</td> <td align="center">❌</td> </tr> <tr> <td><strong>Shelley</strong></td> <td>Decentralization</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td><strong>Allegra</strong></td> <td>Token Locking</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td><strong>Mary</strong></td> <td>Multi-Asset</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td><strong>Alonzo</strong></td> <td>Smart Contracts</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td><strong>Babbage/Vasil</strong></td> <td>Scaling</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td><strong>Conway</strong></td> <td>Governance</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> <td align="center">✅</td> </tr> </tbody> </table>
Legend:
- ✅ Fully Supported
- 🚧 Planned for Future Release
- ❌ Not Supported Yet
📚 Documentation
For detailed documentation on each component:
- Chrysalis.Cbor Documentation
- Chrysalis.Tx Documentation
- API Documentation - Coming soon
- Getting Started Guide - Coming soon
Note: The documentation is currently in development. In the meantime, this README and the code examples provide a good starting point.
Native Library Dependencies
The Plutus VM integration currently requires Rust-based native libraries that are automatically included with the NuGet package. We are actively working towards a pure .NET implementation of the Plutus Virtual Machine for improved cross-platform compatibility and performance.
Current native dependencies:
- Linux:
libpallas_dotnet_rs.so
andlibplutus_vm_dotnet_rs.so
- macOS:
libplutus_vm_dotnet_rs.dylib
🤝 Contributing
We welcome contributions! To get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'feat: add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
Please make sure to update tests as appropriate.
📄 License
This project is licensed under the MIT License - see the LICENSE.md file for details.
<div align="center"> <p>Made with ❤️ by <a href="https://saib.dev">SAIB Inc</a> for the Cardano community</p> </div>
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
- CardanoSharp.Chaos (>= 0.1.0)
- Microsoft.AspNetCore.Cryptography.KeyDerivation (>= 9.0.3)
- SAIB.Blake2Fast (>= 3.0.1)
- System.Formats.Cbor (>= 9.0.3)
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.15 | 131 | 7/10/2025 |
0.7.14 | 133 | 7/9/2025 |
0.7.13 | 138 | 7/8/2025 |
0.7.12 | 127 | 7/8/2025 |
0.7.11 | 160 | 7/3/2025 |
0.7.10 | 137 | 7/2/2025 |
0.7.9 | 339 | 6/10/2025 |
0.7.8 | 197 | 6/5/2025 |
0.7.7 | 201 | 6/3/2025 |
0.7.6 | 106 | 5/30/2025 |
0.7.4 | 254 | 5/16/2025 |
0.7.3 | 232 | 5/14/2025 |
0.7.2 | 166 | 4/4/2025 |
0.7.1 | 176 | 4/4/2025 |
0.7.0 | 175 | 4/3/2025 |
0.6.0 | 122 | 2/21/2025 |
0.5.24 | 568 | 1/20/2025 |
0.5.23 | 178 | 1/10/2025 |
0.5.22 | 228 | 12/23/2024 |
0.5.21 | 124 | 12/22/2024 |
0.5.20 | 131 | 12/20/2024 |
0.5.19 | 114 | 12/20/2024 |
0.5.18 | 126 | 12/20/2024 |
0.5.17 | 134 | 12/19/2024 |
0.5.16 | 134 | 12/18/2024 |
0.5.15 | 120 | 12/18/2024 |
0.5.14 | 123 | 12/17/2024 |
0.5.13 | 111 | 12/17/2024 |
0.5.12 | 101 | 12/17/2024 |
0.5.11 | 112 | 12/17/2024 |
0.5.10 | 119 | 12/17/2024 |
0.5.9 | 112 | 12/17/2024 |
0.5.8 | 128 | 12/17/2024 |
0.5.7 | 168 | 12/14/2024 |
0.5.6 | 132 | 12/13/2024 |
0.5.5 | 147 | 12/12/2024 |
0.5.4 | 122 | 12/11/2024 |
0.5.3 | 111 | 12/10/2024 |
0.5.2 | 123 | 12/10/2024 |
0.5.1 | 118 | 12/10/2024 |
0.5.0 | 120 | 12/10/2024 |
0.4.2 | 139 | 11/27/2024 |
0.4.1 | 106 | 11/27/2024 |
0.4.0 | 143 | 11/22/2024 |
0.3.1 | 121 | 11/22/2024 |
0.3.0 | 127 | 11/5/2024 |
0.2.8 | 130 | 10/21/2024 |
0.2.7 | 157 | 10/20/2024 |
0.2.6 | 173 | 10/18/2024 |
0.2.5 | 126 | 10/17/2024 |
0.2.4 | 119 | 10/17/2024 |
0.2.3 | 123 | 10/16/2024 |
0.2.2 | 302 | 9/20/2024 |
0.2.1 | 133 | 9/19/2024 |
0.2.0 | 114 | 9/19/2024 |
0.1.9 | 690 | 9/13/2024 |
0.1.8 | 161 | 9/11/2024 |
0.1.7 | 148 | 9/11/2024 |
0.1.6 | 149 | 9/11/2024 |
0.1.5 | 146 | 9/6/2024 |
0.1.4 | 145 | 9/5/2024 |
0.1.3 | 144 | 9/5/2024 |
0.1.0 | 89 | 9/3/2024 |
0.0.7 | 118 | 10/10/2023 |
0.0.6 | 104 | 10/6/2023 |
0.0.5 | 106 | 10/6/2023 |
0.0.1 | 80 | 9/3/2024 |