Skip to content

epicchainlabs/epicchain-unity-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮⛓️ EpicChain Unity SDK

EpicChain Unity SDK License Platform EpicChain Version Build Status Discord

The Complete EpicChain Blockchain SDK for Unity Game Developers

Transform your Unity games with seamless EpicChain blockchain integration. Build next-generation Web3 games with NFTs, smart contracts, and decentralized economies.

🚀 Get Started📚 Documentation💡 Examples🤝 Community


🌟 Overview

The EpicChain Unity SDK is a powerful, production-ready toolkit designed specifically for Unity game developers who want to integrate blockchain technology into their games. Whether you're building an NFT marketplace, a play-to-earn economy, or a decentralized multiplayer experience, this SDK provides everything you need to connect your Unity project with the EpicChain blockchain.

Why Choose EpicChain Unity SDK?

  • Native Unity Integration - Built from the ground up for Unity's architecture
  • Production Ready - Battle-tested in real-world gaming applications
  • Developer Friendly - Intuitive API with extensive documentation
  • Cross-Platform - Works on Mobile, Desktop, WebGL, and Console
  • Performance Optimized - Minimal overhead and efficient resource usage
  • Open Source - MIT licensed with active community support

✨ Core Features

🔐 Advanced Wallet Management

Experience enterprise-grade wallet functionality with comprehensive security features:

  • XEP-6 Wallet Standard - Full compliance with EpicChain wallet specifications
  • BIP-39 Mnemonic Generation - Create human-readable backup phrases
  • Multi-Signature Accounts - Support for complex authorization schemes
  • Hardware Wallet Support - Integration with Ledger and other hardware wallets
  • WIF Import/Export - Standard wallet interchange format support
  • Secure Key Storage - Encrypted local storage with password protection
  • HD Wallet Support - Hierarchical deterministic wallet generation
  • Watch-Only Addresses - Monitor addresses without private key access
// Example: Create a secure wallet with mnemonic
var mnemonic = Wallet.GenerateMnemonic();
var wallet = Wallet.CreateFromMnemonic(mnemonic, "SecurePassword123");
Debug.Log($"Wallet Address: {wallet.GetDefaultAccount().Address}");
Debug.Log($"Backup Phrase: {mnemonic}");

📄 Comprehensive Smart Contract Support

Interact with smart contracts effortlessly using our intuitive API:

  • Contract Deployment - Deploy new contracts directly from Unity
  • XEP-17 Token Operations - Full fungible token standard support
  • XEP-11 NFT Integration - Create, mint, and manage NFTs
  • Native Contract Support - Built-in support for EpicChain system contracts
  • Custom Contract Interaction - Call any method on any contract
  • Event Monitoring - Real-time blockchain event notifications
  • EpicPulse Optimization - Automatic epicpulse estimation and optimization
  • Batch Operations - Execute multiple contract calls efficiently
// Example: Mint an NFT
var nftContract = new XEP11Contract("0x123abc...");
var tokenId = await nftContract.Mint(
    ownerAddress: playerAddress,
    metadata: new NFTMetadata {
        Name = "Epic Sword",
        Description = "Legendary weapon",
        Image = "ipfs://..."
    }
);

🎯 Unity-First Architecture

Designed specifically for Unity workflows and best practices:

  • MonoBehaviour Components - Drag-and-drop blockchain integration
  • ScriptableObject Configuration - Visual network and contract setup
  • Coroutine-Based Async - Seamless integration with Unity's async patterns
  • Inspector Integration - Configure everything in the Unity Inspector
  • Prefab Templates - Pre-built components for common use cases
  • Unity Events - Native event system integration
  • Custom Editors - Beautiful custom inspectors for blockchain data
  • Gizmos & Debugging - Visual debugging tools for blockchain operations
// Example: Unity Component Integration
public class PlayerInventory : MonoBehaviour
{
    [SerializeField] private XEP11ContractReference nftContract;
    
    private void Start()
    {
        StartCoroutine(LoadPlayerNFTs());
    }
    
    private IEnumerator LoadPlayerNFTs()
    {
        yield return nftContract.GetTokensOfOwner(playerAddress, OnNFTsLoaded);
    }
}

High-Performance Design

Optimized for real-time gaming performance:

  • Thread-Safe Operations - Safe concurrent blockchain interactions
  • Connection Pooling - Efficient RPC connection management
  • Caching System - Smart caching for frequently accessed data
  • Batch Processing - Group operations for optimal throughput
  • Memory Management - Minimal garbage collection impact
  • Progressive Loading - Load blockchain data without frame drops
  • Background Processing - Heavy operations on background threads
  • WebGL Optimization - Special optimizations for browser deployment

