SetNet.Wallet 1.2.0

dotnet add package SetNet.Wallet --version 1.2.0
                    
NuGet\Install-Package SetNet.Wallet -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SetNet.Wallet" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.Wallet" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.Wallet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SetNet.Wallet --version 1.2.0
                    
#r "nuget: SetNet.Wallet, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SetNet.Wallet@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SetNet.Wallet&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.Wallet&version=1.2.0
                    
Install as a Cake Tool

<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>

SetNet.Wallet

Server-authoritative player currencies for SetNet.

The server owns every coin. Game logic deposits, withdraws, and transfers named currencies by player key with atomic anti-overdraft guarantees; clients read their balances and subscribe to changes but never mutate them. It's the money side of the economy — SetNet.Vendor and SetNet.Auction move currency through this same hub. Added by composition — no base class.

Install

dotnet add package SetNet
dotnet add package SetNet.Wallet

Usage

Call WalletRuntime.Enable() once at startup on both ends.

// server
WalletRuntime.Enable();
var wallet = server.UseWallet();
await wallet.DepositAsync(playerKey, "gold", 500);
bool paid = await wallet.TryWithdrawAsync(playerKey, "gold", 100);        // false if broke
bool sent = await wallet.TryTransferAsync(fromKey, toKey, "gold", 50);    // atomic

// client
WalletRuntime.Enable();
var wallet = client.UseWallet();
wallet.Changed += balances => Redraw(balances);
foreach (var b in await wallet.GetAsync()) Console.WriteLine($"{b.Amount} {b.Currency}");

API

Server: server.UseWallet(IWalletStore?, WalletOptions?)WalletServerDepositAsync, TryWithdrawAsync, TryTransferAsync, GetAsync, KeyOf(peer), PushAsync. Client: client.UseWallet()WalletClientGetAsync(), event Changed. Store: IWalletStore (MemoryWalletStore default). Options: WalletOptions.PlayerKey.

WalletRuntime.Enable() — one-time bootstrap.

Notes

  • Rides the unified SetNet.Protocol messaging layer on the Channels.Wallet channel (all modules share one envelope wire type, 65447) — no per-module wire ids to reserve. Serializer-agnostic: the control protocol is hand-framed byte[], your payloads use your SetNetSerializer.
  • Atomic by contract. TryWithdrawAsync/TryTransferAsync never overdraw and never dupe. Back the store with a transactional store (Redis/SQL) for a multi-node cluster.
  • Stable player key. Default is the connection id; with SetNet.Auth set WalletOptions.PlayerKey to the account id so wallets persist.
  • Mirrors SetNet.Inventory: items there, money here.

Documentation & source

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages (3)

Showing the top 3 NuGet packages that depend on SetNet.Wallet:

Package Downloads
SetNet.Marketplace

Continuous double-sided order-book marketplace for SetNet: post limit buy/sell orders (items/currency escrowed), crossing orders match instantly at the resting price with price-time priority and the rest rests on the book. Settled through SetNet.Inventory + SetNet.Wallet (no dupes; buyer refunded price improvement). server.UseMarketplace(inventory, wallet) + client.UseMarketplace(). Depends on SetNet + SetNet.Inventory + SetNet.Wallet.

SetNet.Vendor

NPC shops for SetNet: define vendor catalogs (buy/sell prices, currency, stock); clients buy and sell and the server settles atomically through SetNet.Wallet + SetNet.Inventory (money before goods, stock reserved before charge). server.UseVendor(inventory, wallet).Define(...) + client.UseVendor(). Depends on SetNet + SetNet.Inventory + SetNet.Wallet.

SetNet.Auction

Auction house for SetNet: list items (escrowed from inventory), bid or buy out (currency escrowed, prior bidder refunded), and a background timer settles expired listings — winner gets the item, seller gets the bid, or the item is returned. All moves go through SetNet.Inventory + SetNet.Wallet (no dupes). server.UseAuction(inventory, wallet) + client.UseAuction(). Depends on SetNet + SetNet.Inventory + SetNet.Wallet.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 177 8/5/2026