RemarkableTools.Mx.WalletConnect 2.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package RemarkableTools.Mx.WalletConnect --version 2.1.2                
NuGet\Install-Package RemarkableTools.Mx.WalletConnect -Version 2.1.2                
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="RemarkableTools.Mx.WalletConnect" Version="2.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RemarkableTools.Mx.WalletConnect --version 2.1.2                
#r "nuget: RemarkableTools.Mx.WalletConnect, 2.1.2"                
#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 RemarkableTools.Mx.WalletConnect as a Cake Addin
#addin nuget:?package=RemarkableTools.Mx.WalletConnect&version=2.1.2

// Install RemarkableTools.Mx.WalletConnect as a Cake Tool
#tool nuget:?package=RemarkableTools.Mx.WalletConnect&version=2.1.2                

Wallet Connect 2.0 documentation

About SDK

The library is used to connect to xPortal wallet and sign transactions.

How to install?

The content is delivered via nuget package:

RemarkableTools.Mx.WalletConnect Package

Quick start guide

Note: This guide does not include the NativeAuthClient Token for connection.
  1. Variables init
ApiProvider Provider = new ApiProvider(new ApiNetworkConfiguration(Network.DevNet));
NetworkConfig NetworkConfig { get; set; } = default!;
Account Account { get; set; } = default!;
  1. Define the Metadata (is showing in xPortal when approving the connection) and NativeAuth Token
var metadata = new Metadata()
{
    Name = "Mx.NET.WinForms",
    Description = "Mx.NET.WinForms login testing",
    Icons = new[] { "https://devnet.remarkable.tools/remarkabletools.ico" },
    Url = "https://devnet.remarkable.tools/"
};
  1. Define the Wallet Connection
const string CHAIN_ID = "D";
const string PROJECT_ID = "WALLET_CONNECT_PROJECT_ID";
IWalletConnect WalletConnect = new WalletConnect(metadata, PROJECT_ID, CHAIN_ID);
  1. At start-up, you should check for old connection and setup the events
await WalletConnect.ClientInit();
WalletConnect.OnSessionUpdateEvent += OnSessionUpdateEvent;
WalletConnect.OnSessionEvent += OnSessionEvent;
WalletConnect.OnSessionDeleteEvent += OnSessionDeleteEvent;
WalletConnect.OnSessionExpireEvent += OnSessionDeleteEvent;
WalletConnect.OnTopicUpdateEvent += OnTopicUpdateEvent;

try
{
    var isConnected = WalletConnect.TryReconnect();
    if (isConnected)
    {
        //initialize some variables
        NetworkConfig = await NetworkConfig.GetFromNetwork(Provider);
        Account = Account.From(await Provider.GetAccount(WalletConnect.Address));

        //do other operations
    }
}
catch (Exception ex)
{
    //Exception occured
}
  1. If you don't have a connection saved, continue with WalletConnect connection initialization
await WalletConnect.Initialize();
  1. Show a QR code generated with the link from WalletConnect.URI

  2. Start the wallet connection

try
{
    await WalletConnect.Connect(); 

    //initialize some variables
    NetworkConfig = await NetworkConfig.GetFromNetwork(Provider);
    Account = Account.From(await Provider.GetAccount(WalletConnect.Address));
}
catch (Exception ex)
{
    //Connection was not approved
}
  1. Session Events
private void OnSessionUpdateEvent(object? sender, GenericEvent<SessionUpdateEvent> @event)
{
    //Wallet connected
}

private void OnSessionEvent(object? sender, GenericEvent<SessionEvent> @event)
{
    //Session event
}

private void OnSessionDeleteEvent(object? sender, EventArgs e)
{
    //Wallet Disconnected

    NetworkConfig = default!;
    Account = default!;
}

private void OnTopicUpdateEvent(object? sender, GenericEvent<TopicUpdateEvent> @event)
{
    //Topic Update
}
  1. Disconnect function
await WalletConnect.Disconnect(); //this will also trigger OnSessionDeleteEvent

9.1 Create a transaction then sign it with WalletConnect

await Account.Sync(Provider); //always sync account first (to have the latest nonce)
var receiver = "RECEIVER_ADDRESS";

var transaction = EGLDTransactionRequest.EGLDTransfer(NetworkConfig,
                                                      Account,
                                                      Address.FromBech32(receiver),
                                                      ESDTAmount.EGLD("1.5"),
                                                      $"hello");

try
{
    var transactionRequestDto = await WalletConnect.Sign(transaction);
    var response = await Provider.SendTransaction(transactionRequestDto);
    //Transaction was sent to network
}
catch (Exception ex)
{
    //Exception occured
}

9.2 Create multiple transactions the sign them with Wallet Connect

await Account.Sync(Provider); //always sync account first (to have the latest nonce)
var receiver = "RECEIVER_ADDRESS";

var transaction1 = EGLDTransactionRequest.EGLDTransfer(
    NetworkConfig,
    Account,
    Address.FromBech32(receiver),
    ESDTAmount.EGLD("0.1"),
    "tx 1");
Account.IncrementNonce();

var transaction2 = EGLDTransactionRequest.EGLDTransfer(
    NetworkConfig,
    Account,
    Address.FromBech32(receiver),
    ESDTAmount.EGLD("0.2"),
    "tx 2");
Account.IncrementNonce();

var transaction3 = EGLDTransactionRequest.EGLDTransfer(
    NetworkConfig,
    Account,
    Address.FromBech32(receiver),
    ESDTAmount.EGLD("0.3"),
    "tx 3");
Account.IncrementNonce();

var transactions = new[] { transaction1, transaction2, transaction3 };
try
{
    var transactionsRequestDto = await WalletConnect.MultiSign(transactions);
    var response = await Provider.SendTransactions(transactionsRequestDto);
    //Transactions were sent to network
}
catch (Exception ex)
{
    //Exception occured
}

Basic usage example

A Windows application example can be found here.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.0 133 6/17/2024
2.1.3 207 12/28/2023
2.1.2 212 10/23/2023
1.0.0 233 1/16/2023

.NET SDK Release