🔗 Network Flexibility

Connect to any EpicChain network with ease:

  • MainNet Support - Production blockchain deployment
  • TestNet Support - Safe testing environment
  • Private Networks - Connect to custom EpicChain networks
  • Multiple RPC Endpoints - Automatic failover and load balancing
  • Network Switching - Dynamic network changes at runtime
  • Custom EpicPulse Tokens - Support for alternative epicpulse payment methods

🚀 Quick Start Guide

Prerequisites

Before you begin, ensure you have:

  • Unity 2021.3 LTS or later installed
  • Basic C# knowledge for scripting
  • EpicChain wallet (optional, for testing)
  • Internet connection for blockchain access

Installation Methods

Method 1: Unity Package Manager (Recommended)

  1. Open your Unity project
  2. Navigate to Window → Package Manager
  3. Click the + button in the top-left corner
  4. Select Add package from git URL
  5. Enter: https://github.com/epicchainlabs/epicchain-unity-sdk.git
  6. Click Add and wait for installation to complete

Method 2: Package Manager Manifest

  1. Open your project's Packages/manifest.json file
  2. Add the following to the dependencies section:
{
  "dependencies": {
    "com.epicchain.unity-sdk": "https://github.com/epicchainlabs/epicchain-unity-sdk.git#1.0.0",
    "com.unity.nuget.newtonsoft-json": "3.2.1"
  }
}
  1. Save the file and return to Unity to trigger the installation

Method 3: Manual Installation

  1. Download the latest release from GitHub Releases
  2. Extract the archive to your project's Assets/Plugins/ folder
  3. Wait for Unity to import the package

Initial Setup

Step 1: Create Configuration Asset

  1. In Unity, right-click in the Project window
  2. Navigate to Create → EpicChain → SDK Configuration
  3. Name it EpicChainConfig
  4. Configure the settings in the Inspector:

Step 2: Create Your First Blockchain Script

Create a new C# script called BlockchainManager.cs:

using EpicChain.Unity.SDK;
using EpicChain.Unity.SDK.Wallet;
using UnityEngine;
using System.Threading.Tasks;

public class BlockchainManager : MonoBehaviour
{
    [Header("Configuration")]
    [SerializeField] private EpicChainUnityConfig config;
    
    [Header("UI References")]
    [SerializeField] private TMPro.TextMeshProUGUI statusText;
    [SerializeField] private TMPro.TextMeshProUGUI addressText;
    [SerializeField] private TMPro.TextMeshProUGUI balanceText;
    
    private Wallet playerWallet;
    
    async void Start()
    {
        await InitializeBlockchain();
    }
    
    private async Task InitializeBlockchain()
    {
        try
        {
            UpdateStatus("Connecting to EpicChain...");
            
            // Initialize the SDK
            await EpicChainUnity.Instance.Initialize(config);
            
            UpdateStatus("Creating wallet...");
            
            // Create or load wallet
            playerWallet = await LoadOrCreateWallet();
            
            // Display wallet info
            var account = playerWallet.GetDefaultAccount();
            addressText.text = $"Address: {account.Address}";
            
            // Check balance
            await UpdateBalance();
            
            UpdateStatus("Connected successfully!");
        }
        catch (System.Exception ex)
        {
            UpdateStatus($"Error: {ex.Message}");
            Debug.LogError($"Blockchain initialization failed: {ex}");
        }
    }
    
    private async Task<Wallet> LoadOrCreateWallet()
    {
        // Try to load existing wallet
        if (PlayerPrefs.HasKey("WalletData"))
        {
            string walletJson = PlayerPrefs.GetString("WalletData");
            string password = "YourSecurePassword"; // Use proper password management
            return Wallet.FromJson(walletJson, password);
        }
        
        // Create new wallet
        var newWallet = Wallet.Create();
        
        // Save wallet (encrypted)
        string password = "YourSecurePassword";
        string walletJson = newWallet.ToJson(password);
        PlayerPrefs.SetString("WalletData", walletJson);
        PlayerPrefs.Save();
        
        return newWallet;
    }
    
    private async Task UpdateBalance()
    {
        var account = playerWallet.GetDefaultAccount();
        var balance = await EpicChainUnity.Instance.GetEpicChainBalance(account.Address);
        balanceText.text = $"XPR Balance: {balance:F8}";
    }
    
