Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

Solnet

> 开发工具
Open source

Solana's .NET SDK and integration library.

391 stars0 likes3 views
WebsiteGitHub

About

Solana's .NET SDK and integration library.

Features

  • Full JSON RPC API coverage
  • Full Streaming JSON RPC API coverage
  • Wallet and accounts (Phantom and solana-keygen compatible)
  • Keystore (Phantom and solana-keygen compatible)
  • Transaction decoding/encoding (base64 and wire format)
  • Message decoding/encoding (base64 and wire format)
  • Instruction decompilation
  • TokenWallet object to send SPL tokens and JIT provisioning of Associated Token Accounts
  • Programs
    • Native Programs
      • System Program
      • Stake Program
    • Solana Program Library (SPL)
      • Compute Budget Program
      • Account Compression Program
      • Governance Program
      • StakePool Program
      • Address Lookup Table Program
      • Memo Program
      • Token Program
      • Token Swap Program
      • Associated Token Account Program
      • Name Service Program
      • Shared Memory Program

For maintainability and due to the size/complexity of some other programs, this repository focuses on Solana's Native Programs and SPL programs. For other commonly used programs see:

  • Serum
  • Mango
  • Pyth

Maintained by Bifrost

  • Metaplex
  • Raydium
  • JupiterSwap
  • JupiterPerps
  • Moonshot
  • Pumpfun
  • Ore

Requirements

  • .NET 6.0 (deprecated)
  • .NET 8.0+ (recommended)

Dependencies

  • BifrostSecurity
  • Portable.BouncyCastle (optional)

Installation

Use the .NET CLI to install Solnet packages into your project (choose the ones you need):

powershell
# Rpc client and streaming
 dotnet add package Solana.Rpc
 dotnet add package Solana.Programs

# Wallets and keys
 dotnet add package Solana.Wallet

# Token helpers
 dotnet add package Solana.Extensions

# Keystore utilities
 dotnet add package Solana.Keystore

Latest Packages on NuGet:

  • Solana.Rpc
  • Solana.Wallet
  • Solana.Programs
  • Solana.Extensions
  • Solana.Keystore

Quickstart

A minimal example to fetch a balance and send a memo:

…

Examples

The Solnet.Examples project contains runnable code examples. Some examples derive accounts from a seed and may fail if an account at a derivation index already exists with the same seed. If you see simulation logs like account address is ... already in use, increment the derivation index (e.g., wallet.GetAccount(index + 1)).

Wallets

The Solnet.Wallet project implements wallet and key generation compatible with both solana-keygen and Phantom.

Initialize a keypair from a secret key

csharp
var account = Account.FromSecretKey("");

Initialize a wallet (Phantom-compatible by default)

csharp
var wallet = new Wallet("mnemonic words ...", WordList.English);
var account = wallet.GetAccount(10);

Initialize a wallet compatible with solana-keygen

csharp
var wallet = new Wallet("mnemonic words ...", WordList.English, "passphrase", SeedMode.Bip39);
var account = wallet.Account; // solana-keygen uses a fixed derivation path

Generating new wallets

csharp
var newMnemonic = new Mnemonic(WordList.English, WordCount.Twelve);
var wallet = new Wallet(newMnemonic);

KeyStore

The Solnet.KeyStore project enables secure storage of keys, seeds, and mnemonics. It implements the Web3 Secret Storage Definition and includes SolanaKeyStoreService to read keys generated by solana-keygen.

Secret KeyStore Service

csharp
var secretKeyStoreService = new SecretKeyStoreService();
var jsonString = secretKeyStoreService.EncryptAndGenerateDefaultKeyStoreAsJson(password, data, address);

try
{
    var decrypted = KeyStore.DecryptKeyStoreFromJson(password, jsonString);
}
catch (Exception)
{
    Console.WriteLine("Invalid password!");
}

Solana KeyStore Service

csharp
var solanaKeyStoreService = new SolanaKeyStoreService();
var wallet = solanaKeyStoreService.RestoreKeystore(filePath, passphrase);

RPC and Streaming RPC

The Solnet.Rpc project contains a full implementation of the Solana JSON RPC.

ClientFactory pattern

csharp
var rpcClient = ClientFactory.GetClient(Cluster.MainNet, logger);
var paidClient = ClientFactory.GetClient("https://your.paid.rpc", logger);
var streamingRpcClient = ClientFactory.GetStreamingClient(Cluster.MainNet, logger);

Using the RPC

…

Using the Streaming RPC

csharp
var txSig = rpcClient.SendTransaction(tx);
var subscription = streamingRpcClient.SubscribeSignature(txSig.Result, (state, response) =>
{
    // handle confirmation
}, Commitment.Finalized);

Sending a transaction

Important: Understanding priority fees

Poorly optimized transactions can get dropped due to high compute demand. Always specify both compute unit limit and price to improve inclusion probability.

csharp
var txBuilder = new TransactionBuilder()
    .AddInstruction(ComputeBudgetProgram.SetComputeUnitLimit(30000))
    .AddInstruction(ComputeBudgetProgram.SetComputeUnitPrice(1000000));
…

Create, Initialize and Mint

…

Transfer a Token to a new Token Account

…

Transaction and Message decoding

csharp
var tx = Transaction.Deserialize(txData);
var msg = Message.Deserialize(msgData);
var signedTx = Transaction.Populate(msg, new List { account.Sign(msgData) });

Programs

The Solnet.Programs project contains implementations of several Native and SPL programs. See Solnet.Examples for more depth, including multi-signature operations.

Hello Solana World

csharp
var memoInstruction = MemoProgram.NewMemo(wallet.Account, "Hello Solana World, using Solnet :)");

var recentHash = rpcClient.GetLatestBlockHash();

var tx = new TransactionBuilder()
    .SetFeePayer(wallet.Account)
    .AddInstruction(ComputeBudgetProgram.SetComputeUnitLimit(30000))
    .AddInstruction(ComputeBudgetProgram.SetComputeUnitPrice(1000000))
    .AddInstruction(memoInstruction)
    .SetRecentBlockHash(recentHash.Result.Value.Blockhash)
    .Build(wallet.Account);

Creating and sending tokens to an Associated Token Account

…

Creating and extending an Address Lookup Table for a complex transaction

…

This pattern is useful when a later transaction needs more account addresses than fit comfortably in the legacy message format. In Solnet, you typically create and populate the ALT with TransactionBuilder, wait for confirmation, and then reference it from a VersionedTransaction when building the larger v0 message.

v0 Transaction Execution

…

v1 Transaction Execution

v1 Transactions no longer require the computebudget program, but instead require TransactionConfig. For more details on v1 can be found here: Sending v1 Transactions

…

Instruction decoding

csharp
var msg = Message.Deserialize(msgBase64);
var decodedInstructions = InstructionDecoder.DecodeInstructions(msg);

Contribution

We encourage everyone to contribute, submit issues and PRs, and join discussions. Every kind of help is welcome.

Legacy Maintainers

  • Hugo - murlokito
  • Tiago - tiago

Current Maintainers

  • Nathan - BifrostTitan

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#cryptocurrencycsharpdefidotnet

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具