Skip to content
kyranjamie edited this page Jan 25, 2024 · 11 revisions

App Developers' Guide

This documentation explains how developers can interact with Leather. This is relevant for app developers looking to craft their own onboarding user experience.

Getting started

When Leather is installed, a script is injected to the page, and a new object StacksProvider assigned to the global window variable.

if (window.LeatherProvider) {
  // User has Leather installed 🥳 
} else {
  // Prompt user to install the wallet
}

LeatherProvider API Reference

The LeatherProvider is a JavaScript object injected into web pages of users with the Leather web extension installed.

authenticationRequest

LeatherProvider.authenticationRequest(encodedJwt: string) => Promise<string>

This method accepts an encoded JWT payload, and returns a JWT payload signed with the users dataPrivateKey. A wallet popup will open, requesting the user select an account.

transactionRequest

LeatherProvider.transactionRequest(encodedJwt: string) => Promise<SponsoredFinishedTxPayload | FinishedTxPayload>

This method accepts an JWT payload with an unsigned transaction encrypted with the app's appPrivateKey. This is decoded, decrypted, validated, and the user prompted to confirm the transaction be signed and broadcast.

getProductInfo

LeatherProvider.getProductInfo() => { version: string, name: string, meta: { tag: string; commit: string } }

Returns information about the users Hiro Wallet installation

Clone this wiki locally