    private void UpdateStatus(string message)
    {
        if (statusText != null)
            statusText.text = message;
        Debug.Log($"[Blockchain] {message}");
    }
    
    public async void OnTransferButtonClicked()
    {
        // Example: Transfer tokens
        try
        {
            UpdateStatus("Sending transaction...");
            
            var txHash = await EpicChainUnity.Instance.TransferEpicChain(
                from: playerWallet.GetDefaultAccount(),
                to: "NRecipientAddressHere",
                amount: 1.0m
            );
            
            UpdateStatus($"Transaction sent: {txHash}");
            
            // Wait for confirmation
            await Task.Delay(15000); // Wait ~15 seconds
            await UpdateBalance();
        }
        catch (System.Exception ex)
        {
            UpdateStatus($"Transfer failed: {ex.Message}");
        }
    }
}

Step 3: Set Up Your Scene

  1. Create a new GameObject in your scene: GameObject → Create Empty
  2. Name it BlockchainManager
  3. Add the BlockchainManager script to it
  4. Assign the EpicChainConfig asset to the script's config field
  5. Create UI elements (TextMeshPro texts) and assign them to the script

Step 4: Test Your Integration

  1. Press Play in Unity
  2. Check the Console for connection messages
  3. Verify that a wallet address appears in your UI
  4. Check that the balance is displayed correctly

📦 Sample Projects

Learn by example with our comprehensive sample projects:

🏪 NFT Marketplace Game

A complete marketplace implementation featuring:

Core Features:

  • NFT Minting System - Create unique in-game items as NFTs
  • Auction Mechanics - Time-based bidding with automatic settlement
  • Direct Trading - Peer-to-peer item exchange
  • Collection Management - Browse, filter, and sort NFTs
  • Price Discovery - Real-time market pricing
  • Transaction History - Complete audit trail of all trades
  • Royalty System - Creator royalties on secondary sales

Technical Implementation:

  • XEP-11 NFT contract integration
  • Metadata storage on IPFS
  • Real-time price updates
  • Transaction signing and verification
  • Event-driven UI updates
// Example: List NFT for sale
public async Task ListNFTForSale(string tokenId, decimal price)
{
    var marketplace = new MarketplaceContract(marketplaceAddress);
    await marketplace.ListItem(
        tokenId: tokenId,
        price: price,
        seller: playerWallet.GetDefaultAccount()
    );
}

Location: Samples~/NFTMarketplace/

⚔️ Blockchain RPG

A full-featured RPG showcasing advanced blockchain integration:

Game Features:

  • Character NFTs - Unique characters stored on-chain
  • Equipment System - NFT weapons, armor, and accessories
  • Skill Progression - Blockchain-verified character stats
  • Guild System - Decentralized player organizations
  • Quest Rewards - Token and NFT rewards
  • Crafting System - Combine items to create new NFTs
  • Trading Post - Player-to-player economy

Blockchain Features:

  • Multi-signature guild treasury
  • On-chain achievement system
  • Provably fair loot drops
  • Cross-game item compatibility
  • Permanent character ownership
// Example: Level up character
public async Task LevelUpCharacter(string characterNFT)
{
    var rpgContract = new RPGContract(contractAddress);
    await rpgContract.LevelUp(
        tokenId: characterNFT,
        player: playerWallet.GetDefaultAccount()
    );
    
    // Update local character data
    await RefreshCharacterStats(characterNFT);
}

Location: Samples~/BlockchainRPG/

💰 Wallet Integration Demo

Comprehensive wallet functionality demonstration:

Demonstrated Features:

  • Wallet Creation - Generate new wallets with mnemonics
  • Wallet Import - Import from WIF, JSON, or mnemonic
  • Multi-Account Support - Manage multiple addresses
  • Transaction Builder - Create and sign custom transactions
  • Balance Tracking - Real-time balance updates
  • Token Management - View and transfer XEP-17 tokens
  • Transaction History - Browse past transactions
  • Address Book - Save frequently used addresses
// Example: Import wallet from mnemonic
public Wallet ImportWalletFromMnemonic(string mnemonic, string password)
{
    if (!Wallet.ValidateMnemonic(mnemonic))
    {
        throw new Exception("Invalid mnemonic phrase");
    }
    
    var wallet = Wallet.CreateFromMnemonic(mnemonic, password);
    Debug.Log($"Wallet imported: {wallet.GetDefaultAccount().Address}");
    return wallet;
}

