Plutonication 2.1.0

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

// Install Plutonication as a Cake Tool
#tool nuget:?package=Plutonication&version=2.1.0                

Plutonication

<img width="1512" alt="Screenshot 2023-08-19 at 22 50 21" src="https://github.com/cisar2218/Plutonication/assets/77352013/78c46443-8b41-4f62-a2d9-0b206bb7cd6d">

Communications protocol that enables seamless interactions between dApps and wallets across all platforms.

Establishing a connection is as easy as scanning a QR code.

This is a c# version.

Short demo: https://youtu.be/hw2B8-sBc9A?si=S4BBA3LEib-BYw5m

Use with any web dApp

<img width="1511" alt="Screenshot 2023-08-22 at 16 26 24" src="https://github.com/cisar2218/Plutonication/assets/77352013/99bb3b51-6602-4a00-ac02-287bdad17958">

You can use plutonication now with any web dApp. Just download Plutonication Extension.

You can find it here: https://github.com/RostislavLitovkin/PlutonicationExtension

Installation

Nuget package: https://www.nuget.org/packages/Plutonication

dotnet add package Plutonication

Other versions

  • Javascript/Typescript - in works
  • Kotlin - planned
  • Swift - planned

Use of Plutonication

The overall structure of Plutonication is designed to be as little intrusive as possible.

If you are building a dApp, you will want to interact with PlutonicationDAppClient static class.

Here is how:

use Plutonication
use Substrate.NetApi

// Access credentials are used to show correct info to the wallet.
AccessCredentials ac = new AccessCredentials
{
    // Plutonication endpoint url - leave this as is
    Url = "wss://plutonication-53tvi.ondigitalocean.app/plutonication",

    // Name of the dApp
    Name = "Galaxy Logic Game",

    // dApp icon
    Icon = "https://rostislavlitovkin.pythonanywhere.com/logo",

    // Unique key used for differentiating - leave this as is
    Key = AccessCredentials.GenerateKey(),
};

// Create a client that connects to the RPC node
// this uses Substrate.NetApi
SubstrateClient substrateClient = new SubstrateClient(
    // RPC node endpoint
    new Uri("wss://rococo-asset-hub-rpc.polkadot.io"),
    Substrate.NetApi.Model.Extrinsics.ChargeTransactionPayment.Default());

await PlutonicationDAppClient.InitializeAsync(
    ac,
    pubkey =>
    {
        // Do something with the pubkey,
        // For example show it to the user.
        Console.WriteLine(pubkey);
    },
    substrateClient);

// Use AccessCredentials to generate a link for connecting.
// Use this link to generate a correct QR code.
// You may use a package like https://github.com/Redth/ZXing.Net.Maui for QR code generation.
qrCode.Value = ac.ToUri().ToString();

// Asure that the pubkey has been received
// ..

// Now you can send payloads
// Do not forget to import other types from Substrate.NetApi
EnumMultiAddress mint_to = new EnumMultiAddress();
var account32 = new AccountId32();
account32.Create(Utils.GetPublicKeyFrom(pubkey));
mint_to.Create(MultiAddress.Id, account32);

System.Collections.Generic.List<byte> parameters = new List<byte>();

// collectionId
parameters.AddRange(new U32(7).Encode());

// itemId
parameters.AddRange(new U32(0).Encode());

// mintTo
parameters.AddRange(mint_to.Encode());

// witnessData
parameters.AddRange(new byte[0] { });

// Send the payload to the wallet for signing.
await PlutonicationDAppClient.SendPayloadAsync(52, 3, parameters.ToArray());

Problem / Motivation

Currently, there is no way to connect a wallet to more exotic devices, like gaming console and wearables.

How it works

  1. The private key is always saved in your wallet on your phone and is never sent anywhere.
  2. You need to pair the dApp with the wallet. To do so, the wallet needs to receive a special link with information needed to establish the connection. The wallet can receive this link for example by scanning a QR code.
  3. Once the link is received, the dApp and the wallet will get paired via websockets. This is to establish a stable connection between different platforms.
  4. After the connection is established, the wallet is ready to receive any Extrinsics, which it can then sigh and send back to the dApp.

Structure

Native plutonication:

flowchart LR

subgraph Cloud
S[Plutonication Websocket Server]
end

subgraph Any device
D[dApp using Plutonication]
end

subgraph Phone
W["Mobile wallet
    Private key always stays here"]
end

S -- Receive signed payload --> D
D -- Send extrinsic payload --> S

S -- Receive extrinsic payload --> W
W -- Send signed payload --> S

D -. Scan QR code for establishing connection .-> W;

Plutonication on existing polkadot.js apps:

flowchart LR

subgraph Cloud
S[Plutonication Websocket Server]
end

subgraph Web
D[dApp using Polkadot.js] ~~~ E[Plutonication Extension]
E -. Connection via Polkadot.js extension .- D
end

subgraph Phone
W["Mobile wallet
    Private key always stays here"]
end

S -- Receive signed payload --> E
E -- Send extrinsic payload --> S

S -- Receive extrinsic payload --> W
W -- Send signed payload --> S

E -. Scan QR code for establishing connection .-> W;

Plutonication Server

  • Used for reliable establishing of connection.
  • Passes payloads between Wallets and dApps.

Mobile Wallet

  • Has access to the private key
  • signs the payloads and sends them back to the dApp.
  • Never exposes the private key

dApp

  • needs to have access to either: Plutonication Native / Plutonication Extension

Plutonication Native

  • A simple package that allows the dApp get connected with the Mobile Wallet.
  • Connects the dApp with the Plutonication server.
  • Helps to generate a QR code for the Wallet to establish the connection.

Plutonication Extension

  • a polkadot.js extension that works with any existing dApp that supports polkadot.js extension.
  • Connects the dApp with the Plutonication server.
  • Generate a QR code for the Wallet to establish the connection.

Limitations

  • both devices need to support internet connection

dApps utilising Plutonication

Feel free to add your own project by making a PR.

Wallets utilising Plutonication

Feel free to add your own project by making a PR.

Inspiration

Product Compatible and additional computed target framework versions.
.NET 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. 
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.5.0 130 7/1/2024
2.4.0 106 6/15/2024
2.3.6 119 3/28/2024
2.3.5 109 3/21/2024
2.3.4 110 3/21/2024
2.3.3 114 3/19/2024
2.3.2 114 3/19/2024
2.3.1 117 2/20/2024
2.3.0 143 2/20/2024
2.2.1 131 2/9/2024
2.2.0 116 2/4/2024
2.1.4 111 2/3/2024
2.1.3 101 2/2/2024
2.1.1 113 1/28/2024
2.1.0 213 11/4/2023
2.0.6 145 8/19/2023
2.0.5 165 8/19/2023
2.0.4 143 8/19/2023
2.0.3 160 8/19/2023
2.0.2 154 8/18/2023
2.0.1 154 8/18/2023
2.0.0 127 8/18/2023
1.0.4 229 3/17/2023
1.0.3 216 3/17/2023
1.0.2 246 2/17/2023
1.0.1 249 2/16/2023
1.0.0 252 2/13/2023