C#
In order to use the C# Interface generation feature of Factori,
you will need to have Netezos
and dotnet
installed on your machine. For resources, look at:
- Dotnet
- https://netezos.dev/
- https://github.com/baking-bad/netezos.
The C# SDK can be found in the src/csharp_sdk
subfolder of your
Factori project directory.
It is generated by activating the --csharp
option of the
factori import kt1
or factori import michelson
commands, as seen below:
factori import kt1 <dir> KT1...XXX --network mainnet --name my_contract --csharp
<dir>
is the working directory (it may be relative, such as .
),
and KT1...XXX
is the address of the contract.
will create the directory <dir>/src/csharp_sdk
where the
following files and directories will appear:
blockchain.cs
: A library for blockchain specific operations;factori_types.cs
: A library of types and functions used by all imported interfaces;my_contract_code.json
: the Micheline code of your contract (useful for deployment)my_contract_csharp_interface.cs
: the C# interface to your contract, described below.
The command also creates a Makefile with useful commands such as:
make csharp-init
which will initiate a C# project.
make format-csharp
will format the generated code.
make csharp-build
will build the code.
In order to run Program.cs
, if you write e.g. a scenario in it, run
dotnet run --project src/csharp_sdk/
Description of the interface file
The interface file (my_contract_csharp_interface.cs
using the
convention from above) consists of both
- Types
- Functions
The types describe the contract's storage as well as all the input types of the contract's entrypoints (and any intermediate types which may need to be defined in the process). The functions are (mainly) of three kinds:
- A deploy function
deploy_my_contract
; - Calling functions for each entrypoint, of the form
call_<entrypoint_name>
. - Utility functions for manipulating types, so that in principle, you
never have to use Micheline or Michelson directly:
- Encoding functions from a type to Micheline (
<type name>_encode
); - Decoding functions from Micheline to a type (
<type name>_decode
); - Random generation of elements of the type (
<type name>_generator
).
- Encoding functions from a type to Micheline (