Getting Started with C#
The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.
The IOTA SDK C# bindings allow .NET developers to build applications that interact with the IOTA network. These bindings wrap the core Rust SDK via a Foreign Function Interface (FFI).
Prerequisites
Before using the C# bindings, ensure you have:
- .NET SDK: Version 8.0 or higher.
Installation
- Pre-built (Recommended)
- Build from Source
Add the IOTA SDK to your project as a NuGet package:
dotnet add package IotaSdk
The package includes pre-built native libraries for macOS (x86_64 and ARM64), Linux (x86_64 and ARM64), and Windows (x86_64 and ARM64).
If a pre-built native library is not available for your operating system or CPU architecture, you can build the C# bindings from source. A Rust toolchain is required.
git clone https://github.com/iotaledger/iota-rust-sdk.git
cd iota-rust-sdk
make csharp
For additional setup instructions and platform-specific details, refer to the C# bindings README in the repository.
Quick Start Example
The following example demonstrates how to connect to the IOTA Testnet and retrieve the Chain ID.
1. Create a console project
dotnet new console -o iota-quickstart
cd iota-quickstart
dotnet add package IotaSdk
2. Replace Program.cs
Replace the contents of Program.cs with the following code:
loading...
3. Run the code
In your terminal, run:
dotnet run
What's Next?
Now that you have connected to the network, you can explore more advanced features:
- Accounts and Addresses: create a mnemonic, derive addresses, and check coin balances.
- Transactions: build, sign, and send Programmable Transaction Blocks (PTBs), including staking and reusing command results.
- Queries: query owned objects, events, and transactions with the GraphQL client.
View more comprehensive examples in the official C# examples directory.