How to use
This is a simple app that uses the Unity implementation of Pravda DApp API for Expload Desktop.
- Clone this repo
ProgramTestas Unity Project
- Select ‘Send Button’ in Canvas
GUI.csas Script for this button
Assets contains C# sources including:
ExploadUnityCodegen.cs is an auxiliary file for generated
Program.cs that forms requests and parses responses of DApp API.
Program.cs is generated file that exposes the functionality to call program methods and parse the raw results.
GUI.cs operates with Unity graphics and UI and uses the functionality from
SmartProgram.cs is a 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 an
Assets folder and place all the generated files into it.
SmartProgram.cs contains three methods:
Emit that issues tokens to the sender's balance.
BalanceOf that checks the balance of the given address.
Transfer that can transfer coins to other address.
pravda gen unity analyses these methods and generates the appropriate classes (
The detailed description of how these classes are generated is available here.
This Unity app has a very simple GUI where you should specify the program’s address in the blockchain, what method to run and the arguments for the chosen method.
It only contains
SampleScene that is shown in the following picture: