Netmavryk 2.8.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Netmavryk --version 2.8.1                
NuGet\Install-Package Netmavryk -Version 2.8.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Netmavryk" Version="2.8.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Netmavryk --version 2.8.1                
#r "nuget: Netmavryk, 2.8.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Netmavryk as a Cake Addin
#addin nuget:?package=Netmavryk&version=2.8.1

// Install Netmavryk as a Cake Tool
#tool nuget:?package=Netmavryk&version=2.8.1                

Netmavryk

<a href="https://www.nuget.org/packages/Netmavryk/"><img src="https://img.shields.io/nuget/v/Netmavryk.svg" /></a> <a href="https://www.nuget.org/packages/Netmavryk/"><img src="https://img.shields.io/nuget/dt/Netmavryk.svg" /></a> License: MIT

The first version of the library has been moved to the v1 branch for historical purposes.

Netmavryk is a cross-platform Mavryk SDK for .NET developers, simplifying the access and interaction with the Mavryk blockchain.

The following features have been implemented so far:

Namespace Description Status
Netmavryk.Contracts Interaction with Mavryk smart contracts Ready to use. Dynamic wrapper: in progress...
Netmavryk.Forge Forging (encoding) operation bytes Ready to use
Netmavryk.Keys Working with keys, HD keys, signing, verifying signature, etc. Ready to use
Netmavryk.Ledger Interaction with Mavryk Ledger App Ready to use (separate package)
Netmavryk.Rpc Mavryk RPC wrapper Ready to use

For full documentation and API Reference, please refer to the Netmavryk website

Contribution

Netmavryk is an open development project so any contribution is highly appreciated, starting from documentation improvements, writing examples of usage, etc. and ending with adding new features (as long as these features do not break existing API or are only intended for one person and for very specific use case).

Do not hesitate to use GitHub issue tracker to report bugs or request features.

Support

Feel free to join our Discord server, Telegram chat, or find us in Mavryk Dev Slack. We will be glad to hear any feedback and feature requests and will try to help you with general use cases of the Netmavryk library.

Getting started

Let's consider the most common use case - sending a transaction.

Installation

PM> Install-Package Netmavryk

Create private key

// generate new key
var key = new Key();

// or use existing one
var key = Key.FromBase58("edsk4ZkGeBwDyFVjZLL2neV5FUeWNN4NJntFNWmWyEBNbRwa2u3jh1");

// use this address to receive some tez
var address = key.PubKey.Address; // tz1SauKgPRsTSuQRWzJA262QR8cKdw1d9pyK

Get some data from RPC

using var rpc = new MavrykNode("https://mainnet-tezos.giganode.io/");

// get a head block
var head = await rpc.Blocks.Head.Hash.GetAsync<string>();

// get account's counter
var counter = await rpc.Blocks.Head.Context.Contracts[address].Counter.GetAsync<int>();

Forge an operation

Since our address has just been created, we need to reveal its public key before sending any operation, so that everyone can validate our signatures. Therefore, we need to send actually two operations: a reveal and then a transaction.

Netmavryk allows you to pack multiple operations into a group and forge/send it as a single batch.

var content = new ManagerOperationContent[]
{
    new RevealContent
    {
        Source = address,
        Counter = ++counter,
        PublicKey = key.PubKey.GetBase58(),
        GasLimit = 1500,
        Fee = 1000 // 0.001 tez
    },
    new TransactionContent
    {
        Source = address,
        Counter = ++counter,
        Amount = 1000000, // 1 tez
        Destination = "tz1KhnTgwoRRALBX6vRHRnydDGSBFsWtcJxc",
        GasLimit = 1500,
        Fee = 1000 // 0.001 tez
    }
};

var bytes = await new LocalForge().ForgeOperationGroupAsync(head, content);

Sign and send

// sign the operation bytes
byte[] signature = key.SignOperation(bytes);

// inject the operation and get its id (operation hash)
var result = await rpc.Inject.Operation.PostAsync(bytes.Concat(signature));

That is it. We have successfully injected our first operation into the Mavryk blockchain.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Netmavryk:

Package Downloads
Netmavryk.Ledger

.Net Standard 2.0 library for interacting with Ledger device and working with Mavryk Ledger App

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.10.1 114 6/18/2024
2.9.0 197 2/8/2024
2.8.2 332 11/9/2023
2.8.1 155 11/9/2023
2.8.0 157 11/8/2023