C# translation overview
Pravda project allows you to write programs in subset of C# language. Pravda Translator translates CIL to Pravda bytecode.
Supported C# subset
Pravda Translator supports only part of all C# features.
For the moment it supports the following:
- Access to the storage via class fields;
- Access to the storage via
Mapping<K, V> (
- Access to sender address via
- Access to list of contract's callers' addresses via
- Class methods that are translated to program methods;
- Integer primitive types (
- Basic arithmetics and logical operations;
- Local variables and method arguments;
- If conditions and loops;
Strings and auxiliary methods (
+, access to particular chars,
Bytes (immutable byte arrays), auxiliary methods (access to particular bytes,
Concat), creation from
- Arrays of primitive types (
String), reading and writing of particular elements;
- Explicit conversion of primitive types via
- Cryptographic functions: Ripemd160 hashing, validation of Ed25519 Signature. See more in Standard library docs.
- User defined classes (although you can't store them in the storage yet).
- Calling other programs via
See some examples (Pcall.cs, PcallProgram.cs).
- Create events in your program via
Log.Event("name of event", <some_data>), see Event.cs
Things that are not supported: - Standard C# library (except of some specific functions from the list above); - Standard C# collections.
Important note: All code placed in
Expload.Pravda namespace is ignored.
It is needed to support stub methods in
You can look at several examples of test programs to learn current abilities of translation:
- String examples that show how to operate with
- Array examples that show how to operate with arrays.
- Simple program with
transfer methods similar to corresponding methods from ERC20
- Buffer -- Dynamic resizable array implemented in C#.
- Zoo program that allows you to create zoos, pets and breed them.
- Poker program that implements simple poker game on the blockchain. _(poker.cs was provided by Ducatur team)