Skip to content

Instantly share code, notes, and snippets.

@rBurgett
Last active October 17, 2023 18:05
Show Gist options
  • Save rBurgett/fbabe07b4d69a13547338c7fa62d8e76 to your computer and use it in GitHub Desktop.
Save rBurgett/fbabe07b4d69a13547338c7fa62d8e76 to your computer and use it in GitHub Desktop.
NodeWallet SDK

NodeWallet SDK

This SDK is designed to work with NodeWallet and provide easy, programmatic, statically-typed access to the user's account(s) and Pocket's RPC.

Primary features/functionality

  1. SDK written in TypeScript which includes subset of Pocket JS
  2. SDK hooks for React
  3. React "Connect" button
  4. Submit stake transaction functionality
  5. NodeWallet backend updates to facilitate added SDK functionality
  6. Backwards compatibility with SendWallet

TypeScript SDK

This is a NodeWallet SDK which will be written in TypeScript and modeled after the MetaMask SDK. On top of providing access to the user's selected account and chain, the NodeWallet SDK will provide a Pocket JS Provider. This provider will be a drop-in replacement for using Pocket JS directly, but rather than communicate over HTTP it will communicate via NodeWallet. This provider will include a large subset of the RPC methods available via Pocket JS with limited exclusions related to size (calls to get the full chain state are too big to go through the wallet), security (private keys are not made available to web pages, so they need to send transactions through the wallet rather than making direct calls to submit transactions), and relevance (calls to make relay requests to other chains is irrelevant for the web wallet). Anyone familiar with Pocket JS's provider library will be able to use NodeWallet's SDK.

SDK Hooks for React

Like MetaMask, the NodeWallet SDK will include React hooks. This functionality will amost exactly mirror MetaMask's React Hooks implementation which means that anyone familiar with MetaMask development will be able to easily use it. This strongly-typed hooks will make it simple to add wallet functionality into web applications.

React "Connect" button

Along with the hooks, the NodeWallet SDK will include a single connect button React UI element which can be addeed to web applications which will initiate the connection to the wallet. Using the connect button with the hooks, POKT functionality can be easily added to any web application.

Stake transaction functionality

NodeWallet currently only provides submit transaction functionality, but with the SDK we will be adding stake transaction functionality. This will allow sites to easily sumit stake transactions via NodeWallet. This will allow any staking companies to use NodeWallet to easily onboard users to their services while allowing users to retain control of their keys and coin.

NodeWallet backend updates

The SDK updates will require a number of updates to the NodeWallet extension in order to facilitate the significantly expanded functionality. This updated functionality will be available via the global pocketNetwork object added to all websites, but the recommending means of accessing it programmitically will be through the SDK.

Backwards compatibility with SendWallet

SendWallet has significantly limited browser integration functionality. We will be careful to make the SDK backwards compatible with SendWallet, although the SDK's available functionality will be limited to that available via SendWallet's integration API. The connect button, React hooks, and standard API for access wallet functionality will be the same regardless of if the user is connecting via NodeWallet or SendWallet. Only the methods available via the Pocket JS provider will be limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment