This is a simple app that using Unity implementaion of Pravda DApp API for Expload Desktop.
- Clone this repo
ProgramTestas Unity Project
- Select Send Button in Canvas
GUI.csas Script for this button
Structure of the repository
Assets contains C# sources including:
ExploadUnityCodegen.cs is auxiliary file for generated
Program.cs that forms requests and parses responses of DApp API.
Program.cs is generated file that exposes functionality to call program's methods and parse the raw results.
GUI.cs operates with Unity graphics and UI and uses functionality from
SmartProgram.cs is C# source file that is compiled to
SmartProgram.exe and translated to Pravda program
SmartProgram.pravda by the following commands:
csc SmartProgram.cs -reference:Pravda.dll pravda compile dotnet -i SmartProgram.exe -o SmartProgram.pravda
You can find
ExploadUnityCodegen.cs were generated from
pravda gen unity -i SmartProgram.pravda
This command will create
Assets folder and place all generated files to it.
SmartProgram.cs contains three methods:
Emit that emits tokens to the sender's balance;
BalanceOf that checks balance of the given address;
Tansfer that can transfer coins to other address.
pravda gen unity analyses these methods and generate appropriate classes (
For detailed description of how these classes were genereated you can look here.
This Unity app has very simple GUI where you should specify address of program in the blockchain, what method to run and arguments for chosen method.
It contains only
SampleScene that is shown at the following picture: