A comprehensive Unity SDK for integrating Casper Network blockchain functionality into Unity games and applications.
- Clean Architecture: Built with SOLID principles and proven design patterns
- Easy Integration: Simple, Unity-friendly API
- Async/Await Support: Full async support with Unity main thread dispatching
- Account Management: Key generation, import, and balance queries
- Transaction System: Fluent transaction builder with validation
- Network Flexibility: Support for Mainnet, Testnet, and custom networks
- Error Handling: Comprehensive exception hierarchy
- Type Safe: Strongly typed models and interfaces
- Unity 2022.3 LTS or higher
- .NET Standard 2.1 or higher
- Windows, macOS, Linux, WebGL, iOS, Android support
- Clone or download this repository
- Copy the
Assets/CasperSDKfolder to your Unity project'sAssetsfolder - Import the required DLLs (Casper.Network.SDK) into
Assets/CasperSDK/Plugins/
Create a network configuration:
- Right-click in Project window
- Create > CasperSDK > Network Configuration
- Configure your network settings (Mainnet/Testnet/Custom)
using CasperSDK.Core;
using CasperSDK.Core.Configuration;
public class MyGame : MonoBehaviour
{
[SerializeField] private NetworkConfig networkConfig;
private void Start()
{
// Initialize the SDK
CasperSDKManager.Instance.Initialize(networkConfig);
}
}// Generate a new key pair
var accountService = CasperSDKManager.Instance.AccountService;
var keyPair = await accountService.GenerateKeyPairAsync();
// Get account balance
var balance = await accountService.GetBalanceAsync(publicKey);
// Build and submit a transaction
var transactionService = CasperSDKManager.Instance.TransactionService;
var transaction = transactionService.CreateTransactionBuilder()
.SetFrom(senderPublicKey)
.SetTarget(recipientPublicKey)
.SetAmount("2500000000") // 2.5 CSPR in motes
.Build();
var txHash = await transactionService.SubmitTransactionAsync(transaction);The SDK follows clean architecture principles with the following design patterns:
- Singleton Pattern:
CasperSDKManager- Single entry point for the SDK - Factory Pattern:
NetworkClientFactory- Creates appropriate network clients - Builder Pattern:
TransactionBuilder- Fluent API for transaction construction - Repository Pattern:
AccountService- Abstraction for account data access - Strategy Pattern: Different network implementations (Mainnet/Testnet)
- Observer Pattern: Event system for blockchain events
CasperSDK/
βββ Runtime/
β βββ Core/
β β βββ Configuration/ # Network and SDK settings
β β βββ Interfaces/ # Service interfaces
β β βββ CasperSDKManager.cs # Main SDK entry point
β β βββ Exceptions.cs # Custom exceptions
β βββ Network/
β β βββ RPC/ # JSON-RPC client
β β βββ Clients/ # Network client implementations
β βββ Services/
β β βββ Account/ # Account management
β β βββ Transaction/ # Transaction services
β βββ Models/ # Data models
β βββ Unity/ # Unity-specific integrations
β βββ Examples/ # Example scripts
βββ Editor/ # Editor tools and utilities
βββ Tests/ # Unit and integration tests
Main entry point for the SDK. Implements Singleton pattern.
// Initialize
CasperSDKManager.Instance.Initialize(config);
// Access services
var accountService = CasperSDKManager.Instance.AccountService;
var transactionService = CasperSDKManager.Instance.TransactionService;
// Shutdown
CasperSDKManager.Instance.Shutdown();Manages Casper accounts and keys.
Task<Account> GetAccountAsync(string publicKey);
Task<string> GetBalanceAsync(string publicKey);
Task<KeyPair> GenerateKeyPairAsync(KeyAlgorithm algorithm);
Task<KeyPair> ImportAccountAsync(string privateKeyHex, KeyAlgorithm algorithm);Handles transaction creation and submission.
ITransactionBuilder CreateTransactionBuilder();
Task<string> SubmitTransactionAsync(Transaction transaction);
Task<ExecutionResult> GetTransactionStatusAsync(string transactionHash);
Task<long> EstimateGasAsync(Transaction transaction);Fluent API for building transactions.
var transaction = service.CreateTransactionBuilder()
.SetFrom(sender)
.SetTarget(recipient)
.SetAmount("1000000000")
.SetGasPrice(1)
.SetTTL(3600000)
.Build();See Assets/CasperSDK/Runtime/Examples/BasicSDKExample.cs for a comprehensive example.
The SDK includes comprehensive unit and integration tests.
- Open Unity Test Runner (Window > General > Test Runner)
- Select "Runtime Tests" or "Editor Tests"
- Click "Run All" or run individual tests
- Unit Tests: Test individual components with mocked dependencies
- Integration Tests: Test against Casper Testnet (requires internet)
- Use Unity's secure storage for private keys in production
- Test with Testnet before deploying to Mainnet
- Always validate user inputs
- Keep dependencies up to date
Contributions are welcome! Please:
- Fork the source repository (not this package repo): π https://github.com/SamDreamsMaker/Casper-Network-Unity-SDK
- Create a feature branch
- Follow the existing code style and patterns
- Add tests for new functionality
- Submit a pull request to the source repository
β οΈ Note: Do NOT submit PRs tocom.caspernetwork.sdk- it's auto-generated from the source repo.
This SDK follows strict code quality standards:
- β SOLID principles
- β Clean code practices
- β Comprehensive error handling
- β XML documentation for all public APIs
- β Unit tests for all components
- β Consistent naming conventions
MIT License - see LICENSE
For issues, questions, or contributions:
- Open an issue on GitHub
- Contact: samdreamsmaker@gmail.com
- Core infrastructure
- Network layer with JSON-RPC
- Account management
- Transaction builder
- Transaction signing (ED25519 & SECP256K1)
- CSPR transfers
- Key import/export (PEM format)
- Smart contract deployment
- Smart contract interaction
- Event listening (SSE - in progress)
- WebGL support optimization
- Sample projects (Wallet β , NFT, Token)
Version: 1.0.0
Last Updated: December 2025
Status: Production Ready
Source Repository: https://github.com/SamDreamsMaker/Casper-Network-Unity-SDK