Location: Samples~/WalletDemo/

🎲 Provably Fair Gaming

Demonstrating transparent, verifiable game mechanics:

Features:

  • Blockchain-based random number generation
  • Verifiable game outcomes
  • Transparent loot box mechanics
  • Fair matchmaking system
  • Tamper-proof leaderboards

Location: Samples~/ProvablyFair/


🏗️ Architecture & Design

Project Structure

EpicChain.Unity.SDK/
│
├── Runtime/
│   ├── Core/                    # Core blockchain functionality
│   │   ├── EpicChainUnity.cs   # Main SDK entry point
│   │   ├── NetworkClient.cs     # RPC client implementation
│   │   └── TransactionBuilder.cs
│   │
│   ├── Contracts/               # Smart contract interactions
│   │   ├── ContractBase.cs     # Base contract class
│   │   ├── XEP17Contract.cs    # Fungible token standard
│   │   ├── XEP11Contract.cs    # NFT standard
│   │   └── NativeContracts/    # Built-in system contracts
│   │
│   ├── Crypto/                  # Cryptographic operations
│   │   ├── KeyPair.cs          # Public/private key management
│   │   ├── Signature.cs        # Digital signatures
│   │   └── Hash.cs             # Hashing functions
│   │
│   ├── Wallet/                  # Wallet management
│   │   ├── Wallet.cs           # Main wallet class
│   │   ├── Account.cs          # Account management
│   │   └── WalletStorage.cs    # Secure storage
│   │
│   ├── Utils/                   # Utility classes
│   │   ├── Serialization/      # JSON/binary serialization
│   │   ├── Encoding/           # Base58/Hex encoding
│   │   └── Extensions/         # C# extension methods
│   │
│   └── Components/              # Unity MonoBehaviour components
│       ├── BlockchainManager.cs
│       ├── WalletController.cs
│       └── ContractInteractor.cs
│
├── Editor/                      # Unity Editor extensions
│   ├── ConfigurationEditor.cs  # Custom inspectors
│   ├── WalletWindow.cs         # Wallet management window
│   └── ContractDeployer.cs     # Contract deployment tool
│
├── Samples~/                    # Sample projects
│   ├── NFTMarketplace/
│   ├── BlockchainRPG/
│   └── WalletDemo/
│
├── Tests/                       # Unit and integration tests
│   ├── Runtime/
│   └── Editor/
│
└── Documentation~/              # Documentation files
    ├── api-reference.md
    ├── unity-integration.md
    └── tutorials/

Design Patterns

The SDK implements several proven design patterns:

  • Singleton Pattern - EpicChainUnity instance management
  • Factory Pattern - Contract and wallet creation
  • Observer Pattern - Blockchain event notifications
  • Strategy Pattern - Pluggable network providers
  • Repository Pattern - Data access abstraction
  • Command Pattern - Transaction building

Thread Safety

All SDK operations are thread-safe and work seamlessly with Unity's threading model:

  • Main thread operations for Unity API calls
  • Background threads for heavy cryptographic operations
  • Async/await pattern for non-blocking operations
  • Coroutine support for Unity-style async

📚 Comprehensive Documentation

API Reference

Complete documentation for every class, method, and property:

Integration Guides

Step-by-step tutorials for common scenarios:

Advanced Topics

Deep dives into complex features:

Video Tutorials

Visual learners can check out our video series:

  • 🎥 Getting Started with EpicChain Unity SDK (15 min)
  • 🎥 Building Your First Blockchain Game (45 min)
  • 🎥 Advanced NFT Implementation (30 min)
  • 🎥 Multiplayer Blockchain Integration (40 min)

🛠️ Development

Building from Source

For developers who want to contribute or customize:

# Clone the repository
git clone https://github.com/epicchainlabs/epicchain-unity-sdk.git

# Navigate to directory
cd epicchain-unity-sdk

# Open in Unity 2021.3 or later
# The project will automatically resolve dependencies

Development Requirements

  • Unity 2021.3 LTS or later
  • .NET Standard 2.1 support
  • Newtonsoft JSON package (auto-installed)
  • Git for version control
  • Visual Studio or Rider (recommended IDEs)

Running Tests

Comprehensive test coverage ensures reliability:

# In Unity Editor
Window → General → Test Runner → Run All Tests

# Via command line
unity -runTests -batchmode -projectPath /path/to/project -testResults results.xml

