Skip to content

A Unity plugin for Ethereum wallet aiming to be ready-to-use in all projects with minimal coding. Players can create their Ethereum wallet and send transactions. Contains lot of demos for learning purposes.

License

Notifications You must be signed in to change notification settings

Block42World/block42-wallet-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Block42

Block42 Unity Wallet Plugin

Overview

A Ethereum wallet and transaction system in Unity. This plug-in is inspired by Alto's unit3d-blockchain-wallet and aims to be scalable and easy-to-use for all other projects with minimal coding. Changes includes separating UI logic from manager logic, optimize the code to follow Unity standard, as well as adding a number of demos for learning purposes. Few advanced usages are also added such as using geth and mining inside Unity.

Please note that this is still in prototype and under heavy development. The final product may be subject to a number of quality assurance tests to verify conformance with specifications.

Requirements

  • Unity 2017+
  • Set Scripting Runtime Version to .NET 4.x Equivalent in PlayerSettings PlayerSettings

Settings

ScriptableObject is used globally for wallet setting, access the settings in menu through Block42 > Wallet > Settings: Menu Wallet Settings Wallet Settings Inspector

  • Network: Ropsten is set as default and used throughout all demos, you can use another testnet, or custom network by providing the URL in settings. Note that the smart contracts used in demos were only deployed in Ropsten. For trying the demos in other networks or using your own smart contracts, deploy the contracts accordingly and set the ABI and the address in ContractController. See Demo 02-MyWalletBalance on how to change them.
  • Infura Api Key: Infura API are used to comuunicate with the blockchains. You can use my API key for development, but make sure you register your own one for free here and put your own key in.
  • Custom Network URL: A mannual URL used for custom network only, it can be your localhost with your desired port, or a AWS server where you run your private chain node with RPC port opened.
  • Gas Price: The default gas price on your chain, it is used when sending ETH/token and mining.
  • Debug Log: A rich log mode for debugging purpose.

Script Overview

  • WalletManager: A master manager on managing wallets, such as create, save and load. This is a static class so all variables and methods can be easily access everywhere. Transactions are asynchronous and Couroutine is required to process transaction. For easier access, a CouroutineManager is automatically created for handling all coroutines of static classes.
  • ContractController: A base class that holds the ABI and address of the smart contract, all other contract should be inherent from this and attach to anywhere of the scene.
  • ERC20ContractController: A child class inherited from ContractController that implements all the method of a ERC20 standard token contract.
  • ERC721ContractController: (TODO) Same as ERC20ContractController but implements a ERC721 standard token contract.

Demos

This projects contains a number of demos from basic to intermediate, and aimed to be Ethereum-beginner-prove. Go to each demo in Demos folder for more details. It's recommended to spend 10 minutes to quickly go through all demos before any integration.

Nethereum

This plugin uses Nethereum library to interact with Ethereum. Most of the time you can simply call functions in WalletManager and be worry-free about how to use it.

If you already have Nethereum in your project, you can safely delete the whole Plugins folder. You may also want to delete these sub-libraies to save building space:

  • Nethereum.Web3 - Used to demonstrate the difference of using Web3 and UnityRPCRequests in Demo 02-StaticWalletBalance. If you are not using any Web3 library in your project, you can delete this.
  • Nethereum.Geth - Used to run an ethereum node and mining within Unity. See Demo 07-Mining for details. If you are not using any Geth library or not mining in Unity, you can delete this.

TODO

  • Add ERC721 token contract controller
  • Add Travis CI for build test

About

A Unity plugin for Ethereum wallet aiming to be ready-to-use in all projects with minimal coding. Players can create their Ethereum wallet and send transactions. Contains lot of demos for learning purposes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages