A modern, production-ready Unity SDK for integrating with the Casper blockchain network.
Features โข Installation โข Quick Start โข Documentation โข Examples
| Feature | Description |
|---|---|
| ๐ Real Cryptography | ED25519 & SECP256K1 with BouncyCastle |
| ๐ธ CSPR Transfers | Send CSPR tokens with one method call |
| ๐ Smart Contracts | Deploy WASM and call contract methods |
| ๐จ NFT Support | CEP-78 standard: mint, transfer, burn |
| ๐ก Event Streaming | Real-time SSE for deploy/block events |
| ๐ Secure Storage | AES-256 encrypted key storage |
| ๐ Multi-Wallet | Manage multiple accounts |
| ๐ Blockchain Integration | Connect to Mainnet or Testnet |
| ๐ Key Import/Export | PEM format for Casper Wallet/Signer |
| ๐ฎ Unity Optimized | Async/await, main thread handling |
- Open Window โ Package Manager
- Click + โ Add package from git URL
- Enter:
https://github.com/SamDreamsMaker/com.caspernetwork.sdk.git
For development or to access sample scenes:
https://github.com/SamDreamsMaker/Casper-Network-Unity-SDK.git?path=Assets/CasperSDK
The SDK includes:
- โ BouncyCastle.Crypto.dll (cryptography - included in Plugins/)
- โ Newtonsoft.Json (auto-installed via UPM)
- Package Manager โ Casper Network SDK โ Samples โ Import "Casper Wallet Demo"
- Open the imported
CasperWalletDemoscene fromAssets/Samples/ - Play the scene
- Click Import Keys to load your Casper Wallet PEM file
- Use the UI buttons for all operations
using CasperSDK.Utilities.Cryptography;
using CasperSDK.Services.Transfer;
// Generate a new key pair
var keyPair = CasperKeyGenerator.GenerateED25519();
Debug.Log($"Public Key: {keyPair.PublicKeyHex}");
Debug.Log($"Account Hash: {keyPair.AccountHash}");
// Transfer CSPR
var transferService = new TransferService(networkClient, config);
var result = await transferService.TransferAsync(
senderKeyPair,
recipientPublicKey,
TransferService.CsprToMotes(10m) // 10 CSPR
);// Import PEM file exported from Casper Wallet
var keyPair = KeyExporter.ImportFromPemFile("path/to/secret_key.pem");
// Export for Casper Wallet
KeyExporter.ExportToPemFiles(keyPair, "output/path");var contractService = new ContractService(networkClient, config);
// Deploy WASM
var result = await contractService.DeployContractAsync(
wasmBytes,
args,
senderKeyPair,
"50000000000" // 50 CSPR payment
);
// Call contract method
var callResult = await contractService.CallContractByHashAsync(
contractHash,
"transfer",
runtimeArgs,
senderKeyPair
);| Service | Description |
|---|---|
| AccountService | Balance queries, key generation, account import |
| TransferService | High-level CSPR transfers |
| ContractService | WASM deployment, contract calls, state queries |
| CEP78Service | NFT mint, transfer, burn, metadata queries |
| EventStreamingService | Real-time SSE events (deploys, blocks) |
| SecureKeyStorage | AES-256 encrypted key storage |
| WalletManager | Multi-account management |
| BlockService | Block queries by hash/height |
| NetworkInfoService | Node status, peers, chainspec |
| Class | Purpose |
|---|---|
| CasperKeyGenerator | Generate ED25519/SECP256K1 keys |
| KeyExporter | PEM import/export |
| DeploySigner | Sign deploys with private key |
| CLValueBuilder | Build runtime arguments |
| CryptoHelper | Blake2b, hex conversion, validation |
Create via Window โ Casper SDK โ Settings or:
Right-click in Project โ Create โ CasperSDK โ Network Config
| Property | Description | Default |
|---|---|---|
NetworkType |
Mainnet, Testnet, Custom | Testnet |
RpcUrl |
JSON-RPC endpoint | testnet node |
EnableLogging |
Debug logs | true |
| Button | Action |
|---|---|
| Generate Account | Create new ED25519 key pair |
| Import Keys | Load PEM from Documents/CasperKeys |
| Refresh Balance | Query CSPR balance |
| Copy Address | Copy public key to clipboard |
| Export Keys | Save PEM to Documents/CasperKeys |
| Open Faucet | Get free testnet CSPR |
| Send Transaction | Transfer CSPR to recipient |
- Casper Wallet โ Settings โ Download Secret Key โ Save PEM
- Copy PEM to
Documents/CasperKeys/ - Package Manager โ Casper Network SDK โ Samples โ Import
- Open the
CasperWalletDemoscene - Play โ Click Import Keys โ Keys loaded
- Refresh Balance โ See your CSPR
- Enter recipient + amount โ Send Transaction
Assets/CasperSDK/
โโโ Editor/ # Settings window, DemoSceneCreator
โโโ Plugins/ # BouncyCastle.Crypto.dll
โโโ Runtime/
โ โโโ Core/ # Configuration, Interfaces
โ โโโ Models/ # Deploy, KeyPair, CLValue
โ โโโ Network/ # RPC client
โ โโโ Services/
โ โ โโโ Account/ # Balance, keys
โ โ โโโ Contract/ # WASM, calls
โ โ โโโ Deploy/ # Builder, Signer, CLValueBuilder
โ โ โโโ Events/ # SSE streaming
โ โ โโโ NFT/ # CEP-78 support
โ โ โโโ Storage/ # Secure key storage
โ โ โโโ Transfer/ # CSPR transfers
โ โ โโโ Wallet/ # Multi-account
โ โโโ Utilities/
โ โ โโโ Cryptography/ # Keys, hashing, PEM import/export
โ โโโ Examples/ # TestnetDemo, BasicSDKExample
โโโ Samples/ # CasperWalletDemo scene & controller (dev only)
โโโ Tests/ # Unit tests (excluded from UPM)
- ED25519: Key generation, signing, verification
- SECP256K1: Key generation, ECDSA signing
- Blake2b-256: Deploy hash, account hash
- PEM: Import/export for wallets
- Build โ DeployBuilder with fluent API
- Hash โ Blake2b-256 body + header hash
- Sign โ ED25519 or SECP256K1 signature
- Submit โ account_put_deploy RPC
MIT License - see LICENSE
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push (
git push origin feature/amazing) - Open Pull Request
- ๐ Report Bug
- ๐ก Request Feature
Built with โค๏ธ for the Casper ecosystem