SolanaSdk 1.2.2
See the version list below for details.
dotnet add package SolanaSdk --version 1.2.2
NuGet\Install-Package SolanaSdk -Version 1.2.2
<PackageReference Include="SolanaSdk" Version="1.2.2" />
<PackageVersion Include="SolanaSdk" Version="1.2.2" />
<PackageReference Include="SolanaSdk" />
paket add SolanaSdk --version 1.2.2
#r "nuget: SolanaSdk, 1.2.2"
#:package SolanaSdk@1.2.2
#addin nuget:?package=SolanaSdk&version=1.2.2
#tool nuget:?package=SolanaSdk&version=1.2.2
SolanaSdk
A comprehensive .NET SDK for Solana blockchain development. Build wallets, sign transactions, derive keys, and integrate with Solana programs using clean, type-safe C# APIs.
Features
| Feature | Description |
|---|---|
| BIP-39 Mnemonics | Generate and recover wallets using 12-24 word seed phrases (8 languages) |
| SLIP-39 Shamir Sharing | Split secrets into multiple shares with threshold recovery |
| SLIP-10 HD Derivation | Hierarchical deterministic key derivation for Ed25519 |
| Multi-Wallet Discovery | Find accounts across Phantom, Solflare, and Ledger paths |
| Program Derived Addresses | Generate PDAs for Solana programs |
| Associated Token Accounts | Derive ATA addresses for SPL tokens |
| Vanity Addresses | Create addresses with custom prefixes or suffixes |
| CLI Compatibility | Import/export Solana CLI keypair JSON files |
Installation
dotnet add package SolanaSdk
Quick Start
Create a New Wallet
using SolanaSdk.Wallet;
using SolanaSdk.Wallet.Bip39;
// Generate a new 24-word wallet
var wallet = new SWallet(WordCount.TwentyFour, WordList.English);
Console.WriteLine($"Mnemonic: {wallet.Mnemonic}");
Console.WriteLine($"Address: {wallet.Account.PublicKey}");
// Sign a message
byte[] signature = wallet.Sign(Encoding.UTF8.GetBytes("Hello Solana!"));
Recover from Mnemonic
string mnemonic = "your twelve word mnemonic phrase goes here ...";
var wallet = new SWallet(mnemonic, WordList.English);
// Derive multiple accounts
var account0 = wallet.GetAccount(0);
var account1 = wallet.GetAccount(1);
Import from CLI Keypair
// From Solana CLI keypair file
var account = SAccount.FromKeypairFile("~/.config/solana/id.json");
// From base58 secret key
var account = SAccount.FromSecretKey("your-base58-secret-key");
// Export back to file
account.SaveKeypairFile("backup.json");
HD Key Derivation
using SolanaSdk.Slip10;
byte[] seed = wallet.DeriveMnemonicSeed();
var slip10 = new Slip10(seed);
// Standard Solana derivation path
var (privateKey, chainCode) = slip10.DerivePath("m/44'/501'/0'/0'");
// Or use the convenience method
var (key, code) = slip10.DeriveSolanaAccount(account: 0, change: 0);
Wallet Discovery
using SolanaSdk.Discovery;
var discovery = new WalletDiscovery();
var result = discovery.Discover(wallet, new DiscoveryOptions
{
Profile = DiscoveryProfile.All, // Phantom, Solflare, Ledger
MaxAccounts = 10
});
foreach (var account in result.Accounts)
{
Console.WriteLine($"{account.Profile}: {account.Address}");
}
Program Derived Addresses
var programId = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
var seeds = new[] { Encoding.UTF8.GetBytes("metadata") };
if (PublicKey.TryFindProgramAddress(seeds, programId, out var pda, out byte bump))
{
Console.WriteLine($"PDA: {pda}, Bump: {bump}");
}
Associated Token Accounts
var wallet = new PublicKey("WalletAddress...");
var mint = new PublicKey("TokenMintAddress...");
var ata = AssociatedTokenAccount.GetAddress(wallet, mint);
Vanity Address Generation
// Generate address starting with "Sol"
var result = VanityAddressGenerator.GenerateWithPrefix("Sol");
Console.WriteLine($"Address: {result.Account.PublicKey}");
Console.WriteLine($"Attempts: {result.Attempts}");
// Parallel generation
var result = await VanityAddressGenerator.GenerateWithPrefixAsync("ABC");
SLIP-39 Secret Sharing
using SolanaSdk.Wallet.Slip39;
var sss = new ShamirsSecretSharing(new StrongRandom());
// Create 2-of-3 shares
var shares = sss.GenerateShares(
extendable: false,
iterationExponent: 0,
groupThreshold: 1,
groups: new[] { new Group(2, 3) },
passphrase: "",
masterSecret: walletSeed
);
// Recover from any 2 shares
var recovered = sss.CombineShares(
new[] { shares[0][0], shares[0][1] },
passphrase: ""
);
Message Signing
// Standard signing
byte[] signature = account.Sign(messageBytes);
// Off-chain message (Phantom/Solflare compatible)
byte[] signature = account.SignMessage("Sign this message");
// Verification
bool isValid = account.Verify(messageBytes, signature);
Secure Key Management
All key classes implement IDisposable with secure memory clearing:
using (var account = new SAccount())
{
byte[] signature = account.Sign(message);
} // Key material is securely zeroed
Supported Languages
BIP-39 mnemonics support: English, Japanese, Spanish, French, Chinese (Simplified/Traditional), Portuguese, Czech.
var mnemonic = "あいこくしん あいさつ ...";
var wordList = WordList.AutoDetect(mnemonic); // Returns Japanese
API Reference
Core Classes
SWallet- BIP-39 HD walletSlip39SWallet- SLIP-39 walletSAccount- Keypair (public + private key)PublicKey- 32-byte Ed25519 public keyPrivateKey- 64-byte Ed25519 private key
Key Derivation
Slip10- SLIP-10 Ed25519 HD derivationEd25519Bip32- BIP-32 style derivation
Utilities
VanityAddressGenerator- Custom address generationAssociatedTokenAccount- ATA derivationKeypair- CLI keypair import/exportSolanaConstants- Program IDs and constants
Requirements
- .NET 8.0+
Links
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 is compatible. 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. |
-
net10.0
- Chaos.NaCl.Standard (>= 1.0.0)
- Portable.BouncyCastle (>= 1.9.0)
-
net8.0
- Chaos.NaCl.Standard (>= 1.0.0)
- Portable.BouncyCastle (>= 1.9.0)
-
net9.0
- Chaos.NaCl.Standard (>= 1.0.0)
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.2.1:
- Enhanced Program Derived Address (PDA) generation
- Improved Associated Token Account derivation
- Better error handling and validation
- Performance optimizations for key derivation
- Updated documentation and examples
v1.2.0:
- Added multi-wallet discovery (Phantom, Solflare, Ledger)
- Enhanced vanity address generation with parallel support
- Improved SLIP-39 implementation
v1.1.0:
- Added SLIP-10 HD key derivation
- Added off-chain message signing
- Enhanced address utilities
v1.0.0:
- Initial release with BIP-39, SLIP-39, Ed25519 support