Test Coverage:

  • Unit tests for all core functionality
  • Integration tests for blockchain operations
  • Performance benchmarks
  • Cross-platform compatibility tests

Code Quality

We maintain high code quality standards:

  • Code Reviews - All PRs require approval
  • Automated Testing - CI/CD pipeline validation
  • Code Coverage - Minimum 80% coverage
  • Documentation - XML docs for all public APIs
  • Style Guide - Consistent C# coding conventions

🤝 Contributing

We welcome contributions from the community! Here's how you can help:

Ways to Contribute

  • 🐛 Bug Reports - Found a bug? Let us know!
  • Feature Requests - Have an idea? We'd love to hear it!
  • 📝 Documentation - Help improve our docs
  • 💻 Code Contributions - Submit pull requests
  • 🧪 Testing - Help test new features
  • 🌍 Translations - Translate documentation

Contribution Process

  1. Fork the Repository

    git clone https://github.com/YOUR_USERNAME/epicchain-unity-sdk.git
  2. Create a Feature Branch

    git checkout -b feature/amazing-feature
  3. Make Your Changes

    • Write clean, documented code
    • Follow existing code style
    • Add tests for new features
  4. Commit Your Changes

    git commit -m "Add amazing feature"
  5. Push to Your Fork

    git push origin feature/amazing-feature
  6. Open a Pull Request

    • Describe your changes clearly
    • Reference any related issues
    • Wait for review and feedback

Coding Standards

Please follow these guidelines:

  • Use meaningful variable and method names
  • Add XML documentation comments
  • Write unit tests for new functionality
  • Follow C# naming conventions
  • Keep methods focused and concise
  • Handle errors appropriately

For full details, see our Contributing Guide.


🐛 Troubleshooting

Common Issues

Issue: "Failed to connect to RPC endpoint"

Solution:

  • Check your internet connection
  • Verify the RPC endpoint URL is correct
  • Try an alternative RPC endpoint
  • Check firewall settings

Issue: "Transaction failed: insufficient funds"

Solution:

  • Check wallet balance has enough XPR for epicpulse
  • Ensure you're accounting for transaction fees
  • For TestNet, request tokens from faucet

Issue: "Smart contract not found"

Solution:

  • Verify contract address is correct
  • Ensure you're connected to the right network
  • Check if contract is deployed

Issue: "WebGL build crashes"

Solution:

  • Use WebGL compatibility mode in config
  • Avoid synchronous blockchain calls
  • Implement proper error handling

Getting Help

If you're stuck:

  1. Check our FAQ
  2. Search GitHub Issues
  3. Join our Discord
  4. Post on our Forum

🌐 Community & Support

Official Channels

Community Resources

  • Developer Blog - Technical articles and updates
  • Monthly Newsletter - Latest news and announcements
  • Community Calls - Bi-weekly developer meetups
  • Hackathons - Regular coding competitions with prizes

📄 License

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

MIT License

Copyright (c) 2024 EpicChain Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

[Full license text...]

🎯 Roadmap

Current Version (1.0.0)

  • ✅ Core wallet functionality
  • ✅ Smart contract interaction
  • ✅ XEP-17 token support
  • ✅ XEP-11 NFT support
  • ✅ Cross-platform compatibility

Upcoming Features (1.1.0 - Q1 2025)

  • 🔄 Advanced caching system
  • 🔄 Offline transaction signing
  • 🔄 Hardware wallet integration
  • 🔄 Enhanced epicpulse estimation
  • 🔄 Batch transaction optimization

Future Plans (2.0.0)

  • 📋 Layer 2 scaling solutions
  • 📋 Cross-chain bridge support
  • 📋 Advanced analytics dashboard
  • 📋 Mobile-optimized UI components
  • 📋 VR/AR blockchain integration

🌟 Showcase

Games Built with EpicChain Unity SDK

CryptoQuest RPG - A fully on-chain RPG with 10,000+ players
NFT Racers - Blockchain-based racing game with tradeable cars
MetaGuild - Decentralized guild management platform

Want your game featured here? Contact us!


🔗 Useful Links

EpicChain Resources

Unity Resources

Development Tools


🚀 Ready to Build?

Transform your game with blockchain technology today!

Get Started NowView SamplesJoin Community


Made with ❤️ by the EpicChain Labs Team

Building the future of blockchain gaming, one commit at a time.

Star on GitHub Follow on Twitter

About

Seamless EpicChain integration for Unity. Build next-gen Web3 games with NFTs, smart contracts, wallets, and on-chain economies.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors