jsPolkadotExtensionWebView

Allows you to load any web dApp in a WebView and inject the hot-wallet that is present in the c# code into the javascript app via the https://github.com/polkadot-js/extensionarrow-up-right.

How it works

Each polkadot web based application uses Polkadot.js extensionarrow-up-right to connect a browser extension wallet (like Talisman extension, ...). This approach is highly recommended, because anyone with a compatible browser extension wallet can connect to the web based dApp without exposing their seed-phrase.

The way these browser extensions establish a connection is simple: They use javascript injection technique to inject their own "wallet code" that allows access to the seed-phrase, signing logic, etc...

That means PlutoFramework needs to do the same thing. It takes the web dApp javascript code and it injects its own code with the "wallet code" exactly according to the Polkadot.js extension specification.

The difference is that this "wallet code" actually does not contain any wallet, nor a signing code. It injects a javascript code that allows a hybrid code communication between javascript and C#. So, the injected code only acts as a wallet, but the actually wallet code is written in c# as part of the PlutoFramework and it uses HybridWebViewarrow-up-right to communicate between c# and javascript languages.

Usage

xmlns:webview="clr-namespace:PlutoFramework.Components.WebView;assembly=PlutoFramework"
...
<webview:PolkadotExtensionWebView
    AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, 1"
    AbsoluteLayout.LayoutFlags="All"
    Source="<dapp_url>"/>

Or you can also use the ExtensionWebViewPage to display the website in a fullscreen browser page:

using PlutoFramework.Components.WebView;
// ...

var dAppUrl = "<dapp_url>";

await Shell.Current.Navigation.PushAsync(new ExtensionWebViewPage(dAppUrl));

Allow origin

Before actually using the wallet code, user needs to confirm that they want to connect to the web dApp.

If you as a developer trust certain origins (like your own websites), you can include them in the ResourceDictionary:

ExtensionWebViewPage

Polkassembly example

The ExtensionWebViewPage can be used if you want a default browser experience, where users can:

  • Navigate back at any time

  • See the actual URL of the website

  • Search for any other website

  • Reload

Last updated